fn State(comptime endian: builtin.Endian) type

An Ascon state.

The state is represented as 5 64-bit words.

The NIST submission (v1.2) serializes these words as big-endian, but software implementations are free to use native endianness.

Parameters

endian: builtin.Endian,

Fields

st: Block,

Functions

fn addByte(self: *Self, byte: u8, offset: usize) void

XOR a byte into the state at a given offset.

fn addBytes(self: *Self, bytes: []const u8) void

XOR bytes into the beginning of the state.

fn asBytes(self: *Self) *[block_bytes]u8

A representation of the state as bytes. The byte order is architecture-dependent…

A representation of the state as bytes. The byte order is architecture-dependent.

fn clear(self: *Self, from: usize, to: usize) void

Set the words storing the bytes of a given range to zero.

fn endianSwap(self: *Self) void

Byte-swap the entire state if the architecture doesn’t match the required endian…

Byte-swap the entire state if the architecture doesn’t match the required endianness.

fn extractBytes(self: *Self, out: []u8) void

Extract the first bytes of the state.

fn init(initial_state: [block_bytes]u8) Self

Initialize the state from a slice of bytes.

fn initFromWords(initial_state: [5]u64) Self

Initialize the state from u64 words in native endianness.

fn initXof() Self

Initialize the state for Ascon XOF

fn initXofA() Self

Initialize the state for Ascon XOFa

inline fn permute(state: *Self) void

Apply a full-round permutation to the state.

inline fn permuteR(state: *Self, comptime rounds: u4) void

Apply a reduced-round permutation to the state.

inline fn permuteRatchet(state: *Self, comptime rounds: u4, comptime rate: u6) void

Apply a permutation to the state and prevent backtracking. The rate is expresse…

Apply a permutation to the state and prevent backtracking. The rate is expressed in bytes and must be a multiple of the word size (8).

fn secureZero(self: *Self) void

Clear the entire state, disabling compiler optimizations.

fn setBytes(self: *Self, bytes: []const u8) void

Set bytes starting at the beginning of the state.

fn xorBytes(self: *Self, out: []u8, in: []const u8) void

XOR the first bytes of the state into a slice of bytes.

Values

block_bytes
comptime_int

Number of bytes in the state.