pub struct Certificate {
pub inner: EtsiTs103097Certificate,
pub issuer: Option<Box<Certificate>>,
/* private fields */
}Expand description
Immutable certificate wrapper.
Fields§
§inner: EtsiTs103097CertificateThe inner ASN.1 certificate.
issuer: Option<Box<Certificate>>Optional issuer certificate (for chain verification).
Implementations§
Source§impl Certificate
impl Certificate
Sourcepub fn from_asn(
asn: EtsiTs103097Certificate,
issuer: Option<Certificate>,
) -> Self
pub fn from_asn( asn: EtsiTs103097Certificate, issuer: Option<Certificate>, ) -> Self
Build from a decoded ASN.1 certificate.
Sourcepub fn from_bytes(bytes: &[u8], issuer: Option<Certificate>) -> Self
pub fn from_bytes(bytes: &[u8], issuer: Option<Certificate>) -> Self
Decode from COER bytes.
Sourcepub fn base(&self) -> &CertificateBase
pub fn base(&self) -> &CertificateBase
Access the inner CertificateBase.
Sourcepub fn tbs(&self) -> &ToBeSignedCertificate
pub fn tbs(&self) -> &ToBeSignedCertificate
Access toBeSigned.
Sourcepub fn to_canonical(&self) -> Certificate
pub fn to_canonical(&self) -> Certificate
Convert certificate to IEEE 1609.2 / ETSI TS 103 097 canonical form:
- Public verification key compressed (compressed_y_0/1).
- Signature r_sig as x_only.
Sourcepub fn as_hashedid8(&self) -> [u8; 8]
pub fn as_hashedid8(&self) -> [u8; 8]
HashedId8 of the canonical certificate, with the hash for the curve of its verification key: SHA-384 for a 384-bit key, SHA-256 otherwise (the hashes approved by ETSI TS 103 097 V2.2.1 clause 4.2, paired with the curves as in the permutation tables of ETSI TS 103 096-2).
Sourcepub fn uses_sha384(&self) -> bool
pub fn uses_sha384(&self) -> bool
SHA-384 is the hash associated with the certificate’s verification key (384-bit curve), used for its HashedId8, the hashId of data it signs and the issuer choice of certificates it issues; SHA-256 otherwise (and for implicit certificates).
Sourcepub fn issuer_identifier(&self) -> IssuerIdentifier
pub fn issuer_identifier(&self) -> IssuerIdentifier
IssuerIdentifier of a certificate issued by this one.
Sourcepub fn as_hashedid3(&self) -> [u8; 3]
pub fn as_hashedid3(&self) -> [u8; 3]
Compute the last 3 bytes of HashedId8.
Sourcepub fn get_list_of_its_aid(&self) -> Vec<u64>
pub fn get_list_of_its_aid(&self) -> Vec<u64>
Return the list of ITS-AID (PSID) values from appPermissions.
Sourcepub fn get_issuer_hashedid8(&self) -> Option<[u8; 8]>
pub fn get_issuer_hashedid8(&self) -> Option<[u8; 8]>
Get issuer HashedId8 stored inside the certificate.
Returns None if self-signed.
Sourcepub fn signature_is_nist_p256(&self) -> bool
pub fn signature_is_nist_p256(&self) -> bool
Check whether the signature uses NIST P-256.
Sourcepub fn verification_key_is_nist_p256(&self) -> bool
pub fn verification_key_is_nist_p256(&self) -> bool
Check whether the verification key is NIST P-256.
Sourcepub fn signature_is_supported(&self) -> bool
pub fn signature_is_supported(&self) -> bool
Is the signature NIST P-256/P-384 or brainpoolP256r1/P384r1?
Sourcepub fn verification_key_is_supported(&self) -> bool
pub fn verification_key_is_supported(&self) -> bool
Is the verification key NIST P-256/P-384 or brainpoolP256r1/P384r1?
Sourcepub fn is_self_signed(&self) -> bool
pub fn is_self_signed(&self) -> bool
Is the certificate self-signed?
Sourcepub fn check_corresponding_issuer(&self, issuer: &Certificate) -> bool
pub fn check_corresponding_issuer(&self, issuer: &Certificate) -> bool
Check whether the issuer’s HashedId8 matches the given issuer certificate.
Sourcepub fn has_all_permissions(&self) -> bool
pub fn has_all_permissions(&self) -> bool
Does certIssuePermissions have a subjectPermissions of all?
Sourcepub fn get_allowed_permissions(&self) -> Vec<u64>
pub fn get_allowed_permissions(&self) -> Vec<u64>
Get the PSID list from certIssuePermissions.subjectPermissions.explicit.
Sourcepub fn check_issuer_has_subject_permissions(&self, issuer: &Certificate) -> bool
pub fn check_issuer_has_subject_permissions(&self, issuer: &Certificate) -> bool
Check whether the issuer has the right permissions to issue this cert.
Sourcepub fn verify_signature_with(
backend: &EcdsaBackend,
tbs: &ToBeSignedCertificate,
signature: &Ieee1609Signature,
verification_key: &PublicVerificationKey,
) -> bool
pub fn verify_signature_with( backend: &EcdsaBackend, tbs: &ToBeSignedCertificate, signature: &Ieee1609Signature, verification_key: &PublicVerificationKey, ) -> bool
Verify the signature of a self-signed certificate: the signer input is the empty string (IEEE 1609.2 clause 5.3.1).
Sourcepub fn verify(&self, backend: &EcdsaBackend) -> bool
pub fn verify(&self, backend: &EcdsaBackend) -> bool
Full certificate verification (self-signed or chained).
Sourcepub fn is_implicit(&self) -> bool
pub fn is_implicit(&self) -> bool
True for an implicit certificate (reconstruction value, no signature).
Sourcepub fn implicit_hash_integer(&self) -> Option<[u8; 32]>
pub fn implicit_hash_integer(&self) -> Option<[u8; 32]>
e = Hn(Hash(ToBeSignedCertificate) || Hash(issuer certificate)): the
leftmost floor(log2 n) = 255 bits of SHA-256 over the 1609.2 hash
input (IEEE Std 1609.2-2016 clauses 5.3.2 and 6.4.3; SEC 4 section
2.3), as a big-endian 32-byte integer. None without issuer.
Sourcepub fn verification_key(&self) -> Option<PublicVerificationKey>
pub fn verification_key(&self) -> Option<PublicVerificationKey>
Public verification key: the explicit key, or the key reconstructed
from the reconstruction value and the issuer key (ECQV, IEEE Std
1609.2-2016 clause 5.3.2). None when not available.
§7.2.1 Authorization Ticket profile.
Sourcepub fn is_root_ca(&self) -> bool
pub fn is_root_ca(&self) -> bool
§7.2.3 Root CA profile.
Trait Implementations§
Source§impl Clone for Certificate
impl Clone for Certificate
Source§fn clone(&self) -> Certificate
fn clone(&self) -> Certificate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Certificate
impl Debug for Certificate
Source§impl PartialEq for Certificate
impl PartialEq for Certificate
impl Eq for Certificate
impl StructuralPartialEq for Certificate
Auto Trait Implementations§
impl !Freeze for Certificate
impl RefUnwindSafe for Certificate
impl Send for Certificate
impl Sync for Certificate
impl Unpin for Certificate
impl UnsafeUnpin for Certificate
impl UnwindSafe for Certificate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.