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