Skip to content

Commit 90d34bf

Browse files
committed
Print error message in sign_data
1 parent 3a427d3 commit 90d34bf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tool/yubico-piv-tool.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ static bool sign_data(ykpiv_state *state, const unsigned char *in, size_t len, u
130130
if(!verify_pin(state)) {
131131
return false;
132132
}
133-
if(ykpiv_sign_data(state, in, len, out, out_len, algorithm, key) == YKPIV_OK) {
134-
return true;
133+
ykpiv_rc res = ykpiv_sign_data(state, in, len, out, out_len, algorithm, key);
134+
if(res != YKPIV_OK)
135+
{
136+
fprintf(stderr, "Signing data failed: '%s'\n", ykpiv_strerror(res));
137+
return false;
135138
}
136-
return false;
139+
return true;
137140
}
138141

139142
#if !((OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER))
@@ -874,7 +877,6 @@ static bool request_certificate(ykpiv_state *state, enum enum_key_format key_for
874877
unsigned char signature[1024] = {0};
875878
size_t sig_len = sizeof(signature);
876879
if(!sign_data(state, signinput, len, signature, &sig_len, algorithm, key)) {
877-
fprintf(stderr, "Failed signing request.\n");
878880
goto request_out;
879881
}
880882
ASN1_STRING_set(req->signature, signature, sig_len);
@@ -1128,7 +1130,6 @@ static bool selfsign_certificate(ykpiv_state *state, enum enum_key_format key_fo
11281130
unsigned char signature[1024] = {0};
11291131
size_t sig_len = sizeof(signature);
11301132
if(!sign_data(state, signinput, len, signature, &sig_len, algorithm, key)) {
1131-
fprintf(stderr, "Failed signing certificate.\n");
11321133
goto selfsign_out;
11331134
}
11341135
ASN1_STRING_set(x509->signature, signature, sig_len);
@@ -1395,7 +1396,6 @@ static bool sign_file(ykpiv_state *state, const char *input, const char *output,
13951396
unsigned char buf[1024] = {0};
13961397
size_t len = sizeof(buf);
13971398
if(!sign_data(state, hashed, hash_len, buf, &len, algo, key)) {
1398-
fprintf(stderr, "failed signing file\n");
13991399
goto out;
14001400
}
14011401

@@ -1699,7 +1699,6 @@ static bool test_signature(ykpiv_state *state, enum enum_slot slot,
16991699
enc_len = data_len;
17001700
}
17011701
if(!sign_data(state, ptr, enc_len, signature, &sig_len, algorithm, key)) {
1702-
fprintf(stderr, "Failed signing test data.\n");
17031702
goto test_out;
17041703
}
17051704

0 commit comments

Comments
 (0)