sim: Conditionalize rsa signature checking
Allow a build with sig-rsa set or not set. Only add the signature to
the TLV if we are building with the signature checking.
diff --git a/sim/src/main.rs b/sim/src/main.rs
index 3156b9c..1bf6e88 100644
--- a/sim/src/main.rs
+++ b/sim/src/main.rs
@@ -601,7 +601,7 @@
fn install_image(flash: &mut Flash, offset: usize, len: usize) -> Vec<u8> {
let offset0 = offset;
- let mut tlv = TlvGen::new_rsa_pss();
+ let mut tlv = make_tlv();
// Generate a boot header. Note that the size doesn't include the header.
let header = ImageHeader {
@@ -655,6 +655,17 @@
copy
}
+// The TLV in use depends on what kind of signature we are verifying.
+#[cfg(feature = "sig-rsa")]
+fn make_tlv() -> TlvGen {
+ TlvGen::new_rsa_pss()
+}
+
+#[cfg(not(feature = "sig-rsa"))]
+fn make_tlv() -> TlvGen {
+ TlvGen::new_hash_only()
+}
+
/// Verify that given image is present in the flash at the given offset.
fn verify_image(flash: &Flash, offset: usize, buf: &[u8]) -> bool {
let mut copy = vec![0u8; buf.len()];