|
9 | 9 | * primitives to make it easier to swap out the used crypto library. |
10 | 10 | * |
11 | 11 | * At this point, the choices are: MCUBOOT_USE_TINYCRYPT, MCUBOOT_USE_CC310, |
12 | | - * MCUBOOT_USE_MBED_TLS, MCUBOOT_USE_PSA_CRYPTO. Note that support for |
13 | | - * MCUBOOT_USE_PSA_CRYPTO is still experimental and it might not support all |
14 | | - * the crypto abstractions that MCUBOOT_USE_MBED_TLS supports. For this |
15 | | - * reason, it's allowed to have both of them defined, and for crypto modules |
16 | | - * that support both abstractions, the MCUBOOT_USE_PSA_CRYPTO will take |
17 | | - * precedence. |
| 12 | + * MCUBOOT_USE_MBED_TLS, MCUBOOT_USE_PSA_CRYPTO, MCUBOOT_USE_CUSTOM_CRYPTO. |
| 13 | + * Note that support for MCUBOOT_USE_PSA_CRYPTO is still experimental and it |
| 14 | + * might not support all the crypto abstractions that MCUBOOT_USE_MBED_TLS |
| 15 | + * supports. For this reason, it's allowed to have both of them defined, and |
| 16 | + * for crypto modules that support both abstractions, the MCUBOOT_USE_PSA_CRYPTO |
| 17 | + * will take precedence. MCUBOOT_USE_CUSTOM_CRYPTO delegates all operations to |
| 18 | + * a platform-supplied <mcuboot_custom_crypto.h> resolved via the include path. |
18 | 19 | */ |
19 | 20 |
|
20 | 21 | #ifndef __BOOTUTIL_CRYPTO_ECDSA_H_ |
|
27 | 28 | #define MCUBOOT_USE_PSA_OR_MBED_TLS |
28 | 29 | #endif /* MCUBOOT_USE_PSA_CRYPTO || MCUBOOT_USE_MBED_TLS */ |
29 | 30 |
|
| 31 | +#if defined(MCUBOOT_USE_CUSTOM_CRYPTO) && defined(MCUBOOT_USE_PSA_OR_MBED_TLS) |
| 32 | + #error "MCUBOOT_USE_CUSTOM_CRYPTO is mutually exclusive with MCUBOOT_USE_PSA_CRYPTO and MCUBOOT_USE_MBED_TLS" |
| 33 | +#endif |
| 34 | + |
30 | 35 | #if defined(MCUBOOT_SIGN_EC384) && \ |
31 | | - !defined(MCUBOOT_USE_PSA_CRYPTO) |
32 | | - #error "P384 requires PSA_CRYPTO to be defined" |
| 36 | + !defined(MCUBOOT_USE_PSA_CRYPTO) && \ |
| 37 | + !defined(MCUBOOT_USE_CUSTOM_CRYPTO) |
| 38 | + #error "P384 requires PSA_CRYPTO or CUSTOM_CRYPTO to be defined" |
33 | 39 | #endif |
34 | 40 |
|
35 | 41 | #if (defined(MCUBOOT_USE_TINYCRYPT) + \ |
36 | 42 | defined(MCUBOOT_USE_CC310) + \ |
37 | | - defined(MCUBOOT_USE_PSA_OR_MBED_TLS)) != 1 |
38 | | - #error "One crypto backend must be defined: either CC310/TINYCRYPT/MBED_TLS/PSA_CRYPTO" |
| 43 | + defined(MCUBOOT_USE_PSA_OR_MBED_TLS) + \ |
| 44 | + defined(MCUBOOT_USE_CUSTOM_CRYPTO)) != 1 |
| 45 | + #error "One crypto backend must be defined: either CC310/TINYCRYPT/MBED_TLS/PSA_CRYPTO/CUSTOM_CRYPTO" |
39 | 46 | #endif |
40 | 47 |
|
41 | 48 | #if defined(MCUBOOT_USE_TINYCRYPT) |
|
66 | 73 | #define BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE (32) |
67 | 74 |
|
68 | 75 | #include "bootutil/sign_key.h" |
69 | | -#if !defined(MCUBOOT_USE_PSA_CRYPTO) |
| 76 | +#if !defined(MCUBOOT_USE_PSA_CRYPTO) && !defined(MCUBOOT_USE_CUSTOM_CRYPTO) |
70 | 77 | #include "bootutil/crypto/common.h" |
71 | 78 | #include "mbedtls/asn1.h" |
72 | 79 | #include "mbedtls/oid.h" |
|
0 commit comments