DoxigAlpha

XSalsa

The XSalsa stream cipher.

Add the output of the XSalsa stream cipher to `in` and stores the result into `out`.

Functions

#
xor
Add the output of the XSalsa stream cipher to `in` and stores the result into `out`.

Nonce length in bytes.

Values

#
nonce_length
Nonce length in bytes.
key_length
Key length in bytes.

Source

Implementation

#
pub fn XSalsa(comptime rounds: comptime_int) type {
    return struct {
        /// Nonce length in bytes.
        pub const nonce_length = 24;
        /// Key length in bytes.
        pub const key_length = 32;

        /// Add the output of the XSalsa stream cipher to `in` and stores the result into `out`.
        /// WARNING: This function doesn't provide authenticated encryption.
        /// Using the AEAD or one of the `box` versions is usually preferred.
        pub fn xor(out: []u8, in: []const u8, counter: u64, key: [key_length]u8, nonce: [nonce_length]u8) void {
            const extended = extend(rounds, key, nonce);
            Salsa(rounds).xor(out, in, counter, extended.key, extended.nonce);
        }
    };
}