Skip to main content

Unverified

Struct Unverified 

Source
pub struct Unverified<T> { /* private fields */ }
Expand description

A decrypted value whose file MAC has not been checked yet.

Carries everything the check needs so a caller cannot be asked for the MAC inputs at some later point where they are no longer in scope.

Implementations§

Source§

impl<T> Unverified<T>

Source

pub fn new( inner: T, computed: Mac, mac_field: impl Into<String>, lastmodified: impl Into<String>, leaves_fed: usize, ) -> Self

Wrap a freshly-decrypted value together with its MAC inputs.

Source

pub fn computed_mac(&self) -> &Mac

The MAC recomputed from the decrypted contents.

Source

pub fn leaves_fed(&self) -> usize

How many leaves went into the recomputed MAC. The denominator.

A MAC over zero leaves matches another MAC over zero leaves, so a walker that silently stopped finding leaves would verify green while checking nothing. Unverified::verify refuses that case outright; this getter lets a caller assert a specific expected count on top.

Source

pub fn verify(self, key: &DataKey) -> Result<T, WireError>

Check the MAC and release the value.

Refuses a zero-leaf verification as vacuous. That is a deliberate divergence from upstream, which would happily verify an empty walk: the only file that legitimately has no leaves is an empty document, and treating one as authenticated is how a broken walker reads as a green gate. A caller that genuinely wants to accept an empty document can say so with Unverified::verify_allowing_empty.

Source

pub fn verify_allowing_empty(self, key: &DataKey) -> Result<T, WireError>

Unverified::verify without the anti-vacuity refusal, for the genuinely empty document.

Source

pub fn into_inner_ignoring_mac(self) -> T

The --ignore-mac escape.

Deliberately verbose. sops offers --ignore-mac and real operators need it — a file whose MAC broke because someone hand-edited lastmodified is still recoverable, and refusing outright would make us less useful than what we replace. So the escape exists; it is just impossible to take without typing its name.

Source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Unverified<U>

Map the wrapped value without unwrapping it, so a caller can keep transforming a still-unauthenticated tree without losing the marker.

Trait Implementations§

Source§

impl<T> Debug for Unverified<T>

Source§

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

Never prints the wrapped value — it is decrypted plaintext, and this type is most likely to be Debug-printed exactly when someone is debugging a MAC failure over a real file.

Auto Trait Implementations§

§

impl<T> Freeze for Unverified<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Unverified<T>
where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for Unverified<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Unverified<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Unverified<T>
where T: 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.