ASCON Suite
Macros
ascon-sliced32.h File Reference
#include <ascon/permutation.h>
#include "ascon-select-backend.h"

Go to the source code of this file.

Macros

#define ascon_set_sliced(state, data, offset)
 Sets data into the ASCON state in sliced form. More...
 
#define ascon_set_word64(state, value, offset)
 
#define ascon_absorb_sliced(state, data, offset)
 Absorbs data into the ASCON state in sliced form. More...
 
#define ascon_absorb_word64(state, value, offset)
 Absorbs data into the ASCON state in sliced form. More...
 
#define ascon_absorb32_low_sliced(state, data, offset)
 Absorbs 32 bits of data into the ASCON state in sliced form. More...
 
#define ascon_absorb32_high_sliced(state, data, offset)
 Absorbs 32 bits of data into the ASCON state in sliced form. More...
 
#define ascon_squeeze_sliced(state, data, offset)
 Squeezes data from the ASCON state in sliced form. More...
 
#define ascon_squeeze_word64(state, value, offset)
 Squeezes a 64-bit from the ASCON state in sliced form. More...
 
#define ascon_encrypt_sliced(state, c, m, offset)
 Encrypts data using the ASCON state in sliced form. More...
 
#define ascon_decrypt_sliced(state, m, c, offset)
 Decrypts data using the ASCON state in sliced form. More...
 
#define ascon_decrypt_sliced_no_insert(state, m, c, offset)
 Decrypts data using the ASCON state in sliced form but do not insert the ciphertext back into the state. More...
 

Macro Definition Documentation

◆ ascon_absorb32_high_sliced

#define ascon_absorb32_high_sliced (   state,
  data,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high = be_load_word32((data)); \
ascon_separate(high); \
s->W[(offset) * 2] ^= (high << 16); \
s->W[(offset) * 2 + 1] ^= (high & 0xFFFF0000U); \
} while (0)
#define be_load_word32(ptr)
Definition: ascon-util.h:68
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
unsigned char data[8]
[snippet_key]
Definition: snippets.c:14

Absorbs 32 bits of data into the ASCON state in sliced form.

Parameters
stateThe ASCON state for the data to be absorbed into.
dataPoints to 4 bytes of data in big-endian byte order to absorb.
offsetOffset of the 64-bit word within the state to absorb at, between 0 and 4.

The data is absorbed into the high bits of the 64-bit word at offset.

Definition at line 173 of file ascon-sliced32.h.

◆ ascon_absorb32_low_sliced

#define ascon_absorb32_low_sliced (   state,
  data,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t low = be_load_word32((data)); \
ascon_separate(low); \
s->W[(offset) * 2] ^= (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] ^= (low >> 16); \
} while (0)

Absorbs 32 bits of data into the ASCON state in sliced form.

Parameters
stateThe ASCON state for the data to be absorbed into.
dataPoints to 4 bytes of data in big-endian byte order to absorb.
offsetOffset of the 64-bit word within the state to absorb at, between 0 and 4.

The data is absorbed into the low bits of the 64-bit word at offset.

Definition at line 154 of file ascon-sliced32.h.

◆ ascon_absorb_sliced

#define ascon_absorb_sliced (   state,
  data,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high = be_load_word32((data)); \
uint32_t low = be_load_word32((data) + 4); \
ascon_separate(high); \
ascon_separate(low); \
s->W[(offset) * 2] ^= (high << 16) | (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] ^= (high & 0xFFFF0000U) | (low >> 16); \
} while (0)

Absorbs data into the ASCON state in sliced form.

Parameters
stateThe ASCON state for the data to be absorbed into.
dataPoints to 8 bytes of data in big-endian byte order to absorb.
offsetOffset of the 64-bit word within the state to absorb at, between 0 and 4.

Definition at line 114 of file ascon-sliced32.h.

◆ ascon_absorb_word64

#define ascon_absorb_word64 (   state,
  value,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high = (uint32_t)((value) >> 32); \
uint32_t low = (uint32_t)(value); \
ascon_separate(high); \
ascon_separate(low); \
s->W[(offset) * 2] ^= (high << 16) | (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] ^= (high & 0xFFFF0000U) | (low >> 16); \
} while (0)

Absorbs data into the ASCON state in sliced form.

Parameters
stateThe ASCON state for the data to be absorbed into.
valueValue as a 64-bit word in big endian order.
offsetOffset of the 64-bit word within the state to absorb at, between 0 and 4.

Definition at line 133 of file ascon-sliced32.h.

◆ ascon_decrypt_sliced

#define ascon_decrypt_sliced (   state,
  m,
  c,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high, low, high2, low2; \
high = be_load_word32((c)); \
low = be_load_word32((c) + 4); \
ascon_separate(high); \
ascon_separate(low); \
high2 = high ^ ((s->W[(offset) * 2] >> 16) | \
(s->W[(offset) * 2 + 1] & 0xFFFF0000U)); \
low2 = low ^ ((s->W[(offset) * 2] & 0x0000FFFFU) | \
(s->W[(offset) * 2 + 1] << 16)); \
s->W[(offset) * 2] = (high << 16) | (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] = (high & 0xFFFF0000U) | (low >> 16); \
ascon_combine(high2); \
ascon_combine(low2); \
be_store_word32((m), high2); \
be_store_word32((m) + 4, low2); \
} while (0)

Decrypts data using the ASCON state in sliced form.

Parameters
stateThe ASCON state.
mPoints to 8 bytes of output plaintext in big-endian byte order.
cPoints to 8 bytes of input ciphertext in big-endian byte order.
offsetOffset of the 64-bit word within the state to absorb and squeeze at, between 0 and 4.

