add public key templates

Beta/developer keys are fully filled out.

Placeholders for production signing keys are also provided.
This commit is contained in:
bunnie 2025-10-06 15:19:19 +08:00
parent ecd7d87bbd
commit a1a5ff1592
5 changed files with 143 additions and 0 deletions

View file

@ -0,0 +1,21 @@
/// ===== PLACEHOLDER - bao2 signing HSM ceremony pending ======
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 auth_data
pub const ID_ED25519_SK_AUTH_DATA: [u8; 37] = [0u8; 37];
/// Bao1 public key "key handle"
pub const ID_ED25519_SK_CRED_ID: [u8; 241] = [0u8; 241];
/// 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[super::BAO1_KEY_SLOT],
aad_len: ID_ED25519_SK_AUTH_DATA.len() as u8,
aad: pad_array(&ID_ED25519_SK_AUTH_DATA),
};

View file

@ -0,0 +1,21 @@
/// ===== PLACEHOLDER - bao2 signing HSM ceremony pending ======
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 auth_data
pub const ID_ED25519_SK_AUTH_DATA: [u8; 37] = [0u8; 37];
/// Bao1 public key "key handle"
pub const ID_ED25519_SK_CRED_ID: [u8; 241] = [0u8; 241];
/// 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[super::BAO2_KEY_SLOT],
aad_len: ID_ED25519_SK_AUTH_DATA.len() as u8,
aad: pad_array(&ID_ED25519_SK_AUTH_DATA),
};

View file

@ -0,0 +1,45 @@
use super::*;
use crate::signatures::Pubkey;
/// Beta public key. Extracted from signing/beta_id_ed25519_sk using extract_sk_credential.py
pub const ID_ED25519_SK_PUB: [u8; 32] = [
0x80, 0x97, 0x99, 0x29, 0xed, 0xd0, 0x4e, 0x40, 0x12, 0x4b, 0x52, 0xca, 0xe9, 0xae, 0x54, 0xb2, 0x4b,
0xdf, 0xf7, 0x2a, 0x7b, 0x8a, 0x00, 0x4c, 0x41, 0x06, 0x5b, 0xd1, 0x40, 0x20, 0x78, 0xa7,
];
/// Beta public key auth_data - needed to validate an image. Extracted by a trial run of
/// signing/fido_signer with `cargo run -- --credential-file ..\credentials\beta.json --file .\test.bin`
/// inside the fido_signer directory. Needs to have the token & key connected to generate this.
pub const ID_ED25519_SK_AUTH_DATA: [u8; 37] = [
0xe3, 0x06, 0x10, 0xe8, 0xa1, 0x62, 0x11, 0x59, 0x60, 0xfe, 0x1e, 0xc2, 0x23, 0xe6, 0x52, 0x9c, 0x9f,
0x4b, 0x6e, 0x80, 0x20, 0x0d, 0xcb, 0x5e, 0x5c, 0x32, 0x1c, 0x8a, 0xf1, 0xe2, 0xb1, 0xbf, 0x05, 0x00,
0x00, 0x02, 0x0f,
];
/// Beta public key "key handle" - used to retrieve the key for signing from the token.
/// Extracted from signing/beta_id_ed25519_sk using extract_sk_credential.py
pub const ID_ED25519_SK_CRED_ID: [u8; 241] = [
0x01, 0x06, 0x60, 0x8b, 0xfa, 0x05, 0x28, 0x24, 0x0d, 0x5b, 0x33, 0x92, 0x1b, 0xb1, 0x38, 0x4e, 0xbe,
0xae, 0xf3, 0xe4, 0x73, 0x7a, 0x5e, 0xb2, 0xd0, 0x7e, 0x77, 0x80, 0x5b, 0x88, 0xcb, 0x1e, 0xd6, 0xea,
0xfc, 0x75, 0xd4, 0x21, 0xc9, 0x41, 0xfa, 0x8d, 0x09, 0xe2, 0x4b, 0x4a, 0x4c, 0xec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, 0xcd, 0x73, 0x3f, 0xaa, 0xfe, 0x94,
0x4a, 0x85, 0x8b,
];
/// Beta public key "relying party"
/// Extracted from signing/beta_id_ed25519_sk using extract_sk_credential.py
pub const ID_ED25519_SK_RP: &'static str = "ssh:";
pub const PUBKEY: Pubkey = Pubkey {
pk: ID_ED25519_SK_PUB,
tag: *KEYSLOT_INITIAL_TAGS[BETA_KEY_SLOT],
aad_len: ID_ED25519_SK_AUTH_DATA.len() as u8,
aad: pad_array(&ID_ED25519_SK_AUTH_DATA),
};

View file

@ -0,0 +1,18 @@
use super::*;
use crate::signatures::Pubkey;
/// Developer public key. The private key is the devkey/ directory, included here for your
/// convenience: "MC4CAQAwBQYDK2VwBCIEIKindlyNoteThisIsADevKeyDontUseForProduction" (base64)
pub const PUB: [u8; 32] = [
0x1c, 0x9b, 0xea, 0xe3, 0x2a, 0xea, 0xc8, 0x75, 0x07, 0xc1, 0x80, 0x94, 0x38, 0x7e, 0xff, 0x1c, 0x74,
0x61, 0x42, 0x82, 0xaf, 0xfd, 0x81, 0x52, 0xd8, 0x71, 0x35, 0x2e, 0xdf, 0x3f, 0x58, 0xbb,
];
/// Developer key has no auth data. It is a classic ed25519ph signature.
pub const AUTH_DATA: [u8; 0] = [];
pub const PUBKEY: Pubkey = Pubkey {
pk: PUB,
tag: *KEYSLOT_INITIAL_TAGS[DEVELOPER_KEY_SLOT],
aad_len: AUTH_DATA.len() as u8,
aad: pad_array(&AUTH_DATA),
};

View file

@ -0,0 +1,38 @@
use crate::signatures::Pubkey;
pub mod bao1;
pub mod bao2;
pub mod beta;
pub mod developer;
pub const BAO1_KEY_SLOT: usize = 0;
pub const BAO2_KEY_SLOT: usize = 1;
pub const BETA_KEY_SLOT: usize = 2;
pub const DEVELOPER_KEY_SLOT: usize = 3;
/// Nominal purposes of pub key slots:
/// - slot 0 is Baochip secured signing key 1
/// - slot 1 is Baochip secured signing key 2
/// - slot 2 is a Beta signing key. It's kept in a secured token but also available in a development
/// environment.
/// - slot 3 is the Developer signing key. It's a well-known key that anyone can use to sign an image. If
/// revoked, it is not a valid signing key. When not revoked, upon being presented with an image signed by
/// this, the bootloader will automatically erase all device-local secrets.
///
/// The dual signing keys for Baochip allows for a laddered upgrade path in case a signing key
/// needs to be replaced, upgraded, or cycled out for any reason.
pub const KEYSLOT_INITIAL_TAGS: [&'static [u8; 4]; 4] = [b"bao1", b"bao2", b"beta", b"dev "];
// helper function to pad arrays out, useful for the auth_data
const fn pad_array<const N: usize, const M: usize>(input: &[u8; N]) -> [u8; M] {
let mut result = [0u8; M];
let mut i = 0;
while i < N && i < M {
result[i] = input[i];
i += 1;
}
result
}
/// This is the exported record that should be copied into the header of all boot images
pub const PUBKEY_HEADER: [Pubkey; 4] = [bao1::PUBKEY, bao2::PUBKEY, beta::PUBKEY, developer::PUBKEY];