30 #if defined(ASCON_BACKEND_SLICED32)
54 unsigned posn, shift, ofs, len;
57 shift = (7U - ofs) * 8U;
60 for (posn = 0; posn < len && posn < size; ++posn, shift -= 8U) {
61 value |= ((uint64_t)(
data[posn])) << shift;
77 for (posn = 0; posn < size; ++posn, shift -= 8U) {
78 value |= ((uint64_t)(
data[posn])) << shift;
88 unsigned posn, shift, ofs, len;
93 shift = (7U - ofs) * 8U;
95 for (posn = 0; posn < len && posn < size; ++posn, shift -= 8U) {
96 value &= ~(((uint64_t)0xFFU) << shift);
97 value |= ((uint64_t)(
data[posn])) << shift;
113 for (posn = 0; posn < size; ++posn, shift -= 8U) {
114 value &= ~(((uint64_t)0xFFU) << shift);
115 value |= ((uint64_t)(
data[posn])) << shift;
132 value = (value & (~((uint64_t)0)) << ((8U - ofs) * 8)) |
133 (value & ((((uint64_t)1) << ((8U - ofs - posn) * 8)) - 1U));
139 state->
S[offset / 8U] = 0;
145 value &= (~((uint64_t)0)) >> (size * 8);
154 unsigned posn, shift, ofs, len;
158 shift = (7U - ofs) * 8U;
160 for (posn = 0; posn < len && posn < size; ++posn, shift -= 8U) {
161 data[posn] = (uint8_t)(value >> shift);
176 for (posn = 0; posn < size; ++posn, shift -= 8U) {
177 data[posn] = (uint8_t)(value >> shift);
184 unsigned offset,
unsigned size)
187 unsigned posn, shift, ofs, len;
191 shift = (7U - ofs) * 8U;
193 for (posn = 0; posn < len && posn < size; ++posn, shift -= 8U) {
194 output[posn] = input[posn] ^ (uint8_t)(value >> shift);
211 for (posn = 0; posn < size; ++posn, shift -= 8U) {
212 output[posn] = input[posn] ^ (uint8_t)(value >> shift);
219 unsigned offset,
unsigned size)
222 unsigned posn, shift, ofs, len;
227 shift = (7U - ofs) * 8U;
229 for (posn = 0; posn < len && posn < size; ++posn, shift -= 8U) {
231 output[posn] = in ^ (uint8_t)(value >> shift);
232 value &= ~(((uint64_t)0xFFU) << shift);
233 value |= ((uint64_t)in) << shift;
251 for (posn = 0; posn < size; ++posn, shift -= 8U) {
253 output[posn] = in ^ (uint8_t)(value >> shift);
254 value &= ~(((uint64_t)0xFFU) << shift);
255 value |= ((uint64_t)in) << shift;
275 memcpy(dest->
W, src->
W,
sizeof(dest->
W));
void ascon_overwrite_with_zeroes(ascon_state_t *state, unsigned offset, unsigned size)
Overwrites a part of the ASCON state with zeroes.
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_extract_bytes(const ascon_state_t *state, uint8_t *data, unsigned offset, unsigned size)
Extracts bytes from the ASCON state.
void ascon_extract_and_overwrite_bytes(ascon_state_t *state, const uint8_t *input, uint8_t *output, unsigned offset, unsigned size)
Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes....
void ascon_add_bytes(ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size)
Adds bytes to the ASCON state by XOR'ing them with existing bytes.
void ascon_extract_and_add_bytes(const ascon_state_t *state, const uint8_t *input, uint8_t *output, unsigned offset, unsigned size)
Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes.
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.
#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 sta...
#define ascon_set_word64(state, value, offset)
#define ascon_squeeze_word64(state, value, offset)
Squeezes a 64-bit from the ASCON state in sliced form.
#define ascon_set_sliced(state, data, offset)
Sets data into the ASCON state in sliced form.
#define ascon_decrypt_sliced(state, m, c, offset)
Decrypts data using the ASCON state in sliced form.
#define ascon_absorb_word64(state, value, offset)
Absorbs data into the ASCON state in sliced form.
#define ascon_squeeze_sliced(state, data, offset)
Squeezes data from the ASCON state in sliced form.
#define ascon_absorb_sliced(state, data, offset)
Absorbs data into the ASCON state in sliced form.
#define ascon_backend_free(state)
#define ascon_backend_init(state)
ascon_state_t state
[snippet_key]
unsigned char data[8]
[snippet_key]
Structure of the internal state of the ASCON permutation.
System utilities of use to applications that use ASCON.
void ascon_clean(void *buf, unsigned size)
Cleans a buffer that contains sensitive material.