ASCON Suite
permutation.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef ASCON_PERMUTATION_H
24 #define ASCON_PERMUTATION_H
25 
26 #include <stdint.h>
27 #include <stddef.h>
28 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
62 typedef union
63 {
64  uint64_t S[5];
65  uint32_t W[10];
66  uint8_t B[40];
67  void *P[40 / sizeof(void *)];
70 
87 
106 
115 void ascon_add_bytes
116  (ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size);
117 
127  (ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size);
128 
137  (ascon_state_t *state, unsigned offset, unsigned size);
138 
148  (const ascon_state_t *state, uint8_t *data, unsigned offset, unsigned size);
149 
161  (const ascon_state_t *state, const uint8_t *input, uint8_t *output,
162  unsigned offset, unsigned size);
163 
182  (ascon_state_t *state, const uint8_t *input, uint8_t *output,
183  unsigned offset, unsigned size);
184 
192 void ascon_permute(ascon_state_t *state, uint8_t first_round);
193 
199 #define ascon_permute12(state) ascon_permute((state), 0)
200 
206 #define ascon_permute8(state) ascon_permute((state), 4)
207 
213 #define ascon_permute6(state) ascon_permute((state), 6)
214 
233 
243 
253 void ascon_copy(ascon_state_t *dest, const ascon_state_t *src);
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif
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_permute(ascon_state_t *state, uint8_t first_round)
Permutes the ASCON state with a specified number of rounds.
Definition: ascon-c32.c:36
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]
Definition: snippets.c:2
unsigned char data[8]
[snippet_key]
Definition: snippets.c:14
Structure of the internal state of the ASCON permutation.
Definition: permutation.h:63