Skip to content

Commit 398b4a7

Browse files
committed
Hkdf uses size_t
Signed-off-by: Dominik Ermel <[email protected]>
1 parent 8b83064 commit 398b4a7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

boot/bootutil/src/encrypted.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,15 @@ parse_x25519_enckey(uint8_t **p, uint8_t *end, uint8_t *private_key)
264264
* @param okm_len On input the requested length; on output the generated length
265265
*/
266266
static int
267-
hkdf(uint8_t *ikm, uint16_t ikm_len, uint8_t *info, uint16_t info_len,
268-
uint8_t *okm, uint16_t *okm_len)
267+
hkdf(const uint8_t *ikm, size_t ikm_len, const uint8_t *info, size_t info_len,
268+
uint8_t *okm, size_t *okm_len)
269269
{
270270
bootutil_hmac_sha256_context hmac;
271271
uint8_t salt[BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE];
272272
uint8_t prk[BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE];
273273
uint8_t T[BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE];
274-
uint16_t off;
275-
uint16_t len;
274+
size_t off;
275+
size_t len;
276276
uint8_t counter;
277277
bool first;
278278
int rc;
@@ -407,7 +407,6 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
407407
{
408408
#if defined(MCUBOOT_ENCRYPT_RSA)
409409
bootutil_rsa_context pk_ctx;
410-
size_t olen;
411410
#endif
412411
#if defined(MCUBOOT_ENCRYPT_EC256)
413412
bootutil_ecdh_p256_context pk_ctx;
@@ -423,11 +422,11 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
423422
uint8_t derived_key[BOOT_ENC_KEY_SIZE + BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE];
424423
uint8_t private_key[PRIV_KEY_LEN];
425424
uint8_t counter[BOOT_ENC_BLOCK_SIZE];
426-
uint16_t len;
427425
#endif
428426
#if !defined(MCUBOOT_ENCRYPT_KW)
429427
uint8_t *cp;
430428
uint8_t *cpend;
429+
size_t len;
431430
#endif
432431
struct bootutil_key *bootutil_enc_key = NULL;
433432
int rc = -1;
@@ -456,7 +455,7 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
456455
return rc;
457456
}
458457

459-
rc = bootutil_rsa_oaep_decrypt(&pk_ctx, &olen, buf, enckey, BOOT_ENC_KEY_SIZE);
458+
rc = bootutil_rsa_oaep_decrypt(&pk_ctx, &len, buf, enckey, BOOT_ENC_KEY_SIZE);
460459
bootutil_rsa_drop(&pk_ctx);
461460
if (rc) {
462461
return rc;

0 commit comments

Comments
 (0)