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>
This commit is contained in:
David Brown 2019-01-11 12:28:26 -07:00 committed by David Brown
parent c4a60a3686
commit 9930a3ec16
2 changed files with 8 additions and 16 deletions

View File

@ -9,6 +9,8 @@ pub enum Caps {
EcdsaP256 = (1 << 2),
SwapUpgrade = (1 << 3),
OverwriteUpgrade = (1 << 4),
EncRsa = (1 << 5),
EncKw = (1 << 6),
}
impl Caps {

View File

@ -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)
}
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