card-myeid: Removed NULL out buffer assertion to allow caller to query required buffer size.

mechanism.c: Bug fix to sc_pkcs11_wrap. Wrong operation was stopped in end of the function.
This commit is contained in:
Hannu Honkanen 2018-06-04 23:35:23 -07:00
parent 287a63c704
commit f2c041d290
2 changed files with 3 additions and 3 deletions

View File

@ -1261,7 +1261,7 @@ static int myeid_wrap_key(struct sc_card *card, u8 *out, size_t outlen)
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
int r;
assert(card != NULL && out != NULL);
assert(card != NULL);
ctx = card->ctx;
LOG_FUNC_CALLED(ctx);
@ -1279,7 +1279,7 @@ static int myeid_wrap_key(struct sc_card *card, u8 *out, size_t outlen)
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
LOG_TEST_RET(ctx, r, "wrap key failed");
if (apdu.resplen <= outlen)
if (apdu.resplen <= outlen && out != NULL)
memcpy(out, apdu.resp, apdu.resplen);
LOG_FUNC_RETURN(ctx, apdu.resplen);

View File

@ -868,7 +868,7 @@ sc_pkcs11_wrap(struct sc_pkcs11_session *session,
targetKey, wrappedData,
wrappedDataLen);
session_stop_operation(session, SC_PKCS11_OPERATION_UNWRAP);
session_stop_operation(session, SC_PKCS11_OPERATION_WRAP);
return rv;
}