silk/certificate_identities
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.
Bounded decoding of certificate subjectAltName values into borrowed identity descriptors.
Details
CertificateSan.decode scans all extensions before decoding one SAN value into caller storage.
CertificateSan.decodeValue accepts a complete DER GeneralNames value without a certificate owner.
Both operations preserve source order and return a count. Descriptor payloads borrow the input owner.
Gotchas
Failure can leave partial descriptors in storage. Use storage only after a successful result. This module checks encoding, not DNS syntax, identity matches, or certificate trust. Other universal content and legacy string repertoires remain opaque after complete framing checks. Schema-specific defaults, SET ordering, and implicit-tag content semantics require their owning schema.
Import as CertificateSan with import silk.certificate_identities { CertificateSan }.
Public declarations: 6.
SanDecodeLimits
pub struct SanDecodeLimitsFinite resource budgets for one SAN decode operation.
Field extensions
pub extensions: usizeMaximum extension count scanned, including unrelated extensions.
Field inputBytes
pub inputBytes: usizeMaximum sum of all extension OID and value lengths, or raw GeneralNames length.
Field identities
pub identities: usizeMaximum number of GeneralName descriptors.
Field nodes
pub nodes: usizeMaximum number of traversed DER nodes.
Field depth
pub depth: usizeMaximum DER depth. The implementation also enforces a ceiling of 32.
Associated function SanDecodeLimits.standard
pub fn standard() -> SanDecodeLimitsReturns budgets of 256 extensions, 1 MiB input, 256 identities, 4096 nodes, and depth 32.
Implementation Copy for SanDecodeLimits
impl Copy for SanDecodeLimitsSanDecodeClass
pub enum SanDecodeClassThe category of a SAN adapter failure.
Malformed
Malformed = 0The SAN DER or GeneralName schema is malformed.
ResourceLimit
ResourceLimit = 1Input, traversal, or descriptor storage exceeds a budget.
SanDecodeReason
pub enum SanDecodeReasonThe adapter-specific cause of a SAN failure.
InvalidDer
InvalidDer = 0DER encoding or GeneralName schema is invalid.
DuplicateSan
DuplicateSan = 1More than one subjectAltName extension is present.
EmptySan
EmptySan = 2A present SAN contains no names.
Extensions
Extensions = 3The extension count exceeds its budget.
InputBytes
InputBytes = 4Input bytes exceed their budget.
Identities
Identities = 5The descriptor count exceeds its budget.
Storage
Storage = 6Caller storage cannot hold every descriptor.
Nodes
Nodes = 7DER node count exceeds its budget.
Depth
Depth = 8DER depth exceeds its budget or the hard ceiling of 32.
SanDecodeError
pub struct SanDecodeErrorAn owned SAN error with an offset in GeneralNames DER, or zero for extension-list failures.
Field kind
pub kind: SanDecodeClassThe category of this failure.
Field reason
pub reason: SanDecodeReasonThe failed adapter rule.
Field offset
pub offset: usizeThe failed DER offset; extension-list failures use zero.
SanDecodeSummary
pub struct SanDecodeSummaryThe initialized descriptor prefix after successful decoding.
Field present
pub present: boolWhether a subjectAltName extension was present.
Field count
pub count: usizeNumber of initialized entries in caller storage.
Field nodes
pub nodes: usizeNumber of DER nodes traversed while validating the selected GeneralNames value.
CertificateSan
pub struct CertificateSanOperations that decode complete SAN values without allocation or identity matching.
Associated function CertificateSan.validateValue
pub fn validateValue<'life0>(value: &'life0 [u8], limits: SanDecodeLimits) -> silk/result.Result<silk/certificate_identities.SanDecodeSummary, silk/certificate_identities.SanDecodeError>Validates one complete DER GeneralNames value without descriptor storage or allocation.
Details
This performs the same complete framing and GeneralName schema checks as decodeValue,
enforces the supplied input, identity, node, and depth budgets, and returns the name count.
Payload syntax such as DNS label policy and IP address width remains the consumer's job.
Associated function CertificateSan.decodeValue
pub fn decodeValue<'a, 'life1>(value: &'a [u8], storage: &'life1 mut [silk/https_identity.PresentedIdentity<'a>], limits: SanDecodeLimits) -> silk/result.Result<silk/certificate_identities.SanDecodeSummary, silk/certificate_identities.SanDecodeError>Decodes one complete DER GeneralNames value into a caller-owned descriptor prefix.
Details
Payloads borrow value; storage remains caller-owned. Success reports the initialized prefix length.
All names retain source order. Unsupported alternatives retain their complete content octets.
Complete DER framing and GeneralName wrappers are checked before success.
Universal checks cover BOOLEAN, INTEGER, ENUMERATED, REAL, BIT STRING, NULL, OID, relative OID, and canonical UTC/GeneralizedTime.
UTF8String, NumericString, PrintableString, IA5String, VisibleString, UniversalString, and BMPString encodings are checked.
ORAddress attribute semantics and otherName open-value semantics remain outside this decoder.
Other universal contents and T61, Videotex, GraphicString, and GeneralString repertoires remain opaque.
Schema-dependent SET ordering, default values, and implicit content rules require the owning schema.
Gotchas
An error can leave partial descriptors. Never consume them after failure.
DNS syntax and IP lengths require HttpsIdentity.verify; this operation does not establish trust.
Associated function CertificateSan.decode
pub fn decode<'a, 'life1>(certificate: &'a silk/certificate.Certificate, storage: &'life1 mut [silk/https_identity.PresentedIdentity<'a>], limits: SanDecodeLimits) -> silk/result.Result<silk/certificate_identities.SanDecodeSummary, silk/certificate_identities.SanDecodeError>Scans every certificate extension and decodes the unique subjectAltName value into caller storage.
Details
Extension count and aggregate OID/value bytes are bounded before SAN parsing.
Duplicate SAN extensions fail before any descriptor is written. Absence returns present = false and zero count.
The result prefix borrows certificate; retain that owner while descriptors are in use.
Gotchas
Parsing failure can leave partial storage. Consume descriptors only after success, then perform identity and trust verification separately.