diff --git a/Cargo.lock b/Cargo.lock index 25f4bbb..ccd05f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -329,14 +329,14 @@ dependencies = [ [[package]] name = "custos-browser" -version = "0.17.0" +version = "0.17.1" dependencies = [ "zeroize", ] [[package]] name = "custos-gen" -version = "0.17.0" +version = "0.17.1" dependencies = [ "custos-vault", "data-encoding", @@ -348,7 +348,7 @@ dependencies = [ [[package]] name = "custos-kdbx" -version = "0.17.0" +version = "0.17.1" dependencies = [ "aes", "argon2", @@ -369,7 +369,7 @@ dependencies = [ [[package]] name = "custos-keys" -version = "0.17.0" +version = "0.17.1" dependencies = [ "custos-vault", "ed25519-dalek", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "custos-native" -version = "0.17.0" +version = "0.17.1" dependencies = [ "custos-browser", "serde_json", @@ -392,11 +392,11 @@ dependencies = [ [[package]] name = "custos-qr" -version = "0.17.0" +version = "0.17.1" [[package]] name = "custos-seal" -version = "0.17.0" +version = "0.17.1" dependencies = [ "chacha20poly1305", "hkdf", @@ -409,7 +409,7 @@ dependencies = [ [[package]] name = "custos-share" -version = "0.17.0" +version = "0.17.1" dependencies = [ "argon2", "chacha20poly1305", @@ -426,7 +426,7 @@ dependencies = [ [[package]] name = "custos-sign" -version = "0.17.0" +version = "0.17.1" dependencies = [ "blake2 0.10.6", "data-encoding", @@ -445,7 +445,7 @@ dependencies = [ [[package]] name = "custos-totp" -version = "0.17.0" +version = "0.17.1" dependencies = [ "custos-vault", "data-encoding", @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "custos-vault" -version = "0.17.0" +version = "0.17.1" dependencies = [ "argon2", "bip39", @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "custos-wasm" -version = "0.17.0" +version = "0.17.1" dependencies = [ "custos-qr", "custos-seal", diff --git a/Cargo.toml b/Cargo.toml index 905fe6a..2e1a92c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/*"] [workspace.package] -version = "0.17.0" +version = "0.17.1" edition = "2024" license = "MPL-2.0" repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic" diff --git a/crates/custos-sign/src/lib.rs b/crates/custos-sign/src/lib.rs index 9fa63e0..3625580 100644 --- a/crates/custos-sign/src/lib.rs +++ b/crates/custos-sign/src/lib.rs @@ -430,8 +430,9 @@ pub fn sha256_hex(bytes: &[u8]) -> String { /// The largest approval text Custos reads (docs/SIGNING.md). pub const MAX_APPROVAL: usize = 8 * 1024; -/// An approval expires at most this many seconds after it is checked. -pub const APPROVAL_MAX_AHEAD: u64 = 3600; +/// An approval expires at most this many seconds after it is checked: 25 hours (a release's approval lives a day, +/// and its card may wait for Mark that long; an hour before core 0.17.1). +pub const APPROVAL_MAX_AHEAD: u64 = 25 * 3600; /// A deploy approval, read from its canonical JSON (docs/SIGNING.md, "approval"). Nothing in it is secret. #[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] @@ -520,15 +521,16 @@ fn unprintable(c: char) -> bool { } /// Checks that `text` is a deploy approval in canonical form that has not expired at `now_secs` and expires at most -/// 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. +/// 25 hours later ([`APPROVAL_MAX_AHEAD`], 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 { 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")); + return Err(Error::Approval("it expires more than 25 hours from now")); } Ok(a) } diff --git a/crates/custos-sign/tests/approval.rs b/crates/custos-sign/tests/approval.rs index 4d6e923..0f06918 100644 --- a/crates/custos-sign/tests/approval.rs +++ b/crates/custos-sign/tests/approval.rs @@ -142,11 +142,15 @@ fn targets_have_limits() { } #[test] -fn the_expiry_is_after_now_and_within_an_hour() { +fn the_expiry_is_after_now_and_within_25_hours() { let at = |exp: u64| with(&format!("\"expires\":{}", NOW + 600), &format!("\"expires\":{exp}")); assert!(approval_check(&at(NOW + 1), NOW).is_ok()); assert!(approval_check(&at(NOW + 3600), NOW).is_ok()); - for exp in [NOW, NOW - 1, 0, NOW + 3601, u64::MAX] { + // A release's approval lives a day, and its card may wait for Mark that long (core 0.17.1). + assert_eq!(APPROVAL_MAX_AHEAD, 25 * 3600); + assert!(approval_check(&at(NOW + 24 * 3600), NOW).is_ok()); + assert!(approval_check(&at(NOW + 25 * 3600), NOW).is_ok()); + for exp in [NOW, NOW - 1, 0, NOW + 25 * 3600 + 1, u64::MAX] { let e = refused(&at(exp), NOW); assert!(e.contains("expire"), "{exp}: {e}"); } diff --git a/crates/custos-vault/src/signing.rs b/crates/custos-vault/src/signing.rs index 65d65cc..d085cac 100644 --- a/crates/custos-vault/src/signing.rs +++ b/crates/custos-vault/src/signing.rs @@ -700,7 +700,7 @@ impl Vault { } /// [`Vault::signing_check`] at `now` (Unix milliseconds): an approval must not have expired then, and must - /// expire at most an hour later. + /// expire at most 25 hours later (`custos_sign::APPROVAL_MAX_AHEAD`). pub fn signing_check_at(&self, req: &Request, now: i64) -> Result { self.check(req, now).map(|(view, _)| view) } diff --git a/crates/custos-vault/tests/signing.rs b/crates/custos-vault/tests/signing.rs index 1940461..81c02f2 100644 --- a/crates/custos-vault/tests/signing.rs +++ b/crates/custos-vault/tests/signing.rs @@ -322,8 +322,12 @@ fn an_approval_needs_its_run_a_canonical_unexpired_text_and_a_matching_context() spaced.approval = Some(spaced.approval.unwrap().replace(',', ", ")); invalid(&mut v, &spaced); let mut late = approval_req("r-42"); - late.approval = Some(approval_text("r-42", "Arca", 3601)); + late.approval = Some(approval_text("r-42", "Arca", 25 * 3600 + 1)); invalid(&mut v, &late); + // A day ahead is fine (core 0.17.1): a release's approval lives that long. + let mut day = approval_req("r-42"); + day.approval = Some(approval_text("r-42", "Arca", 24 * 3600)); + assert!(v.signing_check_at(&day, NOW).is_ok()); let mut past = approval_req("r-42"); past.approval = Some(approval_text("r-42", "Arca", 0)); invalid(&mut v, &past); diff --git a/docs/SIGNING.md b/docs/SIGNING.md index b2b4697..b5f53be 100644 --- a/docs/SIGNING.md +++ b/docs/SIGNING.md @@ -140,7 +140,7 @@ exactly this order: | `repo`, `pipeline`, `version` | 1–64 of `[A-Za-z0-9._+-]` | | `commit` | 40 lower-case hex digits | | `targets` | 1–16 strings of 1–80 characters (Unicode scalar values); no control characters, and none of the invisible ones that change how a line looks on the card (U+00AD, U+061C, U+180E, U+200B–U+200F, U+2028–U+202E, U+2060–U+2069, U+FEFF) | -| `expires` | Unix seconds, later than now and at most 3 600 s after now (checked before the card and again when signing) | +| `expires` | Unix seconds, later than now and at most 90 000 s (25 hours) after now (checked before the card and again when signing). Before core 0.17.1 the limit was 3 600 s; a release's approval now lives a day, so its card can wait for Mark that long | Strings use JSON's minimal escaping: a quote is written `\"`, a backslash `\\`, every other character as itself (no `\u` escapes, no `\/`; control characters cannot occur). There is no newline at the end. Custos @@ -251,7 +251,7 @@ one entry, whatever happened: | `standing` | (core 0.16.0) a standing approval fitted; signed without asking | | `auto` | a test key; signed without asking | | `refused` | Mark refused | -| `expired` | nobody answered within 5 minutes | +| `expired` | nobody answered before the card's wait ran out (the app's wait: 24 hours since Custos 0.17.0, 5 minutes before), or the requester withdrew it | | `out-of-scope` | the pipeline or repo is not on the key's lists (whether or not it was approved) | | `invalid` | the request was malformed (wrong digest length, a manifest or approval not in canonical form, an expired approval, a kind the key cannot do) |