@@ -97,9 +97,6 @@ key_unwrap(const uint8_t *wrapped, uint8_t *enckey, struct bootutil_key *bootuti
97
97
static const uint8_t ec_pubkey_oid [] = MBEDTLS_OID_EC_ALG_UNRESTRICTED ;
98
98
static const uint8_t ec_secp256r1_oid [] = MBEDTLS_OID_EC_GRP_SECP256R1 ;
99
99
100
- #define SHARED_KEY_LEN NUM_ECC_BYTES
101
- #define PRIV_KEY_LEN NUM_ECC_BYTES
102
-
103
100
/*
104
101
* Parses the output of `imgtool keygen`, which produces a PKCS#8 elliptic
105
102
* curve keypair. See RFC5208 and RFC5915.
@@ -179,9 +176,6 @@ parse_ec256_enckey(uint8_t **p, uint8_t *end, uint8_t *private_key)
179
176
static const uint8_t ec_pubkey_oid [] = MBEDTLS_OID_ISO_IDENTIFIED_ORG \
180
177
MBEDTLS_OID_ORG_GOV X25519_OID ;
181
178
182
- #define SHARED_KEY_LEN 32
183
- #define PRIV_KEY_LEN 32
184
-
185
179
static int
186
180
parse_x25519_enckey (uint8_t * * p , uint8_t * end , uint8_t * private_key )
187
181
{
@@ -221,11 +215,11 @@ parse_x25519_enckey(uint8_t **p, uint8_t *end, uint8_t *private_key)
221
215
return -7 ;
222
216
}
223
217
224
- if (len != PRIV_KEY_LEN ) {
218
+ if (len != EC_PRIVK_LEN ) {
225
219
return -8 ;
226
220
}
227
221
228
- memcpy (private_key , * p , PRIV_KEY_LEN );
222
+ memcpy (private_key , * p , EC_PRIVK_LEN );
229
223
return 0 ;
230
224
}
231
225
#endif /* defined(MCUBOOT_ENCRYPT_X25519) */
@@ -399,11 +393,11 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
399
393
bootutil_hmac_sha256_context hmac ;
400
394
bootutil_aes_ctr_context aes_ctr ;
401
395
uint8_t tag [BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE ];
402
- uint8_t shared [SHARED_KEY_LEN ];
396
+ uint8_t shared [EC_SHARED_LEN ];
403
397
uint8_t derived_key [BOOT_ENC_KEY_SIZE + BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE ];
404
398
uint8_t * cp ;
405
399
uint8_t * cpend ;
406
- uint8_t private_key [PRIV_KEY_LEN ];
400
+ uint8_t private_key [EC_PRIVK_LEN ];
407
401
uint8_t counter [BOOT_ENC_BLOCK_SIZE ];
408
402
uint16_t len ;
409
403
#endif
@@ -509,7 +503,7 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
509
503
*/
510
504
511
505
len = BOOT_ENC_KEY_SIZE + BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE ;
512
- rc = hkdf (shared , SHARED_KEY_LEN , (uint8_t * )"MCUBoot_ECIES_v1" , 16 ,
506
+ rc = hkdf (shared , EC_SHARED_LEN , (uint8_t * )"MCUBoot_ECIES_v1" , 16 ,
513
507
derived_key , & len );
514
508
if (rc != 0 || len != (BOOT_ENC_KEY_SIZE + BOOTUTIL_CRYPTO_SHA256_DIGEST_SIZE )) {
515
509
return -1 ;
0 commit comments