#[non_exhaustive]pub enum Error {
Show 30 variants
Codec(Error),
MissingField(u8),
DuplicateField(u8),
WrongFieldType(u8),
FieldValueOutOfRange {
tag: u8,
},
InvalidSerialLength {
len: usize,
},
UnsupportedSignatureAlgorithm(u8),
UnsupportedPublicKeyAlgorithm(u8),
UnsupportedEcCurve(u8),
WrongPublicKeyLength(usize),
BadPublicKeyPrefix,
MissingBuilderField(&'static str),
WrongSignatureLength(usize),
InvalidDnAttribute(u8),
InvalidDnAttributeType(u8),
WrongKeyIdentifierLength(usize),
DnAttributeHasNoX509Oid(u8),
DnAttributeNotTlvEncodable(&'static str),
InvalidDnAttributeForX509 {
asn1_type: &'static str,
reason: &'static str,
},
SignatureVerificationFailed,
TestX509SigningFailed(&'static str),
SigningFailed(&'static str),
NotYetValid {
cert_index: u8,
not_before: MatterTime,
at: MatterTime,
},
Expired {
cert_index: u8,
not_after: MatterTime,
at: MatterTime,
},
UntrustedRoot,
IssuerSubjectMismatch {
cert_index: u8,
},
NotACa {
cert_index: u8,
},
PathLengthExceeded {
cert_index: u8,
},
MissingKeyCertSign {
cert_index: u8,
},
LeafIsCa,
}Expand description
All errors matter-cert can produce.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Codec(Error)
TLV decoding or encoding failed inside matter-codec.
MissingField(u8)
A required certificate field was missing.
DuplicateField(u8)
A certificate field appeared more than once.
WrongFieldType(u8)
A certificate field had an unexpected element type.
FieldValueOutOfRange
A certificate field’s value was outside the spec-defined range.
InvalidSerialLength
The certificate serial number had a length outside the spec-allowed range of 1..=20 bytes.
The Matter operational-certificate profile (§6.5) inherits the X.509
CertificateSerialNumber constraint (RFC 5280 §4.1.2.2): a serial is
at most 20 octets, and a zero-length serial is not a valid INTEGER.
We reject both bounds at parse time so a malformed serial cannot
propagate into the X.509 TBS encoder or signature verification.
UnsupportedSignatureAlgorithm(u8)
Signature algorithm identifier was not ecdsa-with-sha256 (1).
UnsupportedPublicKeyAlgorithm(u8)
Public-key algorithm identifier was not ec-public-key (1).
UnsupportedEcCurve(u8)
EC curve identifier was not prime256v1 (1).
WrongPublicKeyLength(usize)
Public-key bytes had wrong length.
BadPublicKeyPrefix
Public-key bytes did not start with the uncompressed-point marker (0x04).
MissingBuilderField(&'static str)
A required field on MatterCertificate::builder() was not set before
build_unsigned() was called.
WrongSignatureLength(usize)
Signature bytes had wrong length.
InvalidDnAttribute(u8)
A distinguished-name attribute used a context tag not defined by the spec.
InvalidDnAttributeType(u8)
A distinguished-name attribute’s value had the wrong TLV element type.
WrongKeyIdentifierLength(usize)
A key identifier had the wrong length (must be 20 bytes).
DnAttributeHasNoX509Oid(u8)
A Matter DN attribute had no defined X.509 OID mapping.
Occurs when a crate::DnAttribute::Other is encountered during
X.509 conversion. We cannot invent an X.509 OID, and matter.js
wouldn’t have signed against one we made up.
DnAttributeNotTlvEncodable(&'static str)
A DN attribute belongs only to X.509 attestation certificates and has no Matter operational-TLV cert encoding.
Produced if crate::DnAttribute::VendorId or
crate::DnAttribute::ProductId is routed through the Matter TLV
writer. VID/PID identifiers live in DAC/PAI/PAA X.509 attestation
cert DNs (Matter §6.5.6.1), not in operational NOC/ICAC/RCAC TLV
certs, so there is no spec-defined TLV context tag for them.
InvalidDnAttributeForX509
A DN attribute’s value cannot be encoded in its X.509 ASN.1 string type.
E.g., a CountryName containing non-printable bytes cannot
be encoded as PrintableString.
Fields
SignatureVerificationFailed
Signature verification failed.
Reserved for M2.2; not produced by phase 1.
TestX509SigningFailed(&'static str)
Test-support X.509 cert signing failed.
Produced only by test_support::build_x509_der (behind the
test-support feature) when the supplied issuer PKCS#8 key is
malformed or ring rejects the signing request. Never produced by
production code paths.
SigningFailed(&'static str)
Production ECDSA-P256-SHA256 signing via ring failed.
Produced by crate::operational::sign_with_ring when the supplied
issuer PKCS#8 key is malformed, or ring rejects the signing
request.
NotYetValid
A certificate’s not_before is in the future.
Fields
not_before: MatterTimeThe certificate’s not_before timestamp.
at: MatterTimeThe time at which validation was attempted.
Expired
A certificate’s not_after is in the past.
Fields
not_after: MatterTimeThe certificate’s not_after timestamp.
at: MatterTimeThe time at which validation was attempted.
UntrustedRoot
A certificate chain did not terminate at a trusted root.
IssuerSubjectMismatch
A cert’s issuer did not match the next cert’s subject.
NotACa
A non-leaf certificate did not have basic_constraints.is_ca = true.
PathLengthExceeded
Chain length exceeded a cert’s path_len_constraint.
MissingKeyCertSign
A non-leaf (CA) certificate lacked the keyCertSign KeyUsage bit.
RFC 5280 §4.2.1.3 and Matter §6.5.5 require any certificate that
signs other certificates to carry the keyCertSign KeyUsage bit
(and a KeyUsage extension at all). A cert asserting is_ca = true
but lacking KeyUsage::KEY_CERT_SIGN (or with no KeyUsage extension)
is not a valid signing CA and is rejected here.
LeafIsCa
The end-entity leaf certificate asserted basic_constraints.is_ca = true.
RFC 5280 forbids an end-entity (leaf) certificate from asserting the
CA bit. A leaf at chain index 0 with an explicit is_ca = true is a
profile violation and is rejected. An absent basic_constraints
extension on the leaf is permitted (it is not a violation).
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()