diff options
author | Rob Austein <sra@hactrn.net> | 2017-02-14 20:01:04 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-02-14 20:01:04 -0500 |
commit | 44652e52ae7b238adcac5a347ca74f2a9838ab6f (patch) | |
tree | 29016cc0fc056fcff2ebbde81aeb9c406525552a | |
parent | c05eb9f25182bf0db349d943855bebeccca0c691 (diff) |
Erase new head of free list in ks_store().
-rw-r--r-- | ks_flash.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1075,7 +1075,13 @@ static hal_error_t ks_store(hal_ks_t *ks, k->der_len = SIZEOF_FLASH_KEY_BLOCK_DER; k->attributes_len = 0; - if ((err = hal_mkm_get_kek(kek, &kek_len, sizeof(kek))) == HAL_OK) + if (db.ksi.used < db.ksi.size) + err = block_erase_maybe(db.ksi.index[db.ksi.used]); + + if (err == HAL_OK) + err = hal_mkm_get_kek(kek, &kek_len, sizeof(kek)); + + if (err == HAL_OK) err = hal_aes_keywrap(NULL, kek, kek_len, der, der_len, k->der, &k->der_len); memset(kek, 0, sizeof(kek)); |