Skip to main content

algorithm

Function algorithm 

Source
pub fn algorithm<W: Work>(
    identifier: &AlgorithmIdentifier<'_>,
    execution: &W,
) -> Result<Resolution<Algorithm>>
Expand description

Reads which standard digest identifier names.

Every algorithm here takes no parameters: the field “should generally be omitted, but if present, it shall have a value of type NULL” (RFC 8017 Appendix B.1; RFC 5754 §2 and RFC 3370 §2.1 require receivers to accept both). NULL is the primitive NULL the producing reader validated under the document’s own encoding, so a BER long-form length is NULL too (RFC 5652 §1: a signed message is BER).

§Errors

A located resource refusal when execution cannot pay for the comparison; never Malformed or Unsupported.

§Examples

use structured_pkix::algorithm::{self, digest};
// SEQUENCE { OID 2.16.840.1.101.3.4.2.1, NULL }
let der = [0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00];
let identifier = algorithm::read(&reader, &element, "digestAlgorithm")?;
assert_eq!(
    digest::algorithm(&identifier, &execution)?,
    Resolution::Supported(digest::Algorithm::Sha256),
);