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:
parent
287a63c704
commit
f2c041d290
|
@ -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];
|
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(card != NULL && out != NULL);
|
assert(card != NULL);
|
||||||
ctx = card->ctx;
|
ctx = card->ctx;
|
||||||
LOG_FUNC_CALLED(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);
|
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||||
LOG_TEST_RET(ctx, r, "wrap key failed");
|
LOG_TEST_RET(ctx, r, "wrap key failed");
|
||||||
|
|
||||||
if (apdu.resplen <= outlen)
|
if (apdu.resplen <= outlen && out != NULL)
|
||||||
memcpy(out, apdu.resp, apdu.resplen);
|
memcpy(out, apdu.resp, apdu.resplen);
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, apdu.resplen);
|
LOG_FUNC_RETURN(ctx, apdu.resplen);
|
||||||
|
|
|
@ -868,7 +868,7 @@ sc_pkcs11_wrap(struct sc_pkcs11_session *session,
|
||||||
targetKey, wrappedData,
|
targetKey, wrappedData,
|
||||||
wrappedDataLen);
|
wrappedDataLen);
|
||||||
|
|
||||||
session_stop_operation(session, SC_PKCS11_OPERATION_UNWRAP);
|
session_stop_operation(session, SC_PKCS11_OPERATION_WRAP);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue