26 void ascon_xofa(
unsigned char *out,
const unsigned char *in,
size_t inlen)
38 #if defined(ASCON_BACKEND_SLICED64)
39 static uint64_t
const iv[5] = {
40 0x44906568b77b9832ULL, 0xcd8d6cae53455532ULL,
41 0xf7b5212756422129ULL, 0x246885e1de0d225bULL,
44 memcpy(
state->state.
S, iv,
sizeof(iv));
45 #elif defined(ASCON_BACKEND_SLICED32)
46 static uint32_t
const iv[10] = {
47 0xa4b87d44, 0x0846d7a5, 0xb3a2dbf4, 0xaa6f1005,
48 0xf713e811, 0xdc451146, 0x2839e30d, 0x468cb253,
49 0x09e96977, 0xeb2d4297
51 memcpy(
state->state.
W, iv,
sizeof(iv));
53 static uint8_t
const iv[40] = {
54 0x44, 0x90, 0x65, 0x68, 0xb7, 0x7b, 0x98, 0x32,
55 0xcd, 0x8d, 0x6c, 0xae, 0x53, 0x45, 0x55, 0x32,
56 0xf7, 0xb5, 0x21, 0x27, 0x56, 0x42, 0x21, 0x29,
57 0x24, 0x68, 0x85, 0xe1, 0xde, 0x0d, 0x22, 0x5b,
58 0xa8, 0xcb, 0x5c, 0xe3, 0x34, 0x49, 0x97, 0x3f
60 #if defined(ASCON_BACKEND_DIRECT_XOR)
61 memcpy(
state->state.
B, iv,
sizeof(iv));
74 #if !defined(__SIZEOF_SIZE_T__) || __SIZEOF_SIZE_T__ >= 4
75 if (outlen >= (((
size_t)1) << 29))
81 }
else if (outlen == 32U) {
83 #if defined(ASCON_BACKEND_SLICED64)
84 static uint64_t
const iv[5] = {
85 0x01470194fc6528a6ULL, 0x738ec38ac0adffa7ULL,
86 0x2ec8e3296c76384cULL, 0xd6f6a54d7f52377dULL,
89 memcpy(
state->state.
S, iv,
sizeof(iv));
90 #elif defined(ASCON_BACKEND_SLICED32)
91 static uint32_t
const iv[10] = {
92 0x1b16eb02, 0x0108e46d, 0xd29083f3, 0x5b9b8efd,
93 0x2891ae4a, 0x7ad66562, 0xee3bfc7f, 0x9dc27156,
94 0x16801633, 0xc61d5fa9
96 memcpy(
state->state.
W, iv,
sizeof(iv));
98 static uint8_t
const iv[40] = {
99 0x01, 0x47, 0x01, 0x94, 0xfc, 0x65, 0x28, 0xa6,
100 0x73, 0x8e, 0xc3, 0x8a, 0xc0, 0xad, 0xff, 0xa7,
101 0x2e, 0xc8, 0xe3, 0x29, 0x6c, 0x76, 0x38, 0x4c,
102 0xd6, 0xf6, 0xa5, 0x4d, 0x7f, 0x52, 0x37, 0x7d,
103 0xa1, 0x3c, 0x42, 0xa2, 0x23, 0xbe, 0x8d, 0x87
105 #if defined(ASCON_BACKEND_DIRECT_XOR)
106 memcpy(
state->state.
B, iv,
sizeof(iv));
145 const unsigned char *custom,
size_t customlen,
size_t outlen)
149 size_t len = function_name ? strlen(function_name) : 0;
150 #if !defined(__SIZEOF_SIZE_T__) || __SIZEOF_SIZE_T__ >= 4
151 if (outlen >= (((
size_t)1) << 29))
157 }
else if (len <= 32) {
159 memcpy(temp, function_name, len);
183 #if defined(ASCON_BACKEND_SLICED64) || defined(ASCON_BACKEND_SLICED32) || \
184 defined(ASCON_BACKEND_DIRECT_XOR)
194 #if defined(ASCON_BACKEND_SLICED64) || defined(ASCON_BACKEND_SLICED32) || \
195 defined(ASCON_BACKEND_DIRECT_XOR)
205 const unsigned char *custom,
size_t customlen,
size_t outlen)
207 #if defined(ASCON_BACKEND_SLICED64) || defined(ASCON_BACKEND_SLICED32) || \
208 defined(ASCON_BACKEND_DIRECT_XOR)
245 temp = (unsigned)inlen;
247 state->count += temp;
267 temp = (unsigned)inlen;
296 temp = (unsigned)outlen;
298 state->count += temp;
319 temp = (unsigned)outlen;
334 }
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_xofa_squeeze(ascon_xofa_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an ASCON-XOFA state.
void ascon_xofa_reinit(ascon_xofa_state_t *state)
Re-initializes the state for an ASCON-XOFA hashing operation.
void ascon_xofa_reinit_fixed(ascon_xofa_state_t *state, size_t outlen)
Re-initializes the state for an incremental ASCON-XOFA operation, with a fixed output length.
void ascon_xofa(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with ASCON-XOFA and generates a fixed-length 32 byte output.
void ascon_xofa_reinit_custom(ascon_xofa_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-XOFA operation, with a named function,...
void ascon_xofa_absorb(ascon_xofa_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an ASCON-XOFA state.
void ascon_xofa_init_custom(ascon_xofa_state_t *state, const char *function_name, const unsigned char *custom, size_t customlen, size_t outlen)
Initializes the state for an incremental ASCON-XOFA operation, with a named function,...
void ascon_xofa_init_fixed(ascon_xofa_state_t *state, size_t outlen)
Initializes the state for an incremental ASCON-XOFA operation, with a fixed output length.
void ascon_xofa_absorb_custom(ascon_xofa_state_t *state, const unsigned char *custom, size_t customlen)
Absorbs a customization string into an ASCON-XOFA state.
void ascon_xofa_pad(ascon_xofa_state_t *state)
Absorbs enough zeroes into an ASCON-XOFA state to pad the input to the next multiple of the block rat...
void ascon_xofa_init(ascon_xofa_state_t *state)
Initializes the state for an ASCON-XOFA hashing operation.
void ascon_xofa_copy(ascon_xofa_state_t *dest, const ascon_xofa_state_t *src)
Clones a copy of an ASCON-XOFA state.
void ascon_xofa_free(ascon_xofa_state_t *state)
Frees the ASCON-XOFA state and destroys any sensitive material.
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-XOFA 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_HASHA_SIZE
Size of the hash output for ASCON-HASHA and the default hash output size for ASCON-XOFA.