Commit 9930a3ec authored by David Brown's avatar David Brown Committed by David Brown
Browse files

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: default avatarDavid Brown <david.brown@linaro.org>
parent c4a60a36
Loading
Loading
Loading
Loading
+2
Changes for sim/src/caps.rs: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ pub enum Caps {
    EcdsaP256        = (1 << 2),
    SwapUpgrade      = (1 << 3),
    OverwriteUpgrade = (1 << 4),
    EncRsa           = (1 << 5),
    EncKw            = (1 << 6),
}

impl Caps {
+6 −16
Changes for sim/src/image.rs: 6 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -320,29 +320,19 @@ impl Images {
        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)
    }

    #[cfg(feature = "enc-rsa")]
    #[cfg(not(feature = "overwrite-only"))]
    fn status_sz(&self, align: usize) -> usize {
        self.trailer_sz(align) - (16 + 24 + 32)
    }
        let bias = if Caps::EncRsa.present() || Caps::EncKw.present() {
            32
        } else {
            0
        };

    #[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