diff --git a/bao1x-boot/blobs/ac-block-0x3dc000.bin b/bao1x-boot/blobs/ac-block-0x3dc000.bin index 73552f631..2679947d1 100644 Binary files a/bao1x-boot/blobs/ac-block-0x3dc000.bin and b/bao1x-boot/blobs/ac-block-0x3dc000.bin differ diff --git a/bao1x-boot/blobs/ifr_0x180_rv_only.bin b/bao1x-boot/blobs/ifr_0x180_rv_only.bin index 7d6ef38a3..7f1b68a64 100644 Binary files a/bao1x-boot/blobs/ifr_0x180_rv_only.bin and b/bao1x-boot/blobs/ifr_0x180_rv_only.bin differ diff --git a/bao1x-boot/blobs/ifr_0xc0.bin b/bao1x-boot/blobs/ifr_0xc0.bin index dc6c5c3d1..10dc752fc 100644 Binary files a/bao1x-boot/blobs/ifr_0xc0.bin and b/bao1x-boot/blobs/ifr_0xc0.bin differ diff --git a/bao1x-boot/blobs/pubkey-block-0x3e0080.bin b/bao1x-boot/blobs/pubkey-block-0x3e0080.bin index d8ca89924..35b3486ba 100644 Binary files a/bao1x-boot/blobs/pubkey-block-0x3e0080.bin and b/bao1x-boot/blobs/pubkey-block-0x3e0080.bin differ diff --git a/bao1x-boot/blobs/pubkey-block-ifr-0x1a0.bin b/bao1x-boot/blobs/pubkey-block-ifr-0x1a0.bin new file mode 100644 index 000000000..27adbd3fc Binary files /dev/null and b/bao1x-boot/blobs/pubkey-block-ifr-0x1a0.bin differ diff --git a/bao1x-boot/boot1/src/platform/bao1x/slots.rs b/bao1x-boot/boot1/src/platform/bao1x/slots.rs index 995fcbf87..9f313bf9f 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/slots.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/slots.rs @@ -43,19 +43,22 @@ pub fn check_slots(board_type: &bao1x_api::BoardTypeCoding) { if slot_mgr.read(&CP_ID).unwrap().iter().all(|&b| b == 0 || b == 0xFF) { let cp_id = unsafe { core::slice::from_raw_parts(IFR_CP_ID_BASE as *const u8, SLOT_ELEMENT_LEN_BYTES) }; - slot_mgr.write(&mut rram, &CP_ID, cp_id.try_into().unwrap()).unwrap(); + // don't fail on write failure - otherwise we get stuck here and can't debug the chip + slot_mgr.write(&mut rram, &CP_ID, cp_id.try_into().unwrap()).ok(); } // this one may allocate a TRNG, which takes >50 ms to warm up. if slot_mgr.read(&SERIAL_NUMBER).unwrap().iter().all(|&b| b == 0 || b == 0xFF) { let trng = maybe_trng.get_or_insert_with(|| super::trng::ManagedTrng::new(&board_type)); let k = trng.generate_key(); - slot_mgr.write(&mut rram, &SERIAL_NUMBER, &k).unwrap(); + // don't fail on write failure - otherwise we get stuck here and can't debug the chip + slot_mgr.write(&mut rram, &SERIAL_NUMBER, &k).ok(); } if slot_mgr.read(&UUID).unwrap().iter().all(|&b| b == 0 || b == 0xFF) { let trng = maybe_trng.get_or_insert_with(|| super::trng::ManagedTrng::new(&board_type)); let k = trng.generate_key(); - slot_mgr.write(&mut rram, &UUID, &k).unwrap(); + // don't fail on write failure - otherwise we get stuck here and can't debug the chip + slot_mgr.write(&mut rram, &UUID, &k).ok(); } if slot_mgr.read(&IFR_HASH).unwrap().iter().all(|&b| b == 0 || b == 0xFF) { use digest::Digest; @@ -65,7 +68,8 @@ pub fn check_slots(board_type: &bao1x_api::BoardTypeCoding) { unsafe { core::slice::from_raw_parts(bao1x_api::IFR_BASE as *const u8, bao1x_api::IFR_LEN) }; hasher.update(&ifr_slice); let digest = hasher.finalize(); - slot_mgr.write(&mut rram, &IFR_HASH, digest.as_slice().try_into().unwrap()).unwrap(); + // don't fail on write failure - otherwise we get stuck here and can't debug the chip + slot_mgr.write(&mut rram, &IFR_HASH, digest.as_slice().try_into().unwrap()).ok(); } // once all values are written, advance the CP_BOOT_SETUP_DONE state // safety: the offset is correct because we're pulling it from our pre-defined constants and diff --git a/bao1x-boot/boot1/src/repl.rs b/bao1x-boot/boot1/src/repl.rs index e10d31f13..09f6e3080 100644 --- a/bao1x-boot/boot1/src/repl.rs +++ b/bao1x-boot/boot1/src/repl.rs @@ -438,6 +438,17 @@ impl Repl { } else { crate::println!("In-system keys have been generated"); } + let ifr = unsafe { core::slice::from_raw_parts(0x6040_0180 as *const u8, 0x10) }; + let ref_value = [ + 0x00u8, 0x00, 0x00, 0x00, 0x82, 0x8c, 0x42, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + ]; + if ifr == &ref_value { + crate::println!("CM7 & debug confirmed fused off"); + } else { + crate::println!("Factory configuration error - CM7 or debug is enabled!"); + secure = false; + } if !secure { crate::println!("** System did not meet minimum requirements for security **"); } @@ -557,6 +568,14 @@ impl Repl { let mut rcurst = CSR::new(utra::sysctrl::HW_SYSCTRL_BASE as *mut u32); rcurst.wo(utra::sysctrl::SFR_RCURST0, 0x55AA); } + "ifr" => { + // safety: the IFR region is aligned and exists here. It is sealed by hardware in USER mode, + // and should report as all 0's. + let ifr = unsafe { core::slice::from_raw_parts(0x6040_0000 as *const u8, 0x400) }; + for (i, chunk) in ifr.chunks(32).enumerate() { + crate::println!(" {:03x}: {:02x?}", i * 32, chunk); + } + } #[cfg(feature = "test-boot0-keys")] "publock" => { let rram = CSR::new(utra::rrc::HW_RRC_BASE as *mut u32); @@ -655,7 +674,7 @@ impl Repl { _ => { crate::println!("Command not recognized: {}", cmd); crate::print!( - "Commands include: reset, echo, altboot, boot, bootwait, idmode, localecho, uf2, boardtype, audit, lockdown, paranoid, self_destruct" + "Commands include: reset, echo, altboot, boot, bootwait, idmode, localecho, uf2, boardtype, audit, lockdown, paranoid, self_destruct, ifr" ); #[cfg(feature = "test-boot0-keys")] crate::print!(", publock"); diff --git a/bao1x-boot/boot1/src/secboot.rs b/bao1x-boot/boot1/src/secboot.rs index 4927bfc16..4bcf6a976 100644 --- a/bao1x-boot/boot1/src/secboot.rs +++ b/bao1x-boot/boot1/src/secboot.rs @@ -36,6 +36,22 @@ pub fn try_boot(or_die: bool, csprng: &mut Csprng) { if dev2 != 0 { bao1x_hal::sigcheck::erase_secrets(&mut Some(csprng)).inspect_err(|e| crate::println!("{}", e)).ok(); // "ok" because the expected error is a check on logic/configuration bugs, not attacks } + bollard!(bao1x_hal::sigcheck::die_no_std, 4); + csprng.random_delay(); + { + // check IFR settings - this confirms that the Cortex M7 is disabled, and that hardware JTAG debug is + // disabled + let ifr = unsafe { core::slice::from_raw_parts(0x6040_0180 as *const u8, 0x10) }; + let ref_value = [ + 0x00u8, 0x00, 0x00, 0x00, 0x82, 0x8c, 0x42, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + if ifr != &ref_value { + bao1x_hal::sigcheck::erase_secrets(&mut Some(csprng)) + .inspect_err(|e| crate::println!("{}", e)) + .ok(); // "ok" because the expected error is a check on logic/configuration bugs, not attacks + crate::println!("Incorrect IFR: factory error, or under attack. Secrets erased."); + } + } csprng.random_delay(); let (paranoid1, paranoid2) = one_way.hardened_get2(PARANOID_MODE, PARANOID_MODE_DUPE).unwrap(); diff --git a/libs/bao1x-api/src/offsets/common.rs b/libs/bao1x-api/src/offsets/common.rs index 364941872..96e3571dc 100644 --- a/libs/bao1x-api/src/offsets/common.rs +++ b/libs/bao1x-api/src/offsets/common.rs @@ -191,7 +191,7 @@ pub const BOOT0_REVOCATION_OFFSET: usize = BOOT1_REVOCATION_OFFSET + PUBKEY_SLOT /// nor does it have any guarantee of being a monotonic or smoothly spaced out. It could /// even be all zeros (in which case LOT_CODE should be used). However, nominally, the plan /// is for SERIAL_NUMBER to be exactly the CP_ID field. -pub const SERIAL_NUMBER: SlotIndex = SlotIndex::Data(0, PartitionAccess::All, RwPerms::ReadOnly); +pub const SERIAL_NUMBER: SlotIndex = SlotIndex::Data(0, PartitionAccess::Open, RwPerms::ReadWrite); /// `UUID` is a 256-bit random number that can be used as a UUID for the chip. It is publicly /// readable and generated by a TRNG. This is suitable for putting into a KDF and generating diff --git a/libs/bao1x-api/src/pubkeys/bao1.rs b/libs/bao1x-api/src/pubkeys/bao1.rs index ed9c64a7b..d4e39f684 100644 --- a/libs/bao1x-api/src/pubkeys/bao1.rs +++ b/libs/bao1x-api/src/pubkeys/bao1.rs @@ -1,18 +1,31 @@ -/// ===== PLACEHOLDER - bao1 signing HSM ceremony pending ====== -#[allow(unused_imports)] use super::*; use crate::signatures::Pubkey; -/// Bao1 public key. Will be extracted from signing/bao1_id_ed25519_sk using extract_sk_credential.py -pub const ID_ED25519_SK_PUB: [u8; 32] = [0u8; 32]; +/// Bao1 public key. Extracted from signing/bao1_id_ed25519_sk using extract_sk_credential.py +pub const ID_ED25519_SK_PUB: [u8; 32] = [ + 0xa8, 0x7a, 0x5f, 0x98, 0xda, 0xab, 0xfb, 0x51, 0x2f, 0xc3, 0xc2, 0xe5, 0x74, 0x9b, 0x3b, 0xeb, 0x19, + 0x23, 0x88, 0xd2, 0x01, 0x60, 0xa7, 0xdd, 0x58, 0x88, 0xfb, 0x9d, 0xa4, 0x09, 0x52, 0x3a, +]; /// Bao1 public key "key handle" -pub const ID_ED25519_SK_CRED_ID: [u8; 241] = [0u8; 241]; +pub const ID_ED25519_SK_CRED_ID: [u8; 241] = [ + 0x01, 0x51, 0x65, 0x4a, 0xc1, 0x45, 0x55, 0xa9, 0x8e, 0xd8, 0xd5, 0x32, 0x78, 0x80, 0x01, 0xb9, 0x25, + 0xd6, 0x5f, 0xeb, 0xc9, 0xdb, 0x15, 0x6c, 0x4a, 0x1f, 0xa5, 0xf4, 0xcf, 0x1b, 0xcc, 0xa8, 0xf4, 0xa2, + 0x5e, 0xd7, 0xf7, 0xc8, 0xc4, 0x61, 0xeb, 0x8a, 0x16, 0xd9, 0xf8, 0x5b, 0x0e, 0xd1, 0x9b, 0x35, 0x12, + 0x71, 0xfa, 0x89, 0x66, 0x2f, 0xe1, 0x53, 0xf1, 0xda, 0x9a, 0xaf, 0x9a, 0xbd, 0xf5, 0x13, 0xe8, 0xd7, + 0xaa, 0xea, 0xf3, 0x93, 0x70, 0x77, 0x58, 0x91, 0xfd, 0xab, 0x3a, 0x3e, 0xcd, 0x38, 0x9a, 0xcd, 0x2d, + 0x00, 0x73, 0x7d, 0x2d, 0xf3, 0x10, 0xdd, 0x6a, 0x82, 0x80, 0x35, 0xd8, 0x83, 0xbe, 0x01, 0x2d, 0x80, + 0x98, 0x3b, 0xa3, 0x89, 0xba, 0x70, 0x64, 0xa9, 0x81, 0xa7, 0x8a, 0xb3, 0x28, 0xdd, 0x63, 0x46, 0xbf, + 0x00, 0x06, 0xf5, 0x17, 0x53, 0xd6, 0x0e, 0x7e, 0xce, 0xcd, 0x3a, 0x89, 0xb0, 0x87, 0x34, 0x59, 0x89, + 0x29, 0x8b, 0x9b, 0x7b, 0xd6, 0xea, 0xe4, 0x3f, 0x66, 0x92, 0xdc, 0xaf, 0x98, 0x1f, 0xad, 0x02, 0xe0, + 0xab, 0x88, 0x6c, 0x89, 0x56, 0x42, 0x26, 0xc9, 0x66, 0x49, 0x50, 0xee, 0xca, 0x38, 0x61, 0x61, 0xdb, + 0x84, 0xbd, 0x63, 0xd0, 0x46, 0x6b, 0x66, 0xdf, 0x59, 0xf2, 0xe1, 0xf9, 0xba, 0xfb, 0x0c, 0xb9, 0x60, + 0xbc, 0x9a, 0x4d, 0x2f, 0xb2, 0x0f, 0xc1, 0xb1, 0xb3, 0xb0, 0xc9, 0xeb, 0x5c, 0x3a, 0x41, 0x88, 0x56, + 0x58, 0x03, 0xe4, 0x85, 0xe5, 0xac, 0xc0, 0x6d, 0x15, 0xfe, 0xc1, 0xde, 0x98, 0x69, 0xb4, 0x0c, 0x61, + 0x05, 0xf0, 0x13, 0xab, 0xbd, 0x71, 0xc7, 0x0a, 0x22, 0x11, 0xec, 0xf0, 0x8a, 0xe3, 0xf3, 0x85, 0x90, + 0x83, 0xe9, 0x03, +]; /// Bao1 public key "relying party" pub const ID_ED25519_SK_RP: &'static str = "ssh:"; -pub const PUBKEY: Pubkey = Pubkey { - pk: ID_ED25519_SK_PUB, - // Placeholder: tag is 0. - tag: [0u8; 4], // *KEYSLOT_INITIAL_TAGS[BAO1_KEY_SLOT], -}; +pub const PUBKEY: Pubkey = Pubkey { pk: ID_ED25519_SK_PUB, tag: *KEYSLOT_INITIAL_TAGS[BAO1_KEY_SLOT] }; diff --git a/libs/bao1x-api/src/pubkeys/bao2.rs b/libs/bao1x-api/src/pubkeys/bao2.rs index be2d55936..a782f60e6 100644 --- a/libs/bao1x-api/src/pubkeys/bao2.rs +++ b/libs/bao1x-api/src/pubkeys/bao2.rs @@ -1,9 +1,7 @@ -/// ===== PLACEHOLDER - bao2 signing HSM ceremony pending ====== -#[allow(unused_imports)] use super::*; use crate::signatures::Pubkey; -/// Bao1 public key. Will be extracted from signing/bao1_id_ed25519_sk using extract_sk_credential.py +/// Bao2 public key. Extracted from signing/bao2_id_ed25519_sk using extract_sk_credential.py pub const ID_ED25519_SK_PUB: [u8; 32] = [ 0x79, 0x13, 0x5d, 0xc6, 0x67, 0xaf, 0xf4, 0xf7, 0xd3, 0x52, 0xb9, 0x03, 0x28, 0x78, 0x8e, 0xbf, 0x92, 0xc7, 0x86, 0x78, 0x21, 0x38, 0xb3, 0x77, 0x37, 0x0b, 0x15, 0x19, 0x4e, 0x31, 0x28, 0x88, diff --git a/signing/bao1_id_ed25519_sk b/signing/bao1_id_ed25519_sk new file mode 100644 index 000000000..085a98121 --- /dev/null +++ b/signing/bao1_id_ed25519_sk @@ -0,0 +1,12 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAASgAAABpzay1zc2 +gtZWQyNTUxOUBvcGVuc3NoLmNvbQAAACCoel+Y2qv7US/DwuV0mzvrGSOI0gFgp91YiPud +pAlSOgAAAARzc2g6AAABaCSBXfkkgV35AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY2 +9tAAAAIKh6X5jaq/tRL8PC5XSbO+sZI4jSAWCn3ViI+52kCVI6AAAABHNzaDoBAAAA8QFR +ZUrBRVWpjtjVMniAAbkl1l/rydsVbEofpfTPG8yo9KJe1/fIxGHrihbZ+FsO0Zs1EnH6iW +Yv4VPx2pqvmr31E+jXqurzk3B3WJH9qzo+zTiazS0Ac30t8xDdaoKANdiDvgEtgJg7o4m6 +cGSpgaeKsyjdY0a/AAb1F1PWDn7OzTqJsIc0WYkpi5t71urkP2aS3K+YH60C4KuIbIlWQi +bJZklQ7so4YWHbhL1j0EZrZt9Z8uH5uvsMuWC8mk0vsg/BsbOwyetcOkGIVlgD5IXlrMBt +Ff7B3phptAxhBfATq71xxwoiEezwiuPzhZCD6QMAAAAAAAAAFWJ1bm5pZUBidW5uaWUtZG +Vza3RvcAECAw== +-----END OPENSSH PRIVATE KEY----- diff --git a/signing/bao1_id_ed25519_sk.pub b/signing/bao1_id_ed25519_sk.pub new file mode 100644 index 000000000..0ef2af423 --- /dev/null +++ b/signing/bao1_id_ed25519_sk.pub @@ -0,0 +1 @@ +sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIKh6X5jaq/tRL8PC5XSbO+sZI4jSAWCn3ViI+52kCVI6AAAABHNzaDo= bunnie@bunnie-desktop diff --git a/signing/fido-signer/Cargo.lock b/signing/fido-signer/Cargo.lock index d73ad4a3f..9dd427f53 100644 --- a/signing/fido-signer/Cargo.lock +++ b/signing/fido-signer/Cargo.lock @@ -1234,9 +1234,9 @@ dependencies = [ [[package]] name = "xous" -version = "0.9.68" +version = "0.9.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c12a67abde4d3a3dcebcd390b0910e25cf2654b1a34fc3b060e2da98d41cbcff" +checksum = "acaeff6cedd119aa86d1b06fef4e2935bc4b132468a38f3f006b5574018ba5e2" dependencies = [ "lazy_static", ]