Merge branch 'pr-191'

This commit is contained in:
Klas Lindfors
2019-05-07 14:44:35 +02:00
3 changed files with 23 additions and 4 deletions
+4 -1
View File
@@ -1,6 +1,5 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <strsafe.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif
@@ -24,6 +23,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
#include <strsafe.h> /* must be included after openssl headers */
#endif
#include "internal.h" #include "internal.h"
/* /*
+13 -1
View File
@@ -305,7 +305,19 @@ ykpiv_rc _ykpiv_select_application(ykpiv_state *state) {
* will result in another selection of the PIV applet. */ * will result in another selection of the PIV applet. */
res = _ykpiv_get_version(state, NULL); res = _ykpiv_get_version(state, NULL);
if (res == YKPIV_OK) res = _ykpiv_get_serial(state, NULL, false); if (res != YKPIV_OK) {
if (state->verbose) {
fprintf(stderr, "Failed to retrieve version: '%s'\n", ykpiv_strerror(res));
}
}
res = _ykpiv_get_serial(state, NULL, false);
if (res != YKPIV_OK) {
if (state->verbose) {
fprintf(stderr, "Failed to retrieve serial number: '%s'\n", ykpiv_strerror(res));
}
res = YKPIV_OK;
}
return res; return res;
} }
+6 -2
View File
@@ -1842,6 +1842,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
{ {
ykpiv_rc piv_rv; ykpiv_rc piv_rv;
CK_RV rv; CK_RV rv;
size_t cbSignatureLen = 0;
DIN; DIN;
@@ -1934,9 +1935,12 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
dump_data(op_info.buf, op_info.buf_len, stderr, CK_TRUE, format_arg_hex); dump_data(op_info.buf, op_info.buf_len, stderr, CK_TRUE, format_arg_hex);
#endif #endif
*pulSignatureLen = sizeof(op_info.buf); *pulSignatureLen = cbSignatureLen = sizeof(op_info.buf);
piv_rv = ykpiv_sign_data(piv_state, op_info.buf, op_info.buf_len, op_info.buf, &cbSignatureLen, op_info.op.sign.algo, op_info.op.sign.key_id);
*pulSignatureLen = cbSignatureLen;
piv_rv = ykpiv_sign_data(piv_state, op_info.buf, op_info.buf_len, op_info.buf, pulSignatureLen, op_info.op.sign.algo, op_info.op.sign.key_id);
if (piv_rv != YKPIV_OK) { if (piv_rv != YKPIV_OK) {
if (piv_rv == YKPIV_AUTHENTICATION_ERROR) { if (piv_rv == YKPIV_AUTHENTICATION_ERROR) {
DBG("Operation requires authentication or touch"); DBG("Operation requires authentication or touch");