Struct rpki::crypto::digest::DigestAlgorithm
source · pub struct DigestAlgorithm(/* private fields */);
Expand description
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.
Implementations§
source§impl DigestAlgorithm
impl DigestAlgorithm
source§impl DigestAlgorithm
impl DigestAlgorithm
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 5754. The
object identifier to be used is id-sha256
. When encoding, the
parameters field must be absent, whereas when decoding, it may either
be absent or NULL
.
Note that this differs from SignatureAlgorithm
identifiers where
the NULL
must be present when encoding.
The functions and methods in this section allow decoding and encoding such values.
sourcepub fn take_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Self, DecodeError<S::Error>>
pub fn take_from<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<Self, DecodeError<S::Error>>
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.
sourcepub fn take_opt_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Option<Self>, DecodeError<S::Error>>
pub fn take_opt_from<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<Option<Self>, DecodeError<S::Error>>
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.
sourcepub fn take_set_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Self, DecodeError<S::Error>>
pub fn take_set_from<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<Self, DecodeError<S::Error>>
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.
sourcepub fn skip_set<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<(), DecodeError<S::Error>>
pub fn skip_set<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<(), DecodeError<S::Error>>
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.
sourcepub fn take_oid_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Self, DecodeError<S::Error>>
pub fn take_oid_from<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<Self, DecodeError<S::Error>>
Takes a single algorithm object identifier from a constructed value.
sourcepub fn encode_set(self) -> impl Values
pub fn encode_set(self) -> impl Values
Provides an encoder for a indentifer as the sole value of a set.
sourcepub fn encode_oid(self) -> impl Values
pub fn encode_oid(self) -> impl Values
Provides an encoder for just the object identifier of the algorithm.
Trait Implementations§
source§impl Clone for DigestAlgorithm
impl Clone for DigestAlgorithm
source§fn clone(&self) -> DigestAlgorithm
fn clone(&self) -> DigestAlgorithm
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DigestAlgorithm
impl Debug for DigestAlgorithm
source§impl Default for DigestAlgorithm
impl Default for DigestAlgorithm
source§fn default() -> DigestAlgorithm
fn default() -> DigestAlgorithm
source§impl Hash for DigestAlgorithm
impl Hash for DigestAlgorithm
source§impl PartialEq for DigestAlgorithm
impl PartialEq for DigestAlgorithm
source§fn eq(&self, other: &DigestAlgorithm) -> bool
fn eq(&self, other: &DigestAlgorithm) -> bool
self
and other
values to be equal, and is used
by ==
.