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.

SHA-1 and SHA-2 accept absent or primitive NULL parameters (RFC 8017 Appendix B.1, RFC 5754 §2 and RFC 3370 §2.1). The producing reader validates NULL under the document’s encoding, including BER long-form lengths. SHA3-224/256/384/512 require absent parameters, even in BER (RFC 9688 §2).

§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),
);