|
35 | 35 | #if (defined(MCUBOOT_USE_TINYCRYPT) + \ |
36 | 36 | defined(MCUBOOT_USE_CC310) + \ |
37 | 37 | defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO) + \ |
38 | | - defined(MCUBOOT_USE_PSA_OR_MBED_TLS)) != 1 |
| 38 | + defined(MCUBOOT_USE_PSA_OR_MBED_TLS) + \ |
| 39 | + defined(MCUBOOT_USE_NRF_OBERON_EXPERIMENT)) != 1 |
39 | 40 | #error "One crypto backend must be defined: either CC310/TINYCRYPT/MBED_TLS/PSA_CRYPTO" |
40 | 41 | #endif |
41 | 42 |
|
|
58 | 59 | #define MCUBOOT_ECDSA_NEED_ASN1_SIG |
59 | 60 | #endif /* MCUBOOT_USE_MBED_TLS */ |
60 | 61 |
|
| 62 | +#if defined(MCUBOOT_USE_NRF_OBERON_EXPERIMENT) |
| 63 | + #include <ocrypto_ecdsa_p256.h> |
| 64 | +#endif /* MCUBOOT_USE_NRF_OBERON_EXPERIMENT */ |
| 65 | + |
61 | 66 | /*TODO: remove this after cypress port mbedtls to abstract crypto api */ |
62 | 67 | #if defined(MCUBOOT_USE_CC310) || defined(MCUBOOT_USE_MBED_TLS) |
63 | 68 | #define NUM_ECC_BYTES (256 / 8) |
@@ -136,7 +141,7 @@ static int bootutil_import_key(uint8_t **cp, uint8_t *end) |
136 | 141 | } |
137 | 142 | #endif /* (MCUBOOT_USE_TINYCRYPT || MCUBOOT_USE_MBED_TLS || MCUBOOT_USE_CC310) && !MCUBOOT_USE_PSA_CRYPTO */ |
138 | 143 |
|
139 | | -#ifndef MCUBOOT_USE_PSA_CRYPTO |
| 144 | +#if !defined(MCUBOOT_USE_PSA_CRYPTO) && !defined(MCUBOOT_USE_NRF_OBERON_EXPERIMENT) |
140 | 145 | /* |
141 | 146 | * cp points to ASN1 string containing an integer. |
142 | 147 | * Verify the tag, and that the length is 32 bytes. Helper function. |
@@ -186,7 +191,7 @@ static int bootutil_decode_sig(uint8_t signature[NUM_ECC_BYTES * 2], uint8_t *cp |
186 | 191 | } |
187 | 192 | return 0; |
188 | 193 | } |
189 | | -#endif /* !MCUBOOT_USE_PSA_CRYPTO */ |
| 194 | +#endif /* !defined(MCUBOOT_USE_PSA_CRYPTO) && !defined(MCUBOOT_USE_NRF_OBERON_EXPERIMENT) */ |
190 | 195 |
|
191 | 196 | #if defined(MCUBOOT_USE_TINYCRYPT) |
192 | 197 | typedef uintptr_t bootutil_ecdsa_context; |
@@ -719,6 +724,42 @@ static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx, |
719 | 724 | } |
720 | 725 | #endif /* MCUBOOT_USE_NRF_EXTERNAL_CRYPTO */ |
721 | 726 |
|
| 727 | +#if defined(MCUBOOT_USE_NRF_OBERON_EXPERIMENT) |
| 728 | +typedef uintptr_t bootutil_ecdsa_context; |
| 729 | + |
| 730 | +static inline void bootutil_ecdsa_init(bootutil_ecdsa_context *ctx) |
| 731 | +{ |
| 732 | + (void)ctx; |
| 733 | +} |
| 734 | + |
| 735 | +static inline void bootutil_ecdsa_drop(bootutil_ecdsa_context *ctx) |
| 736 | +{ |
| 737 | + (void)ctx; |
| 738 | +} |
| 739 | + |
| 740 | +static inline int bootutil_ecdsa_verify(bootutil_ecdsa_context *ctx, |
| 741 | + uint8_t *pk, size_t pk_len, |
| 742 | + uint8_t *hash, size_t hash_len, |
| 743 | + uint8_t *sig, size_t sig_len) |
| 744 | +{ |
| 745 | + if (pk == NULL || hash == NULL || sig == NULL) { |
| 746 | + return -1; |
| 747 | + } |
| 748 | + |
| 749 | + return ocrypto_ecdsa_p256_verify_hash(sig, hash, pk); |
| 750 | +} |
| 751 | + |
| 752 | +static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx, |
| 753 | + uint8_t **cp,uint8_t *end) |
| 754 | +{ |
| 755 | + /* NOTE: No corresponding funciton in ocrypto */ |
| 756 | + (void)ctx; |
| 757 | + (void)cp; |
| 758 | + (void)end; |
| 759 | + return 0; |
| 760 | +} |
| 761 | +#endif /* MCUBOOT_USE_NRF_OBERON_EXPERIMENT */ |
| 762 | + |
722 | 763 | #ifdef __cplusplus |
723 | 764 | } |
724 | 765 | #endif |
|
0 commit comments