add functional code slice

this puts a domain separator in every signature block
a domain separator meaning, even though the same private key
maybe be used to sign multiple blocks, because a functional code
is embedded in the block that is tied to the block's function, you
can't take a pre-signed block and shove it into another block's slot
and expect it to work.
This commit is contained in:
bunnie 2025-09-29 22:17:56 +08:00
parent 6b8d8f09f7
commit 15562abf00

View file

@ -10,22 +10,30 @@ pub const PUBLIC_KEY_LENGTH: usize = 32; // length of an ed25519 public key.
#[repr(u32)]
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum FunctionCode {
/// Should never be used
Invalid = 0,
/// Code for a valid boot0 region
Boot0 = 0,
Boot0 = 1,
/// Code for a valid boot1 region
Boot1 = 1,
Boot1 = 2,
/// Expected code when being passed a boot1 region update. Self-signing/sealing implementations
/// can change this code to Boot1; externally signed implementations would accept UpdatedBoot1
/// as interchangeable with Boot1
UpdatedBoot1 = 2,
UpdatedBoot1 = 3,
/// Loader
Loader = 4,
UpdatedLoader = 5,
/// Baremetal options
Baremetal = 6,
UpdatedBaremetal = 7,
/// Kernel region
Kernel = 3,
UpdatedKernel = 4,
Kernel = 0x1_00,
UpdatedKernel = 0x1_01,
/// Application region
App = 5,
UpdatedApp = 6,
App = 0x10_0000,
UpdatedApp = 0x10_0001,
/// Developer use - can go in any region, but only usable with secrets wiped.
Developer = 7,
Developer = 0x1000_0000,
}
pub const BAOCHIP_SIG_VERSION: u32 = 0x1_00;