blob: 1b62a6ba7904a3376a9c162977755f251accfdc3 [file] [log] [blame]
Almir Okatoeb6b7bf2021-09-07 17:06:35 -03001/*
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
13extern const unsigned char rsa_pub_key[];
14extern const unsigned int rsa_pub_key_len;
15#elif defined(MCUBOOT_SIGN_EC256)
16#define HAVE_KEYS
17extern const unsigned char ecdsa_pub_key[];
18extern const unsigned int ecdsa_pub_key_len;
19#elif defined(MCUBOOT_SIGN_ED25519)
20#define HAVE_KEYS
21extern const unsigned char ed25519_pub_key[];
22extern 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)
31const 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};
45const int bootutil_key_cnt = 1;
46#endif /* HAVE_KEYS */
47#else
48unsigned int pub_key_len;
49struct bootutil_key bootutil_keys[1] = {
50 {
51 .key = 0,
52 .len = &pub_key_len,
53 }
54};
55const int bootutil_key_cnt = 1;
56#endif /* !MCUBOOT_HW_KEY */