Skip to content

Commit ec8809f

Browse files
committed
bootutil: Enc uses one context type for key exchange
Signed-off-by: Dominik Ermel <[email protected]>
1 parent 6c2bbf0 commit ec8809f

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

boot/bootutil/include/bootutil/crypto/ecdh_p256.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern "C" {
3535

3636
#if defined(MCUBOOT_USE_TINYCRYPT)
3737
typedef uintptr_t bootutil_ecdh_p256_context;
38+
typedef bootutil_ecdh_p256_context bootutil_key_xchange_ctx;
3839
static inline void bootutil_ecdh_p256_init(bootutil_ecdh_p256_context *ctx)
3940
{
4041
(void)ctx;

boot/bootutil/include/bootutil/crypto/ecdh_x25519.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],
2626
const uint8_t peer_public_value[32]);
2727

2828
typedef uintptr_t bootutil_ecdh_x25519_context;
29+
typedef bootutil_ecdh_x25519_context bootutil_key_xchange_ctx;
2930
static inline void bootutil_ecdh_x25519_init(bootutil_ecdh_x25519_context *ctx)
3031
{
3132
(void)ctx;

boot/bootutil/include/bootutil/crypto/rsa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ extern "C" {
6868
typedef struct {
6969
psa_key_id_t key_id;
7070
} bootutil_rsa_context;
71+
typedef bootutil_rsa_context bootutil_key_xchange_ctx;
7172

7273
static inline void bootutil_rsa_init(bootutil_rsa_context *ctx)
7374
{
@@ -176,6 +177,7 @@ static inline int bootutil_rsassa_pss_verify(const bootutil_rsa_context *ctx,
176177
#elif defined(MCUBOOT_USE_MBED_TLS)
177178

178179
typedef mbedtls_rsa_context bootutil_rsa_context;
180+
typedef bootutil_rsa_context bootutil_key_xchange_ctx;
179181

180182
static inline void bootutil_rsa_init(bootutil_rsa_context *ctx)
181183
{

boot/bootutil/src/encrypted.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,7 @@ static int fake_rng(void *p_rng, unsigned char *output, size_t len)
405405
int
406406
boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
407407
{
408-
#if defined(MCUBOOT_ENCRYPT_RSA)
409-
bootutil_rsa_context pk_ctx;
410-
#endif
411-
#if defined(MCUBOOT_ENCRYPT_EC256)
412-
bootutil_ecdh_p256_context pk_ctx;
413-
#endif
414-
#if defined(MCUBOOT_ENCRYPT_X25519)
415-
bootutil_ecdh_x25519_context pk_ctx;
416-
#endif
408+
bootutil_key_exchange_ctx pk_ctx;
417409
#if defined(MCUBOOT_ENCRYPT_EC256) || defined(MCUBOOT_ENCRYPT_X25519)
418410
bootutil_hmac_sha256_context hmac;
419411
bootutil_aes_ctr_context aes_ctr;

0 commit comments

Comments
 (0)