Skip to main content

CryptoProvider

Trait CryptoProvider 

Source
pub trait CryptoProvider: Send + Sync {
    // Required methods
    fn hash(&self, alg: HashAlgorithm, data: &[u8]) -> Digest;
    fn sign(&self, sk: &SigningKey, msg: &[u8]) -> [u8; 64];
    fn verify(&self, pk: &[u8; 32], msg: &[u8], sig: &[u8; 64]) -> Result<()>;
    fn aead_encrypt(
        &self,
        key: &[u8; 32],
        nonce: &[u8; 12],
        aad: &[u8],
        pt: &[u8],
    ) -> Result<Vec<u8>>;
    fn aead_decrypt(
        &self,
        key: &[u8; 32],
        nonce: &[u8; 12],
        aad: &[u8],
        ct: &[u8],
    ) -> Result<Vec<u8>>;
}

Required Methods§

Source

fn hash(&self, alg: HashAlgorithm, data: &[u8]) -> Digest

Source

fn sign(&self, sk: &SigningKey, msg: &[u8]) -> [u8; 64]

Source

fn verify(&self, pk: &[u8; 32], msg: &[u8], sig: &[u8; 64]) -> Result<()>

Source

fn aead_encrypt( &self, key: &[u8; 32], nonce: &[u8; 12], aad: &[u8], pt: &[u8], ) -> Result<Vec<u8>>

Source

fn aead_decrypt( &self, key: &[u8; 32], nonce: &[u8; 12], aad: &[u8], ct: &[u8], ) -> Result<Vec<u8>>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§