pub trait CryptoProvider:
Clone
+ Send
+ Sync {
type Hasher: Clone + Unpin;
type AeadKey: Unpin;
Show 18 methods
// Required methods
fn cipher_suites() -> &'static [CipherSuite];
fn signature_schemes() -> &'static [SignatureScheme];
fn key_exchange_groups() -> &'static [KeyExchangeGroup];
fn secure_random(&self, buf: &mut [u8]);
fn new_hash(&self, suite: CipherSuite) -> Self::Hasher;
fn hash_update(&self, state: &mut Self::Hasher, data: &[u8]);
fn hash_finalize(&self, state: Self::Hasher) -> Result<Hash, Error>;
fn hmac(
&self,
suite: CipherSuite,
key: &Hash,
data: &[u8],
) -> Result<Hash, Error>;
fn hkdf_extract(
&self,
suite: CipherSuite,
salt: &Hash,
ikm: &[u8],
) -> Result<Hash, Error>;
fn hkdf_expand_label(
&self,
out: &mut [u8],
suite: CipherSuite,
secret: &Hash,
label: &[u8],
context: &[u8],
) -> Result<(), Error>;
fn new_aead_key(&self, suite: CipherSuite, key: &[u8]) -> Self::AeadKey;
fn aead_encrypt(
&self,
key: &Self::AeadKey,
nonce: &[u8],
aad: &[u8],
data: &mut [u8],
plaintext_len: usize,
) -> Result<usize, Error>;
fn aead_decrypt(
&self,
key: &Self::AeadKey,
nonce: &[u8],
aad: &[u8],
data: &mut [u8],
) -> Result<usize, Error>;
fn key_exchange_generate_keypair(
&self,
group: KeyExchangeGroup,
) -> Result<(KeyExchangeSecretKey, KeyExchangePublicKey), Error>;
fn key_exchange(
&self,
secret: &KeyExchangeSecretKey,
peer_public: &[u8],
) -> Result<Vec<u8, KEY_EXCHANGE_SHARED_SECRET_MAX_SIZE>, Error>;
fn sign(
&self,
scheme: SignatureScheme,
secret_key: &[u8],
data: &[u8],
) -> Result<Vec<u8, SIGNATURE_MAX_SIZE>, Error>;
fn verify(
&self,
scheme: SignatureScheme,
public_key: &[u8],
data: &[u8],
signature: &[u8],
) -> Result<(), Error>;
// Provided method
fn hash(&self, suite: CipherSuite, data: &[u8]) -> Result<Hash, Error> { ... }
}Required Associated Types§
Required Methods§
fn cipher_suites() -> &'static [CipherSuite]
fn signature_schemes() -> &'static [SignatureScheme]
fn key_exchange_groups() -> &'static [KeyExchangeGroup]
fn secure_random(&self, buf: &mut [u8])
Sourcefn new_hash(&self, suite: CipherSuite) -> Self::Hasher
fn new_hash(&self, suite: CipherSuite) -> Self::Hasher
Create a new incremental hash state for the given suite.
Sourcefn hash_update(&self, state: &mut Self::Hasher, data: &[u8])
fn hash_update(&self, state: &mut Self::Hasher, data: &[u8])
Absorb data into the hash state.
Sourcefn hash_finalize(&self, state: Self::Hasher) -> Result<Hash, Error>
fn hash_finalize(&self, state: Self::Hasher) -> Result<Hash, Error>
Finalize the hash and write the digest into out. Consumes the state.
fn hmac( &self, suite: CipherSuite, key: &Hash, data: &[u8], ) -> Result<Hash, Error>
fn hkdf_extract( &self, suite: CipherSuite, salt: &Hash, ikm: &[u8], ) -> Result<Hash, Error>
fn hkdf_expand_label( &self, out: &mut [u8], suite: CipherSuite, secret: &Hash, label: &[u8], context: &[u8], ) -> Result<(), Error>
fn new_aead_key(&self, suite: CipherSuite, key: &[u8]) -> Self::AeadKey
fn aead_encrypt( &self, key: &Self::AeadKey, nonce: &[u8], aad: &[u8], data: &mut [u8], plaintext_len: usize, ) -> Result<usize, Error>
fn aead_decrypt( &self, key: &Self::AeadKey, nonce: &[u8], aad: &[u8], data: &mut [u8], ) -> Result<usize, Error>
fn key_exchange_generate_keypair( &self, group: KeyExchangeGroup, ) -> Result<(KeyExchangeSecretKey, KeyExchangePublicKey), Error>
fn key_exchange( &self, secret: &KeyExchangeSecretKey, peer_public: &[u8], ) -> Result<Vec<u8, KEY_EXCHANGE_SHARED_SECRET_MAX_SIZE>, Error>
fn sign( &self, scheme: SignatureScheme, secret_key: &[u8], data: &[u8], ) -> Result<Vec<u8, SIGNATURE_MAX_SIZE>, Error>
fn verify( &self, scheme: SignatureScheme, public_key: &[u8], data: &[u8], signature: &[u8], ) -> Result<(), Error>
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".