28 void ascon_xof(
unsigned char *out,
const unsigned char *in,
size_t inlen)
40 #if defined(ASCON_BACKEND_SLICED64)
41 static uint64_t
const iv[5] = {
42 0xb57e273b814cd416ULL, 0x2b51042562ae2420ULL,
43 0x66a3a7768ddf2218ULL, 0x5aad0a7a8153650cULL,
46 memcpy(
state->state.
S, iv,
sizeof(iv));
47 #elif defined(ASCON_BACKEND_SLICED32)
48 static uint32_t
const iv[10] = {
49 0x7e351ae6, 0xc7578281, 0x1d238220, 0x70045f44,
50 0xa13e3f04, 0x5dd5ab52, 0xc30c1db2, 0x3e378142,
51 0xb624d656, 0x3735189d
53 memcpy(
state->state.
W, iv,
sizeof(iv));
55 static uint8_t
const iv[40] = {
56 0xb5, 0x7e, 0x27, 0x3b, 0x81, 0x4c, 0xd4, 0x16,
57 0x2b, 0x51, 0x04, 0x25, 0x62, 0xae, 0x24, 0x20,
58 0x66, 0xa3, 0xa7, 0x76, 0x8d, 0xdf, 0x22, 0x18,
59 0x5a, 0xad, 0x0a, 0x7a, 0x81, 0x53, 0x65, 0x0c,
60 0x4f, 0x3e, 0x0e, 0x32, 0x53, 0x94, 0x93, 0xb6
62 #if defined(ASCON_BACKEND_DIRECT_XOR)
63 memcpy(
state->state.
B, iv,
sizeof(iv));
76 #if !defined(__SIZEOF_SIZE_T__) || __SIZEOF_SIZE_T__ >= 4
77 if (outlen >= (((
size_t)1) << 29))
83 }
else if (outlen == 32U) {
85 #if defined(ASCON_BACKEND_SLICED64)
86 static uint64_t
const iv[5] = {
87 0xee9398aadb67f03dULL, 0x8bb21831c60f1002ULL,
88 0xb48a92db98d5da62ULL, 0x43189921b8f8e3e8ULL,
91 memcpy(
state->state.
S, iv,
sizeof(iv));
92 #elif defined(ASCON_BACKEND_SLICED32)
93 static uint32_t
const iv[10] = {
94 0xa540dbc7, 0xf9afb5c6, 0x1445a340, 0xbd249301,
95 0x604d4fc8, 0xcb9ba8b5, 0x94514c98, 0x12a4eede,
96 0x6339f398, 0x4bca84c0
98 memcpy(
state->state.
W, iv,
sizeof(iv));
100 static uint8_t
const iv[40] = {
101 0xee, 0x93, 0x98, 0xaa, 0xdb, 0x67, 0xf0, 0x3d,
102 0x8b, 0xb2, 0x18, 0x31, 0xc6, 0x0f, 0x10, 0x02,
103 0xb4, 0x8a, 0x92, 0xdb, 0x98, 0xd5, 0xda, 0x62,
104 0x43, 0x18, 0x99, 0x21, 0xb8, 0xf8, 0xe3, 0xe8,
105 0x34, 0x8f, 0xa5, 0xc9, 0xd5, 0x25, 0xe1, 0x40
107 #if defined(ASCON_BACKEND_DIRECT_XOR)
108 memcpy(
state->state.
B, iv,
sizeof(iv));
147 const unsigned char *custom,
size_t customlen,
size_t outlen)
151 size_t len = function_name ? strlen(function_name) : 0;
152 #if !defined(__SIZEOF_SIZE_T__) || __SIZEOF_SIZE_T__ >= 4
153 if (outlen >= (((
size_t)1) << 29))
159 }
else if (len <= 32) {
161 memcpy(temp, function_name, len);
185 #if defined(ASCON_BACKEND_SLICED64) || defined(ASCON_BACKEND_SLICED32) || \
186 defined(ASCON_BACKEND_DIRECT_XOR)
196 #if defined(ASCON_BACKEND_SLICED64) || defined(ASCON_BACKEND_SLICED32) || \
197 defined(ASCON_BACKEND_DIRECT_XOR)
207 const unsigned char *custom,
size_t customlen,
size_t outlen)
209 #if defined(ASCON_BACKEND_SLICED64) || defined(ASCON_BACKEND_SLICED32) || \
210 defined(ASCON_BACKEND_DIRECT_XOR)
247 temp = (unsigned)inlen;
249 state->count += temp;
269 temp = (unsigned)inlen;
297 temp = (unsigned)outlen;
299 state->count += temp;
319 temp = (unsigned)outlen;
335 }
else if (
state->count != 0) {
#define ascon_absorb_8(state, data, offset)
#define ascon_pad(state, offset)
#define ascon_squeeze_8(state, data, offset)
#define ascon_squeeze_partial(state, data, offset, count)
#define ascon_absorb_partial(state, data, offset, count)
#define ascon_separator(state)
#define be_store_word64(ptr, x)
void ascon_xof_free(ascon_xof_state_t *state)
Frees the ASCON-XOF state and destroys any sensitive material.
void ascon_xof_pad(ascon_xof_state_t *state)
Absorbs enough zeroes into an ASCON-XOF state to pad the input to the next multiple of the block rate...
void ascon_xof_reinit(ascon_xof_state_t *state)
Re-initializes the state for an ASCON-XOF hashing operation.
void ascon_xof_absorb_custom(ascon_xof_state_t *state, const unsigned char *custom, size_t customlen)
Absorbs a customization string into an ASCON-XOF state.
void ascon_xof_absorb(ascon_xof_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an ASCON-XOF state.
void ascon_xof_init(ascon_xof_state_t *state)
Initializes the state for an ASCON-XOF hashing operation.
void ascon_xof_init_custom(ascon_xof_state_t *state, const char *function_name, const unsigned char *custom, size_t customlen, size_t outlen)
Initializes the state for an incremental ASCON-XOF operation, with a named function,...
void ascon_xof_reinit_fixed(ascon_xof_state_t *state, size_t outlen)
Re-initializes the state for an incremental ASCON-XOF operation, with a fixed output length.
void ascon_xof_reinit_custom(ascon_xof_state_t *state, const char *function_name, const unsigned char *custom, size_t customlen, size_t outlen)
Re-nitializes the state for an incremental ASCON-XOF operation, with a named function,...
void ascon_xof_copy(ascon_xof_state_t *dest, const ascon_xof_state_t *src)
Clones a copy of an ASCON-XOF state.
void ascon_xof_squeeze(ascon_xof_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an ASCON-XOF state.
void ascon_xof(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with ASCON-XOF and generates a fixed-length 32 byte output.
void ascon_xof_init_fixed(ascon_xof_state_t *state, size_t outlen)
Initializes the state for an incremental ASCON-XOF operation, with a fixed output length.
void ascon_free(ascon_state_t *state)
Frees an ASCON permutation state and attempts to destroy any sensitive material.
void ascon_release(ascon_state_t *state)
Temporarily releases access to any shared hardware resources that a permutation state was using.
void ascon_overwrite_bytes(ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size)
Overwrites existing bytes in the ASCON state.
void ascon_copy(ascon_state_t *dest, const ascon_state_t *src)
Copies the entire ASCON permutation state from a source to a destination.
void ascon_permute(ascon_state_t *state, uint8_t first_round)
Permutes the ASCON state with a specified number of rounds.
void ascon_acquire(ascon_state_t *state)
Re-acquires access to any shared hardware resources that a permutation state was using.
void ascon_init(ascon_state_t *state)
Initializes the words of the ASCON permutation state to zero.
ascon_state_t state
[snippet_key]
State information for ASCON-XOF incremental mode.
ASCON-XOF and ASCON-XOFA extensible output functions (XOF's).
#define ASCON_XOF_RATE
Rate of absorbing and squeezing data for ASCON-XOF, ASCON-XOFA, ASCON-HASH, and ASCON-HASHA.
#define ASCON_HASH_SIZE
Size of the hash output for ASCON-HASH and the default hash output size for ASCON-XOF.