From e3140609e44770aa088810b1bc22fab5436942a0 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 21 Oct 2025 19:08:35 +0800 Subject: [PATCH] designate the eraseable keys only some keys are marked as writeable to harden against potential oracle attacks, i.e., if we made all keys erasable and an oracle attack was found, then the entire key region can be exposed by the oracle attack. Instead, some key material always persists, but a sufficiently large amount of seed material is erased such that the key is not recoverable by guessing the key. --- libs/bao1x-api/src/offsets/baosec.rs | 15 ++++++++++++--- libs/bao1x-api/src/offsets/common.rs | 5 ++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libs/bao1x-api/src/offsets/baosec.rs b/libs/bao1x-api/src/offsets/baosec.rs index 7e1b73726..a8e04ea7e 100644 --- a/libs/bao1x-api/src/offsets/baosec.rs +++ b/libs/bao1x-api/src/offsets/baosec.rs @@ -57,8 +57,9 @@ pub const ROOT_SEED: SlotIndex = SlotIndex::Key(256, PartitionAccess::Fw0, RwPer pub const RMA_KEY: SlotIndex = SlotIndex::Key(257, PartitionAccess::Fw0, RwPerms::ReadOnly); /// Reserved for use as a CP to FT tracking cookie. This is used to help track inventory -/// between CP and FT, if such a feature is desired in the supply chain. -pub const CP_COOKIE: SlotIndex = SlotIndex::Key(258, PartitionAccess::Fw0, RwPerms::ReadOnly); +/// between CP and FT, if such a feature is desired in the supply chain. Blanked on entry +/// to developer mode. +pub const CP_COOKIE: SlotIndex = SlotIndex::Key(258, PartitionAccess::Fw0, RwPerms::ReadWrite); /// `NUISANCE_KEYS` are hashed together with `ROOT_SEED` to derive the core secret. /// Their primary purpose is to annoy microscopists trying to read the secret key by @@ -95,7 +96,15 @@ pub const NUISANCE_KEYS: [SlotIndex; 2] = [NUISANCE_KEYS_0, NUISANCE_KEYS_1]; /// out interleaved with the NUISANCE_KEY readout, where the selection to read a CHAFF_KEY /// or a NUISANCE_KEY is done randomly, thus introducing some disorder in the power side /// channel timing of the NUISANCE_KEY readout. -pub const CHAFF_KEYS: SlotIndex = SlotIndex::KeyRange(128..256, PartitionAccess::Fw0, RwPerms::ReadOnly); +/// +/// This block has ReadWrite permissions because it's what gets blanked when the system +/// goes to developer mode. We don't blank *all* the keys because write-permission on a key +/// can lead to "oracle" attacks where portions of the key can be guessed by setting individual +/// bits. But this is enough bits that it should make the original key unrecoverable. Once +/// the chaff is cleared, we also don't care as much about side channels since we're now operating +/// in a fundamentally insecure regime (e.g. developer mode - you can just read out the data by +/// running your own code on the device). +pub const CHAFF_KEYS: SlotIndex = SlotIndex::KeyRange(128..256, PartitionAccess::Fw0, RwPerms::ReadWrite); /// All the slots of concern located in a single iterator. The idea is that everything is /// condensed here and used to check for access integrity using the array below. diff --git a/libs/bao1x-api/src/offsets/common.rs b/libs/bao1x-api/src/offsets/common.rs index a637990bf..7261e768a 100644 --- a/libs/bao1x-api/src/offsets/common.rs +++ b/libs/bao1x-api/src/offsets/common.rs @@ -118,9 +118,8 @@ pub const BOOT0_REVOCATION_OFFSET: usize = BOOT1_REVOCATION_OFFSET + PUBKEY_SLOT /// uniqueness, in that there is nothing essentially that prevents duplicates, forgeries /// or procedural errors replicating this. The serial number also is not strictly incrementing /// 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). Its primary -/// purpose is to serve as a debugging hint for practical manufacturing issues. You are -/// free to read it and use it, but beware. +/// 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); /// `UUID` is a 256-bit random number that can be used as a UUID for the chip. It is publicly