pub struct Certificate { /* private fields */ }Expand description
A certificate
§Example
use quantcrypt::certificates::Certificate;
use quantcrypt::is_ipd_mode_enabled;
let cert_path = if is_ipd_mode_enabled() {
"test/data_ipd/MlDsa44EcdsaP256SHA256-2.16.840.1.114027.80.8.1.4_ta.pem"
} else {
"test/data/MlDsa44EcdsaP256SHA256-2.16.840.1.114027.80.8.1.4_ta.pem"
};
let cert = Certificate::from_file(cert_path).unwrap();
assert!(cert.verify_self_signed().unwrap());Implementations§
Source§impl Certificate
impl Certificate
Sourcepub fn to_pem(&self) -> Result<String, QuantCryptError>
pub fn to_pem(&self) -> Result<String, QuantCryptError>
Sourcepub fn from_der(der: &[u8]) -> Result<Certificate, QuantCryptError>
pub fn from_der(der: &[u8]) -> Result<Certificate, QuantCryptError>
Sourcepub fn from_pem(pem: &str) -> Result<Certificate, QuantCryptError>
pub fn from_pem(pem: &str) -> Result<Certificate, QuantCryptError>
Sourcepub fn get_subject(&self) -> RdnSequence
pub fn get_subject(&self) -> RdnSequence
Sourcepub fn get_issuer(&self) -> RdnSequence
pub fn get_issuer(&self) -> RdnSequence
Sourcepub fn get_serial_number(&self) -> SerialNumber
pub fn get_serial_number(&self) -> SerialNumber
Sourcepub fn get_subject_key_identifier(
&self,
) -> Result<SubjectKeyIdentifier, QuantCryptError>
pub fn get_subject_key_identifier( &self, ) -> Result<SubjectKeyIdentifier, QuantCryptError>
Sourcepub fn verify_self_signed(&self) -> Result<bool, QuantCryptError>
pub fn verify_self_signed(&self) -> Result<bool, QuantCryptError>
Verify that the certificate is self-signed
§Returns
True if the certificate is self-signed, false otherwise
Sourcepub fn get_public_key(&self) -> Result<PublicKey, QuantCryptError>
pub fn get_public_key(&self) -> Result<PublicKey, QuantCryptError>
Sourcepub fn verify_child(&self, child: &Certificate) -> Result<bool, QuantCryptError>
pub fn verify_child(&self, child: &Certificate) -> Result<bool, QuantCryptError>
Verify that the specified certificate is a child of this certificate.
This checks that the specified child certificate has the same issuer as this certificate’s subject, that the child’s Subject Key Identifier matches the Authority Key Identifier of this certificate, and that the child’s signature is valid.
§Arguments
child- The child certificate
§Returns
True if the child certificate is a child of this certificate, false otherwise
Sourcepub fn from_file(path: &str) -> Result<Certificate, QuantCryptError>
pub fn from_file(path: &str) -> Result<Certificate, QuantCryptError>
Sourcepub fn to_der_file(&self, path: &str) -> Result<(), QuantCryptError>
pub fn to_der_file(&self, path: &str) -> Result<(), QuantCryptError>
Sourcepub fn to_pem_file(&self, path: &str) -> Result<(), QuantCryptError>
pub fn to_pem_file(&self, path: &str) -> Result<(), QuantCryptError>
Sourcepub fn is_identified_by(&self, rid: &RecipientIdentifier) -> bool
pub fn is_identified_by(&self, rid: &RecipientIdentifier) -> bool
Sourcepub fn is_key_encipherment_enabled(&self) -> bool
pub fn is_key_encipherment_enabled(&self) -> bool
Sourcepub fn get_public_key_oid(&self) -> String
pub fn get_public_key_oid(&self) -> String
Get the OID of algorithm used for the public key
§Returns
The OID of the algorithm used for the public key
Sourcepub fn get_signature_oid(&self) -> String
pub fn get_signature_oid(&self) -> String
Get the OID of algorithm used for the signature
§Returns
The OID of the algorithm used for the signature
Sourcepub fn get_public_key_oid_friendly_name(&self) -> String
pub fn get_public_key_oid_friendly_name(&self) -> String
Get the friendly name of the algorithm used for the public key
§Returns
The friendly name of the algorithm used for the public key
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 more