[][src]Struct secret_keeper::ciphers::xchacha20::XChaCha20

pub struct XChaCha20 { /* fields omitted */ }

XChaCha20-Poly1305 encryption cipher Encryption algorithm is a pure rust implementation by RustCrypto AEAD

Implementations

impl XChaCha20[src]

pub fn init_from(key: &[u8], nonce: &[u8]) -> Result<Self, Error>[src]

Initialize cipher with provided key and nonce key length must be exactly KEYBYTES. nonce length must be >= NONCEBYTES

pub fn init() -> Result<Self, Error>[src]

Initialize cipher, generating new key and nonce Key is generated with crate::rand (platform CSRNG)

pub fn with_nonce(nonce: &[u8]) -> Result<Self, Error>[src]

Initialize cipher with nonce, generating new key Key is generated with crate::rand (platform CSRNG) Nonce length must be >= NONCEBYTES

Trait Implementations

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 Debug for XChaCha20[src]

Implementation of Debug that doesn't print key to prevent accidental leaks via logging

impl Import for XChaCha20[src]

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

Import key by unwrapping and decrypting it

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.