Skip to main content

Extensions

Struct Extensions 

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

The extensions of one certificate, in the order it holds them.

Implementations§

Source§

impl<'a> Extensions<'a>

Source

pub fn memory(&self) -> &Memory

Account retaining this collection’s storage. Deferred decoding may explicitly use a different current execution domain.

Source

pub fn iter<'r, 'e, W: Work + 'e>( &'r self, execution: &'e W, ) -> impl Iterator<Item = Result<&'r Extension<'a>>> + 'e
where 'r: 'e,

Every extension in order, funded by this query’s current execution. The constructor allocates/clones nothing. Each metadata step is paid before advancing; a resource failure is yielded once, then traversal stops. Empty/exhausted catalogues perform no additional charged work. Recognition and payload parsing must fund their own data-dependent work.

Source

pub fn len(&self) -> usize

How many there are.

Source

pub fn is_empty(&self) -> bool

Whether there are none.

Source

pub fn get<W: Work>( &self, kind: Oid<'_>, execution: &W, ) -> Result<Option<&Extension<'a>>>

One extension by identifier. There is at most one of each: a certificate carrying two copies is refused when it is read, because which of them applies would have no answer.

Source

pub fn unhandled_critical<'r, E, W: Work>( &'r self, recognizer: &impl Recognizer<W, Error = E>, execution: &W, ) -> CallbackResult<OwnedVec<&'r Extension<'a>>, E>

The critical extensions this run did not understand: the ones nobody knows, and the ones this crate knows by identifier but whose values do not parse.

A non-empty answer is what blocks a verdict. Knowing the identifier is not understanding the extension: a critical key usage whose value never parsed was never understood, and filtering it out by identifier alone would leave a validator seeing no blocker for a demand the certificate marked as one. Extensions a recognizer claims are that scheme’s to decode and are taken at its word.

The answer is returned rather than acted on, because what to do about it belongs to the policy layer and the report has to name them. An error is a spent budget and only that: it says this run gave up before the question was answered, which must not be reported as a demand nobody understood.

Source

pub fn criticals<'r, 'e, W: Work + 'e>( &'r self, execution: &'e W, ) -> impl Iterator<Item = Result<&'r Extension<'a>>> + 'e
where 'r: 'e,

The critical extensions, in the order the certificate wrote them and without reading any of their values.

Separate from Self::understands because working out whether one was understood decodes its value, and how much that value holds is a document’s to decide. A caller holding a budget charges for an entry and then asks: the two joined into one step would decode before the charge could refuse it, since asking for the next entry is what would do the decoding. Each metadata entry is admitted before testing its critical flag, including skipped entries and a complete miss. A resource error is yielded once, then iteration permanently ends without further charges.

§Examples
use structured_asn1::memory::Memory;
use structured_pkix::{Certificate, Result};
fn has_critical(certificate: &Certificate<'_>, execution: &Memory) -> Result<bool> {
    match certificate.tbs().extensions().criticals(execution).next() {
        Some(item) => { item?; Ok(true) }
        None => Ok(false),
    }
}
Source

