Skip to content

Commit 2371c0a

Browse files
de-nordicnvlsianpu
authored andcommitted
boot: Rename boot_enc_decrypt to boot_decrypt_key
All of boot_enc_ function follow the same pattern where they take encryption context as the first parameter, and the boot_enc_decrypt stands out here as it does not work around the encryption context, but is rather single-part decryption function only used for decrypting of the image encryption key. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 50f3514 commit 2371c0a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

boot/bootutil/include/bootutil/enc_key.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ struct enc_key_data {
4848
extern const struct bootutil_key bootutil_enc_key;
4949
struct boot_status;
5050

51+
/* Decrypt random, symmetric encryption key */
52+
int boot_decrypt_key(const uint8_t *buf, uint8_t *enckey);
53+
5154
int boot_enc_init(struct enc_key_data *enc_state, uint8_t slot);
5255
int boot_enc_drop(struct enc_key_data *enc_state, uint8_t slot);
5356
int boot_enc_set_key(struct enc_key_data *enc_state, uint8_t slot,
5457
const struct boot_status *bs);
5558
int boot_enc_load(struct enc_key_data *enc_state, int image_index,
5659
const struct image_header *hdr, const struct flash_area *fap,
5760
struct boot_status *bs);
58-
int boot_enc_decrypt(const uint8_t *buf, uint8_t *enckey);
5961
bool boot_enc_valid(struct enc_key_data *enc_state, int image_index,
6062
const struct flash_area *fap);
6163
void boot_encrypt(struct enc_key_data *enc_state, int image_index,

boot/bootutil/src/bootutil_misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ boot_read_enc_key(const struct flash_area *fap, uint8_t slot, struct boot_status
283283
}
284284
/* Only try to decrypt non-erased TLV metadata */
285285
if (i != BOOT_ENC_TLV_ALIGN_SIZE) {
286-
rc = boot_enc_decrypt(bs->enctlv[slot], bs->enckey[slot]);
286+
rc = boot_decrypt_key(bs->enctlv[slot], bs->enckey[slot]);
287287
}
288288
}
289289
#else

boot/bootutil/src/encrypted.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static int fake_rng(void *p_rng, unsigned char *output, size_t len)
415415
* @param enckey An AES-128 or AES-256 key sized buffer to store to plain key.
416416
*/
417417
int
418-
boot_enc_decrypt(const uint8_t *buf, uint8_t *enckey)
418+
boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
419419
{
420420
#if defined(MCUBOOT_ENCRYPT_RSA)
421421
bootutil_rsa_context rsa;
@@ -660,7 +660,7 @@ boot_enc_load(struct enc_key_data *enc_state, int image_index,
660660
return -1;
661661
}
662662

663-
return boot_enc_decrypt(buf, bs->enckey[slot]);
663+
return boot_decrypt_key(buf, bs->enckey[slot]);
664664
}
665665

666666
bool

0 commit comments

Comments
 (0)