[][src]Struct rpki::crypto::digest::DigestAlgorithm

pub struct DigestAlgorithm;

The digest algorithms used by RPKI.

These are the algorithms used by the signature algorithms. For use in RPKI, RFC 7935 limits them to exactly one, SHA-256. Because of that, this type is currently a zero-sized struct. If additional algorithms are ever introduced in the future, it will change into an enum.

Methods

impl DigestAlgorithm[src]

pub fn digest(self, data: &[u8]) -> Digest[src]

Returns the digest of data using this algorithm.

Important traits for Context
pub fn start(self) -> Context[src]

Returns a digest context for multi-step calculation of the digest.

impl DigestAlgorithm[src]

ASN.1 Values

Digest algorithms appear in CMS either alone or in sets with the following syntax:

DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
DigestAlgorithmIdentifier  ::= AlgorithmIdentifier
AlgorithmIdentifier        ::= SEQUENCE {
     algorithm                 OBJECT IDENTIFIER,
     parameters                ANY DEFINED BY algorithm OPTIONAL }

In RPKI signed objects, a set is limited to exactly one identifer. The allowed algorithms are limited, too. In particular, RFC 7935 only allows SHA-256. Its algorithm identifier is defined in RFC 4055. The parameters field may either be absent or NULL.

The functions and methods in this section allow decoding and encoding such values.

pub fn take_from<S: Source>(cons: &mut Constructed<S>) -> Result<Self, S::Err>[src]

Takes and returns a single digest algorithm identifier.

Returns a malformed error if the algorithm isn’t one of the allowed algorithms or if the value isn’t correctly encoded.

pub fn take_opt_from<S: Source>(
    cons: &mut Constructed<S>
) -> Result<Option<Self>, S::Err>
[src]

Takes and returns an optional digest algorithm identifier.

Returns Ok(None) if the next value isn’t a sequence. Returns a malformed error if the sequence isn’t a correctly encoded algorithm identifier or if algorithm isn’t one of the allowed algorithms.

pub fn take_set_from<S: Source>(
    cons: &mut Constructed<S>
) -> Result<Self, S::Err>
[src]

Takes and returns a set of digest algorithm identifiers.

The set must contain exactly one identifier as required everywhere for RPKI. If it contains more than one or identifiers that are not allowed, a malformed error is returned.

pub fn skip_set<S: Source>(cons: &mut Constructed<S>) -> Result<(), S::Err>[src]

Parses a SET OF DigestAlgorithmIdentifiers.

This is used in the digestAlgorithms field of the SignedData container. It provides all the digest algorithms used later on, so that the data can be read over. We don’t really need this, so this function returns () on success.

Section 2.1.2. of RFC 6488 requires there to be exactly one element chosen from the allowed values.

pub fn encode(self) -> impl Values[src]

Provides an encoder for a single algorithm identifier.

pub fn encode_set(self) -> impl Values[src]

Provides an encoder for a indentifer as the sole value of a set.

pub fn encode_oid(self) -> impl Values[src]

Provides an encoder for just the object identifier of the algorithm.

Trait Implementations

impl Copy for DigestAlgorithm[src]

impl PartialEq<DigestAlgorithm> for DigestAlgorithm[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl Clone for DigestAlgorithm[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for DigestAlgorithm[src]

impl Debug for DigestAlgorithm[src]

impl Hash for DigestAlgorithm[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.