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§
Sourcefn supports(&self, algorithm: CryptoAlgorithm) -> bool
fn supports(&self, algorithm: CryptoAlgorithm) -> bool
Reports whether an operation is implemented.
Provided Methods§
Sourcefn hash(
&self,
algorithm: HashAlgorithm,
_data: &[u8],
) -> Result<Vec<u8>, CryptoError>
fn hash( &self, algorithm: HashAlgorithm, _data: &[u8], ) -> Result<Vec<u8>, CryptoError>
Hashes data.
Sourcefn block_encrypt(
&self,
algorithm: BlockCipherAlgorithm,
_key: &[u8],
_block: &mut [u8],
) -> Result<(), CryptoError>
fn block_encrypt( &self, algorithm: BlockCipherAlgorithm, _key: &[u8], _block: &mut [u8], ) -> Result<(), CryptoError>
Encrypts exactly one block in place.
Sourcefn new_hmac(
&self,
algorithm: HmacAlgorithm,
_key: &[u8],
) -> Result<Box<dyn Mac>, CryptoError>
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.
Sourcefn new_stream_cipher(
&self,
algorithm: StreamCipherAlgorithm,
_key: &[u8],
) -> Result<Box<dyn StreamCipher>, CryptoError>
fn new_stream_cipher( &self, algorithm: StreamCipherAlgorithm, _key: &[u8], ) -> Result<Box<dyn StreamCipher>, CryptoError>
Creates a keyed stream cipher.
Sourcefn new_aead(
&self,
algorithm: AeadAlgorithm,
_key: &[u8],
) -> Result<Box<dyn AeadCipher>, CryptoError>
fn new_aead( &self, algorithm: AeadAlgorithm, _key: &[u8], ) -> Result<Box<dyn AeadCipher>, CryptoError>
Creates a keyed AEAD cipher.
Sourcefn new_cbc(
&self,
algorithm: CbcAlgorithm,
_key: &[u8],
) -> Result<Box<dyn CbcCipher>, CryptoError>
fn new_cbc( &self, algorithm: CbcAlgorithm, _key: &[u8], ) -> Result<Box<dyn CbcCipher>, CryptoError>
Creates a keyed CBC cipher.
Sourcefn start_key_exchange(
&self,
algorithm: KeyExchangeAlgorithm,
) -> Result<Box<dyn ActiveKeyExchange>, CryptoError>
fn start_key_exchange( &self, algorithm: KeyExchangeAlgorithm, ) -> Result<Box<dyn ActiveKeyExchange>, CryptoError>
Starts a one-shot ephemeral key exchange.
Sourcefn generate_signing_key(
&self,
scheme: SignatureScheme,
) -> Result<Arc<dyn SigningKey>, CryptoError>
fn generate_signing_key( &self, scheme: SignatureScheme, ) -> Result<Arc<dyn SigningKey>, CryptoError>
Generates an exportable signing key.
Sourcefn import_signing_key(
&self,
scheme: SignatureScheme,
_pkcs8_der: &[u8],
) -> Result<Arc<dyn SigningKey>, CryptoError>
fn import_signing_key( &self, scheme: SignatureScheme, _pkcs8_der: &[u8], ) -> Result<Arc<dyn SigningKey>, CryptoError>
Imports an exportable PKCS#8 signing key.
Sourcefn verify_signature(
&self,
scheme: SignatureScheme,
_public_key: PublicKey<'_>,
_message: &[u8],
_signature: &[u8],
) -> Result<(), CryptoError>
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".