pub trait SymmetricCipher {
// Required methods
fn encrypt(
&self,
key: &[u8],
nonce: &[u8],
plaintext: &[u8],
) -> Result<Bytes, CryptoError>;
fn decrypt(
&self,
key: &[u8],
nonce: &[u8],
ciphertext: &[u8],
) -> Result<Bytes, CryptoError>;
}Expand description
Symmetric cipher port — AES-256-GCM.
Required Methods§
Sourcefn encrypt(
&self,
key: &[u8],
nonce: &[u8],
plaintext: &[u8],
) -> Result<Bytes, CryptoError>
fn encrypt( &self, key: &[u8], nonce: &[u8], plaintext: &[u8], ) -> Result<Bytes, CryptoError>
Encrypt plaintext with key and nonce.
§Errors
Returns CryptoError::InvalidKeyLength or
CryptoError::EncryptionFailed.
Sourcefn decrypt(
&self,
key: &[u8],
nonce: &[u8],
ciphertext: &[u8],
) -> Result<Bytes, CryptoError>
fn decrypt( &self, key: &[u8], nonce: &[u8], ciphertext: &[u8], ) -> Result<Bytes, CryptoError>
Decrypt and authenticate ciphertext with key and nonce.
§Errors
Returns CryptoError::DecryptionFailed if authentication fails.