feat(client): embed the release public key
This commit is contained in:
parent
2790aadeba
commit
23e725f89e
2 changed files with 13 additions and 12 deletions
|
|
@ -9,14 +9,14 @@ use super::UpdateError;
|
||||||
|
|
||||||
/// Public half of the release signing key, embedded in the binary.
|
/// Public half of the release signing key, embedded in the binary.
|
||||||
///
|
///
|
||||||
/// This is a PLACEHOLDER (all zeros). While it is unchanged the updater refuses to run
|
/// The matching secret key lives only in the CI secret `VNOX_RELEASE_SIGNING_KEY`
|
||||||
/// ([`is_placeholder`]), so a build without a real key can never accept an update.
|
/// (`manifest.json.sig` is produced from it). An all-zero value is treated as an unconfigured
|
||||||
///
|
/// placeholder and the updater refuses to run ([`is_placeholder`]). Rotating the key requires
|
||||||
/// To replace it: generate an Ed25519 key pair offline, keep the secret key only in the CI
|
/// shipping a release signed with the old key that embeds the new one.
|
||||||
/// secret store (`manifest.json.sig` is produced from it), and paste the 32 byte public key
|
pub const RELEASE_PUBLIC_KEY: [u8; 32] = [
|
||||||
/// here. Rotating the key requires shipping a release signed with the old key that embeds the new
|
0x7e, 0xd5, 0x38, 0x8c, 0xff, 0x33, 0xa2, 0xaf, 0x13, 0x52, 0xc2, 0x67, 0xef, 0x84, 0x2f, 0xe0,
|
||||||
/// one.
|
0xac, 0x37, 0x13, 0x42, 0xb7, 0x6b, 0xba, 0x4c, 0x0b, 0x7c, 0x41, 0xaf, 0x11, 0x4c, 0x95, 0x4c,
|
||||||
pub const RELEASE_PUBLIC_KEY: [u8; 32] = [0u8; 32];
|
];
|
||||||
|
|
||||||
/// Second public key accepted during a key rotation, `None` otherwise. A release that embeds both
|
/// Second public key accepted during a key rotation, `None` otherwise. A release that embeds both
|
||||||
/// keys is signed with the old one; the next releases are signed with the new one.
|
/// keys is signed with the old one; the next releases are signed with the new one.
|
||||||
|
|
@ -159,16 +159,17 @@ mod tests {
|
||||||
verify_any(&[old, public()], msg, &sign(msg)).unwrap();
|
verify_any(&[old, public()], msg, &sign(msg)).unwrap();
|
||||||
assert!(verify_any(&[old], msg, &sign(msg)).is_err());
|
assert!(verify_any(&[old], msg, &sign(msg)).is_err());
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
verify_any(&[RELEASE_PUBLIC_KEY], msg, &sign(msg)),
|
verify_any(&[[0u8; 32]], msg, &sign(msg)),
|
||||||
Err(UpdateError::NoReleaseKey)
|
Err(UpdateError::NoReleaseKey)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn placeholder_key_never_verifies() {
|
fn placeholder_key_never_verifies() {
|
||||||
assert!(is_placeholder(&RELEASE_PUBLIC_KEY));
|
assert!(is_placeholder(&[0u8; 32]));
|
||||||
|
assert!(!is_placeholder(&RELEASE_PUBLIC_KEY));
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
verify(&RELEASE_PUBLIC_KEY, b"m", &sign(b"m")),
|
verify(&[0u8; 32], b"m", &sign(b"m")),
|
||||||
Err(UpdateError::NoReleaseKey)
|
Err(UpdateError::NoReleaseKey)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ async fn placeholder_key_disables_updates() {
|
||||||
let fx = Fixture::new().await;
|
let fx = Fixture::new().await;
|
||||||
fx.publish_good("0.2.0");
|
fx.publish_good("0.2.0");
|
||||||
let mut cfg = fx.config();
|
let mut cfg = fx.config();
|
||||||
cfg.public_keys = keys::production_keys();
|
cfg.public_keys = vec![[0u8; 32]];
|
||||||
let manager = UpdateManager::new(cfg, None, fx.dir.path().join("u.json"));
|
let manager = UpdateManager::new(cfg, None, fx.dir.path().join("u.json"));
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
manager.check().await,
|
manager.check().await,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue