pub struct HmacEnvelope<K: KeyProvider> { /* private fields */ }Expand description
HMAC-SHA-256 backed envelope. Sealed messages are self-describing
CBOR maps: signature recipients can decode the envelope, fetch the
key by kid, and verify without out-of-band coordination.
Implementations§
Source§impl<K: KeyProvider> HmacEnvelope<K>
impl<K: KeyProvider> HmacEnvelope<K>
pub fn new(keys: Arc<K>, signing_kid: impl Into<String>) -> Self
pub fn with_clock_skew_secs(self, secs: i64) -> Self
Sourcepub fn with_nonce_store(self, store: Arc<dyn NonceStore>) -> Self
pub fn with_nonce_store(self, store: Arc<dyn NonceStore>) -> Self
Attach a nonce store so open rejects replays. Without this,
the envelope is only protected by the clock-skew window — an
attacker who captured a sealed message can replay it inside
that window.
Sourcepub async fn seal(&self, payload: Value) -> Result<SealedEnvelope, CoolError>
pub async fn seal(&self, payload: Value) -> Result<SealedEnvelope, CoolError>
Seal a request body. The returned bytes are a CBOR-encoded
SealedEnvelope payload — the sender wraps these in their
codec of choice on the way out.
Sourcepub async fn open(&self, envelope: &SealedEnvelope) -> Result<Value, CoolError>
pub async fn open(&self, envelope: &SealedEnvelope) -> Result<Value, CoolError>
Verify a sealed envelope. Returns the body on success. Constant- time MAC compare; clock-skew window enforced; envelope kid is resolved through the configured provider so callers can rotate keys without changing the recipient.
Trait Implementations§
Source§impl<K: Clone + KeyProvider> Clone for HmacEnvelope<K>
impl<K: Clone + KeyProvider> Clone for HmacEnvelope<K>
Source§fn clone(&self) -> HmacEnvelope<K>
fn clone(&self) -> HmacEnvelope<K>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more