[][src]Trait arx_kw::ArxKW

pub trait ArxKW {
    type Key;
    pub fn encrypt(
        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>; }

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 impls 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

Loading content...

Required methods

pub fn encrypt(
    key: &Self::Key,
    plaintext: &[u8]
) -> Result<(Vec<u8>, AuthTag), ArxKwError>
[src]

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]

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.

Loading content...

Implementors

impl ArxKW for E[src]

type Key = [u8; 48]

impl ArxKW for EX[src]

type Key = [u8; 48]

impl ArxKW for G[src]

type Key = [u8; 32]

impl ArxKW for GX[src]

type Key = [u8; 32]

Loading content...