blob: 9e660d84f7d336e5e559d90d28b8948280455c2c [file] [log] [blame]
David Brown5153bd62017-01-06 11:16:53 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#include <bootutil/sign_key.h>
21
Marti Bolivara4818a52018-04-12 13:02:38 -040022/*
23 * Even though this is in principle a Zephyr-specific file, the
24 * simulator builds it and uses it as well. Because of that, we can't
25 * use Kconfig symbols for key types, and have to rely on the MCUBoot
26 * symbols (which Zephyr provides via this header, and the simulator
27 * provides via the compiler command line).
28 */
29#include <mcuboot_config/mcuboot_config.h>
30
Fabio Utzig19356bf2017-05-11 16:19:36 -030031#if defined(MCUBOOT_SIGN_RSA)
Marti Bolivara4818a52018-04-12 13:02:38 -040032#define HAVE_KEYS
Fabio Utzig806af0e2018-04-26 10:53:54 -030033extern const unsigned char rsa_pub_key[];
34extern unsigned int rsa_pub_key_len;
Fabio Utzig19356bf2017-05-11 16:19:36 -030035#elif defined(MCUBOOT_SIGN_EC256)
Marti Bolivara4818a52018-04-12 13:02:38 -040036#define HAVE_KEYS
Fabio Utzig806af0e2018-04-26 10:53:54 -030037extern const unsigned char ecdsa_pub_key[];
38extern unsigned int ecdsa_pub_key_len;
David Brown3869e762017-02-02 08:10:23 -070039#else
40#error "No public key available for given signing algorithm."
41#endif
David Brown5153bd62017-01-06 11:16:53 -070042
Fabio Utzig806af0e2018-04-26 10:53:54 -030043/*
44 * NOTE: *_pub_key and *_pub_key_len are autogenerated based on the provided
45 * key file. If no key file was configured, the array and length must be
46 * provided and added to the build manually.
47 */
Marti Bolivara4818a52018-04-12 13:02:38 -040048#if defined(HAVE_KEYS)
David Brown5153bd62017-01-06 11:16:53 -070049const struct bootutil_key bootutil_keys[] = {
David Brown0d0652a2017-04-11 17:33:30 -060050 {
Fabio Utzig806af0e2018-04-26 10:53:54 -030051#if defined(MCUBOOT_SIGN_RSA)
52 .key = rsa_pub_key,
53 .len = &rsa_pub_key_len,
54#elif defined(MCUBOOT_SIGN_EC256)
55 .key = ecdsa_pub_key,
56 .len = &ecdsa_pub_key_len,
57#endif
David Brown0d0652a2017-04-11 17:33:30 -060058 },
David Brown5153bd62017-01-06 11:16:53 -070059};
60const int bootutil_key_cnt = 1;
Fabio Utzig19356bf2017-05-11 16:19:36 -030061#endif