Commit 0f64197a authored by Salome Thirot's avatar Salome Thirot Committed by Fabio Utzig
Browse files

boot: Add AES256 support for image encryption

Support only works when using mbedtls as the cryptographic library.

Signed-off-by: default avatarSalome Thirot <salome.thirot@arm.com>
parent 9b97456e
Loading
Loading
Loading
Loading
+1 −1
Changes for NOTICE: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -8,4 +8,4 @@ Portions of this software were developed at
Runtime Inc, copyright 2015.

Portions of this software were developed at
Arm Limited, copyright 2019-2020.
Arm Limited, copyright 2019-2021.
+2 −0
Changes for boot/bootutil/include/bootutil/caps.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017 Linaro Limited
 * Copyright (c) 2021 Arm Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -47,6 +48,7 @@ uint32_t bootutil_get_caps(void);
#define BOOTUTIL_CAP_DOWNGRADE_PREVENTION   (1<<12)
#define BOOTUTIL_CAP_ENC_X25519             (1<<13)
#define BOOTUTIL_CAP_BOOTSTRAP              (1<<14)
#define BOOTUTIL_CAP_AES256                 (1<<15)

/*
 * Query the number of images this bootloader is configured for.  This
+5 −1
Changes for boot/bootutil/include/bootutil/crypto/aes_ctr.h: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -21,11 +21,15 @@

#if defined(MCUBOOT_USE_MBED_TLS)
    #include <mbedtls/aes.h>
    #define BOOTUTIL_CRYPTO_AES_CTR_KEY_SIZE (16)
    #include "bootutil/enc_key_public.h"
    #define BOOTUTIL_CRYPTO_AES_CTR_KEY_SIZE BOOT_ENC_KEY_SIZE
    #define BOOTUTIL_CRYPTO_AES_CTR_BLOCK_SIZE (16)
#endif /* MCUBOOT_USE_MBED_TLS */

#if defined(MCUBOOT_USE_TINYCRYPT)
    #if defined(MCUBOOT_AES_256)
        #error "Cannot use AES-256 for encryption with Tinycrypt library."
    #endif
    #include <string.h>
    #include <tinycrypt/aes.h>
    #include <tinycrypt/ctr_mode.h>
+3 −0
Changes for boot/bootutil/include/bootutil/crypto/aes_kw.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
#endif /* MCUBOOT_USE_MBED_TLS */

#if defined(MCUBOOT_USE_TINYCRYPT)
    #if defined(MCUBOOT_AES_256)
        #error "Cannot use AES-256 for encryption with Tinycrypt library."
    #endif
    #include <tinycrypt/aes.h>
    #include <tinycrypt/constants.h>
#endif /* MCUBOOT_USE_TINYCRYPT */
+8 −4
Changes for boot/bootutil/include/bootutil/enc_key_public.h: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 * SPDX-License-Identifier: Apache-2.0
 *
 * Copyright (c) 2018-2019 JUUL Labs
 * Copyright (c) 2019 Arm Limited
 * Copyright (c) 2019-2021 Arm Limited
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * Original license:
@@ -32,12 +32,16 @@
extern "C" {
#endif

#ifdef MCUBOOT_AES_256
#define BOOT_ENC_KEY_SIZE       32
#else
#define BOOT_ENC_KEY_SIZE       16
#endif

#define TLV_ENC_RSA_SZ    256
#define TLV_ENC_KW_SZ     24
#define TLV_ENC_EC256_SZ  (65 + 32 + 16)
#define TLV_ENC_X25519_SZ (32 + 32 + 16)
#define TLV_ENC_KW_SZ     BOOT_ENC_KEY_SIZE + 8
#define TLV_ENC_EC256_SZ  (65 + 32 + BOOT_ENC_KEY_SIZE)
#define TLV_ENC_X25519_SZ (32 + 32 + BOOT_ENC_KEY_SIZE)

#if defined(MCUBOOT_ENCRYPT_RSA)
#define BOOT_ENC_TLV_SIZE TLV_ENC_RSA_SZ
Loading