Skip to main content

RetryingDecryptor

Struct RetryingDecryptor 

Source
pub struct RetryingDecryptor<D> { /* private fields */ }
Expand description

An AeadDecryptor that retries once after a NoMatchingKey error by calling try_refresh on the inner decryptor.

It covers cross-server key propagation during rotation (one server seals with a freshly rotated key another has not loaded yet) and is the cipher analogue of RetryingVerifier. Wrap the root decryptor with it so any composition underneath — a ScheduledRefreshCipher, a MultiKeyDecryptor, or arbitrary nesting — gets one retry without implementing it. The retry’s refresh is gated by the inner layer’s policy, so a burst of unknown-kid bundles cannot force a burst of upstream fetches.

The retry fires only on NoMatchingKey, so callers must pass a CipherMatch with a kid and register kids on all keys in the set. A key with no registered kid can never be ruled out: it falls back to a ByAlgorithm match, is attempted, and its authentication failure masks the miss as Other — no retry fires. Likewise, with no CipherMatch at all, a stale key set surfaces as an authentication failure from try-all dispatch, indistinguishable from tampering and deliberately not retried.

See composing crypto strategies for how this layer (additions) pairs with the scheduled layer (removals).

Implementations§

Source§

impl<D: AeadDecryptor> RetryingDecryptor<D>

Source

pub fn new(inner: D) -> Self

Wraps a decryptor so that a NoMatchingKey result triggers a refresh and one retry.

Trait Implementations§

Source§

impl<D: AeadDecryptor> AeadDecryptor for RetryingDecryptor<D>

Source§

fn cipher_match(&self, m: &CipherMatch<'_>) -> Option<KeyMatchStrength>

Returns how well this decryptor matches the given selection criteria. Read more
Source§

fn decrypt<'a>( &'a self, cipher_match: Option<&'a CipherMatch<'a>>, nonce: &'a [u8], ciphertext: &'a [u8], tag: &'a [u8], aad: &'a [u8], ) -> MaybeSendBoxFuture<'a, Result<Vec<u8>, DecryptError>>

Asynchronously decrypts the given ciphertext with the provided nonce, tag, and associated data. Read more
Source§

fn try_refresh(&self) -> MaybeSendBoxFuture<'_, bool>

Requests a best-effort refresh of the decryptor’s key material — the cipher analogue of JwsVerifier::try_refresh. Read more
Source§

impl<D: Clone> Clone for RetryingDecryptor<D>

Source§

fn clone(&self) -> RetryingDecryptor<D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug> Debug for RetryingDecryptor<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> Freeze for RetryingDecryptor<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for RetryingDecryptor<D>
where D: RefUnwindSafe,

§

impl<D> Send for RetryingDecryptor<D>
where D: Send,

§

impl<D> Sync for RetryingDecryptor<D>
where D: Sync,

§

impl<D> Unpin for RetryingDecryptor<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for RetryingDecryptor<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for RetryingDecryptor<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.