From 26148282e67a6de0afcaa418c9730ccd5836b234 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 18 Aug 2023 13:07:06 +0200 Subject: [PATCH] Fix credential creation for ES512. Signed-off-by: Pol Henarejos --- src/fido/fido.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fido/fido.c b/src/fido/fido.c index abb0bf9..885e58b 100644 --- a/src/fido/fido.c +++ b/src/fido/fido.c @@ -262,6 +262,9 @@ int derive_key(const uint8_t *app_id, if (cinfo == NULL) { return 1; } + if (cinfo->bit_size % 8 != 0) { + outk[0] >>= 8 - (cinfo->bit_size % 8); + } r = mbedtls_ecp_read_key(curve, key, outk, ceil((float) cinfo->bit_size / 8)); mbedtls_platform_zeroize(outk, sizeof(outk)); if (r != 0) {