silk.tls.certificate_profile.
Check one certificate against the TLS server certificate profile, and read its extensions.
When to use#
silk.tls.certificate_path uses this module for each certificate of a chain. Use
CertificateProfile.inspect directly to check one certificate for a role (leaf, intermediate,
or anchor) and to read its basic constraints, key usage, and other extensions. Use
CertificateProfile.verifyIssuedBy to check that one certificate signed another.
Details#
The profile is strict. Keys and signatures must be ECDSA P-256 with SHA-256, ECDSA P-384 with SHA-384, or RSA with SHA-256 (2048 to 4096 bits). An unknown critical extension or another algorithm is an error. The result borrows the certificate and does not allocate.
Errors#
ProfileErrorwith the reason, the extension, and the position of the problem.
Gotchas#
A certificate that passes does not mean that you can trust it. This module does not check dates, the chain, the host name, or revocation.
Import as CertificateProfile with import silk.tls.certificate_profile { CertificateProfile }.
Public declarations: 10.
CertificateRole#
pub enum CertificateRoleThe certificate's intended position in the restricted TLS-server profile.
ServerLeaf#
ServerLeafA peer end-entity certificate inspected for admission to later TLS-server validation.
Intermediate#
IntermediateA non-anchor CA certificate below the trust endpoint.
Anchor#
AnchorAn explicitly configured trust endpoint outside the returned path.
CertificateKeyKind#
pub enum CertificateKeyKindThe admitted public-key algorithm and bounded key profile.
P256#
P256An uncompressed validated secp256r1 point.
P384#
P384An uncompressed validated secp384r1 point.
Rsa#
RsaAn odd 2048..4096-bit RSA modulus with exponent 65537.
ProfileLimits#
pub struct ProfileLimitsInclusive budgets for one semantic inspection or configured-constraint validation.
Field extensions#
pub extensions: usizeMaximum number of certificate extensions, including unknown and duplicate OIDs.
Field extensionBytes#
pub extensionBytes: usizeMaximum bytes in each extension value, including opaque unknown noncritical values.
Field sanNames#
pub sanNames: usizeMaximum names in one subjectAltName value.
Field constraintSubtrees#
pub constraintSubtrees: usizeMaximum GeneralSubtree values across one NameConstraints value.
Field nodes#
pub nodes: usizeMaximum traversed extension-value TLV nodes across one operation.
Field depth#
pub depth: usizeMaximum traversed extension-value TLV depth. A value root has depth one.
Implementation Copy for ProfileLimits#
impl Copy for ProfileLimitsImplementation ProfileLimits#
impl ProfileLimitsAssociated function defaults#
pub fn defaults() -> ProfileLimitsReturns 64 extensions, 16384 bytes per value, 256 SAN names, 256 constraint subtrees, 4096 traversed nodes, and depth 16.
ProfileClass#
pub enum ProfileClassThe broad category of a semantic profile failure.
Malformed#
MalformedDER or recognized extension content violates the selected schema.
Unsupported#
UnsupportedA well-formed value is outside the deliberately restricted profile.
ResourceLimit#
ResourceLimitA configured finite budget or target size bound is exceeded.
Implementation Debug for ProfileClass#
impl Debug for ProfileClassOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as Malformed.
ProfileOffsetSpace#
pub enum ProfileOffsetSpaceThe byte sequence in which a profile error offset is measured.
CertificateDer#
CertificateDerOffset in the complete decoded certificate DER.
ConfiguredConstraintDer#
ConfiguredConstraintDerOffset in caller-supplied configured NameConstraints DER.
Implementation Debug for ProfileOffsetSpace#
impl Debug for ProfileOffsetSpaceOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as CertificateDer.
ProfileReason#
pub enum ProfileReasonThe stable semantic reason for a profile rejection.
Version#
VersionThe certificate version is invalid for the selected role.
Serial#
SerialA path-certificate serial is nonpositive, zero, or longer than 20 content octets.
UniqueIdentifier#
UniqueIdentifierAn issuer or subject unique identifier is present.
PublicKey#
PublicKeyThe public-key algorithm, encoding, parameters, or mathematical key is not admitted.
SignatureAlgorithm#
SignatureAlgorithmThe signature algorithm OID or signature BIT STRING metadata is not admitted.
SignatureParameters#
SignatureParametersA recognized signature algorithm has forbidden, missing, or unsupported parameters.
SignatureAlgorithmMismatch#
SignatureAlgorithmMismatchInner and outer signature identifiers do not denote the same admitted effective algorithm.
Extensions#
ExtensionsMore certificate extensions are present than the configured bound.
ExtensionBytes#
ExtensionBytesOne extension value exceeds its configured byte bound.
DuplicateExtension#
DuplicateExtensionA duplicate extension OID is present.
UnknownCriticalExtension#
UnknownCriticalExtensionA critical extension has no supported semantics in this profile.
MalformedExtension#
MalformedExtensionA recognized extension violates strict DER or its selected schema.
BasicConstraints#
BasicConstraintsBasicConstraints conflicts with the role or path-length rules.
KeyUsage#
KeyUsageKeyUsage encoding or dependent bits are invalid.
MissingKeyUsage#
MissingKeyUsageA present KeyUsage does not authorize the selected role.
ExtendedKeyUsage#
ExtendedKeyUsageExtendedKeyUsage is empty or malformed.
MissingServerAuth#
MissingServerAuthA present ExtendedKeyUsage omits id-kp-serverAuth.
SubjectAltName#
SubjectAltNamesubjectAltName is malformed or contains an invalid DNS/IP identity.
EmptySubject#
EmptySubjectAn empty subject lacks a nonempty critical subjectAltName.
UnsupportedCriticalName#
UnsupportedCriticalNameA critical subjectAltName contains an unsupported GeneralName alternative.
NameConstraints#
NameConstraintsNameConstraints is malformed, empty, noncritical, or used on an end entity.
UnsupportedNameConstraint#
UnsupportedNameConstraintA NameConstraints subtree form is outside the DNS/IP subset.
PolicyProcessing#
PolicyProcessingA certificate-policy feature requiring policy-tree processing is present.
TlsFeature#
TlsFeatureTLS Feature is present although this profile cannot satisfy must-staple semantics.
Role#
RoleThe certificate role's CA or BasicConstraints policy is violated.
SanNames#
SanNamesA SAN name count exceeds its configured bound.
ConstraintSubtrees#
ConstraintSubtreesA NameConstraints subtree count exceeds its configured bound.
Nodes#
NodesThe traversed extension-value node count exceeds its configured bound.
Depth#
DepthThe traversed extension-value depth exceeds its configured bound.
SizeOverflow#
SizeOverflowChecked size or counter arithmetic cannot be represented.
IssuerName#
IssuerNameThe subject issuer Name DER does not exactly equal the issuer subject Name DER.
SignatureRejected#
SignatureRejectedAn admitted cryptographic primitive rejected the retained signature.
NameConstraintViolation#
NameConstraintViolationA subordinate DNS or IP subjectAltName violates one NameConstraints source.
NameComparisons#
NameComparisonsThe caller-supplied name/subtree comparison budget is exhausted.
Implementation Debug for ProfileReason#
impl Debug for ProfileReasonOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as Version.
ProfileError#
pub struct ProfileErrorThe error when a certificate does not fit the TLS server certificate profile, with the reason, the extension, and the byte offset of the problem. It owns its values.
Field kind#
pub kind: ProfileClassBroad failure category.
Field reason#
pub reason: ProfileReasonStable semantic failure reason.
Field extensionIndex#
pub extensionIndex: Option<usize>Zero-based extension index when the failure belongs to one certificate extension.
Field offsetSpace#
pub offsetSpace: ProfileOffsetSpaceCoordinate system for offset.
Field offset#
pub offset: usizeByte offset in the selected coordinate system.
Implementation Debug for ProfileError#
impl Debug for ProfileErrorOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as ProfileError { kind: ..., reason: ..., ... }.
KeyUsage#
pub struct KeyUsageParsed KeyUsage bits retained independently of their original DER positions.
Field digitalSignature#
pub digitalSignature: booldigitalSignature bit.
Field contentCommitment#
pub contentCommitment: boolcontentCommitment/nonRepudiation bit.
Field keyEncipherment#
pub keyEncipherment: boolkeyEncipherment bit.
Field dataEncipherment#
pub dataEncipherment: booldataEncipherment bit.
Field keyAgreement#
pub keyAgreement: boolkeyAgreement bit.
Field keyCertSign#
pub keyCertSign: boolkeyCertSign bit.
Field crlSign#
pub crlSign: boolcRLSign bit.
Field encipherOnly#
pub encipherOnly: boolencipherOnly bit.
Field decipherOnly#
pub decipherOnly: booldecipherOnly bit.
Implementation Copy for KeyUsage#
impl Copy for KeyUsageExtendedKeyUsage#
pub struct ExtendedKeyUsageParsed ExtendedKeyUsage facts used by the restricted TLS-server profile.
Field serverAuth#
pub serverAuth: boolWhether id-kp-serverAuth occurs.
Field anyExtendedKeyUsage#
pub anyExtendedKeyUsage: boolWhether anyExtendedKeyUsage occurs. It never substitutes for serverAuth.
Field purposeCount#
pub purposeCount: usizeNumber of key-purpose identifiers in the original extension.
Implementation Copy for ExtendedKeyUsage#
impl Copy for ExtendedKeyUsageCertificateProfile#
pub struct CertificateProfile<'a>A checked view of one decoded certificate for the TLS server certificate profile, with its extensions.
When to use#
Make one with CertificateProfile.inspect to check one certificate for a role (leaf,
intermediate, or anchor) and to read its basic constraints, key usage, and other extensions.
silk.tls.certificate_path does this for each certificate of a chain.
Details#
The profile is strict. Keys and signatures must be ECDSA P-256 with SHA-256, ECDSA P-384 with SHA-384, or RSA with SHA-256 (2048 to 4096 bits). An unknown critical extension or another algorithm is an error. The view borrows the certificate and does not allocate.
Gotchas#
A certificate that passes does not mean that you can trust it. The profile does not check dates, the chain, the host name, or revocation.
Implementation Copy for CertificateProfile<'a>#
impl<'a> Copy for CertificateProfile<'a>Implementation CertificateProfile<'a>#
impl<'a> CertificateProfile<'a>Associated function inspect#
pub fn inspect(
certificate: &'a Certificate,
selectedRole: CertificateRole,
limits: ProfileLimits,
) -> Result<CertificateProfile<'a>, ProfileError>Checks certificate for the role selectedRole, and returns a view of its checked fields.
For a leaf or an intermediate, the inner and outer signature algorithms must match and be supported. For an anchor, the signature, serial number, dates, and self-signature are not checked, because you chose to trust it.
The profile is strict. Keys and signatures must be ECDSA P-256 with SHA-256, ECDSA P-384
with SHA-384, or RSA with SHA-256 (2048 to 4096 bits). An unknown critical extension or
another algorithm is an error. The result borrows certificate and does not allocate.
Errors#
Failurewith aProfileErrorif the certificate does not fit the profile for the role or goes overlimits.
Gotchas#
It does not verify a signature or check dates, the chain, the host name, or revocation. A certificate that passes does not mean that you can trust it.
Method certificate#
pub fn certificate(self: &Self) -> &'a CertificateBorrows the structurally decoded certificate retained by this view.
Method certificateRole#
pub fn certificateRole(self: &Self) -> CertificateRoleReturns the role under which this certificate was inspected.
Method keyKind#
pub fn keyKind(self: &Self) -> CertificateKeyKindReturns the admitted public-key profile.
Method ca#
pub fn ca(self: &Self) -> boolReturns the admitted BasicConstraints CA value, or false when absent.
Method pathLength#
pub fn pathLength(self: &Self) -> Option<usize>Returns the admitted BasicConstraints path length when present.
Method keyUsage#
pub fn keyUsage(self: &Self) -> Option<KeyUsage>Returns admitted KeyUsage facts when the extension was present.
Method extendedKeyUsage#
pub fn extendedKeyUsage(self: &Self) -> Option<ExtendedKeyUsage>Returns admitted ExtendedKeyUsage facts when the extension was present.
Method subjectAltNamesDer#
pub fn subjectAltNamesDer(self: &Self) -> Option<&'a [u8]>Borrows the exact subjectAltName extension-value DER when present.
Method nameConstraintsDer#
pub fn nameConstraintsDer(self: &Self) -> Option<&'a [u8]>Borrows the exact embedded NameConstraints extension-value DER when present.
Associated function validateConfiguredNameConstraints#
pub fn validateConfiguredNameConstraints(
value: &[u8],
limits: ProfileLimits,
) -> Result<(), ProfileError>Validates strict configured DNS/IP NameConstraints without allocating or retaining input.
Associated function checkNameConstraints#
pub fn checkNameConstraints(
subject: &CertificateProfile,
constraintDer: &[u8],
comparisons: &mut usize,
maximumComparisons: usize,
offsetSpace: ProfileOffsetSpace,
) -> Result<(), ProfileError>Checks every DNS and IP subjectAltName against one strict NameConstraints value.
Details#
Exclusions run before permissions. The operation consumes one comparison before each
same-form name/subtree comparison and updates comparisons across calls. offsetSpace
identifies the coordinate system used by any returned constraint error.
Gotchas#
The constraint value must first pass validateConfiguredNameConstraints or profile
inspection. The operation checks only one constraint source. Callers must apply all sources.
Associated function verifyIssuedBy#
pub fn verifyIssuedBy(
subject: &CertificateProfile,
issuer: &CertificateProfile,
) -> Result<(), ProfileError>Verifies exact issuer-name linkage and the subject's retained original TBS signature.
Gotchas#
This checks only one edge. It does not establish path, time, constraint, trust, or identity authentication.
Category: TLS and certificates.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.