pub fn understands<E, W: Work>( &self, item: &Extension<'a>, recognizer: &impl Recognizer<W, Error = E>, execution: &W, ) -> CallbackResult<bool, E>

Whether this run understood one extension: this crate decodes it, or a scheme claims it and it holds one complete value.

Knowing the identifier is not understanding the extension: a critical key usage whose value never parsed was never understood, and taking it by identifier alone would leave a validator seeing no blocker for a demand the certificate marked as one.

Source§

impl<'a> Extensions<'a>

The extensions this crate reads into structures of their own.

Each is read when it is asked for rather than when the certificate is, because an extension that cannot be read is not a certificate that cannot be read. Lookup and decoding use the caller’s current execution domain; the original parser’s cumulative local ceilings still apply.

Source

pub fn read_element( parent: &ScopedReader<'a, '_>, element: &Element<'a>, field: &'static str, ) -> Result<Self>

Reads one original Extensions SEQUENCE with the certificate catalogue invariants: nonempty, no duplicate OIDs, primitive extnValue, and the producing encoding’s DEFAULT rules. This does not recognize/trust values.

Source

pub fn read_implicit( parent: &ScopedReader<'a, '_>, element: &Element<'a>, number: u32, field: &'static str, ) -> Result<Self>

Reads [number] IMPLICIT Extensions without changing original bytes. The number is selected by the enclosing schema (RFC3161 §§2.4.1–2.4.2). This strict catalogue is suitable for requests, not TSTInfo inspection recovery; use read_with there before deciding duplicate/fault policy. Original source/depth and producing local/current aggregate work survive. https://www.rfc-editor.org/rfc/rfc3161#section-2.4.1

Source

pub fn basic_constraints<W: Work>( &self, execution: &W, ) -> Result<Option<BasicConstraints>>

Whether this is a certification authority, and how deep a path below it may go.

Source

pub fn key_usage<W: Work>(&self, execution: &W) -> Result<Option<KeyUsage<'a>>>

What the key may be used for.

Source

pub fn extended_key_usage<W: Work>( &self, execution: &W, ) -> Result<Option<ExtendedKeyUsage<'a>>>

The further purposes the key is named for.

Source

pub fn subject_alt_name<W: Work>( &self, execution: &W, ) -> Result<Option<OwnedVec<GeneralName<'a>>>>

The further names for the subject.

Source

pub fn issuer_alt_name<W: Work>( &self, execution: &W, ) -> Result<Option<OwnedVec<GeneralName<'a>>>>

The further names for the issuer.

Source

pub fn subject_key_identifier<W: Work>( &self, execution: &W, ) -> Result<Option<SubjectKeyIdentifier<'a>>>

The identifier for the key this certificate carries.

Source

pub fn authority_key_identifier<W: Work>( &self, execution: &W, ) -> Result<Option<AuthorityKeyIdentifier<'a>>>

The identifier for the key that signed it.

Source

pub fn name_constraints<W: Work>( &self, execution: &W, ) -> Result<Option<NameConstraints<'a>>>

The name space this authority may certify within.

Source

pub fn certificate_policies<W: Work>( &self, execution: &W, ) -> Result<Option<CertificatePolicies<'a>>>

The policies the certificate was issued under.

Source

pub fn policy_mappings<W: Work>( &self, execution: &W, ) -> Result<Option<PolicyMappings<'a>>>

The policies of one domain treated as equivalent to another’s.

Source

pub fn policy_constraints<W: Work>( &self, execution: &W, ) -> Result<Option<PolicyConstraints>>

The limits on policy processing below this certificate.

Source

pub fn inhibit_any_policy<W: Work>( &self, execution: &W, ) -> Result<Option<InhibitAnyPolicy>>

After how many certificates the identifier standing for any policy stops being accepted.

Source

pub fn authority_info_access<W: Work>( &self, execution: &W, ) -> Result<Option<InfoAccess<'a>>>

Where the issuer’s certificate and status service are published.

Source

pub fn subject_info_access<W: Work>( &self, execution: &W, ) -> Result<Option<InfoAccess<'a>>>

Where services belonging to the subject are published.

Source

pub fn crl_distribution_points<W: Work>( &self, execution: &W, ) -> Result<Option<DistributionPoints<'a>>>

Where revocation lists covering this certificate are published.

Source

pub fn freshest_crl<W: Work>( &self, execution: &W, ) -> Result<Option<DistributionPoints<'a>>>

Where the delta revocation list is published.

Source

pub fn qc_statements<W: Work>( &self, execution: &W, ) -> Result<Option<QcStatements<'a>>>

What the issuer claims about this being a qualified certificate.

Trait Implementations§

Source§

impl<'a> Debug for Extensions<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Extensions<'a>

§

impl<'a> !RefUnwindSafe for Extensions<'a>

§

impl<'a> !Send for Extensions<'a>

§

impl<'a> !Sync for Extensions<'a>

§

impl<'a> !UnwindSafe for Extensions<'a>

§

impl<'a> Unpin for Extensions<'a>

§

impl<'a> UnsafeUnpin for Extensions<'a>

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> 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, 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.