From 8fc03a5a95d3b75b29909a9f030fd74b294bf63b Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 1 Feb 2019 20:46:16 +0100 Subject: [PATCH] Fix bug in auth_get() when storing the authentication_sum. Remove the superfluous auth_get() call in unlock(). --- storage.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/storage.c b/storage.c index adf0e42ab1..ae0d7d78c4 100644 --- a/storage.c +++ b/storage.c @@ -250,7 +250,7 @@ static secbool auth_get(uint16_t key, const void **val, uint16_t *len) // Cache the authentication sum. for (size_t i = 0; i < SHA256_DIGEST_LENGTH/sizeof(uint32_t); i++) { #if BYTE_ORDER == LITTLE_ENDIAN - REVERSE32(((uint32_t*)authentication_sum)[i], sum[i]); + REVERSE32(sum[i], ((uint32_t*)authentication_sum)[i]); #else ((uint32_t*)authentication_sum)[i] = sum[i]; #endif @@ -690,10 +690,8 @@ static secbool unlock(uint32_t pin) memzero(keys, sizeof(keys)); memzero(tag, sizeof(tag)); - // Call auth_get() to initialize the authentication_sum. - auth_get(0, &buffer, &len); - // Check that the authenticated version number matches the norcow version. + // NOTE: storage_get_encrypted() calls auth_get(), which initializes the authentication_sum. uint32_t version; if (sectrue != storage_get_encrypted(VERSION_KEY, &version, sizeof(version), &len) || len != sizeof(version) || version != norcow_active_version) { handle_fault();