Fix ECDSA signature encoding.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-03-20 10:12:16 +01:00
parent 1197389e02
commit 62743bbb3c
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3

View File

@ -525,7 +525,7 @@ static int cmd_authenticate() {
size_t olen = 0; size_t olen = 0;
memcpy(res_APDU, "\x7C\x00\x82\x00", 4); memcpy(res_APDU, "\x7C\x00\x82\x00", 4);
res_APDU_size = 4; res_APDU_size = 4;
r = ecdsa_sign(&ctx, a81.data, a81.len, res_APDU + res_APDU_size, &olen); r = mbedtls_ecdsa_write_signature(&ctx, algo == PIV_ALGO_ECCP256 ? MBEDTLS_MD_SHA256 : MBEDTLS_MD_SHA384, a81.data, a81.len, res_APDU + res_APDU_size, MBEDTLS_ECDSA_MAX_LEN, &olen, random_gen, NULL);
mbedtls_ecdsa_free(&ctx); mbedtls_ecdsa_free(&ctx);
res_APDU[res_APDU_size - 1] = olen; res_APDU[res_APDU_size - 1] = olen;
res_APDU[res_APDU_size - 3] = olen + 2; res_APDU[res_APDU_size - 3] = olen + 2;