ASCON Suite
prf.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_PRF_H
24 #define ASCON_PRF_H
25 
56 #include <ascon/permutation.h>
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
65 #define ASCON_PRF_KEY_SIZE 16
66 
70 #define ASCON_PRF_TAG_SIZE 16
71 
75 #define ASCON_PRF_SHORT_KEY_SIZE ASCON_PRF_KEY_SIZE
76 
80 #define ASCON_PRF_SHORT_MAX_INPUT_SIZE 16
81 
85 #define ASCON_PRF_SHORT_MAX_OUTPUT_SIZE 16
86 
90 #define ASCON_PRF_SHORT_TAG_SIZE ASCON_PRF_SHORT_MAX_OUTPUT_SIZE
91 
95 #define ASCON_MAC_KEY_SIZE ASCON_PRF_KEY_SIZE
96 
100 #define ASCON_MAC_TAG_SIZE ASCON_PRF_TAG_SIZE
101 
107 typedef struct
108 {
110  unsigned char count;
111  unsigned char mode;
114 
131 void ascon_prf
132  (unsigned char *out, size_t outlen,
133  const unsigned char *in, size_t inlen,
134  const unsigned char *key);
135 
153 void ascon_prf_fixed
154  (unsigned char *out, size_t outlen,
155  const unsigned char *in, size_t inlen,
156  const unsigned char *key);
157 
175 int ascon_prf_short
176  (unsigned char *out, size_t outlen,
177  const unsigned char *in, size_t inlen,
178  const unsigned char *key);
179 
193 void ascon_mac
194  (unsigned char *tag,
195  const unsigned char *in, size_t inlen,
196  const unsigned char *key);
197 
211  (const unsigned char *tag,
212  const unsigned char *in, size_t inlen,
213  const unsigned char *key);
214 
225 void ascon_prf_init(ascon_prf_state_t *state, const unsigned char *key);
226 
240  (ascon_prf_state_t *state, const unsigned char *key, size_t outlen);
241 
253 void ascon_prf_reinit(ascon_prf_state_t *state, const unsigned char *key);
254 
269  (ascon_prf_state_t *state, const unsigned char *key, size_t outlen);
270 
277 
287 void ascon_prf_absorb
288  (ascon_prf_state_t *state, const unsigned char *in, size_t inlen);
289 
303  (ascon_prf_state_t *state, unsigned char *out, size_t outlen);
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 
309 #endif
Direct access to the ASCON permutation primitive.
void ascon_prf_free(ascon_prf_state_t *state)
Frees the ASCON-Prf state and destroys any sensitive material.
Definition: ascon-prf.c:146
void ascon_prf(unsigned char *out, size_t outlen, const unsigned char *in, size_t inlen, const unsigned char *key)
Processes a key and input data with ASCON-Prf to produce a tag.
Definition: ascon-prf.c:39
void ascon_prf_fixed(unsigned char *out, size_t outlen, const unsigned char *in, size_t inlen, const unsigned char *key)
Processes a key and input data with ASCON-Prf to produce a fixed-length output tag.
Definition: ascon-prf.c:51
void ascon_prf_fixed_init(ascon_prf_state_t *state, const unsigned char *key, size_t outlen)
Initializes the state for an incremental ASCON-Prf operation with fixed-length output.
Definition: ascon-prf.c:116
void ascon_mac(unsigned char *tag, const unsigned char *in, size_t inlen, const unsigned char *key)
Processes a key and input data with ASCON-Mac to produce a tag.
Definition: ascon-prf.c:86
int ascon_prf_short(unsigned char *out, size_t outlen, const unsigned char *in, size_t inlen, const unsigned char *key)
Processes a key and input data with ASCON-PrfShort to produce a tag.
Definition: ascon-prf.c:63
void ascon_prf_init(ascon_prf_state_t *state, const unsigned char *key)
Initializes the state for an incremental ASCON-Prf operation.
Definition: ascon-prf.c:110
void ascon_prf_squeeze(ascon_prf_state_t *state, unsigned char *out, size_t outlen)
Squeezes output from an incremental ASCON-Prf operation.
Definition: ascon-prf.c:208
void ascon_prf_reinit(ascon_prf_state_t *state, const unsigned char *key)
Re-initializes the state for an incremental ASCON-Prf operation.
Definition: ascon-prf.c:133
int ascon_mac_verify(const unsigned char *tag, const unsigned char *in, size_t inlen, const unsigned char *key)
Verifies an ASCON-Mac tag value.
Definition: ascon-prf.c:98
void ascon_prf_fixed_reinit(ascon_prf_state_t *state, const unsigned char *key, size_t outlen)
Re-initializes the state for an incremental ASCON-Prf operation with fixed-length output.
Definition: ascon-prf.c:140
void ascon_prf_absorb(ascon_prf_state_t *state, const unsigned char *in, size_t inlen)
Absorbs input data into an incremental ASCON-Prf state.
Definition: ascon-prf.c:157
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
State information for the ASCON-Prf incremental mode.
Definition: prf.h:108
ascon_state_t state
Definition: prf.h:109
unsigned char mode
Definition: prf.h:111
unsigned char count
Definition: prf.h:110
Structure of the internal state of the ASCON permutation.
Definition: permutation.h:63