Commit 2ee5f7f7 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

sim: Test software rollback protection

parent 07e1381d
Loading
Loading
Loading
Loading
+2 −0
Changes for .travis.yml: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ matrix:
      env: MULTI_FEATURES="sig-ecdsa enc-kw validate-primary-slot" TEST=sim
    - os: linux
      env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only large-write,sig-ecdsa enc-ec256 validate-primary-slot" TEST=sim
    - os: linux
      env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only downgrade-prevention" TEST=sim

    - os: linux
      language: go
+1 −0
Changes for sim/Cargo.toml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ enc-ec256 = ["mcuboot-sys/enc-ec256"]
bootstrap = ["mcuboot-sys/bootstrap"]
multiimage = ["mcuboot-sys/multiimage"]
large-write = []
downgrade-prevention = ["mcuboot-sys/downgrade-prevention"]

[dependencies]
byteorder = "1.3"
+3 −0
Changes for sim/mcuboot-sys/Cargo.toml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ bootstrap = []
# Support multiple images (currently 2 instead of 1).
multiimage = []

# Check (in software) against version downgrades.
downgrade-prevention = []

[build-dependencies]
cc = "1.0.25"

+9 −0
Changes for sim/mcuboot-sys/build.rs: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ fn main() {
    let enc_ec256 = env::var("CARGO_FEATURE_ENC_EC256").is_ok();
    let bootstrap = env::var("CARGO_FEATURE_BOOTSTRAP").is_ok();
    let multiimage = env::var("CARGO_FEATURE_MULTIIMAGE").is_ok();
    let downgrade_prevention = env::var("CARGO_FEATURE_DOWNGRADE_PREVENTION").is_ok();

    let mut conf = cc::Build::new();
    conf.define("__BOOTSIM__", None);
@@ -31,6 +32,10 @@ fn main() {
    conf.define("MCUBOOT_MAX_IMG_SECTORS", Some("128"));
    conf.define("MCUBOOT_IMAGE_NUMBER", Some(if multiimage { "2" } else { "1" }));

    if downgrade_prevention && !overwrite_only {
        panic!("Downgrade prevention requires overwrite only");
    }

    if bootstrap {
        conf.define("MCUBOOT_BOOTSTRAP", None);
    }
@@ -39,6 +44,10 @@ fn main() {
        conf.define("MCUBOOT_VALIDATE_PRIMARY_SLOT", None);
    }

    if downgrade_prevention {
        conf.define("MCUBOOT_DOWNGRADE_PREVENTION", None);
    }

    // Currently no more than one sig type can be used simultaneously.
    if vec![sig_rsa, sig_rsa3072, sig_ecdsa, sig_ed25519].iter()
        .fold(0, |sum, &v| sum + v as i32) > 1 {
+1 −0
Changes for sim/src/caps.rs: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ pub enum Caps {
    Ed25519              = (1 << 9),
    EncEc256             = (1 << 10),
    SwapUsingMove        = (1 << 11),
    DowngradePrevention  = (1 << 12),
}

impl Caps {
Loading