Type Function Salsa [src]
Alias for std.crypto.salsa20.Salsa
The Salsa stream cipher.
Prototype
pub fn Salsa(comptime rounds: comptime_int) type
Parameters
rounds: comptime_int
Source
pub fn Salsa(comptime rounds: comptime_int) type {
return struct {
/// Nonce length in bytes.
pub const nonce_length = 8;
/// Key length in bytes.
pub const key_length = 32;
/// Add the output of the Salsa 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 {
debug.assert(in.len == out.len);
var d: [4]u32 = undefined;
d[0] = mem.readInt(u32, nonce[0..4], .little);
d[1] = mem.readInt(u32, nonce[4..8], .little);
d[2] = @as(u32, @truncate(counter));
d[3] = @as(u32, @truncate(counter >> 32));
SalsaImpl(rounds).salsaXor(out, in, keyToWords(key), d);
}
};
}