aboutsummaryrefslogtreecommitdiff
path: root/ks_flash.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-04-30 10:21:09 -0400
committerRob Austein <sra@hactrn.net>2017-04-30 10:21:09 -0400
commita76a684fbd33c2b90a33e9c12e7536149630d6b5 (patch)
treeedb512556900a5a6680dd946050e60c0ea8e1128 /ks_flash.c
parent18c297c5f88681236aec2537f7e7f2d9b50fcd7e (diff)
parent018b238e7aac5b4a990a28f49323b821246c9f66 (diff)
Merge branch 'ksng' into no-rtos
Diffstat (limited to 'ks_flash.c')
-rw-r--r--ks_flash.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ks_flash.c b/ks_flash.c
index b14e568..8aadc37 100644
--- a/ks_flash.c
+++ b/ks_flash.c
@@ -2119,7 +2119,7 @@ hal_error_t hal_set_pin(const hal_user_t user,
* while re-implementing it on top of the new keystore.
*/
-hal_error_t hal_mkm_flash_read(uint8_t *buf, const size_t len)
+hal_error_t hal_mkm_flash_read_no_lock(uint8_t *buf, const size_t len)
{
if (buf != NULL && len != KEK_LENGTH)
return HAL_ERROR_MASTERKEY_BAD_LENGTH;
@@ -2128,18 +2128,22 @@ hal_error_t hal_mkm_flash_read(uint8_t *buf, const size_t len)
hal_error_t err;
unsigned b;
- hal_ks_lock();
-
if ((err = fetch_pin_block(&b, &block)) != HAL_OK)
- goto done;
+ return err;
if (block->pin.kek_set != FLASH_KEK_SET)
- err = HAL_ERROR_MASTERKEY_NOT_SET;
+ return HAL_ERROR_MASTERKEY_NOT_SET;
- else if (buf != NULL)
+ if (buf != NULL)
memcpy(buf, block->pin.kek, len);
- done:
+ return HAL_OK;
+}
+
+hal_error_t hal_mkm_flash_read(uint8_t *buf, const size_t len)
+{
+ hal_ks_lock();
+ const hal_error_t err = hal_mkm_flash_read_no_lock(buf, len);
hal_ks_unlock();
return err;
}