From 66b4caac452c5945042a76a15d4492d5de5137bb Mon Sep 17 00:00:00 2001 From: Fabio Utzig Date: Sat, 4 Jan 2020 20:19:28 -0300 Subject: [PATCH] sim: allow generation of non-signed + encrypted EC images Signed-off-by: Fabio Utzig --- sim/src/image.rs | 7 +++++-- sim/src/tlv.rs | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sim/src/image.rs b/sim/src/image.rs index b7f8ed62..fe97f12c 100644 --- a/sim/src/image.rs +++ b/sim/src/image.rs @@ -1267,8 +1267,11 @@ fn make_tlv() -> TlvGen { TlvGen::new_enc_rsa() } } else if Caps::EncEc256.present() { - //FIXME: should fail with RSA signature? - TlvGen::new_ecdsa_ecies_p256() + if Caps::EcdsaP256.present() { + TlvGen::new_ecdsa_ecies_p256() + } else { + TlvGen::new_ecies_p256() + } } else { // The non-encrypted configuration. if Caps::RSA2048.present() { diff --git a/sim/src/tlv.rs b/sim/src/tlv.rs index c4bd54ea..80d82ae0 100644 --- a/sim/src/tlv.rs +++ b/sim/src/tlv.rs @@ -214,6 +214,16 @@ impl TlvGen { } } + #[allow(dead_code)] + pub fn new_ecies_p256() -> TlvGen { + TlvGen { + flags: TlvFlags::ENCRYPTED as u32, + kinds: vec![TlvKinds::SHA256, TlvKinds::ENCEC256], + size: 4 + 32 + 4 + 32 + 4 + 113, + ..Default::default() + } + } + #[allow(dead_code)] pub fn new_ecdsa_ecies_p256() -> TlvGen { TlvGen {