Trait sequoia_openpgp::crypto::hash::Digest

source ·
pub trait Digest: DynClone + Write + Send + Sync {
    // Required methods
    fn algo(&self) -> HashAlgorithm;
    fn digest_size(&self) -> usize;
    fn update(&mut self, data: &[u8]);
    fn digest(&mut self, digest: &mut [u8]) -> Result<()>;

    // Provided method
    fn into_digest(self) -> Result<Vec<u8>>
       where Self: Sized { ... }
}
Expand description

Hasher capable of calculating a digest for the input byte stream.

This provides an abstract interface to the hash functions used in OpenPGP. Digests can be are created using HashAlgorithm::context.

Required Methods§

source

fn algo(&self) -> HashAlgorithm

Returns the algorithm.

source

fn digest_size(&self) -> usize

Size of the digest in bytes

source

fn update(&mut self, data: &[u8])

Writes data into the hash function.

source

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

Finalizes the hash function and writes the digest into the provided slice.

Resets the hash function contexts.

digest must be at least self.digest_size() bytes large, otherwise the digest will be truncated.

Provided Methods§

source

fn into_digest(self) -> Result<Vec<u8>>
where Self: Sized,

Finalizes the hash function and computes the digest.

Trait Implementations§

source§

impl Digest for Box<dyn Digest>

source§

fn update(&mut self, data: &[u8])

Writes data into the hash function.

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

Finalizes the hash function and writes the digest into the provided slice.

Resets the hash function contexts.

digest must be at least self.digest_size() bytes large, otherwise the digest will be truncated.

source§

fn algo(&self) -> HashAlgorithm

Returns the algorithm.
source§

fn digest_size(&self) -> usize

Size of the digest in bytes
source§

fn into_digest(self) -> Result<Vec<u8>>
where Self: Sized,

Finalizes the hash function and computes the digest.

Implementations on Foreign Types§

source§

impl Digest for Box<dyn Digest>

source§

fn update(&mut self, data: &[u8])

Writes data into the hash function.

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

Finalizes the hash function and writes the digest into the provided slice.

Resets the hash function contexts.

digest must be at least self.digest_size() bytes large, otherwise the digest will be truncated.

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

impl Digest for Md5

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Ripemd160

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Sha1

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Sha224

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Sha256

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Sha384

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Sha512

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

source§

impl Digest for Sha1CD

source§

fn algo(&self) -> HashAlgorithm

source§

fn digest_size(&self) -> usize

source§

fn update(&mut self, data: &[u8])

source§

fn digest(&mut self, digest: &mut [u8]) -> Result<()>

Implementors§