Trait ece::crypto::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§
sourcefn generate_ephemeral_keypair(&self) -> Result<Box<dyn LocalKeyPair>>
fn generate_ephemeral_keypair(&self) -> Result<Box<dyn LocalKeyPair>>
Generate a random ephemeral local key pair.
sourcefn import_key_pair(
&self,
components: &EcKeyComponents
) -> Result<Box<dyn LocalKeyPair>>
fn import_key_pair( &self, components: &EcKeyComponents ) -> Result<Box<dyn LocalKeyPair>>
Import a local keypair from its raw components.
sourcefn import_public_key(&self, raw: &[u8]) -> Result<Box<dyn RemotePublicKey>>
fn import_public_key(&self, raw: &[u8]) -> Result<Box<dyn RemotePublicKey>>
Import the public key component in the binary uncompressed point representation.
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>>
sourcefn aes_gcm_128_encrypt(
&self,
key: &[u8],
iv: &[u8],
data: &[u8]
) -> Result<Vec<u8>>
fn aes_gcm_128_encrypt( &self, key: &[u8], iv: &[u8], data: &[u8] ) -> Result<Vec<u8>>
Should return [ciphertext, auth_tag].