David Brown | e2acfae | 2020-01-21 16:45:01 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2017-2020 Linaro LTD |
| 2 | // Copyright (c) 2017-2020 JUUL Labs |
| 3 | // |
| 4 | // SPDX-License-Identifier: Apache-2.0 |
| 5 | |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 6 | //! TLV Support |
| 7 | //! |
| 8 | //! mcuboot images are followed immediately by a list of TLV items that contain integrity |
| 9 | //! information about the image. Their generation is made a little complicated because the size of |
| 10 | //! the TLV block is in the image header, which is included in the hash. Since some signatures can |
| 11 | //! vary in size, we just make them the largest size possible. |
| 12 | //! |
| 13 | //! Because of this header, we have to make two passes. The first pass will compute the size of |
| 14 | //! the TLV, and the second pass will build the data for the TLV. |
| 15 | |
David Brown | 91d6863 | 2019-07-29 14:32:13 -0600 | [diff] [blame] | 16 | use byteorder::{ |
| 17 | LittleEndian, WriteBytesExt, |
| 18 | }; |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 19 | use crate::image::ImageVersion; |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 20 | use pem; |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 21 | use base64; |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 22 | use log::info; |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 23 | use ring::{digest, rand, agreement, hkdf, hmac}; |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 24 | use ring::rand::SecureRandom; |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 25 | use ring::signature::{ |
| 26 | RsaKeyPair, |
| 27 | RSA_PSS_SHA256, |
| 28 | EcdsaKeyPair, |
| 29 | ECDSA_P256_SHA256_ASN1_SIGNING, |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 30 | Ed25519KeyPair, |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 31 | }; |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 32 | use aes_ctr::{ |
| 33 | Aes128Ctr, |
| 34 | stream_cipher::{ |
| 35 | generic_array::GenericArray, |
| 36 | NewFixStreamCipher, |
| 37 | StreamCipherCore, |
| 38 | }, |
| 39 | }; |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 40 | use mcuboot_sys::c; |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 41 | |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 42 | #[repr(u16)] |
David Brown | c3898d6 | 2019-08-05 14:20:02 -0600 | [diff] [blame] | 43 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 44 | #[allow(dead_code)] // TODO: For now |
| 45 | pub enum TlvKinds { |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 46 | KEYHASH = 0x01, |
David Brown | 27648b8 | 2017-08-31 10:40:29 -0600 | [diff] [blame] | 47 | SHA256 = 0x10, |
| 48 | RSA2048 = 0x20, |
| 49 | ECDSA224 = 0x21, |
| 50 | ECDSA256 = 0x22, |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 51 | RSA3072 = 0x23, |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 52 | ED25519 = 0x24, |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 53 | ENCRSA2048 = 0x30, |
| 54 | ENCKW128 = 0x31, |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 55 | ENCEC256 = 0x32, |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 56 | DEPENDENCY = 0x40, |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | #[allow(dead_code, non_camel_case_types)] |
| 60 | pub enum TlvFlags { |
| 61 | PIC = 0x01, |
| 62 | NON_BOOTABLE = 0x02, |
| 63 | ENCRYPTED = 0x04, |
| 64 | RAM_LOAD = 0x20, |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 65 | } |
| 66 | |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 67 | /// A generator for manifests. The format of the manifest can be either a |
| 68 | /// traditional "TLV" or a SUIT-style manifest. |
| 69 | pub trait ManifestGen { |
David Brown | ac46e26 | 2019-01-11 15:46:18 -0700 | [diff] [blame] | 70 | /// Retrieve the header magic value for this manifest type. |
| 71 | fn get_magic(&self) -> u32; |
| 72 | |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 73 | /// Retrieve the flags value for this particular manifest type. |
| 74 | fn get_flags(&self) -> u32; |
| 75 | |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 76 | /// Retrieve the number of bytes of this manifest that is "protected". |
| 77 | /// This field is stored in the outside image header instead of the |
| 78 | /// manifest header. |
| 79 | fn protect_size(&self) -> u16; |
| 80 | |
| 81 | /// Add a dependency on another image. |
| 82 | fn add_dependency(&mut self, id: u8, version: &ImageVersion); |
| 83 | |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 84 | /// Add a sequence of bytes to the payload that the manifest is |
| 85 | /// protecting. |
| 86 | fn add_bytes(&mut self, bytes: &[u8]); |
| 87 | |
David Brown | e90b13f | 2019-12-06 15:04:00 -0700 | [diff] [blame] | 88 | /// Set an internal flag indicating that the next `make_tlv` should |
| 89 | /// corrupt the signature. |
| 90 | fn corrupt_sig(&mut self); |
| 91 | |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 92 | /// Construct the manifest for this payload. |
| 93 | fn make_tlv(self: Box<Self>) -> Vec<u8>; |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 94 | |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 95 | /// Generate a new encryption random key |
| 96 | fn generate_enc_key(&mut self); |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 97 | |
| 98 | /// Return the current encryption key |
| 99 | fn get_enc_key(&self) -> Vec<u8>; |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 102 | #[derive(Debug, Default)] |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 103 | pub struct TlvGen { |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 104 | flags: u32, |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 105 | kinds: Vec<TlvKinds>, |
David Brown | 4243ab0 | 2017-07-11 12:24:23 -0600 | [diff] [blame] | 106 | payload: Vec<u8>, |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 107 | dependencies: Vec<Dependency>, |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 108 | enc_key: Vec<u8>, |
David Brown | e90b13f | 2019-12-06 15:04:00 -0700 | [diff] [blame] | 109 | /// Should this signature be corrupted. |
| 110 | gen_corrupted: bool, |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 111 | } |
| 112 | |
David Brown | c3898d6 | 2019-08-05 14:20:02 -0600 | [diff] [blame] | 113 | #[derive(Debug)] |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 114 | struct Dependency { |
| 115 | id: u8, |
| 116 | version: ImageVersion, |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 117 | } |
| 118 | |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 119 | const AES_KEY_LEN: usize = 16; |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 120 | |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 121 | impl TlvGen { |
| 122 | /// Construct a new tlv generator that will only contain a hash of the data. |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 123 | #[allow(dead_code)] |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 124 | pub fn new_hash_only() -> TlvGen { |
| 125 | TlvGen { |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 126 | kinds: vec![TlvKinds::SHA256], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 127 | ..Default::default() |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 131 | #[allow(dead_code)] |
| 132 | pub fn new_rsa_pss() -> TlvGen { |
| 133 | TlvGen { |
Fabio Utzig | 754438d | 2018-12-14 06:39:58 -0200 | [diff] [blame] | 134 | kinds: vec![TlvKinds::SHA256, TlvKinds::RSA2048], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 135 | ..Default::default() |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 139 | #[allow(dead_code)] |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 140 | pub fn new_rsa3072_pss() -> TlvGen { |
| 141 | TlvGen { |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 142 | kinds: vec![TlvKinds::SHA256, TlvKinds::RSA3072], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 143 | ..Default::default() |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
| 147 | #[allow(dead_code)] |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 148 | pub fn new_ecdsa() -> TlvGen { |
| 149 | TlvGen { |
Fabio Utzig | 754438d | 2018-12-14 06:39:58 -0200 | [diff] [blame] | 150 | kinds: vec![TlvKinds::SHA256, TlvKinds::ECDSA256], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 151 | ..Default::default() |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 155 | #[allow(dead_code)] |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 156 | pub fn new_ed25519() -> TlvGen { |
| 157 | TlvGen { |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 158 | kinds: vec![TlvKinds::SHA256, TlvKinds::ED25519], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 159 | ..Default::default() |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
| 163 | #[allow(dead_code)] |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 164 | pub fn new_enc_rsa() -> TlvGen { |
| 165 | TlvGen { |
| 166 | flags: TlvFlags::ENCRYPTED as u32, |
| 167 | kinds: vec![TlvKinds::SHA256, TlvKinds::ENCRSA2048], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 168 | ..Default::default() |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
| 172 | #[allow(dead_code)] |
Fabio Utzig | 754438d | 2018-12-14 06:39:58 -0200 | [diff] [blame] | 173 | pub fn new_sig_enc_rsa() -> TlvGen { |
| 174 | TlvGen { |
| 175 | flags: TlvFlags::ENCRYPTED as u32, |
| 176 | kinds: vec![TlvKinds::SHA256, TlvKinds::RSA2048, TlvKinds::ENCRSA2048], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 177 | ..Default::default() |
Fabio Utzig | 754438d | 2018-12-14 06:39:58 -0200 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
| 181 | #[allow(dead_code)] |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 182 | pub fn new_enc_kw() -> TlvGen { |
| 183 | TlvGen { |
| 184 | flags: TlvFlags::ENCRYPTED as u32, |
| 185 | kinds: vec![TlvKinds::SHA256, TlvKinds::ENCKW128], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 186 | ..Default::default() |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 187 | } |
| 188 | } |
| 189 | |
Fabio Utzig | 251ef1d | 2018-12-18 17:20:19 -0200 | [diff] [blame] | 190 | #[allow(dead_code)] |
| 191 | pub fn new_rsa_kw() -> TlvGen { |
| 192 | TlvGen { |
| 193 | flags: TlvFlags::ENCRYPTED as u32, |
| 194 | kinds: vec![TlvKinds::SHA256, TlvKinds::RSA2048, TlvKinds::ENCKW128], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 195 | ..Default::default() |
Fabio Utzig | 251ef1d | 2018-12-18 17:20:19 -0200 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
Fabio Utzig | b4d20c8 | 2018-12-27 16:08:39 -0200 | [diff] [blame] | 199 | #[allow(dead_code)] |
| 200 | pub fn new_ecdsa_kw() -> TlvGen { |
| 201 | TlvGen { |
| 202 | flags: TlvFlags::ENCRYPTED as u32, |
| 203 | kinds: vec![TlvKinds::SHA256, TlvKinds::ECDSA256, TlvKinds::ENCKW128], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 204 | ..Default::default() |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
| 208 | #[allow(dead_code)] |
Fabio Utzig | 66b4caa | 2020-01-04 20:19:28 -0300 | [diff] [blame] | 209 | pub fn new_ecies_p256() -> TlvGen { |
| 210 | TlvGen { |
| 211 | flags: TlvFlags::ENCRYPTED as u32, |
| 212 | kinds: vec![TlvKinds::SHA256, TlvKinds::ENCEC256], |
Fabio Utzig | 66b4caa | 2020-01-04 20:19:28 -0300 | [diff] [blame] | 213 | ..Default::default() |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | #[allow(dead_code)] |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 218 | pub fn new_ecdsa_ecies_p256() -> TlvGen { |
| 219 | TlvGen { |
| 220 | flags: TlvFlags::ENCRYPTED as u32, |
| 221 | kinds: vec![TlvKinds::SHA256, TlvKinds::ECDSA256, TlvKinds::ENCEC256], |
Fabio Utzig | 9a2b5de | 2019-11-22 12:50:02 -0300 | [diff] [blame] | 222 | ..Default::default() |
Fabio Utzig | b4d20c8 | 2018-12-27 16:08:39 -0200 | [diff] [blame] | 223 | } |
| 224 | } |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | impl ManifestGen for TlvGen { |
David Brown | ac46e26 | 2019-01-11 15:46:18 -0700 | [diff] [blame] | 228 | fn get_magic(&self) -> u32 { |
| 229 | 0x96f3b83d |
| 230 | } |
| 231 | |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 232 | /// Retrieve the header flags for this configuration. This can be called at any time. |
| 233 | fn get_flags(&self) -> u32 { |
| 234 | self.flags |
| 235 | } |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 236 | |
| 237 | /// Add bytes to the covered hash. |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 238 | fn add_bytes(&mut self, bytes: &[u8]) { |
David Brown | 4243ab0 | 2017-07-11 12:24:23 -0600 | [diff] [blame] | 239 | self.payload.extend_from_slice(bytes); |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 240 | } |
| 241 | |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 242 | fn protect_size(&self) -> u16 { |
David Brown | 2b73ed9 | 2020-01-08 17:01:22 -0700 | [diff] [blame] | 243 | if self.dependencies.is_empty() { |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 244 | 0 |
| 245 | } else { |
David Brown | 2b73ed9 | 2020-01-08 17:01:22 -0700 | [diff] [blame] | 246 | // Include the header and space for each dependency. |
| 247 | 4 + (self.dependencies.len() as u16) * (4 + 4 + 8) |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
| 251 | fn add_dependency(&mut self, id: u8, version: &ImageVersion) { |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 252 | self.dependencies.push(Dependency { |
| 253 | id: id, |
| 254 | version: version.clone(), |
| 255 | }); |
| 256 | } |
| 257 | |
David Brown | e90b13f | 2019-12-06 15:04:00 -0700 | [diff] [blame] | 258 | fn corrupt_sig(&mut self) { |
| 259 | self.gen_corrupted = true; |
| 260 | } |
| 261 | |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 262 | /// Compute the TLV given the specified block of data. |
David Brown | 43643dd | 2019-01-11 15:43:28 -0700 | [diff] [blame] | 263 | fn make_tlv(self: Box<Self>) -> Vec<u8> { |
Fabio Utzig | ea3d3ab | 2019-09-11 19:35:33 -0300 | [diff] [blame] | 264 | let mut protected_tlv: Vec<u8> = vec![]; |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 265 | |
David Brown | 2b73ed9 | 2020-01-08 17:01:22 -0700 | [diff] [blame] | 266 | if self.protect_size() > 0 { |
Fabio Utzig | ea3d3ab | 2019-09-11 19:35:33 -0300 | [diff] [blame] | 267 | protected_tlv.push(0x08); |
| 268 | protected_tlv.push(0x69); |
David Brown | 2b73ed9 | 2020-01-08 17:01:22 -0700 | [diff] [blame] | 269 | let size = self.protect_size(); |
| 270 | protected_tlv.write_u16::<LittleEndian>(size).unwrap(); |
Fabio Utzig | ea3d3ab | 2019-09-11 19:35:33 -0300 | [diff] [blame] | 271 | for dep in &self.dependencies { |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 272 | protected_tlv.write_u16::<LittleEndian>(TlvKinds::DEPENDENCY as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 273 | protected_tlv.write_u16::<LittleEndian>(12).unwrap(); |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 274 | |
Fabio Utzig | ea3d3ab | 2019-09-11 19:35:33 -0300 | [diff] [blame] | 275 | // The dependency. |
| 276 | protected_tlv.push(dep.id); |
| 277 | for _ in 0 .. 3 { |
| 278 | protected_tlv.push(0); |
| 279 | } |
| 280 | protected_tlv.push(dep.version.major); |
| 281 | protected_tlv.push(dep.version.minor); |
| 282 | protected_tlv.write_u16::<LittleEndian>(dep.version.revision).unwrap(); |
| 283 | protected_tlv.write_u32::<LittleEndian>(dep.version.build_num).unwrap(); |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 284 | } |
David Brown | 2b73ed9 | 2020-01-08 17:01:22 -0700 | [diff] [blame] | 285 | |
| 286 | assert_eq!(size, protected_tlv.len() as u16, "protected TLV length incorrect"); |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | // Ring does the signature itself, which means that it must be |
| 290 | // given a full, contiguous payload. Although this does help from |
| 291 | // a correct usage perspective, it is fairly stupid from an |
| 292 | // efficiency view. If this is shown to be a performance issue |
| 293 | // with the tests, the protected data could be appended to the |
| 294 | // payload, and then removed after the signature is done. For now, |
| 295 | // just make a signed payload. |
| 296 | let mut sig_payload = self.payload.clone(); |
Fabio Utzig | ea3d3ab | 2019-09-11 19:35:33 -0300 | [diff] [blame] | 297 | sig_payload.extend_from_slice(&protected_tlv); |
| 298 | |
| 299 | let mut result: Vec<u8> = vec![]; |
| 300 | |
| 301 | // add back signed payload |
| 302 | result.extend_from_slice(&protected_tlv); |
| 303 | |
| 304 | // add non-protected payload |
David Brown | 3dc86c9 | 2020-01-08 17:22:55 -0700 | [diff] [blame] | 305 | let npro_pos = result.len(); |
Fabio Utzig | ea3d3ab | 2019-09-11 19:35:33 -0300 | [diff] [blame] | 306 | result.push(0x07); |
| 307 | result.push(0x69); |
David Brown | 3dc86c9 | 2020-01-08 17:22:55 -0700 | [diff] [blame] | 308 | // Placeholder for the size. |
| 309 | result.write_u16::<LittleEndian>(0).unwrap(); |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 310 | |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 311 | if self.kinds.contains(&TlvKinds::SHA256) { |
David Brown | e90b13f | 2019-12-06 15:04:00 -0700 | [diff] [blame] | 312 | // If a signature is not requested, corrupt the hash we are |
| 313 | // generating. But, if there is a signature, output the |
| 314 | // correct hash. We want the hash test to pass so that the |
| 315 | // signature verification can be validated. |
| 316 | let mut corrupt_hash = self.gen_corrupted; |
| 317 | for k in &[TlvKinds::RSA2048, TlvKinds::RSA3072, |
| 318 | TlvKinds::ECDSA224, TlvKinds::ECDSA256, |
| 319 | TlvKinds::ED25519] |
| 320 | { |
| 321 | if self.kinds.contains(k) { |
| 322 | corrupt_hash = false; |
| 323 | break; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if corrupt_hash { |
| 328 | sig_payload[0] ^= 1; |
| 329 | } |
| 330 | |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 331 | let hash = digest::digest(&digest::SHA256, &sig_payload); |
David Brown | 8054ce2 | 2017-07-11 12:12:09 -0600 | [diff] [blame] | 332 | let hash = hash.as_ref(); |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 333 | |
David Brown | 8054ce2 | 2017-07-11 12:12:09 -0600 | [diff] [blame] | 334 | assert!(hash.len() == 32); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 335 | result.write_u16::<LittleEndian>(TlvKinds::SHA256 as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 336 | result.write_u16::<LittleEndian>(32).unwrap(); |
David Brown | 8054ce2 | 2017-07-11 12:12:09 -0600 | [diff] [blame] | 337 | result.extend_from_slice(hash); |
David Brown | e90b13f | 2019-12-06 15:04:00 -0700 | [diff] [blame] | 338 | |
| 339 | // Undo the corruption. |
| 340 | if corrupt_hash { |
| 341 | sig_payload[0] ^= 1; |
| 342 | } |
| 343 | |
| 344 | } |
| 345 | |
| 346 | if self.gen_corrupted { |
| 347 | // Corrupt what is signed by modifying the input to the |
| 348 | // signature code. |
| 349 | sig_payload[0] ^= 1; |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 350 | } |
| 351 | |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 352 | if self.kinds.contains(&TlvKinds::RSA2048) || |
| 353 | self.kinds.contains(&TlvKinds::RSA3072) { |
| 354 | |
| 355 | let is_rsa2048 = self.kinds.contains(&TlvKinds::RSA2048); |
| 356 | |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 357 | // Output the hash of the public key. |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 358 | let hash = if is_rsa2048 { |
| 359 | digest::digest(&digest::SHA256, RSA_PUB_KEY) |
| 360 | } else { |
| 361 | digest::digest(&digest::SHA256, RSA3072_PUB_KEY) |
| 362 | }; |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 363 | let hash = hash.as_ref(); |
| 364 | |
| 365 | assert!(hash.len() == 32); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 366 | result.write_u16::<LittleEndian>(TlvKinds::KEYHASH as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 367 | result.write_u16::<LittleEndian>(32).unwrap(); |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 368 | result.extend_from_slice(hash); |
| 369 | |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 370 | // For now assume PSS. |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 371 | let key_bytes = if is_rsa2048 { |
| 372 | pem::parse(include_bytes!("../../root-rsa-2048.pem").as_ref()).unwrap() |
| 373 | } else { |
| 374 | pem::parse(include_bytes!("../../root-rsa-3072.pem").as_ref()).unwrap() |
| 375 | }; |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 376 | assert_eq!(key_bytes.tag, "RSA PRIVATE KEY"); |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 377 | let key_pair = RsaKeyPair::from_der(&key_bytes.contents).unwrap(); |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 378 | let rng = rand::SystemRandom::new(); |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 379 | let mut signature = vec![0; key_pair.public_modulus_len()]; |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 380 | if is_rsa2048 { |
| 381 | assert_eq!(signature.len(), 256); |
| 382 | } else { |
| 383 | assert_eq!(signature.len(), 384); |
| 384 | } |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 385 | key_pair.sign(&RSA_PSS_SHA256, &rng, &sig_payload, &mut signature).unwrap(); |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 386 | |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 387 | if is_rsa2048 { |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 388 | result.write_u16::<LittleEndian>(TlvKinds::RSA2048 as u16).unwrap(); |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 389 | } else { |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 390 | result.write_u16::<LittleEndian>(TlvKinds::RSA3072 as u16).unwrap(); |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 391 | } |
David Brown | 91d6863 | 2019-07-29 14:32:13 -0600 | [diff] [blame] | 392 | result.write_u16::<LittleEndian>(signature.len() as u16).unwrap(); |
David Brown | 7e701d8 | 2017-07-11 13:24:25 -0600 | [diff] [blame] | 393 | result.extend_from_slice(&signature); |
| 394 | } |
| 395 | |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 396 | if self.kinds.contains(&TlvKinds::ECDSA256) { |
| 397 | let keyhash = digest::digest(&digest::SHA256, ECDSA256_PUB_KEY); |
| 398 | let keyhash = keyhash.as_ref(); |
| 399 | |
| 400 | assert!(keyhash.len() == 32); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 401 | result.write_u16::<LittleEndian>(TlvKinds::KEYHASH as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 402 | result.write_u16::<LittleEndian>(32).unwrap(); |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 403 | result.extend_from_slice(keyhash); |
| 404 | |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 405 | let key_bytes = pem::parse(include_bytes!("../../root-ec-p256-pkcs8.pem").as_ref()).unwrap(); |
| 406 | assert_eq!(key_bytes.tag, "PRIVATE KEY"); |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 407 | |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 408 | let key_pair = EcdsaKeyPair::from_pkcs8(&ECDSA_P256_SHA256_ASN1_SIGNING, |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 409 | &key_bytes.contents).unwrap(); |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 410 | let rng = rand::SystemRandom::new(); |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 411 | let signature = key_pair.sign(&rng, &sig_payload).unwrap(); |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 412 | |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 413 | result.write_u16::<LittleEndian>(TlvKinds::ECDSA256 as u16).unwrap(); |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 414 | |
David Brown | e90b13f | 2019-12-06 15:04:00 -0700 | [diff] [blame] | 415 | |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 416 | // signature must be padded... |
| 417 | let mut signature = signature.as_ref().to_vec(); |
| 418 | while signature.len() < 72 { |
| 419 | signature.push(0); |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 420 | } |
| 421 | |
David Brown | 91d6863 | 2019-07-29 14:32:13 -0600 | [diff] [blame] | 422 | result.write_u16::<LittleEndian>(signature.len() as u16).unwrap(); |
Fabio Utzig | 05ab014 | 2018-07-10 09:15:28 -0300 | [diff] [blame] | 423 | result.extend_from_slice(signature.as_ref()); |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 424 | } |
| 425 | |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 426 | if self.kinds.contains(&TlvKinds::ED25519) { |
| 427 | let keyhash = digest::digest(&digest::SHA256, ED25519_PUB_KEY); |
| 428 | let keyhash = keyhash.as_ref(); |
| 429 | |
| 430 | assert!(keyhash.len() == 32); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 431 | result.write_u16::<LittleEndian>(TlvKinds::KEYHASH as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 432 | result.write_u16::<LittleEndian>(32).unwrap(); |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 433 | result.extend_from_slice(keyhash); |
| 434 | |
David Brown | 7a81c4b | 2019-07-29 15:20:21 -0600 | [diff] [blame] | 435 | let hash = digest::digest(&digest::SHA256, &sig_payload); |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 436 | let hash = hash.as_ref(); |
| 437 | assert!(hash.len() == 32); |
| 438 | |
| 439 | let key_bytes = pem::parse(include_bytes!("../../root-ed25519.pem").as_ref()).unwrap(); |
| 440 | assert_eq!(key_bytes.tag, "PRIVATE KEY"); |
| 441 | |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 442 | let key_pair = Ed25519KeyPair::from_seed_and_public_key( |
| 443 | &key_bytes.contents[16..48], &ED25519_PUB_KEY[12..44]).unwrap(); |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 444 | let signature = key_pair.sign(&hash); |
| 445 | |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 446 | result.write_u16::<LittleEndian>(TlvKinds::ED25519 as u16).unwrap(); |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 447 | |
| 448 | let signature = signature.as_ref().to_vec(); |
David Brown | 91d6863 | 2019-07-29 14:32:13 -0600 | [diff] [blame] | 449 | result.write_u16::<LittleEndian>(signature.len() as u16).unwrap(); |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 450 | result.extend_from_slice(signature.as_ref()); |
| 451 | } |
| 452 | |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 453 | if self.kinds.contains(&TlvKinds::ENCRSA2048) { |
| 454 | let key_bytes = pem::parse(include_bytes!("../../enc-rsa2048-pub.pem") |
| 455 | .as_ref()).unwrap(); |
| 456 | assert_eq!(key_bytes.tag, "PUBLIC KEY"); |
| 457 | |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 458 | let cipherkey = self.get_enc_key(); |
| 459 | let cipherkey = cipherkey.as_slice(); |
| 460 | let encbuf = match c::rsa_oaep_encrypt(&key_bytes.contents, cipherkey) { |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 461 | Ok(v) => v, |
| 462 | Err(_) => panic!("Failed to encrypt secret key"), |
| 463 | }; |
| 464 | |
| 465 | assert!(encbuf.len() == 256); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 466 | result.write_u16::<LittleEndian>(TlvKinds::ENCRSA2048 as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 467 | result.write_u16::<LittleEndian>(256).unwrap(); |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 468 | result.extend_from_slice(&encbuf); |
| 469 | } |
| 470 | |
| 471 | if self.kinds.contains(&TlvKinds::ENCKW128) { |
| 472 | let key_bytes = base64::decode( |
| 473 | include_str!("../../enc-aes128kw.b64").trim()).unwrap(); |
| 474 | |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 475 | let cipherkey = self.get_enc_key(); |
| 476 | let cipherkey = cipherkey.as_slice(); |
| 477 | let encbuf = match c::kw_encrypt(&key_bytes, cipherkey) { |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 478 | Ok(v) => v, |
| 479 | Err(_) => panic!("Failed to encrypt secret key"), |
| 480 | }; |
| 481 | |
| 482 | assert!(encbuf.len() == 24); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 483 | result.write_u16::<LittleEndian>(TlvKinds::ENCKW128 as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 484 | result.write_u16::<LittleEndian>(24).unwrap(); |
Fabio Utzig | 1e48b91 | 2018-09-18 09:04:18 -0300 | [diff] [blame] | 485 | result.extend_from_slice(&encbuf); |
| 486 | } |
| 487 | |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 488 | if self.kinds.contains(&TlvKinds::ENCEC256) { |
| 489 | let key_bytes = pem::parse(include_bytes!("../../enc-ec256-pub.pem").as_ref()).unwrap(); |
| 490 | assert_eq!(key_bytes.tag, "PUBLIC KEY"); |
| 491 | |
| 492 | let rng = rand::SystemRandom::new(); |
| 493 | let pk = match agreement::EphemeralPrivateKey::generate(&agreement::ECDH_P256, &rng) { |
| 494 | Ok(v) => v, |
| 495 | Err(_) => panic!("Failed to generate ephemeral keypair"), |
| 496 | }; |
| 497 | |
| 498 | let pubk = match pk.compute_public_key() { |
| 499 | Ok(pubk) => pubk, |
| 500 | Err(_) => panic!("Failed computing ephemeral public key"), |
| 501 | }; |
| 502 | |
| 503 | let peer_pubk = agreement::UnparsedPublicKey::new(&agreement::ECDH_P256, &key_bytes.contents[26..]); |
| 504 | |
| 505 | #[derive(Debug, PartialEq)] |
| 506 | struct OkmLen<T: core::fmt::Debug + PartialEq>(T); |
| 507 | |
| 508 | impl hkdf::KeyType for OkmLen<usize> { |
| 509 | fn len(&self) -> usize { |
| 510 | self.0 |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | let derived_key = match agreement::agree_ephemeral( |
| 515 | pk, &peer_pubk, ring::error::Unspecified, |shared| { |
| 516 | let salt = hkdf::Salt::new(hkdf::HKDF_SHA256, &[]); |
| 517 | let prk = salt.extract(&shared); |
| 518 | let okm = match prk.expand(&[b"MCUBoot_ECIES_v1"], OkmLen(48)) { |
| 519 | Ok(okm) => okm, |
| 520 | Err(_) => panic!("Failed building HKDF OKM"), |
| 521 | }; |
| 522 | let mut buf = [0u8; 48]; |
| 523 | match okm.fill(&mut buf) { |
| 524 | Ok(_) => Ok(buf), |
| 525 | Err(_) => panic!("Failed generating HKDF output"), |
| 526 | } |
| 527 | }, |
| 528 | ) { |
| 529 | Ok(v) => v, |
| 530 | Err(_) => panic!("Failed building HKDF"), |
| 531 | }; |
| 532 | |
| 533 | let key = GenericArray::from_slice(&derived_key[..16]); |
| 534 | let nonce = GenericArray::from_slice(&[0; 16]); |
| 535 | let mut cipher = Aes128Ctr::new(&key, &nonce); |
| 536 | let mut cipherkey = self.get_enc_key(); |
| 537 | cipher.apply_keystream(&mut cipherkey); |
| 538 | |
| 539 | let key = hmac::Key::new(hmac::HMAC_SHA256, &derived_key[16..]); |
| 540 | let tag = hmac::sign(&key, &cipherkey); |
| 541 | |
| 542 | let mut buf = vec![]; |
| 543 | buf.append(&mut pubk.as_ref().to_vec()); |
| 544 | buf.append(&mut tag.as_ref().to_vec()); |
| 545 | buf.append(&mut cipherkey); |
| 546 | |
| 547 | assert!(buf.len() == 113); |
David Brown | 6972118 | 2019-12-04 14:50:52 -0700 | [diff] [blame] | 548 | result.write_u16::<LittleEndian>(TlvKinds::ENCEC256 as u16).unwrap(); |
David Brown | 4fae8b8 | 2019-12-05 11:26:59 -0700 | [diff] [blame] | 549 | result.write_u16::<LittleEndian>(113).unwrap(); |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 550 | result.extend_from_slice(&buf); |
| 551 | } |
| 552 | |
David Brown | 3dc86c9 | 2020-01-08 17:22:55 -0700 | [diff] [blame] | 553 | // Patch the size back into the TLV header. |
| 554 | let size = (result.len() - npro_pos) as u16; |
| 555 | let mut size_buf = &mut result[npro_pos + 2 .. npro_pos + 4]; |
| 556 | size_buf.write_u16::<LittleEndian>(size).unwrap(); |
| 557 | |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 558 | result |
| 559 | } |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 560 | |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 561 | fn generate_enc_key(&mut self) { |
| 562 | let rng = rand::SystemRandom::new(); |
| 563 | let mut buf = vec![0u8; AES_KEY_LEN]; |
| 564 | match rng.fill(&mut buf) { |
| 565 | Err(_) => panic!("Error generating encrypted key"), |
| 566 | Ok(_) => (), |
| 567 | } |
| 568 | info!("New encryption key: {:02x?}", buf); |
| 569 | self.enc_key = buf; |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | fn get_enc_key(&self) -> Vec<u8> { |
Fabio Utzig | e84f0ef | 2019-11-22 12:29:32 -0300 | [diff] [blame] | 573 | if self.enc_key.len() != AES_KEY_LEN { |
| 574 | panic!("No random key was generated"); |
| 575 | } |
| 576 | self.enc_key.clone() |
Fabio Utzig | 90f449e | 2019-10-24 07:43:53 -0300 | [diff] [blame] | 577 | } |
David Brown | 187dd88 | 2017-07-11 11:15:23 -0600 | [diff] [blame] | 578 | } |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 579 | |
| 580 | include!("rsa_pub_key-rs.txt"); |
Fabio Utzig | 3929743 | 2019-05-08 18:51:10 -0300 | [diff] [blame] | 581 | include!("rsa3072_pub_key-rs.txt"); |
Fabio Utzig | 80fde2f | 2017-12-05 09:25:31 -0200 | [diff] [blame] | 582 | include!("ecdsa_pub_key-rs.txt"); |
Fabio Utzig | 9771028 | 2019-05-24 17:44:49 -0300 | [diff] [blame] | 583 | include!("ed25519_pub_key-rs.txt"); |