silk/https_identity
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 HTTPS DNS-ID and IP-ID matching over caller-supplied identities.
When to use
Use HttpsIdentity.reference with the original HTTPS host before DNS resolution.
Use HttpsIdentity.verify with the complete SAN list from the same leaf used for trust validation.
Details
DNS inputs borrow ASCII LDH bytes or prepared A-labels. IP references own network-order octets. DNS comparison ignores ASCII case. A whole leftmost wildcard matches exactly one label. The matcher validates all SANs before success and uses constant temporary storage without allocation.
Gotchas
Success proves only name matching, not signatures, path trust, name constraints, or TLS authentication. There is no CN, URI-ID, SRV-ID, alias, or reverse-DNS fallback. Trailing dots and Unicode inputs are rejected. The caller must validate HTTPS origins and convert IP literals; brackets, ports, escapes and zones are not DNS inputs.
Import as HttpsIdentity with import silk.https_identity { HttpsIdentity }.
Public declarations: 13.
UnsupportedForm
pub enum UnsupportedFormA reference form that HTTPS identity verification does not support.
IpvFuture
IpvFuture = 0An IPvFuture reference is unsupported.
ZoneIdentifier
ZoneIdentifier = 1A scoped address reference is unsupported.
UriId
UriId = 2A URI-ID reference is unsupported for HTTPS.
SrvId
SrvId = 3An SRV-ID reference is unsupported for HTTPS.
OriginHost
pub union OriginHost<'name>The original HTTPS host, classified by the caller before DNS resolution.
Dns
OriginHost<'name>.Dns { bytes: &'name [u8] }: OriginHost<'name>Borrowed ASCII DNS bytes without a trailing dot.
Field bytes
pub bytes: &'name [u8]The exact bytes; no normalization or text conversion is implicit.
Ipv4
OriginHost<'name>.Ipv4 { bytes: Array<u8, 4> }: OriginHost<'name>Four owned network-order address octets.
Field bytes
pub bytes: Array<u8, 4>The exact bytes; no normalization or text conversion is implicit.
Ipv6
OriginHost<'name>.Ipv6 { bytes: Array<u8, 16> }: OriginHost<'name>Sixteen owned network-order address octets.
Field bytes
pub bytes: Array<u8, 16>The exact bytes; no normalization or text conversion is implicit.
Unsupported
OriginHost<'name>.Unsupported { form: UnsupportedForm }: OriginHost<'name>An explicitly unsupported reference form.
Field form
pub form: UnsupportedFormThe unsupported reference form.
ReferenceIdentity
pub union ReferenceIdentity<'name>A DNS borrow or owned binary IP reference; public construction does not validate it.
Dns
ReferenceIdentity<'name>.Dns { bytes: &'name [u8] }: ReferenceIdentity<'name>Borrowed ASCII DNS bytes without a trailing dot.
Field bytes
pub bytes: &'name [u8]The exact bytes; no normalization or text conversion is implicit.
Ipv4
ReferenceIdentity<'name>.Ipv4 { bytes: Array<u8, 4> }: ReferenceIdentity<'name>Four owned network-order address octets.
Field bytes
pub bytes: Array<u8, 4>The exact bytes; no normalization or text conversion is implicit.
Ipv6
ReferenceIdentity<'name>.Ipv6 { bytes: Array<u8, 16> }: ReferenceIdentity<'name>Sixteen owned network-order address octets.
Field bytes
pub bytes: Array<u8, 16>The exact bytes; no normalization or text conversion is implicit.
PresentedIdentity
pub union PresentedIdentity<'cert>One untrusted SAN descriptor in original certificate order.
Dns
PresentedIdentity<'cert>.Dns { bytes: &'cert [u8] }: PresentedIdentity<'cert>Borrowed ASCII DNS bytes without a trailing dot.
Field bytes
pub bytes: &'cert [u8]The exact bytes; no normalization or text conversion is implicit.
Ip
PresentedIdentity<'cert>.Ip { bytes: &'cert [u8] }: PresentedIdentity<'cert>Borrowed network-order address octets; only lengths four and sixteen are valid.
Field bytes
pub bytes: &'cert [u8]The exact bytes; no normalization or text conversion is implicit.
Other
PresentedIdentity<'cert>.Other { tag: u8, bytes: &'cert [u8] }: PresentedIdentity<'cert>An uninterpreted GeneralName with an alternative number other than two or seven.
Field tag
pub tag: u8The decoded GeneralName alternative number, from zero through eight except two and seven.
Field bytes
pub bytes: &'cert [u8]The complete alternative content octets, counted even when this form is ignored.
CertificateStructureError
pub enum CertificateStructureErrorA structural failure reported by a complete SAN decoder.
InvalidDer
InvalidDer = 0The SAN input violates DER framing.
InvalidGeneralName
InvalidGeneralName = 1A GeneralName violates its structural encoding.
DuplicateSanExtension
DuplicateSanExtension = 2The certificate contains more than one SAN extension.
EmptySanExtension
EmptySanExtension = 3A present SAN extension has no GeneralNames.
CertificateIdentities
pub union CertificateIdentities<'cert>The complete SAN state; an absent extension is distinct from an empty extension.
Absent
CertificateIdentities<'cert>.Absent: CertificateIdentities<'cert>The certificate has no SAN extension; common names are never consulted.
Decoded
CertificateIdentities<'cert>.Decoded { entries: &'cert [silk/https_identity.PresentedIdentity<'cert>] }: CertificateIdentities<'cert>All SAN descriptors in source order, with no filtered entries.
Field entries
pub entries: &'cert [silk/https_identity.PresentedIdentity<'cert>]The complete shared descriptor slice and payloads, bounded by the same lifetime.
Malformed
CertificateIdentities<'cert>.Malformed { reason: CertificateStructureError }: CertificateIdentities<'cert>A structural failure that must prevent a match.
Field reason
pub reason: CertificateStructureErrorThe failed rule.
NameError
pub enum NameErrorThe first failed DNS admission rule under the documented precedence.
EmptyName
EmptyName = 0The name has no octets.
NameTooLong
NameTooLong = 1The name exceeds 253 octets.
EmptyLabel
EmptyLabel = 2A label has no octets.
LabelTooLong
LabelTooLong = 3A label exceeds 63 octets.
Nul
Nul = 4The name contains an embedded zero octet.
NonAscii
NonAscii = 5The name contains an octet above 127.
InvalidCharacter
InvalidCharacter = 6A label contains an octet outside ASCII letters, digits and hyphens.
EdgeHyphen
EdgeHyphen = 7A label starts or ends with a hyphen.
TrailingDot
TrailingDot = 8The name ends with a dot.
WildcardReference
WildcardReference = 9A reference contains an asterisk.
NumericFinalLabel
NumericFinalLabel = 10The final label contains decimal digits only.
MissingWildcardSuffix
MissingWildcardSuffix = 11A wildcard name has no suffix.
CertificateIdentityError
pub enum CertificateIdentityErrorAn invalid SAN descriptor form or binary address size.
InvalidIpLength
InvalidIpLength = 0An IP SAN has neither four nor sixteen octets.
WrongGeneralNameTag
WrongGeneralNameTag = 1An Other descriptor uses tag two, seven, or a number above eight.
LimitKind
pub enum LimitKindThe exhausted matcher budget.
SanCount
SanCount = 0The total descriptor count exceeds the configured budget.
SanBytes
SanBytes = 1The sum of payload lengths exceeds the configured budget.
IdentityError
pub union IdentityErrorAn identity failure that is independent of certificate path trust.
MalformedReference
IdentityError.MalformedReference { reason: NameError }: IdentityErrorThe reference violates DNS admission rules.
Field reason
pub reason: NameErrorThe failed rule.
MalformedCertificateStructure
IdentityError.MalformedCertificateStructure { reason: CertificateStructureError }: IdentityErrorThe complete SAN structure is malformed.
Field reason
pub reason: CertificateStructureErrorThe failed rule.
MalformedCertificateName
IdentityError.MalformedCertificateName { index: usize, reason: NameError }: IdentityErrorA DNS SAN violates name admission rules.
Field index
pub index: usizeThe original zero-based SAN index.
Field reason
pub reason: NameErrorThe failed rule.
MalformedCertificateIdentity
IdentityError.MalformedCertificateIdentity { index: usize, reason: CertificateIdentityError }: IdentityErrorA SAN descriptor has an invalid form.
Field index
pub index: usizeThe original zero-based SAN index.
Field reason
pub reason: CertificateIdentityErrorThe failed rule.
Unsupported
IdentityError.Unsupported { form: UnsupportedForm }: IdentityErrorAn explicitly unsupported reference form.
Field form
pub form: UnsupportedFormThe unsupported reference form.
LimitExceeded
IdentityError.LimitExceeded { kind: LimitKind }: IdentityErrorA count or byte budget was exceeded.
Field kind
pub kind: LimitKindThe exhausted resource budget.
NoMatch
IdentityError.NoMatch: IdentityErrorNo eligible SAN matches the reference.
IdentityLimits
pub struct IdentityLimitsInclusive SAN budgets; zero allows none of the corresponding resource.
Field maxSanCount
pub maxSanCount: usizeMaximum number of descriptors, including ignored and unsupported forms.
Field maxSanBytes
pub maxSanBytes: usizeMaximum sum of all payload lengths, counting each alias occurrence.
Associated function IdentityLimits.standard
pub fn standard() -> IdentityLimitsReturns inclusive limits of 256 SAN descriptors and 65536 payload octets.
IdentityMatch
pub struct IdentityMatchThe first matching SAN index after validation of the entire SAN set.
Field sanIndex
pub sanIndex: usizeThe original zero-based index of the first matching SAN.
HttpsIdentity
pub struct HttpsIdentityPure HTTPS DNS-ID and IP-ID reference construction and verification.
Associated function HttpsIdentity.exactDnsNameError
pub fn exactDnsNameError<'life0>(bytes: &'life0 [u8]) -> silk/option.Option<silk/https_identity.NameError>Returns the shared HTTPS-profile admission error for one exact DNS name, when invalid.
Details
This applies the canonical 253-octet, LDH-label, edge-hyphen, wildcard-free, and nonnumeric-final-label grammar used by HTTPS reference identities.
Associated function HttpsIdentity.presentedDnsNameError
pub fn presentedDnsNameError<'life0>(bytes: &'life0 [u8]) -> silk/option.Option<silk/https_identity.NameError>Returns the shared HTTPS-profile admission error for one presented DNS name, when invalid.
Details
A wildcard is admitted only as the complete leftmost *. label and remains included in the
253-octet total-name bound. All other label policy is identical to exact DNS names.
Associated function HttpsIdentity.reference
pub fn reference<'name>(host: silk/https_identity.OriginHost<'name>) -> silk/result.Result<silk/https_identity.ReferenceIdentity<'name>, silk/https_identity.IdentityError>Creates a reference from the original HTTPS host without allocation or name substitution.
Details
DNS bytes remain borrowed and unchanged. IP arrays become owned network-order addresses. DNS names require 1..253 ASCII octets and 1..63-octet LDH labels without a numeric final label. Errors follow empty name, total length, NUL, non-ASCII, trailing dot, wildcard, then label grammar order. Label checks proceed left to right: empty, length, characters, then edge hyphens. Numeric final labels fail last.
Gotchas
Supply the original origin host before resolution, never an alias, peer name, or resolved address.
The caller checks HTTPS and converts IP literals. DNS input rejects brackets, ports, escapes, underscores and Unicode.
A-label grammar does not validate Punycode. Explicit IPvFuture, zones, URI-ID and SRV-ID return Unsupported.
Associated function HttpsIdentity.verify
pub fn verify<'name, 'cert, 'life2, 'life3>(reference: &'life2 silk/https_identity.ReferenceIdentity<'name>, certificate: &'life3 silk/https_identity.CertificateIdentities<'cert>, limits: IdentityLimits) -> silk/result.Result<silk/https_identity.IdentityMatch, silk/https_identity.IdentityError>Validates the complete SAN list and returns the first matching DNS-ID or IP-ID index.
Details
Revalidates public references, then checks structure, count, total bytes, and every SAN in order before comparison. DNS matches ignore ASCII case. A whole leftmost wildcard matches one label; invalid wildcard placement is ignored. Other malformed DNS names fail, including non-ASCII before wildcard handling. NUL is checked after invalid wildcard skipping. IP SANs require four or sixteen equal network-order bytes. IPv4 and mapped IPv6 remain distinct. All descriptors consume limits, including aliases and ignored forms. Zero budgets are valid. Errors retain no input borrow. Work is linear in reference bytes, SAN count and payload bytes, with constant temporary storage and no allocation.
Gotchas
A malformed later SAN defeats an earlier match, even if its identity kind differs from the reference.
Empty present SANs fail structurally. Absent, unsupported-only and mismatching sets return NoMatch; there is no CN fallback.
Success does not validate trust, name constraints, signatures, time, or the TLS handshake.
Implementation Copy for silk/https_identity.OriginHost<'a>
impl Copy for silk/https_identity.OriginHost<'a>Implementation Copy for silk/https_identity.ReferenceIdentity<'a>
impl Copy for silk/https_identity.ReferenceIdentity<'a>Implementation Copy for silk/https_identity.PresentedIdentity<'a>
impl Copy for silk/https_identity.PresentedIdentity<'a>Implementation Copy for silk/https_identity.CertificateIdentities<'a>
impl Copy for silk/https_identity.CertificateIdentities<'a>Implementation Copy for IdentityError
impl Copy for IdentityErrorImplementation Copy for IdentityLimits
impl Copy for IdentityLimitsImplementation Copy for IdentityMatch
impl Copy for IdentityMatch