ASCON Suite
kmac.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_KMAC_H
24 #define ASCON_KMAC_H
25 
26 #include <ascon/xof.h>
27 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 #define ASCON_KMAC_SIZE ASCON_HASH_SIZE
54 
58 #define ASCON_KMACA_SIZE ASCON_HASHA_SIZE
59 
63 typedef struct
64 {
68 
72 typedef struct
73 {
77 
93 void ascon_kmac
94  (const unsigned char *key, size_t keylen,
95  const unsigned char *in, size_t inlen,
96  const unsigned char *custom, size_t customlen,
97  unsigned char *out, size_t outlen);
98 
111 void ascon_kmac_init
112  (ascon_kmac_state_t *state, const unsigned char *key, size_t keylen,
113  const unsigned char *custom, size_t customlen, size_t outlen);
114 
131  (ascon_kmac_state_t *state, const unsigned char *key, size_t keylen,
132  const unsigned char *custom, size_t customlen, size_t outlen);
133 
140 
151  (ascon_kmac_state_t *state, const unsigned char *in, size_t inlen);
152 
163  (ascon_kmac_state_t *state, unsigned char *out, size_t outlen);
164 
180 void ascon_kmaca
181  (const unsigned char *key, size_t keylen,
182  const unsigned char *in, size_t inlen,
183  const unsigned char *custom, size_t customlen,
184  unsigned char *out, size_t outlen);
185 
198 void ascon_kmaca_init
199  (ascon_kmaca_state_t *state, const unsigned char *key, size_t keylen,
200  const unsigned char *custom, size_t customlen, size_t outlen);
201 
218  (ascon_kmaca_state_t *state, const unsigned char *key, size_t keylen,
219  const unsigned char *custom, size_t customlen, size_t outlen);
220 
227 
238  (ascon_kmaca_state_t *state, const unsigned char *in, size_t inlen);
239 
250  (ascon_kmaca_state_t *state, unsigned char *out, size_t outlen);
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif
void ascon_kmaca_absorb(ascon_kmaca_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an incremental ASCON-KMACA state.
Definition: ascon-kmaca.c:111
void ascon_kmaca_init(ascon_kmaca_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
Initializes an incremental KMAC state using ASCON-XOFA.
Definition: ascon-kmaca.c:84
void ascon_kmac_reinit(ascon_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
Re-initializes an incremental KMAC state using ASCON-XOF.
Definition: ascon-kmac.c:97
void ascon_kmac_absorb(ascon_kmac_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an incremental ASCON-KMAC state.
Definition: ascon-kmac.c:111
void ascon_kmac_free(ascon_kmac_state_t *state)
Frees the ASCON-KMAC state and destroys any sensitive material.
Definition: ascon-kmac.c:104
void ascon_kmac_squeeze(ascon_kmac_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an incremental ASCON-KMAC state.
Definition: ascon-kmac.c:117
void ascon_kmac_init(ascon_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
Initializes an incremental KMAC state using ASCON-XOF.
Definition: ascon-kmac.c:84
void ascon_kmaca(const unsigned char *key, size_t keylen, const unsigned char *in, size_t inlen, const unsigned char *custom, size_t customlen, unsigned char *out, size_t outlen)
Computes a KMAC value using ASCON-XOFA.
Definition: ascon-kmaca.c:71
void ascon_kmaca_free(ascon_kmaca_state_t *state)
Frees the ASCON-KMACA state and destroys any sensitive material.
Definition: ascon-kmaca.c:104
void ascon_kmaca_squeeze(ascon_kmaca_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an incremental ASCON-KMACA state.
Definition: ascon-kmaca.c:117
void ascon_kmaca_reinit(ascon_kmaca_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen, size_t outlen)
Re-initializes an incremental KMAC state using ASCON-XOFA.
Definition: ascon-kmaca.c:97
void ascon_kmac(const unsigned char *key, size_t keylen, const unsigned char *in, size_t inlen, const unsigned char *custom, size_t customlen, unsigned char *out, size_t outlen)
Computes a KMAC value using ASCON-XOF.
Definition: ascon-kmac.c:71
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
State information for the ASCON-KMAC incremental mode.
Definition: kmac.h:64
ascon_xof_state_t xof
Definition: kmac.h:65
State information for the ASCON-KMACA incremental mode.
Definition: kmac.h:73
ascon_xofa_state_t xof
Definition: kmac.h:74
State information for ASCON-XOF incremental mode.
Definition: xof.h:61
State information for ASCON-XOFA incremental mode.
Definition: xof.h:72
ASCON-XOF and ASCON-XOFA extensible output functions (XOF's).