[vault] Approval: sign kind approval only by domi-approve (made with the release keys, signing_add_approve for older vaults), run on requests and in the audit, context version, signing_check_at; docs/SIGNING.md

This commit is contained in:
2026-11-04 20:50:49 +01:00
parent 6739423f4d
commit 8a10c695c5
5 changed files with 475 additions and 38 deletions
+13 -6
View File
@@ -460,6 +460,19 @@ fn unprintable(c: char) -> bool {
/// an hour later (docs/SIGNING.md). It is parsed, written again in canonical form and compared byte for byte, so
/// any other spelling of the same values (key order, spaces, escapes, a trailing newline) is refused.
pub fn approval_check(text: &str, now_secs: u64) -> Result<Approval, Error> {
let a = approval_parse(text)?;
if a.expires <= now_secs {
return Err(Error::Approval("it has expired"));
}
if a.expires > now_secs.saturating_add(APPROVAL_MAX_AHEAD) {
return Err(Error::Approval("it expires more than an hour from now"));
}
Ok(a)
}
/// [`approval_check`] without the clock: the canonical form and every member's rule, not the expiry. For reading
/// what a refused or expired request said; never enough to sign.
pub fn approval_parse(text: &str) -> Result<Approval, Error> {
let err = |why: &'static str| Err(Error::Approval(why));
if text.len() > MAX_APPROVAL {
return err("larger than 8 KiB");
@@ -508,12 +521,6 @@ pub fn approval_check(text: &str, now_secs: u64) -> Result<Approval, Error> {
if a.canonical() != text {
return err("not in canonical form (key order, spaces or escaping)");
}
if a.expires <= now_secs {
return err("it has expired");
}
if a.expires > now_secs.saturating_add(APPROVAL_MAX_AHEAD) {
return err("it expires more than an hour from now");
}
Ok(a)
}