Skip to main content

read

Function read 

Source
pub fn read<'a, W: Work>(
    identifier: AlgorithmIdentifier<'a>,
    execution: &W,
) -> Result<Option<Parameters<'a>>>
Expand description

Reads a retained identifier’s original PSS parameters under current work.

For verification callbacks that retain an AlgorithmIdentifier without its former reader. Source parser, encoding, parameter depth and cumulative ceiling come from that identifier; execution supplies current funding and its root-operation ceiling. No reader is fabricated and no parser, resource account, parameter copy or default encoding is created.

Like read_in, returns None for absent parameters. RFC4055 §3.1 and RFC5756 §2 require signature parameters, while absent PSS key parameters mean unrestricted PSS usage; that role is the caller’s decision. Use the key’s original algorithm identifier: absent PSS restrictions do not inherit from another certificate (RFC4055 §3.3). No backend acceptance is implied. https://www.rfc-editor.org/rfc/rfc5756#section-2

§Errors

Reports located schema/encoding errors, including written DER defaults, separately from terminal source/current work, depth or storage refusal. Returned scalar views borrow the original source, not current execution.

§Examples

use std::sync::Arc;
use structured_asn1::{Parser, memory::{Memory, MemoryAccount}};
use structured_pkix::algorithm::{self, pss};
let source = Parser::der(Memory::new(Arc::new(MemoryAccount::new(4096, 4096))));
let bytes = b"\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0a\x30\x00";
let identifier = {
    let mut reader = source.read(bytes, 400).unwrap();
    let element = reader.next_element().unwrap().unwrap();
    algorithm::read(&reader, &element, "signatureAlgorithm")?
};
let current = Memory::new(Arc::new(MemoryAccount::new(4096, 4096)));
let parameters = pss::read(identifier, &current)?.unwrap();
assert_eq!(parameters.element().span().start, 413);
assert_eq!(parameters.salt().as_u64(), Some(20));