pub unsafe extern "C" fn ocrypto_chacha20_encode(
    c: *mut u8,
    m: *const u8,
    m_len: usize,
    n: *const u8,
    n_len: usize,
    key: *const u8,
    count: u32
)
Expand description

ChaCha20 cipher stream encoder.

The message * m - is encrypted by applying the XOR operation with a pseudo random cipher stream derived from the encryption key * key - , the nonce * n - , and the initial block counter * count - .

Calling the function a second time with the generated ciphertext as input message * m - decrypts it back to the original message.

  • c - Generated ciphertext. Same length as input message.
  • m - Input message.
  • m_len - Length of * c - and * m - .
  • n - Nonce.
  • n_len - Nonce length. 0 <= * n_len - <= * ocrypto_chacha20_NONCE_BYTES_MAX - .
  • key - Encryption key.
  • count - Initial block counter.

@remark * c - may be same as * m - .

@remark When reusing an encryption key * key - for a different message * m - , a different nonce * n - or initial block counter * count - must be used.