[vault] Signing: the signing body member (release and test key sets, scope, sign-only API, append-only audit log); custos-sign draws from SysRng; the wasm build links getrandom 0.2 to the browser CSPRNG
This commit is contained in:
@@ -23,6 +23,7 @@ pub mod identity;
|
||||
mod item;
|
||||
mod save;
|
||||
mod secret;
|
||||
pub mod signing;
|
||||
|
||||
pub use item::{Attachment, Field, HISTORY_LIMIT, HistoryEntry, Item, ItemType, new_id, now_ms};
|
||||
pub use save::{CrashPoint, save_atomic, save_atomic_crashing};
|
||||
@@ -70,6 +71,10 @@ pub enum Error {
|
||||
NotACert,
|
||||
#[error("those words are not the ones in the recovery phrase")]
|
||||
WrongWords,
|
||||
#[error("this vault already has {0} signing keys")]
|
||||
SigningExists(&'static str),
|
||||
#[error("signing keys: {0}")]
|
||||
Signing(String),
|
||||
#[error("{0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
}
|
||||
@@ -261,6 +266,8 @@ struct Body {
|
||||
factors: Vec<FactorJson>,
|
||||
#[serde(default)]
|
||||
identity: Option<identity::RootJson>,
|
||||
#[serde(default)]
|
||||
signing: Option<signing::StoreJson>,
|
||||
}
|
||||
|
||||
/// What `to_bytes` serializes: borrows the items instead of cloning every secret.
|
||||
@@ -272,6 +279,8 @@ struct BodyRef<'a> {
|
||||
factors: Vec<FactorJson>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
identity: Option<identity::RootJson>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
signing: Option<signing::StoreJson>,
|
||||
}
|
||||
|
||||
/// An unlocked vault: the vault key and the decrypted items, both wiped on drop.
|
||||
@@ -286,6 +295,8 @@ pub struct Vault {
|
||||
kdf_new: KdfParams,
|
||||
/// The Domi identity's root key (docs/IDENTITY.md), never handed out.
|
||||
identity: Option<identity::Root>,
|
||||
/// Signing keys and their audit log (docs/SIGNING.md); no key is ever handed out.
|
||||
signing: signing::Store,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Vault {
|
||||
@@ -385,6 +396,7 @@ impl Vault {
|
||||
factors: Vec::new(),
|
||||
kdf_new: kdf,
|
||||
identity: None,
|
||||
signing: signing::Store::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -401,6 +413,7 @@ impl Vault {
|
||||
factors: Vec::new(),
|
||||
kdf_new: kdf,
|
||||
identity: None,
|
||||
signing: signing::Store::default(),
|
||||
};
|
||||
v.add_factor(a, label_a)?;
|
||||
v.add_factor(b, label_b)?;
|
||||
@@ -433,6 +446,7 @@ impl Vault {
|
||||
factors: vec![rec],
|
||||
kdf_new: KdfParams::DEFAULT,
|
||||
identity: None,
|
||||
signing: signing::Store::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -554,7 +568,20 @@ impl Vault {
|
||||
Some(j) => Some(identity::Root::from_json(j).ok_or(Error::Corrupted)?),
|
||||
None => None,
|
||||
};
|
||||
Ok(Vault { key, version: header.version, slots: header.slots, items: body.items, factors, kdf_new, identity })
|
||||
let signing = match body.signing {
|
||||
Some(j) => signing::Store::from_json(j).ok_or(Error::Corrupted)?,
|
||||
None => signing::Store::default(),
|
||||
};
|
||||
Ok(Vault {
|
||||
key,
|
||||
version: header.version,
|
||||
slots: header.slots,
|
||||
items: body.items,
|
||||
factors,
|
||||
kdf_new,
|
||||
identity,
|
||||
signing,
|
||||
})
|
||||
}
|
||||
|
||||
/// Wraps the vault key for device unlock with key material only this device can produce (e.g. a
|
||||
@@ -588,6 +615,7 @@ impl Vault {
|
||||
items: &self.items,
|
||||
factors: self.factors.iter().map(FactorRec::json).collect(),
|
||||
identity: self.identity.as_ref().map(identity::Root::json),
|
||||
signing: self.signing.json(),
|
||||
};
|
||||
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