pub trait Crypto: RefUnwindSafe {
// Required methods
fn fill_random(&self, buffer: &mut [u8]) -> Result<(), InternalError>;
fn hmac_sha256(
&self,
key: &[u8],
) -> Result<Box<dyn Sha256Hmac>, InternalError>;
fn sha512_digest(&self) -> Result<Box<dyn Sha512Digest>, InternalError>;
fn encrypt(
&self,
cipher: SignalCipherType,
key: &[u8],
iv: &[u8],
data: &[u8],
) -> Result<Vec<u8>, InternalError>;
fn decrypt(
&self,
cipher: SignalCipherType,
key: &[u8],
iv: &[u8],
data: &[u8],
) -> Result<Vec<u8>, InternalError>;
}
Expand description
Cryptography routines used in the signal protocol.
Required Methods§
Sourcefn fill_random(&self, buffer: &mut [u8]) -> Result<(), InternalError>
fn fill_random(&self, buffer: &mut [u8]) -> Result<(), InternalError>
Fill the provided buffer with some random bytes.
Sourcefn hmac_sha256(&self, key: &[u8]) -> Result<Box<dyn Sha256Hmac>, InternalError>
fn hmac_sha256(&self, key: &[u8]) -> Result<Box<dyn Sha256Hmac>, InternalError>
Start to calculate a SHA-256 HMAC using the provided key.
Sourcefn sha512_digest(&self) -> Result<Box<dyn Sha512Digest>, InternalError>
fn sha512_digest(&self) -> Result<Box<dyn Sha512Digest>, InternalError>
Start to generate a SHA-512 digest.
Sourcefn encrypt(
&self,
cipher: SignalCipherType,
key: &[u8],
iv: &[u8],
data: &[u8],
) -> Result<Vec<u8>, InternalError>
fn encrypt( &self, cipher: SignalCipherType, key: &[u8], iv: &[u8], data: &[u8], ) -> Result<Vec<u8>, InternalError>
Encrypt the provided data using AES.
Sourcefn decrypt(
&self,
cipher: SignalCipherType,
key: &[u8],
iv: &[u8],
data: &[u8],
) -> Result<Vec<u8>, InternalError>
fn decrypt( &self, cipher: SignalCipherType, key: &[u8], iv: &[u8], data: &[u8], ) -> Result<Vec<u8>, InternalError>
Decrypt the provided data using AES.