[vault] Provision: the provision audit body member (checked entries, no value member, append-only, newest 5 000; docs/FORMAT.md)
This commit is contained in:
@@ -21,6 +21,7 @@ mod device;
|
||||
mod format;
|
||||
pub mod identity;
|
||||
mod item;
|
||||
pub mod provision;
|
||||
mod save;
|
||||
mod secret;
|
||||
pub mod signing;
|
||||
@@ -79,6 +80,9 @@ pub enum Error {
|
||||
UnknownKey,
|
||||
#[error("this vault already has {0} signing keys")]
|
||||
SigningExists(&'static str),
|
||||
/// Names the member that does not fit (docs/FORMAT.md), never its value.
|
||||
#[error("provision audit: {0}")]
|
||||
Provision(&'static str),
|
||||
#[error("signing keys: {0}")]
|
||||
Signing(String),
|
||||
#[error("{0}")]
|
||||
@@ -274,6 +278,8 @@ struct Body {
|
||||
identity: Option<identity::RootJson>,
|
||||
#[serde(default)]
|
||||
signing: Option<signing::StoreJson>,
|
||||
#[serde(default)]
|
||||
provision: Option<provision::ProvisionJson>,
|
||||
}
|
||||
|
||||
/// What `to_bytes` serializes: borrows the items instead of cloning every secret.
|
||||
@@ -287,6 +293,8 @@ struct BodyRef<'a> {
|
||||
identity: Option<identity::RootJson>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
signing: Option<signing::StoreJson>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
provision: Option<provision::ProvisionJson>,
|
||||
}
|
||||
|
||||
/// An unlocked vault: the vault key and the decrypted items, both wiped on drop.
|
||||
@@ -303,6 +311,8 @@ pub struct Vault {
|
||||
identity: Option<identity::Root>,
|
||||
/// Signing keys and their audit log (docs/SIGNING.md); no key is ever handed out.
|
||||
signing: signing::Store,
|
||||
/// The Provisio audit (docs/FORMAT.md), oldest first.
|
||||
provision: Vec<provision::ProvisionEntry>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Vault {
|
||||
@@ -403,6 +413,7 @@ impl Vault {
|
||||
kdf_new: kdf,
|
||||
identity: None,
|
||||
signing: signing::Store::default(),
|
||||
provision: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -420,6 +431,7 @@ impl Vault {
|
||||
kdf_new: kdf,
|
||||
identity: None,
|
||||
signing: signing::Store::default(),
|
||||
provision: Vec::new(),
|
||||
};
|
||||
v.add_factor(a, label_a)?;
|
||||
v.add_factor(b, label_b)?;
|
||||
@@ -453,6 +465,7 @@ impl Vault {
|
||||
kdf_new: KdfParams::DEFAULT,
|
||||
identity: None,
|
||||
signing: signing::Store::default(),
|
||||
provision: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -587,6 +600,7 @@ impl Vault {
|
||||
kdf_new,
|
||||
identity,
|
||||
signing,
|
||||
provision: provision::from_json(body.provision),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -622,6 +636,7 @@ impl Vault {
|
||||
factors: self.factors.iter().map(FactorRec::json).collect(),
|
||||
identity: self.identity.as_ref().map(identity::Root::json),
|
||||
signing: self.signing.json(),
|
||||
provision: provision::json(&self.provision),
|
||||
};
|
||||
serde_json::to_writer(&mut *json, &body).map_err(|e| Error::Io(std::io::Error::other(e.to_string())))?;
|
||||
let sealed = crypto::seal(&self.key, &body_nonce, &json, &out);
|
||||
|
||||
Reference in New Issue
Block a user