Skip to content

Commit 687dc8c

Browse files
de-nordicnvlsianpu
authored andcommitted
bootutil: boot_decrypt_key: Only one bootutil_hmac_sha256_drop needed
Optimize out some unneeded calls. Signed-off-by: Dominik Ermel <[email protected]>
1 parent a0065f8 commit 687dc8c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

boot/bootutil/src/encrypted.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,18 +557,15 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
557557

558558
/* Assumes the tag buffer is at least sizeof(hmac_tag_size(state)) bytes */
559559
rc = bootutil_hmac_sha256_finish(&hmac, tag, BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE);
560+
(void)bootutil_hmac_sha256_drop(&hmac);
560561
if (rc != 0) {
561-
(void)bootutil_hmac_sha256_drop(&hmac);
562562
return -1;
563563
}
564564

565565
if (bootutil_constant_time_compare(tag, &buf[EC_TAG_INDEX], 32) != 0) {
566-
(void)bootutil_hmac_sha256_drop(&hmac);
567566
return -1;
568567
}
569568

570-
bootutil_hmac_sha256_drop(&hmac);
571-
572569
/*
573570
* Finally decrypt the received ciphered key
574571
*/

0 commit comments

Comments
 (0)