Almir Okato | eb6b7bf | 2021-09-07 17:06:35 -0300 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd. |
| 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | */ |
| 6 | |
| 7 | #include <bootutil/sign_key.h> |
| 8 | #include <mcuboot_config/mcuboot_config.h> |
| 9 | |
| 10 | #if !defined(MCUBOOT_HW_KEY) |
| 11 | #if defined(MCUBOOT_SIGN_RSA) |
| 12 | #define HAVE_KEYS |
| 13 | extern const unsigned char rsa_pub_key[]; |
| 14 | extern const unsigned int rsa_pub_key_len; |
| 15 | #elif defined(MCUBOOT_SIGN_EC256) |
| 16 | #define HAVE_KEYS |
| 17 | extern const unsigned char ecdsa_pub_key[]; |
| 18 | extern const unsigned int ecdsa_pub_key_len; |
| 19 | #elif defined(MCUBOOT_SIGN_ED25519) |
| 20 | #define HAVE_KEYS |
| 21 | extern const unsigned char ed25519_pub_key[]; |
| 22 | extern const unsigned int ed25519_pub_key_len; |
| 23 | #endif |
| 24 | |
| 25 | /* |
| 26 | * NOTE: *_pub_key and *_pub_key_len are autogenerated based on the provided |
| 27 | * key file. If no key file was configured, the array and length must be |
| 28 | * provided and added to the build manually. |
| 29 | */ |
| 30 | #if defined(HAVE_KEYS) |
| 31 | const struct bootutil_key bootutil_keys[] = { |
| 32 | { |
| 33 | #if defined(MCUBOOT_SIGN_RSA) |
| 34 | .key = rsa_pub_key, |
| 35 | .len = &rsa_pub_key_len, |
| 36 | #elif defined(MCUBOOT_SIGN_EC256) |
| 37 | .key = ecdsa_pub_key, |
| 38 | .len = &ecdsa_pub_key_len, |
| 39 | #elif defined(MCUBOOT_SIGN_ED25519) |
| 40 | .key = ed25519_pub_key, |
| 41 | .len = &ed25519_pub_key_len, |
| 42 | #endif |
| 43 | }, |
| 44 | }; |
| 45 | const int bootutil_key_cnt = 1; |
| 46 | #endif /* HAVE_KEYS */ |
| 47 | #else |
| 48 | unsigned int pub_key_len; |
| 49 | struct bootutil_key bootutil_keys[1] = { |
| 50 | { |
| 51 | .key = 0, |
| 52 | .len = &pub_key_len, |
| 53 | } |
| 54 | }; |
| 55 | const int bootutil_key_cnt = 1; |
| 56 | #endif /* !MCUBOOT_HW_KEY */ |