Skip to main content

CryptoProvider

Trait CryptoProvider 

Source
pub trait CryptoProvider {
    type CipherSuite: TlsCipherSuite;
    type Signature: AsRef<[u8]>;

    // Required method
    fn rng(&mut self) -> impl CryptoRngCore;

    // Provided methods
    fn verifier(
        &mut self,
    ) -> Result<&mut impl TlsVerifier<Self::CipherSuite>, TlsError> { ... }
    fn signer(
        &mut self,
    ) -> Result<(impl SignerMut<Self::Signature>, SignatureScheme), TlsError> { ... }
    fn client_cert(&mut self) -> Option<Certificate<impl AsRef<[u8]>>> { ... }
}

Required Associated Types§

Required Methods§

Source

fn rng(&mut self) -> impl CryptoRngCore

Provided Methods§

Source

fn verifier( &mut self, ) -> Result<&mut impl TlsVerifier<Self::CipherSuite>, TlsError>

Source

fn signer( &mut self, ) -> Result<(impl SignerMut<Self::Signature>, SignatureScheme), TlsError>

Provide a signing key for client certificate authentication.

The provider resolves the private key internally (e.g. from memory, flash, or a hardware crypto module such as an HSM/TPM/secure element).

Source

fn client_cert(&mut self) -> Option<Certificate<impl AsRef<[u8]>>>

Resolve the client certificate for mutual TLS authentication.

Return None if no client certificate is available (an empty certificate message will be sent to the server). The data type D can be borrowed (&[u8]) or owned (e.g. heapless::Vec<u8, N>) — the certificate is only needed long enough to encode into the TLS message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: CryptoProvider> CryptoProvider for &mut T

Implementors§

Source§

impl<CipherSuite: TlsCipherSuite, RNG: CryptoRngCore> CryptoProvider for UnsecureProvider<'_, CipherSuite, RNG>