sim: Use enc capability
Now that we can dynamically query whether mcuboot is built with
encryption support, remove conditional compilation in favor of a dynamic
query.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/src/caps.rs b/sim/src/caps.rs
index 77be9de..dec879b 100644
--- a/sim/src/caps.rs
+++ b/sim/src/caps.rs
@@ -9,6 +9,8 @@
EcdsaP256 = (1 << 2),
SwapUpgrade = (1 << 3),
OverwriteUpgrade = (1 << 4),
+ EncRsa = (1 << 5),
+ EncKw = (1 << 6),
}
impl Caps {
diff --git a/sim/src/image.rs b/sim/src/image.rs
index a25e738..417e873 100644
--- a/sim/src/image.rs
+++ b/sim/src/image.rs
@@ -320,29 +320,19 @@
fails > 0
}
- #[cfg(not(feature = "overwrite-only"))]
fn trailer_sz(&self, align: usize) -> usize {
c::boot_trailer_sz(align as u8) as usize
}
// FIXME: could get status sz from bootloader
- #[cfg(not(feature = "overwrite-only"))]
- #[cfg(not(feature = "enc-rsa"))]
- #[cfg(not(feature = "enc-kw"))]
fn status_sz(&self, align: usize) -> usize {
- self.trailer_sz(align) - (16 + 24)
- }
+ let bias = if Caps::EncRsa.present() || Caps::EncKw.present() {
+ 32
+ } else {
+ 0
+ };
- #[cfg(feature = "enc-rsa")]
- #[cfg(not(feature = "overwrite-only"))]
- fn status_sz(&self, align: usize) -> usize {
- self.trailer_sz(align) - (16 + 24 + 32)
- }
-
- #[cfg(feature = "enc-kw")]
- #[cfg(not(feature = "overwrite-only"))]
- fn status_sz(&self, align: usize) -> usize {
- self.trailer_sz(align) - (16 + 24 + 32)
+ self.trailer_sz(align) - (16 + 24 + bias)
}
/// This test runs a simple upgrade with no fails in the images, but