David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 1 | /* |
| 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 Bolivar | a4818a5 | 2018-04-12 13:02:38 -0400 | [diff] [blame] | 22 | /* |
| 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 Utzig | 19356bf | 2017-05-11 16:19:36 -0300 | [diff] [blame] | 31 | #if defined(MCUBOOT_SIGN_RSA) |
Marti Bolivar | a4818a5 | 2018-04-12 13:02:38 -0400 | [diff] [blame] | 32 | #define HAVE_KEYS |
Fabio Utzig | 806af0e | 2018-04-26 10:53:54 -0300 | [diff] [blame] | 33 | extern const unsigned char rsa_pub_key[]; |
| 34 | extern unsigned int rsa_pub_key_len; |
Fabio Utzig | 19356bf | 2017-05-11 16:19:36 -0300 | [diff] [blame] | 35 | #elif defined(MCUBOOT_SIGN_EC256) |
Marti Bolivar | a4818a5 | 2018-04-12 13:02:38 -0400 | [diff] [blame] | 36 | #define HAVE_KEYS |
Fabio Utzig | 806af0e | 2018-04-26 10:53:54 -0300 | [diff] [blame] | 37 | extern const unsigned char ecdsa_pub_key[]; |
| 38 | extern unsigned int ecdsa_pub_key_len; |
David Brown | 3869e76 | 2017-02-02 08:10:23 -0700 | [diff] [blame] | 39 | #else |
| 40 | #error "No public key available for given signing algorithm." |
| 41 | #endif |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 42 | |
Fabio Utzig | 806af0e | 2018-04-26 10:53:54 -0300 | [diff] [blame] | 43 | /* |
| 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 Bolivar | a4818a5 | 2018-04-12 13:02:38 -0400 | [diff] [blame] | 48 | #if defined(HAVE_KEYS) |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 49 | const struct bootutil_key bootutil_keys[] = { |
David Brown | 0d0652a | 2017-04-11 17:33:30 -0600 | [diff] [blame] | 50 | { |
Fabio Utzig | 806af0e | 2018-04-26 10:53:54 -0300 | [diff] [blame] | 51 | #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 Brown | 0d0652a | 2017-04-11 17:33:30 -0600 | [diff] [blame] | 58 | }, |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 59 | }; |
| 60 | const int bootutil_key_cnt = 1; |
Fabio Utzig | 19356bf | 2017-05-11 16:19:36 -0300 | [diff] [blame] | 61 | #endif |