Skip to content

Commit 84562a4

Browse files
committed
dice: zero IAK stack key on all exits
F/2591
1 parent 76f0b3c commit 84562a4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/dice/dice.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,18 +660,23 @@ static int wolfboot_attest_get_private_key(ecc_key *key,
660660
{
661661
uint8_t priv[WOLFBOOT_DICE_KEY_LEN];
662662
size_t priv_len = sizeof(priv);
663+
int ret = -1;
663664

664665
if (hal_attestation_get_iak_private_key(priv, &priv_len) != 0) {
665-
return -1;
666+
goto cleanup;
666667
}
667668
if (priv_len != WOLFBOOT_DICE_KEY_LEN) {
668-
return -1;
669+
goto cleanup;
669670
}
670671
if (wc_ecc_import_private_key_ex(priv, (word32)priv_len, NULL, 0,
671672
key, ECC_SECP256R1) != 0) {
672-
return -1;
673+
goto cleanup;
673674
}
674-
return 0;
675+
ret = 0;
676+
677+
cleanup:
678+
wc_ForceZero(priv, sizeof(priv));
679+
return ret;
675680
}
676681
#else
677682
if (hal_uds_derive_key(uds, uds_len) != 0) {

0 commit comments

Comments
 (0)