Skip to main content

RTCCrypto

Trait RTCCrypto 

Source
pub trait RTCCrypto: Send + Sync {
    // Required method
    fn supports(&self, algorithm: CryptoAlgorithm) -> bool;

    // Provided methods
    fn hash(
        &self,
        algorithm: HashAlgorithm,
        _data: &[u8],
    ) -> Result<Vec<u8>, CryptoError> { ... }
    fn block_encrypt(
        &self,
        algorithm: BlockCipherAlgorithm,
        _key: &[u8],
        _block: &mut [u8],
    ) -> Result<(), CryptoError> { ... }
    fn new_hmac(
        &self,
        algorithm: HmacAlgorithm,
        _key: &[u8],
    ) -> Result<Box<dyn Mac>, CryptoError> { ... }
    fn new_stream_cipher(
        &self,
        algorithm: StreamCipherAlgorithm,
        _key: &[u8],
    ) -> Result<Box<dyn StreamCipher>, CryptoError> { ... }
    fn new_aead(
        &self,
        algorithm: AeadAlgorithm,
        _key: &[u8],
    ) -> Result<Box<dyn AeadCipher>, CryptoError> { ... }
    fn new_cbc(
        &self,
        algorithm: CbcAlgorithm,
        _key: &[u8],
    ) -> Result<Box<dyn CbcCipher>, CryptoError> { ... }
    fn start_key_exchange(
        &self,
        algorithm: KeyExchangeAlgorithm,
    ) -> Result<Box<dyn ActiveKeyExchange>, CryptoError> { ... }
    fn generate_signing_key(
        &self,
        scheme: SignatureScheme,
    ) -> Result<Arc<dyn SigningKey>, CryptoError> { ... }
    fn import_signing_key(
        &self,
        scheme: SignatureScheme,
        _pkcs8_der: &[u8],
    ) -> Result<Arc<dyn SigningKey>, CryptoError> { ... }
    fn verify_signature(
        &self,
        scheme: SignatureScheme,
        _public_key: PublicKey<'_>,
        _message: &[u8],
        _signature: &[u8],
    ) -> Result<(), CryptoError> { ... }
}
Expand description

Provider-neutral cryptographic operations.

Required Methods§

Source

fn supports(&self, algorithm: CryptoAlgorithm) -> bool

Reports whether an operation is implemented.

Provided Methods§

Source

fn hash( &self, algorithm: HashAlgorithm, _data: &[u8], ) -> Result<Vec<u8>, CryptoError>

Hashes data.

Source

fn block_encrypt( &self, algorithm: BlockCipherAlgorithm, _key: &[u8], _block: &mut [u8], ) -> Result<(), CryptoError>

Encrypts exactly one block in place.

Source

fn new_hmac( &self, algorithm: HmacAlgorithm, _key: &[u8], ) -> Result<Box<dyn Mac>, CryptoError>

Creates a keyed MAC.

This is the only HMAC entry point. Deriving the key schedule is the expensive part, so it happens here rather than per message; a caller that authenticates many messages with one key holds the returned Mac. One-shot callers simply drop it after a single sign or verify.

Source

fn new_stream_cipher( &self, algorithm: StreamCipherAlgorithm, _key: &[u8], ) -> Result<Box<dyn StreamCipher>, CryptoError>

Creates a keyed stream cipher.

Source

fn new_aead( &self, algorithm: AeadAlgorithm, _key: &[u8], ) -> Result<Box<dyn AeadCipher>, CryptoError>

Creates a keyed AEAD cipher.

Source

fn new_cbc( &self, algorithm: CbcAlgorithm, _key: &[u8], ) -> Result<Box<dyn CbcCipher>, CryptoError>

Creates a keyed CBC cipher.

Source

fn start_key_exchange( &self, algorithm: KeyExchangeAlgorithm, ) -> Result<Box<dyn ActiveKeyExchange>, CryptoError>

Starts a one-shot ephemeral key exchange.

Source

fn generate_signing_key( &self, scheme: SignatureScheme, ) -> Result<Arc<dyn SigningKey>, CryptoError>

Generates an exportable signing key.

Source

fn import_signing_key( &self, scheme: SignatureScheme, _pkcs8_der: &[u8], ) -> Result<Arc<dyn SigningKey>, CryptoError>

Imports an exportable PKCS#8 signing key.

Source

fn verify_signature( &self, scheme: SignatureScheme, _public_key: PublicKey<'_>, _message: &[u8], _signature: &[u8], ) -> Result<(), CryptoError>

Verifies a signature.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§