Definition at line 262 of file ascon-sliced32.h.

◆ ascon_decrypt_sliced_no_insert

#define ascon_decrypt_sliced_no_insert (   state,
  m,
  c,
  offset 
)
Value:
do { \
const ascon_state_t *s = (state); \
uint32_t high, low; \
high = be_load_word32((c)); \
low = be_load_word32((c) + 4); \
ascon_separate(high); \
ascon_separate(low); \
high ^= ((s->W[(offset) * 2] >> 16) | \
(s->W[(offset) * 2 + 1] & 0xFFFF0000U)); \
low ^= ((s->W[(offset) * 2] & 0x0000FFFFU) | \
(s->W[(offset) * 2 + 1] << 16)); \
ascon_combine(high); \
ascon_combine(low); \
be_store_word32((m), high); \
be_store_word32((m) + 4, low); \
} while (0)
Structure of the internal state of the ASCON permutation.
Definition: permutation.h:63

Decrypts data using the ASCON state in sliced form but do not insert the ciphertext back into the state.

Parameters
stateThe ASCON state.
mPoints to 8 bytes of output plaintext in big-endian byte order.
cPoints to 8 bytes of input ciphertext in big-endian byte order.
offsetOffset of the 64-bit word within the state to absorb and squeeze at, between 0 and 4.

Definition at line 292 of file ascon-sliced32.h.

◆ ascon_encrypt_sliced

#define ascon_encrypt_sliced (   state,
  c,
  m,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high = be_load_word32((m)); \
uint32_t low = be_load_word32((m) + 4); \
ascon_separate(high); \
ascon_separate(low); \
s->W[(offset) * 2] ^= (high << 16) | (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] ^= (high & 0xFFFF0000U) | (low >> 16); \
high = (s->W[(offset) * 2] >> 16) | \
(s->W[(offset) * 2 + 1] & 0xFFFF0000U); \
low = (s->W[(offset) * 2] & 0x0000FFFFU) | \
(s->W[(offset) * 2 + 1] << 16); \
ascon_combine(high); \
ascon_combine(low); \
be_store_word32((c), high); \
be_store_word32((c) + 4, low); \
} while (0)

Encrypts data using the ASCON state in sliced form.

Parameters
stateThe ASCON state.
cPoints to 8 bytes of output ciphertext in big-endian byte order.
mPoints to 8 bytes of input plaintext in big-endian byte order.
offsetOffset of the 64-bit word within the state to absorb and squeeze at, between 0 and 4.

Definition at line 234 of file ascon-sliced32.h.

◆ ascon_set_sliced

#define ascon_set_sliced (   state,
  data,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high = be_load_word32((data)); \
uint32_t low = be_load_word32((data) + 4); \
ascon_separate(high); \
ascon_separate(low); \
s->W[(offset) * 2] = (high << 16) | (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] = (high & 0xFFFF0000U) | (low >> 16); \
} while (0)

Sets data into the ASCON state in sliced form.

Parameters
stateThe ASCON state for the data to be absorbed into.
dataPoints to 8 bytes of data in big-endian byte order to set.
offsetOffset of the 64-bit word within the state to set at, between 0 and 4.

Definition at line 76 of file ascon-sliced32.h.

◆ ascon_set_word64

#define ascon_set_word64 (   state,
  value,
  offset 
)
Value:
do { \
ascon_state_t *s = (state); \
uint32_t high = (uint32_t)((value) >> 32); \
uint32_t low = (uint32_t)(value); \
ascon_separate(high); \
ascon_separate(low); \
s->W[(offset) * 2] = (high << 16) | (low & 0x0000FFFFU); \
s->W[(offset) * 2 + 1] = (high & 0xFFFF0000U) | (low >> 16); \
} while (0)

Definition at line 95 of file ascon-sliced32.h.

◆ ascon_squeeze_sliced

#define ascon_squeeze_sliced (   state,
  data,
  offset 
)
Value:
do { \
const ascon_state_t *s = (state); \
uint32_t high, low; \
high = (s->W[(offset) * 2] >> 16) | \
(s->W[(offset) * 2 + 1] & 0xFFFF0000U); \
low = (s->W[(offset) * 2] & 0x0000FFFFU) | \
(s->W[(offset) * 2 + 1] << 16); \
ascon_combine(high); \
ascon_combine(low); \
be_store_word32((data), high); \
be_store_word32((data) + 4, low); \
} while (0)

Squeezes data from the ASCON state in sliced form.

Parameters
stateThe ASCON state to extract the data from.
dataPoints to the 8 bytes to be extracted from the state.
offsetOffset of the 64-bit word within the state to extract, between 0 and 4.

Definition at line 190 of file ascon-sliced32.h.

◆ ascon_squeeze_word64

#define ascon_squeeze_word64 (   state,
  value,
  offset 
)
Value:
do { \
const ascon_state_t *s = (state); \
uint32_t high, low; \
high = (s->W[(offset) * 2] >> 16) | \
(s->W[(offset) * 2 + 1] & 0xFFFF0000U); \
low = (s->W[(offset) * 2] & 0x0000FFFFU) | \
(s->W[(offset) * 2 + 1] << 16); \
ascon_combine(high); \
ascon_combine(low); \
(value) = (((uint64_t)high) << 32) | low; \
} while (0)

Squeezes a 64-bit from the ASCON state in sliced form.

Parameters
stateThe ASCON state to extract the data from.
valueReturns the 64-bit word that is squeezed out.
offsetOffset of the 64-bit word within the state to extract, between 0 and 4.

Definition at line 212 of file ascon-sliced32.h.