Skip to main content

AlgorithmIdentifier

Struct AlgorithmIdentifier 

Source
pub struct AlgorithmIdentifier<'a> { /* private fields */ }
Expand description

An algorithm and its parameters, as the certificate wrote them.

Implementations§

Source§

impl<'a> AlgorithmIdentifier<'a>

Source

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.

Source

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.

Source

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.

Source

pub fn algorithm(self) -> Oid<'a>

Which algorithm.

Source

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.

Source

pub fn offset(self) -> u64

Original algorithm element offset, without scanning or deriving a new range.

Source

pub fn encoding(self) -> Encoding

Encoding selected by the original schema reader for this identifier.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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)?);

Trait Implementations§

Source§

impl<'a> Clone for AlgorithmIdentifier<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for AlgorithmIdentifier<'a>

Source§

impl<'a> Debug for AlgorithmIdentifier<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.