pub enum DigestAlgorithm {
Sha1,
Sha256,
Sha384,
Sha512,
}
Expand description
A hashing algorithm used for digesting data.
Instances can be converted to and from Oid via From
/Into
implementations.
They can also be converted to and from The ASN.1 AlgorithmIdentifier, which is commonly used to represent them in X.509 certificates.
Instances can be converted into a digest::Context capable of computing
digests via From
/Into
.
Variants
Sha1
SHA-1.
Corresponds to OID 1.3.14.3.2.26.
Sha256
SHA-256.
Corresponds to OID 2.16.840.1.101.3.4.2.1.
Sha384
SHA-384.
Corresponds to OID 2.16.840.1.101.3.4.2.2.
Sha512
SHA-512.
Corresponds to OID 2.16.840.1.101.3.4.2.3.
Implementations
sourceimpl DigestAlgorithm
impl DigestAlgorithm
sourcepub fn digester(&self) -> Context
pub fn digester(&self) -> Context
Obtain an object that can be used to digest content using this algorithm.
sourcepub fn digest_reader<R: Read>(&self, fh: &mut R) -> Result<Vec<u8>, Error>
pub fn digest_reader<R: Read>(&self, fh: &mut R) -> Result<Vec<u8>, Error>
Digest content from a reader.
sourcepub fn rsa_pkcs1_encode(
&self,
message: &[u8],
target_length_in_bytes: usize
) -> Result<Vec<u8>, Error>
pub fn rsa_pkcs1_encode(
&self,
message: &[u8],
target_length_in_bytes: usize
) -> Result<Vec<u8>, Error>
EMSA-PKCS1-v1_5 padding procedure.
As defined by https://tools.ietf.org/html/rfc3447#section-9.2.
message
is the message to digest and encode.
target_length_in_bytes
is the target length of the padding. This should match the RSA
key length. e.g. 2048 bit keys are length 256.
Trait Implementations
sourceimpl Clone for DigestAlgorithm
impl Clone for DigestAlgorithm
sourcefn clone(&self) -> DigestAlgorithm
fn clone(&self) -> DigestAlgorithm
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for DigestAlgorithm
impl Debug for DigestAlgorithm
sourceimpl Display for DigestAlgorithm
impl Display for DigestAlgorithm
sourceimpl From<DigestAlgorithm> for Oid
impl From<DigestAlgorithm> for Oid
sourcefn from(alg: DigestAlgorithm) -> Self
fn from(alg: DigestAlgorithm) -> Self
Converts to this type from the input type.
sourceimpl From<DigestAlgorithm> for AlgorithmIdentifier
impl From<DigestAlgorithm> for AlgorithmIdentifier
sourcefn from(alg: DigestAlgorithm) -> Self
fn from(alg: DigestAlgorithm) -> Self
Converts to this type from the input type.
sourceimpl From<DigestAlgorithm> for Context
impl From<DigestAlgorithm> for Context
sourcefn from(alg: DigestAlgorithm) -> Self
fn from(alg: DigestAlgorithm) -> Self
Converts to this type from the input type.
sourceimpl Hash for DigestAlgorithm
impl Hash for DigestAlgorithm
sourceimpl PartialEq<DigestAlgorithm> for DigestAlgorithm
impl PartialEq<DigestAlgorithm> for DigestAlgorithm
sourceimpl TryFrom<&'_ AlgorithmIdentifier> for DigestAlgorithm
impl TryFrom<&'_ AlgorithmIdentifier> for DigestAlgorithm
type Error = X509CertificateError
type Error = X509CertificateError
The type returned in the event of a conversion error.
sourcefn try_from(v: &AlgorithmIdentifier) -> Result<Self, Self::Error>
fn try_from(v: &AlgorithmIdentifier) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl TryFrom<&'_ Oid<Bytes>> for DigestAlgorithm
impl TryFrom<&'_ Oid<Bytes>> for DigestAlgorithm
impl Copy for DigestAlgorithm
impl Eq for DigestAlgorithm
impl StructuralEq for DigestAlgorithm
impl StructuralPartialEq for DigestAlgorithm
Auto Trait Implementations
impl RefUnwindSafe for DigestAlgorithm
impl Send for DigestAlgorithm
impl Sync for DigestAlgorithm
impl Unpin for DigestAlgorithm
impl UnwindSafe for DigestAlgorithm
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more