Identity

Trait Identity 

Source
pub trait Identity {
    // Required method
    fn unwrap_stanza(
        &self,
        stanza: &Stanza,
    ) -> Option<Result<FileKey, DecryptError>>;

    // Provided method
    fn unwrap_stanzas(
        &self,
        stanzas: &[Stanza],
    ) -> Option<Result<FileKey, DecryptError>> { ... }
}
Expand description

A private key or other value that can unwrap an opaque file key from a recipient stanza.

§Implementation notes

The canonical entry point for this trait is Identity::unwrap_stanzas. The default implementation of that method is:

stanzas.iter().find_map(|stanza| self.unwrap_stanza(stanza))

The age crate otherwise does not call Identity::unwrap_stanza directly. As such, if you want to add file-level stanza checks, override Identity::unwrap_stanzas.

Required Methods§

Source

fn unwrap_stanza( &self, stanza: &Stanza, ) -> Option<Result<FileKey, DecryptError>>

Attempts to unwrap the given stanza with this identity.

This method is part of the Identity trait to expose age’s one joint for external implementations. You should not need to call this directly; instead, pass identities to Decryptor::decrypt.

The age crate only calls this method via Identity::unwrap_stanzas.

Returns:

  • Some(Ok(file_key)) on success.
  • Some(Err(e)) if a decryption error occurs.
  • None if the recipient stanza does not match this key.

Provided Methods§

Source

fn unwrap_stanzas( &self, stanzas: &[Stanza], ) -> Option<Result<FileKey, DecryptError>>

Attempts to unwrap any of the given stanzas, which are assumed to come from the same age file header, and therefore contain the same file key.

This method is part of the Identity trait to expose age’s one joint for external implementations. You should not need to call this directly; instead, pass identities to Decryptor::decrypt.

Returns:

  • Some(Ok(file_key)) on success.
  • Some(Err(e)) if a decryption error occurs.
  • None if none of the recipient stanzas match this identity.

Implementors§

Source§

impl Identity for age::ssh::Identity

Available on crate feature ssh only.
Source§

impl Identity for age::scrypt::Identity

Source§

impl Identity for age::x25519::Identity

Source§

impl<C: Callbacks> Identity for IdentityPluginV1<C>

Available on crate feature plugin only.
Source§

impl<R: Read, C: Callbacks> Identity for age::encrypted::Identity<R, C>