Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
ascon-kmac.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 LWCRYPTO_ASCON_KMAC_H
24 #define LWCRYPTO_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 
60 
76 void ascon_kmac
77  (const unsigned char *key, size_t keylen,
78  const unsigned char *in, size_t inlen,
79  const unsigned char *custom, size_t customlen,
80  unsigned char *out, size_t outlen);
81 
93 void ascon_kmac_init
94  (ascon_kmac_state_t *state, const unsigned char *key, size_t keylen,
95  const unsigned char *custom, size_t customlen);
96 
107  (ascon_kmac_state_t *state, const unsigned char *in, size_t inlen);
108 
118 void ascon_kmac_set_output_length(ascon_kmac_state_t *state, size_t outlen);
119 
135  (ascon_kmac_state_t *state, unsigned char *out, size_t outlen);
136 
151  (ascon_kmac_state_t *state, unsigned char out[ASCON_KMAC_SIZE]);
152 
168 void ascon_kmaca
169  (const unsigned char *key, size_t keylen,
170  const unsigned char *in, size_t inlen,
171  const unsigned char *custom, size_t customlen,
172  unsigned char *out, size_t outlen);
173 
185 void ascon_kmaca_init
186  (ascon_kmac_state_t *state, const unsigned char *key, size_t keylen,
187  const unsigned char *custom, size_t customlen);
188 
199  (ascon_kmac_state_t *state, const unsigned char *in, size_t inlen);
200 
210 void ascon_kmaca_set_output_length(ascon_kmac_state_t *state, size_t outlen);
211 
227  (ascon_kmac_state_t *state, unsigned char *out, size_t outlen);
228 
243  (ascon_kmac_state_t *state, unsigned char out[ASCON_KMAC_SIZE]);
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif
void ascon_kmaca_init(ascon_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen)
Initializes an incremental KMAC state using ASCON-XOFA.
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.
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.
void ascon_kmac_set_output_length(ascon_kmac_state_t *state, size_t outlen)
Sets the desired output length for an incremental ASCON-KMAC state.
void ascon_kmac_squeeze(ascon_kmac_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an incremental ASCON-KMAC state.
#define ASCON_KMAC_SIZE
Default size of the output for ASCON-KMAC and ASCON-KMACA.
Definition: ascon-kmac.h:53
void ascon_kmaca_finalize(ascon_kmac_state_t *state, unsigned char out[ASCON_KMAC_SIZE])
Squeezes fixed-length data from an incremental ASCON-KMACA state and finalizes the KMAC process...
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.
void ascon_kmac_init(ascon_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen)
Initializes an incremental KMAC state using ASCON-XOF.
void ascon_kmaca_absorb(ascon_kmac_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an incremental ASCON-KMACA state.
State information for ASCON-XOF and ASCON-XOFA incremental modes.
Definition: ascon-xof.h:54
ascon_xof_state_t ascon_kmac_state_t
State information for the ASCON-KMAC and ASCON-KMACA incremental modes.
Definition: ascon-kmac.h:59
void ascon_kmac_finalize(ascon_kmac_state_t *state, unsigned char out[ASCON_KMAC_SIZE])
Squeezes fixed-length data from an incremental ASCON-KMAC state and finalizes the KMAC process...
void ascon_kmaca_squeeze(ascon_kmac_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an incremental ASCON-KMACA state.
void ascon_kmaca_set_output_length(ascon_kmac_state_t *state, size_t outlen)
Sets the desired output length for an incremental ASCON-KMACA state.