[][src]Trait secret_keeper::ciphers::Cipher

pub trait Cipher: Debug + Sync + Send {
    fn supports_aad(&self) -> bool;
#[must_use] fn seal<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        plaintext: &'life1 [u8],
        aad: Option<&'life2 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn open<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ciphertext: &'life1 [u8],
        aad: Option<&'life2 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn seal_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        file_path: &'life1 str,
        aad: Option<&'life2 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<(Bytes, AuthTag, u64), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn seal_write<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        data: &'life1 mut [u8],
        file: &'life2 mut File,
        aad: Option<&'life3 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<(AuthTag, u64), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        'life3: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn seal_detached<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        src: &'life1 mut [u8],
        aad: Option<&'life2 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<AuthTag, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn open_read<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        file: &'life1 mut File,
        len: u64,
        size_hint: Option<u64>,
        tag: &'life2 [u8],
        aad: Option<&'life3 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        'life3: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn open_detached<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        buf: &'life1 mut [u8],
        tag: &'life2 [u8],
        aad: Option<&'life3 [u8]>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        'life3: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn export<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        uri: &'life1 str,
        nonce: &'life2 [u8],
        keeper: &'life3 Box<dyn SecretKeeper>
    ) -> Pin<Box<dyn Future<Output = Result<WrappedKey, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        'life3: 'async_trait,
        Self: 'async_trait
;
fn nonce_len(&self) -> usize;
fn key_len(&self) -> usize;
fn tag_len(&self) -> usize;
fn get_nonce(&self) -> &[u8]; }

Describes interface to encrypt/decrypt file

Required methods

fn supports_aad(&self) -> bool

Returns whether or not this encryption supports aad

#[must_use]fn seal<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    plaintext: &'life1 [u8],
    aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Encrypts the slice, with optional authenticated data Return value is a simple vector that contains the ciphertext plus a MAC-based authentication tag.

#[must_use]fn open<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    ciphertext: &'life1 [u8],
    aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Decrypts the slice. The ciphertext buffer was created with seal(), and contains an appended auth tag. For CompressingCipher, this method may be less efficient than open_detached, because it needs to make two heap allocs: one for decryption, and one for decompression. If you can use open_detached, the decryption is done in place so the first alloc is avoided. Return value is the decrypted plaintext.

#[must_use]fn seal_file<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    file_path: &'life1 str,
    aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(Bytes, AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Encrypt the file, with optional associated data. Return tuple has encrypted data, auth tag, and file size

#[must_use]fn seal_write<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    data: &'life1 mut [u8],
    file: &'life2 mut File,
    aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 

Encrypt the data and write/append to the file. Returns the auth tag and length of data appended data buf may be overwritten for encryption-in-place

#[must_use]fn seal_detached<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    src: &'life1 mut [u8],
    aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<AuthTag, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Encrypt the slice, with optional associated data. The data is encrypted in place. The tag returned must be used with open_detached

#[must_use]fn open_read<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    file: &'life1 mut File,
    len: u64,
    size_hint: Option<u64>,
    tag: &'life2 [u8],
    aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 

Read len bytes from the file, decrypt, and return. To reduce memory allocations, (particularly for compressing ciphers), caller should set size_hint to size of decompressed/decrypted data, if known. For non-compressing cipher such as xchacha20-poly1305, return Bytes.len() == len

#[must_use]fn open_detached<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    buf: &'life1 mut [u8],
    tag: &'life2 [u8],
    aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 

Decrypts slice in-place. buf: mutable buffer containing ciphertext (in), to be overwritten with plaintext tag: auth tag data aad: optional associated data

#[must_use]fn export<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    uri: &'life1 str,
    nonce: &'life2 [u8],
    keeper: &'life3 Box<dyn SecretKeeper>
) -> Pin<Box<dyn Future<Output = Result<WrappedKey, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 

Export key by encrypting and wrapping it

fn nonce_len(&self) -> usize

number of bytes in nonce for this cipher

fn key_len(&self) -> usize

number of bytes in key for this cipher

fn tag_len(&self) -> usize

number of bytes in tag

fn get_nonce(&self) -> &[u8]

return nonce as slice

Loading content...

Implementors

impl Cipher for AesGcm256[src]

fn nonce_len(&self) -> usize[src]

number of bytes in nonce for this cipher

fn key_len(&self) -> usize[src]

number of bytes in key for this cipher

fn get_nonce(&self) -> &[u8][src]

return nonce as slice

fn supports_aad(&self) -> bool[src]

Returns whether or not this encryption supports aad

fn seal<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    plaintext: &'life1 [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypts the slice, with optional authenticated data Return value is a simple vector that contains the ciphertext plus a MAC-based authentication tag.

fn open<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    ciphertext: &'life1 [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Decrypts the in-memory block, with optional authenticated data

