Skip to content

Commit f140546

Browse files
add sanity check of hash to atmel port
1 parent 976e4b2 commit f140546

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

wolfcrypt/src/port/atmel/atmel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,16 @@ int atmel_ecc_create_key(int slotId, byte* peerKey)
467467
int atmel_ecc_sign(int slotId, const byte* message, byte* signature)
468468
{
469469
int ret;
470+
#ifndef WC_ALLOW_ECC_ZERO_HASH
471+
byte hashIsZero = 0;
472+
word32 zIdx;
473+
474+
/* defensive sanity check on all 0's hash */
475+
for (zIdx = 0; zIdx < ATECC_KEY_SIZE; zIdx++)
476+
hashIsZero |= message[zIdx];
477+
if (hashIsZero == 0)
478+
return ECC_BAD_ARG_E;
479+
#endif
470480

471481
ret = atcab_sign(slotId, message, signature);
472482
ret = atmel_ecc_translate_err(ret);

0 commit comments

Comments
 (0)