Skip to content

Commit 51afa7a

Browse files
de-nordictejlmand
authored andcommitted
[nrf noup] boot: bootutil: Add required signature decoding
The CC310 and bl_crypto require decoded signature instead of raw ASN.1 Signed-off-by: Dominik Ermel <[email protected]>
1 parent c457401 commit 51afa7a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

boot/bootutil/include/bootutil/crypto/ecdsa_p256.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,20 @@ static inline int bootutil_ecdsa_p256_verify(bootutil_ecdsa_p256_context *ctx,
225225
{
226226
(void)ctx;
227227
(void)pk_len;
228-
(void)sig_len;
229228
(void)hash_len;
229+
uint8_t dsig[2 * NUM_ECC_BYTES];
230+
231+
if (bootutil_decode_sig(dsig, sig, sig + sig_len)) {
232+
return -1;
233+
}
230234

231235
/* Only support uncompressed keys. */
232236
if (pk[0] != 0x04) {
233237
return -1;
234238
}
235239
pk++;
236240

237-
return cc310_ecdsa_verify_secp256r1(hash, pk, sig, BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE);
241+
return cc310_ecdsa_verify_secp256r1(hash, pk, dsig, BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE);
238242
}
239243

240244
static inline int bootutil_ecdsa_p256_parse_public_key(bootutil_ecdsa_p256_context *ctx,
@@ -398,7 +402,11 @@ static inline int bootutil_ecdsa_p256_verify(bootutil_ecdsa_p256_context *ctx,
398402
{
399403
(void)ctx;
400404
(void)pk_len;
401-
(void)sig_len;
405+
uint8_t dsig[2 * NUM_ECC_BYTES];
406+
407+
if (bootutil_decode_sig(dsig, sig, sig + sig_len)) {
408+
return -1;
409+
}
402410

403411
/* As described on the compact representation in IETF protocols,
404412
* the first byte of the key defines if the ECC points are

0 commit comments

Comments
 (0)