pub struct AlgorithmIdentifier<'a> { /* private fields */ }Expand description
An algorithm and its parameters, as the certificate wrote them.
Implementations§
Source§impl<'a> AlgorithmIdentifier<'a>
impl<'a> AlgorithmIdentifier<'a>
Sourcepub fn has_null_parameter(self) -> bool
pub fn has_null_parameter(self) -> bool
Whether a written primitive NULL was validated by the producing reader. Original parameter bytes remain unchanged; absence is not NULL here.
Sourcepub fn same_written_in(self, other: &Self, parent: &Reader<'_>) -> Result<bool>
pub fn same_written_in(self, other: &Self, parent: &Reader<'_>) -> Result<bool>
Compares written values without assuming algorithm-specific defaults. Two validated primitive NULLs share a value despite BER length spelling; other parameters retain opaque encoded identity. Both identifiers must come from this producing parser. This is not algorithm acceptance.
§Errors
Returns a located resource refusal or a foreign-parser error before comparing identifiers from another parsing session.
Sourcepub fn digest_matches_in(
self,
other: &Self,
parent: &Reader<'_>,
) -> Result<bool>
pub fn digest_matches_in( self, other: &Self, parent: &Reader<'_>, ) -> Result<bool>
Compares RFC5754 §2 SHA224/256/384/512 identifiers with absent/NULL defaults. Unknown algorithms retain written-value semantics, not a guessed default. Invalid known parameters and resource/caller refusals remain errors. Selected-provider support and signature-profile acceptance are separate. https://www.rfc-editor.org/rfc/rfc5754#section-2
§Errors
Returns invalid known parameters, foreign-parser misuse, or resource refusal separately from an ordinary identity mismatch.
Sourcepub fn parameters(self) -> Option<&'a [u8]>
pub fn parameters(self) -> Option<&'a [u8]>
The parameters, as the whole encoded element, or None where the
certificate wrote none.
Kept encoded because what they mean depends on the algorithm: the same bytes are a curve for one and a hash function and salt length for another.
Sourcepub fn offset(self) -> u64
pub fn offset(self) -> u64
Original algorithm element offset, without scanning or deriving a new range.
Sourcepub fn encoding(self) -> Encoding
pub fn encoding(self) -> Encoding
Encoding selected by the original schema reader for this identifier.
Sourcepub fn parameters_reader_in<'query>(
self,
parent: &Reader<'query>,
field: &'static str,
) -> Result<Option<Reader<'query>>>where
'a: 'query,
pub fn parameters_reader_in<'query>(
self,
parent: &Reader<'query>,
field: &'static str,
) -> Result<Option<Reader<'query>>>where
'a: 'query,
Opens the whole original parameter TLV at its original reader depth.
parent must belong to the original parser session; rebinding its
current execution account is allowed. A foreign session is rejected
before lookup, work or allocation. Both current funding and the original
cumulative session ceiling govern all later decoding. Absence is only
returned after admission, never as a resource fallback.
The returned depth equals an immediate inside.reread(parameter, encoding)
after this identifier was read, including an IMPLICIT context envelope.
It includes the parameter header, not just its contents; no replacement
parser, canonical serialization or extra parameter nesting is introduced.
Sourcepub fn same_session(self, parent: &ScopedReader<'_, '_>) -> bool
pub fn same_session(self, parent: &ScopedReader<'_, '_>) -> bool
Whether this original identifier was produced by this parser session. Account equality does not establish source/session identity. This O(1) metadata predicate reads no parameters and spends no data-dependent work.
Sourcepub fn as_bytes(self) -> &'a [u8] ⓘ
pub fn as_bytes(self) -> &'a [u8] ⓘ
The whole identifier as it was encoded.
For read_implicit, this retains the original context tag, not a
synthesized SEQUENCE suitable for reparsing as an untagged identifier.
Sourcepub fn has_no_parameters(self) -> bool
pub fn has_no_parameters(self) -> bool
Whether the parameters are absent, or the null that means the same thing for the algorithms that spell it that way.
Sourcepub fn matches(
self,
other: &AlgorithmIdentifier<'_>,
execution: &Memory,
) -> Result<bool>
pub fn matches( self, other: &AlgorithmIdentifier<'_>, execution: &Memory, ) -> Result<bool>
Whether two identifiers name the same algorithm with the same parameters.
An absent parameter and an explicit null are treated as the same, and nothing else is. Issuers disagree about which of the two to write for the algorithms that take no parameters, and both say the same thing; any other difference changes what is being verified.
The equivalence is deliberately not algorithm-specific. Which parameter encodings an algorithm permits at all, including that the Edwards-curve identifiers forbid the null form, is the algorithm registry’s decision, made against the identifier inside the signed bytes. This comparison only asks whether the unsigned outer identifier agrees with that signed one, and absent versus null cannot change which algorithm that is: an outer null beside a signed absent is a malformed spelling of the same identity, not a different algorithm escaping the mismatch check.
Deferred comparisons charge the supplied current operation. Their
resource diagnostics identify self’s original field and offset; they
do not assert that the two identifiers share a source. Parser-local
limits apply only when comparing through the producing reader.
§Errors
Returns a resource refusal before an unfunded byte comparison.
§Examples
let identifier = structured_pkix::algorithm::read(&reader, &element, "algorithm")?;
assert!(identifier.matches(&identifier, &execution)?);