[−][src]Trait arx_kw::ArxKW
Provides encryption and decryption capabilites
The ArxKW trait requires a fixed-length array reference for keys and authentication tags, but the ciphertext and plaintext inputs can be slices (their lengths are verified to be valid if used with the E and G variants)
Associated Types
type Key
[src]
The type of data which is used as a key for the type that impl
s this trait.
Note that this is not the same for all variants of ARX-KW. all of the currently-defined variants use the same-sized keys
Required methods
pub fn encrypt(
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
[src]
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
Encrypts the plaintext using ARX-KW and returns the encrypted ciphertext and an AuthTag
The authentication tag can be stored/transported alongside it and is needed (along with the key used to encrypt the plaintext) in order to decrypt the wrapped key.
Errors
Returns an error if the key or plaintext is of invalid length or if the end of the ChaCha cipher is reached unexpectedly.
pub fn decrypt(
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
[src]
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
Attempts to decrypt the ciphertext using ARX-KW and returns the decrypted plaintext if
successful. As ARX-KW is a form of authenticated encryption, the authenticity of the
decrypted text is verified if the function returns an Ok
value.
which can be stored/transported alongside it.
Errors
Returns an error if the key or ciphertext is of invalid length or if the end of the ChaCha cipher is reached unexpectedly.
Implementors
impl ArxKW for E
[src]
type Key = [u8; 48]
pub fn encrypt(
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
[src]
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
pub fn decrypt(
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
[src]
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
impl ArxKW for EX
[src]
type Key = [u8; 48]
pub fn encrypt(
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
[src]
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
pub fn decrypt(
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
[src]
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
impl ArxKW for G
[src]
type Key = [u8; 32]
pub fn encrypt(
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
[src]
key: &Self::Key,
plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
pub fn decrypt(
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>
[src]
key: &Self::Key,
ciphertext: &[u8],
authentication_tag: &AuthTag
) -> Result<Vec<u8>, ArxKwError>