[][src]Crate salsa20

The Salsa20 stream cipher.

Cipher functionality is accessed using traits from re-exported stream-cipher crate.

Security Warning

This crate does not ensure ciphertexts are authentic! Thus ciphertext integrity is not verified, which can lead to serious vulnerabilities!

Usage

use salsa20::Salsa20;
use salsa20::stream_cipher::generic_array::GenericArray;
use salsa20::stream_cipher::{NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek};

let mut data = [1, 2, 3, 4, 5, 6, 7];

let key = GenericArray::from_slice(b"an example very very secret key.");
let nonce = GenericArray::from_slice(b"a nonce.");

// create cipher instance
let mut cipher = Salsa20::new(&key, &nonce);

// apply keystream (encrypt)
cipher.apply_keystream(&mut data);
assert_eq!(data, [182, 14, 133, 113, 210, 25, 165]);

// seek to the keystream beginning and apply it again to the `data` (decrypt)
cipher.seek(0);
cipher.apply_keystream(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5, 6, 7]);

Re-exports

pub use stream_cipher;

Structs

Salsa

The Salsa20 family of stream ciphers (implemented generically over a number of rounds).

XSalsa20

XSalsa20 is a Salsa20 variant with an extended 192-bit (24-byte) nonce.

Constants

BLOCK_SIZE

Size of a Salsa20 block in bytes

KEY_SIZE

Size of a Salsa20 key in bytes

Type Definitions

Salsa8

Salsa20/8 stream cipher (reduced-round variant of Salsa20 with 8 rounds, not recommended)

Salsa12

Salsa20/12 stream cipher (reduced-round variant of Salsa20 with 12 rounds, not recommended)

Salsa20

Salsa20/20 stream cipher (20 rounds; recommended)