blob: 9bed4d80fd4ba03e6d19d2c8c276077aa2a32066 [file] [log] [blame]
George Becksteind82afbf2020-10-29 17:32:11 -04001/*
2 * Copyright (c) 2020 Embedded Planet
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License
16 */
17
18#include <bootutil/sign_key.h>
19#include <mcuboot_config/mcuboot_config.h>
20
21#if defined(MCUBOOT_SIGN_RSA)
22#define HAVE_KEYS
23extern const unsigned char rsa_pub_key[];
24extern unsigned int rsa_pub_key_len;
25#elif defined(MCUBOOT_SIGN_EC256)
26#define HAVE_KEYS
27extern const unsigned char ecdsa_pub_key[];
28extern unsigned int ecdsa_pub_key_len;
29#elif defined(MCUBOOT_SIGN_ED25519)
30#define HAVE_KEYS
31extern const unsigned char ed25519_pub_key[];
32extern unsigned int ed25519_pub_key_len;
George Becksteind82afbf2020-10-29 17:32:11 -040033#endif
34
35/*
36 * Note: Keys for both signing and encryption must be provided by the application.
37 * mcuboot's imgtool utility can be used to generate these keys and convert them into compatible C code.
38 * See imgtool's documentation, specifically the section: "Incorporating the public key into the code" which can be found here:
39 * https://github.com/JuulLabs-OSS/mcuboot/blob/master/docs/imgtool.md#incorporating-the-public-key-into-the-code
40 */
41#if defined(HAVE_KEYS)
42const struct bootutil_key bootutil_keys[] = {
43 {
44#if defined(MCUBOOT_SIGN_RSA)
45 .key = rsa_pub_key,
46 .len = &rsa_pub_key_len,
47#elif defined(MCUBOOT_SIGN_EC256)
48 .key = ecdsa_pub_key,
49 .len = &ecdsa_pub_key_len,
50#elif defined(MCUBOOT_SIGN_ED25519)
51 .key = ed25519_pub_key,
52 .len = &ed25519_pub_key_len,
53#endif
54 },
55};
56const int bootutil_key_cnt = 1;
57
58#if defined(MCUBOOT_ENCRYPT_RSA)
59
60extern const unsigned char enc_priv_key[];
61extern const unsigned int enc_priv_key_len;
62
63const struct bootutil_key bootutil_enc_key = {
64 .key = enc_priv_key,
65 .len = &enc_priv_key_len,
66};
67#elif defined(MCUBOOT_ENCRYPT_KW)
68#error "Encrypted images with AES-KW is not implemented yet."
69#endif
70
71#endif