1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! Static configuration for the native `VaultService`: the entity message names,
//! the versioned outbox topics (including the V-1 audit-coverage topics), the KV
//! and transit-key state tokens, the transit-algorithm allow-list, the envelope
//! tags, the version/list/TTL bounds, the seal probe, and the dynamic
//! DB-credential lease-reaper cadence. Extracted verbatim from the former god
//! file; every value is byte-stable for downstream audit/CDC consumers.
use OnceLock;
use Duration;
pub const VAULT_SECRET_MSG: &str = "udb.core.vault.entity.v1.VaultSecret";
pub const VAULT_TRANSIT_KEY_MSG: &str = "udb.core.vault.entity.v1.VaultTransitKey";
pub const VAULT_DB_CREDENTIAL_LEASE_MSG: &str =
"udb.core.vault.entity.v1.VaultDbCredentialLease";
pub const TOPIC_SECRET_PUT: &str = "udb.vault.secret.put.v1";
pub const TOPIC_SECRET_ACCESSED: &str = "udb.vault.secret.accessed.v1";
pub const TOPIC_SECRET_DELETED: &str = "udb.vault.secret.deleted.v1";
pub const TOPIC_SECRET_RESTORED: &str = "udb.vault.secret.restored.v1";
pub const TOPIC_SECRET_DESTROYED: &str = "udb.vault.secret.destroyed.v1";
pub const TOPIC_KEY_CREATED: &str = "udb.vault.transit_key.created.v1";
pub const TOPIC_KEY_ROTATED: &str = "udb.vault.transit_key.rotated.v1";
pub const TOPIC_TRANSIT_DECRYPTED: &str = "udb.vault.transit.decrypted.v1";
pub const TOPIC_DB_CREDENTIAL_ISSUED: &str = "udb.vault.db_credential.issued.v1";
// Audit-coverage topics. `secret.listed` fulfils the ListSecrets event contract
// declared in the proto (`method_event_contract`); the transit.* audit topics
// give the previously-unaudited crypto RPCs (Encrypt/Sign/Hmac/Verify) the same
// tenant-bound outbox audit trail the Decrypt read already emits. Every payload
// carries only tenant/key/version metadata — NEVER plaintext, ciphertext, or key
// material (vault's redaction doctrine).
pub const TOPIC_SECRET_LISTED: &str = "udb.vault.secret.listed.v1";
pub const TOPIC_TRANSIT_ENCRYPTED: &str = "udb.vault.transit.encrypted.v1";
pub const TOPIC_TRANSIT_SIGNED: &str = "udb.vault.transit.signed.v1";
pub const TOPIC_TRANSIT_HMAC: &str = "udb.vault.transit.hmac.v1";
pub const TOPIC_TRANSIT_VERIFIED: &str = "udb.vault.transit.verified.v1";
// KV secret version states.
pub const STATE_ACTIVE: &str = "ACTIVE";
pub const STATE_DELETED: &str = "DELETED";
pub const STATE_DESTROYED: &str = "DESTROYED";
// Transit key states — mirror the auth-service signing-key registry rotation:
// ACTIVE encrypts/signs (and decrypts/verifies); VERIFYING decrypts/verifies
// only, during the rotation overlap; RETIRED is excluded.
pub const KEY_STATE_ACTIVE: &str = "ACTIVE";
pub const KEY_STATE_VERIFYING: &str = "VERIFYING";
pub const DEFAULT_TRANSIT_ALGORITHM: &str = "aes256-gcm-siv";
/// The asymmetric signing algorithm: a key created with this algorithm signs via
/// real Ed25519 (Sign/Verify), not the symmetric HMAC used by every other key.
/// The 32-byte transit key material doubles as the Ed25519 seed, so no separate
/// key generation is needed.
pub const SIGNING_TRANSIT_ALGORITHM: &str = "ed25519";
/// The transit algorithms the crypto stack actually implements: the
/// AES-256-GCM-SIV envelope primitive (Encrypt/Decrypt/HMAC-Sign) and Ed25519
/// (asymmetric Sign/Verify). An unknown `algorithm` on CreateTransitKey is
/// rejected up front instead of being silently coerced to the default (a latent
/// capability lie). Extend this set only when a new primitive is genuinely wired
/// into the seal/open/sign path.
pub const SUPPORTED_TRANSIT_ALGORITHMS: & =
&;
/// Transit ciphertext envelope tag: `udb-vault:v<keyver>:<b64(nonce||ct)>`.
/// Distinct from the broker's `udb-aead:` master-key envelope so the two layers
/// are never confused.
pub const VAULT_TRANSIT_ENVELOPE_PREFIX: &str = "udb-vault:v";
/// Transit MAC/signature envelope tag: `udb-vmac:v<keyver>:<b64(mac)>`.
pub const VAULT_HMAC_PREFIX: &str = "udb-vmac:v";
/// Ed25519 signature envelope tag: `udb-vsig:v<keyver>:<b64(sig)>`. Distinct from
/// the HMAC tag so Verify dispatches to the right primitive by the envelope alone.
pub const VAULT_ED25519_PREFIX: &str = "udb-vsig:v";
/// Bound on how many versions of a single path/key are scanned in one read.
pub const MAX_VERSIONS_SCAN: u32 = 10_000;
/// Per-list secret-path cap.
pub const MAX_LIST_SECRETS: u32 = 1_000;
pub const DEFAULT_DB_CREDENTIAL_TTL_SECONDS: i32 = 900;
pub const MIN_DB_CREDENTIAL_TTL_SECONDS: i32 = 60;
pub const DEFAULT_DB_CREDENTIAL_MAX_TTL_SECONDS: i32 = 3600;
pub const VAULT_DB_LEASE_REAPER_BATCH: i64 = 100;
/// Constant the seal gate round-trips through `encrypt_secret_at_rest` to probe
/// master-key availability without exposing real secret material.
pub const SEAL_PROBE: &str = "udb-vault-seal-probe";
pub const VAULT_RUNTIME_REQUIRED_MESSAGE: &str =
"vault service requires runtime native-entity dispatch (no runtime configured)";
pub const VAULT_MASTER_KEY_UNAVAILABLE_MESSAGE: &str =
"vault is sealed: master key unavailable";