[team] Team vaults: member keys, member slots (kind 6), policies per environment, the canonical sign.request, approval statements, policy proofs; cosign and Tauri updater envelopes; v0.18.0
This commit is contained in:
@@ -51,6 +51,8 @@ pub enum KeyKind {
|
||||
CodeSigning,
|
||||
/// An Android app's signing key (core 0.14.0): RSA-4096 and a self-signed certificate; signs `apk` only.
|
||||
Android,
|
||||
/// A team's cosign key (core 0.18.0, docs/TEAM.md): ECDSA P-256; signs `cosign` only, in a team vault only.
|
||||
EcdsaP256,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -64,6 +66,12 @@ pub enum SignKind {
|
||||
/// APK Signature Scheme v2/v3: 1 to 4 SHA-512 digests, signed with RSA PKCS#1 v1.5, by an Android key only
|
||||
/// (core 0.14.0).
|
||||
Apk,
|
||||
/// Tauri's updater: minisign over a BLAKE2b-512 digest, wrapped in base64 (core 0.18.0, team vaults only).
|
||||
#[serde(rename = "tauri-updater")]
|
||||
TauriUpdater,
|
||||
/// A cosign container image signature: ECDSA P-256 over the simple-signing payload (core 0.18.0, team vaults
|
||||
/// only).
|
||||
Cosign,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -153,6 +161,18 @@ pub struct AuditEntry {
|
||||
/// The request's run id (core 0.12.0), when it had a well-formed one.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub run: Option<String>,
|
||||
/// A team vault's entry (core 0.18.0, docs/TEAM.md): the member whose Custos signed or refused.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub by: Option<String>,
|
||||
/// The environment the request was for.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub env: Option<String>,
|
||||
/// The request hash (hex).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub request: Option<String>,
|
||||
/// The members whose approvals counted.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub approvers: Vec<String>,
|
||||
}
|
||||
|
||||
/// A standing approval (core 0.16.0, docs/SIGNING.md): what Mark allowed for good, when, and how often it was used.
|
||||
@@ -212,26 +232,29 @@ pub struct KeyView {
|
||||
/// The certificate (DER), for root, code-signing and Android keys.
|
||||
pub cert: Option<Vec<u8>>,
|
||||
pub issuer: Option<String>,
|
||||
/// The `cosign.pub` PEM, for ECDSA P-256 keys (core 0.18.0).
|
||||
pub public_pem: Option<String>,
|
||||
}
|
||||
|
||||
enum Secret {
|
||||
pub(crate) enum Secret {
|
||||
Ed25519(Ed25519Secret),
|
||||
Rsa(RsaSecret),
|
||||
P256(custos_sign::P256Secret),
|
||||
}
|
||||
|
||||
struct Key {
|
||||
id: String,
|
||||
kind: KeyKind,
|
||||
role: Role,
|
||||
name: String,
|
||||
secret: Secret,
|
||||
public: Option<[u8; 32]>,
|
||||
key_id: Option<[u8; 8]>,
|
||||
cert: Option<Vec<u8>>,
|
||||
issuer: Option<String>,
|
||||
created: i64,
|
||||
pipelines: Vec<String>,
|
||||
repos: Vec<String>,
|
||||
pub(crate) struct Key {
|
||||
pub(crate) id: String,
|
||||
pub(crate) kind: KeyKind,
|
||||
pub(crate) role: Role,
|
||||
pub(crate) name: String,
|
||||
pub(crate) secret: Secret,
|
||||
pub(crate) public: Option<[u8; 32]>,
|
||||
pub(crate) key_id: Option<[u8; 8]>,
|
||||
pub(crate) cert: Option<Vec<u8>>,
|
||||
pub(crate) issuer: Option<String>,
|
||||
pub(crate) created: i64,
|
||||
pub(crate) pipelines: Vec<String>,
|
||||
pub(crate) repos: Vec<String>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Key {
|
||||
@@ -243,8 +266,8 @@ impl fmt::Debug for Key {
|
||||
/// The keys and the log, in the vault.
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) struct Store {
|
||||
keys: Vec<Key>,
|
||||
audit: Vec<AuditEntry>,
|
||||
pub(crate) keys: Vec<Key>,
|
||||
pub(crate) audit: Vec<AuditEntry>,
|
||||
standing: Vec<StandingRule>,
|
||||
}
|
||||
|
||||
@@ -321,6 +344,10 @@ impl Store {
|
||||
KeyKind::RootCa | KeyKind::CodeSigning | KeyKind::Android => {
|
||||
Secret::Rsa(RsaSecret::from_pkcs8_der(k.secret.expose().to_vec()).ok()?)
|
||||
}
|
||||
KeyKind::EcdsaP256 => {
|
||||
let scalar: [u8; 32] = k.secret.expose().try_into().ok()?;
|
||||
Secret::P256(custos_sign::P256Secret::from_bytes(scalar).ok()?)
|
||||
}
|
||||
};
|
||||
let public = match &k.public {
|
||||
Some(p) => Some(unb64(p)?.try_into().ok()?),
|
||||
@@ -380,6 +407,7 @@ impl Store {
|
||||
secret: SecretBytes::new(match &k.secret {
|
||||
Secret::Ed25519(s) => s.expose().to_vec(),
|
||||
Secret::Rsa(s) => s.expose().to_vec(),
|
||||
Secret::P256(s) => s.expose().to_vec(),
|
||||
}),
|
||||
public: k.public.map(|p| b64(&p)),
|
||||
key_id: k.key_id.map(|i| hex(&i)),
|
||||
@@ -393,13 +421,13 @@ impl Store {
|
||||
Some(StoreJson { keys, audit: self.audit.clone(), standing: self.standing.clone() })
|
||||
}
|
||||
|
||||
fn get(&self, id: &str) -> Option<&Key> {
|
||||
pub(crate) fn get(&self, id: &str) -> Option<&Key> {
|
||||
self.keys.iter().find(|k| k.id == id)
|
||||
}
|
||||
}
|
||||
|
||||
/// Unix seconds from the vault's milliseconds, as minisign and approvals count them.
|
||||
fn seconds(now_ms: i64) -> u64 {
|
||||
pub(crate) fn seconds(now_ms: i64) -> u64 {
|
||||
(now_ms.max(0) / 1000) as u64
|
||||
}
|
||||
|
||||
@@ -450,6 +478,8 @@ fn kind_word(kind: SignKind) -> &'static str {
|
||||
SignKind::Authenticode => "authenticode",
|
||||
SignKind::Approval => "approval",
|
||||
SignKind::Apk => "apk",
|
||||
SignKind::TauriUpdater => "tauri-updater",
|
||||
SignKind::Cosign => "cosign",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,6 +695,10 @@ impl Vault {
|
||||
},
|
||||
cert: k.cert.clone(),
|
||||
issuer: k.issuer.clone(),
|
||||
public_pem: match &k.secret {
|
||||
Secret::P256(s) => s.public_pem().ok(),
|
||||
_ => None,
|
||||
},
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -925,6 +959,10 @@ impl Vault {
|
||||
signature,
|
||||
reason,
|
||||
run,
|
||||
by: None,
|
||||
env: None,
|
||||
request: None,
|
||||
approvers: Vec::new(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1156,6 +1194,7 @@ mod tests {
|
||||
.map(|k| match &k.secret {
|
||||
Secret::Ed25519(s) => s.expose().to_vec(),
|
||||
Secret::Rsa(s) => s.expose().to_vec(),
|
||||
Secret::P256(s) => s.expose().to_vec(),
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(secrets.len(), 9, "the release set with domi-approve, the test set, two Android keys");
|
||||
|
||||
Reference in New Issue
Block a user