ece::crypto

Trait Cryptographer

Source
pub trait Cryptographer:
    Send
    + Sync
    + 'static {
    // Required methods
    fn generate_ephemeral_keypair(&self) -> Result<Box<dyn LocalKeyPair>>;
    fn import_key_pair(
        &self,
        components: &EcKeyComponents,
    ) -> Result<Box<dyn LocalKeyPair>>;
    fn import_public_key(&self, raw: &[u8]) -> Result<Box<dyn RemotePublicKey>>;
    fn compute_ecdh_secret(
        &self,
        remote: &dyn RemotePublicKey,
        local: &dyn LocalKeyPair,
    ) -> Result<Vec<u8>>;
    fn hkdf_sha256(
        &self,
        salt: &[u8],
        secret: &[u8],
        info: &[u8],
        len: usize,
    ) -> Result<Vec<u8>>;
    fn aes_gcm_128_encrypt(
        &self,
        key: &[u8],
        iv: &[u8],
        data: &[u8],
    ) -> Result<Vec<u8>>;
    fn aes_gcm_128_decrypt(
        &self,
        key: &[u8],
        iv: &[u8],
        ciphertext_and_tag: &[u8],
    ) -> Result<Vec<u8>>;
    fn random_bytes(&self, dest: &mut [u8]) -> Result<()>;
}

Required Methods§

Source

fn generate_ephemeral_keypair(&self) -> Result<Box<dyn LocalKeyPair>>

Generate a random ephemeral local key pair.

Source

fn import_key_pair( &self, components: &EcKeyComponents, ) -> Result<Box<dyn LocalKeyPair>>

Import a local keypair from its raw components.

Source

fn import_public_key(&self, raw: &[u8]) -> Result<Box<dyn RemotePublicKey>>

Import the public key component in the binary uncompressed point representation.

Source

fn compute_ecdh_secret( &self, remote: &dyn RemotePublicKey, local: &dyn LocalKeyPair, ) -> Result<Vec<u8>>

Source

fn hkdf_sha256( &self, salt: &[u8], secret: &[u8], info: &[u8], len: usize, ) -> Result<Vec<u8>>

Source

fn aes_gcm_128_encrypt( &self, key: &[u8], iv: &[u8], data: &[u8], ) -> Result<Vec<u8>>

Should return [ciphertext, auth_tag].

Source

fn aes_gcm_128_decrypt( &self, key: &[u8], iv: &[u8], ciphertext_and_tag: &[u8], ) -> Result<Vec<u8>>

Source

fn random_bytes(&self, dest: &mut [u8]) -> Result<()>

Implementors§