pub trait RTCCrypto: Send + Sync {
Show 13 methods
// 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_header_mask(
&self,
algorithm: HeaderMaskAlgorithm,
_key: &[u8],
) -> Result<Box<dyn HeaderMask>, 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 key_exchange_respond(
&self,
algorithm: KeyExchangeAlgorithm,
peer_share: &[u8],
) -> Result<(Vec<u8>, SecretVec), 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_header_mask(
&self,
algorithm: HeaderMaskAlgorithm,
_key: &[u8],
) -> Result<Box<dyn HeaderMask>, CryptoError>
fn new_header_mask( &self, algorithm: HeaderMaskAlgorithm, _key: &[u8], ) -> Result<Box<dyn HeaderMask>, CryptoError>
Creates a keyed record-number mask generator (RFC 9147 section 4.2.3).
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 key_exchange_respond(
&self,
algorithm: KeyExchangeAlgorithm,
peer_share: &[u8],
) -> Result<(Vec<u8>, SecretVec), CryptoError>
fn key_exchange_respond( &self, algorithm: KeyExchangeAlgorithm, peer_share: &[u8], ) -> Result<(Vec<u8>, SecretVec), CryptoError>
Answers a key exchange the peer started: makes this side’s share for peer_share
and the shared secret. For the Diffie-Hellman groups that is a key pair and an
agreement, which is what the default does; a KEM-based group (X25519MLKEM768)
encapsulates to the peer’s key instead, and its provider overrides this.
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".