Add rsa+kw testing support to simulator
Allows simulating images signed with RSA-2048 and encrypted with
AES-128-KW.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/src/lib.rs b/sim/src/lib.rs
index 7eb27c5..629b916 100644
--- a/sim/src/lib.rs
+++ b/sim/src/lib.rs
@@ -1183,7 +1183,14 @@
// The TLV in use depends on what kind of signature we are verifying.
#[cfg(feature = "sig-rsa")]
+#[cfg(feature = "enc-kw")]
+fn make_tlv() -> TlvGen {
+ TlvGen::new_rsa_kw()
+}
+
+#[cfg(feature = "sig-rsa")]
#[cfg(not(feature = "enc-rsa"))]
+#[cfg(not(feature = "enc-kw"))]
fn make_tlv() -> TlvGen {
TlvGen::new_rsa_pss()
}
@@ -1205,6 +1212,7 @@
TlvGen::new_sig_enc_rsa()
}
+#[cfg(not(feature = "sig-rsa"))]
#[cfg(feature = "enc-kw")]
fn make_tlv() -> TlvGen {
TlvGen::new_enc_kw()
diff --git a/sim/src/tlv.rs b/sim/src/tlv.rs
index 6931d0b..afc34aa 100644
--- a/sim/src/tlv.rs
+++ b/sim/src/tlv.rs
@@ -107,6 +107,16 @@
}
}
+ #[allow(dead_code)]
+ pub fn new_rsa_kw() -> TlvGen {
+ TlvGen {
+ flags: TlvFlags::ENCRYPTED as u32,
+ kinds: vec![TlvKinds::SHA256, TlvKinds::RSA2048, TlvKinds::ENCKW128],
+ size: 4 + 32 + 4 + 32 + 4 + 256 + 4 + 24,
+ payload: vec![],
+ }
+ }
+
/// Retrieve the header flags for this configuration. This can be called at any time.
pub fn get_flags(&self) -> u32 {
self.flags