fn seal_file<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    file_path: &'life1 str,
    aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(Bytes, AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypts the file, with optional associated data, Returns encrypted data, tag, and file size

fn seal_write<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    data: &'life1 mut [u8],
    file: &'life2 mut File,
    aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypt the data and append to the file. Returns the auth tag and length of data appended

fn open_read<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    file: &'life1 mut File,
    len: u64,
    _size_hint: Option<u64>,
    tag: &'life2 [u8],
    aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Read len bytes from the file and decrypt Returns data as Bytes In non-compressing cipher, data.len() == len, so size_hint is ignored.

fn open_detached<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    buf: &'life1 mut [u8],
    tag: &'life2 [u8],
    aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Decrypts the data in-place buf: mutable buffer containing ciphertext (in), to be overwritten with plaintext tag: auth tag data aad: optional additional authenticated data

fn export<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    uri: &'life1 str,
    nonce: &'life2 [u8],
    keeper: &'life3 Box<dyn SecretKeeper>
) -> Pin<Box<dyn Future<Output = Result<WrappedKey, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Export key by encrypting and wrapping it

impl Cipher for XChaCha20[src]

fn nonce_len(&self) -> usize[src]

number of bytes in nonce for this cipher

fn key_len(&self) -> usize[src]

number of bytes in key for this cipher

fn get_nonce(&self) -> &[u8][src]

return nonce as slice

fn supports_aad(&self) -> bool[src]

Returns whether or not this encryption supports aad

fn seal<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    plaintext: &'life1 [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypts the slice, with optional authenticated data Return value is a simple vector that contains the ciphertext plus a MAC-based authentication tag.

fn open<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    ciphertext: &'life1 [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Decrypts the in-memory block, with optional authenticated data

fn seal_file<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    file_path: &'life1 str,
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(Bytes, AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypts the file, with optional associated data, Returns encrypted data, tag, and file size

fn seal_write<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    data: &'life1 mut [u8],
    file: &'life2 mut File,
    _aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypt the data and append to the file. Returns the auth tag and length of data appended

fn open_read<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    file: &'life1 mut File,
    len: u64,
    _size_hint: Option<u64>,
    tag: &'life2 [u8],
    _aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Read len bytes from the file and decrypt Returns data as Bytes In non-compressing cipher, data.len() == len, so size_hint is ignored.

fn open_detached<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    buf: &'life1 mut [u8],
    tag: &'life2 [u8],
    _aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Decrypts the data in-place buf: mutable buffer containing ciphertext (in), to be overwritten with plaintext tag: auth tag data aad: optional additional authenticated data

fn export<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    uri: &'life1 str,
    nonce: &'life2 [u8],
    keeper: &'life3 Box<dyn SecretKeeper>
) -> Pin<Box<dyn Future<Output = Result<WrappedKey, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Export key by encrypting and wrapping it

impl Cipher for XChaCha20Compress[src]

fn nonce_len(&self) -> usize[src]

number of bytes in nonce for this cipher

fn key_len(&self) -> usize[src]

number of bytes in key for this cipher

fn get_nonce(&self) -> &[u8][src]

return nonce as slice

fn supports_aad(&self) -> bool[src]

Returns whether or not this encryption supports aad

fn seal<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    plaintext: &'life1 [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypts the slice, with optional authenticated data Return value is a simple vector that contains the ciphertext plus a MAC-based authentication tag.

fn open<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    ciphertext: &'life1 [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Decrypts and uncompresses the slice. The ciphertext buffer was created with seal(), and contains an appended auth tag. This method may be less efficient than open_detached, because it needs to make two heap allocs: one for decryption, and one for decompression. If you can use open_detached, the decryption is done in place so the first alloc is avoided. Return value is the decrypted plaintext.

fn seal_file<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    file_path: &'life1 str,
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(Bytes, AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Compress and encrypt the file, with optional associated data.

fn seal_write<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    data: &'life1 mut [u8],
    file: &'life2 mut File,
    _aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(AuthTag, u64), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypt the data and append to the file. Returns the auth tag and length of data appended

fn open_read<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    file: &'life1 mut File,
    len: u64,
    size_hint: Option<u64>,
    tag: &'life2 [u8],
    _aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Read len bytes from the file and decrypt Returns data as Bytes. In compressing cipher, size_hint should be used if size of decompressed data is known.

fn seal_detached<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    src: &'life1 mut [u8],
    _aad: Option<&'life2 [u8]>
) -> Pin<Box<dyn Future<Output = Result<AuthTag, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypt the slice, with optional associated data.

fn open_detached<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    _buf: &'life1 mut [u8],
    _tag: &'life2 [u8],
    _aad: Option<&'life3 [u8]>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Decrypts the data in-place Note: this is not applicable for compressed encryptors because the decrypted data may exceed the provided buffer length. Use open_compressed instead.

fn export<'life0, 'life1, 'life2, 'life3, 'async_trait>(
    &'life0 self,
    uri: &'life1 str,
    nonce: &'life2 [u8],
    keeper: &'life3 Box<dyn SecretKeeper>
) -> Pin<Box<dyn Future<Output = Result<WrappedKey, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    'life3: 'async_trait,
    Self: 'async_trait, 
[src]

Export key by encrypting and wrapping it

Loading content...