Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
sparkle-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_SPARKLE_KMAC_H
24 #define LWCRYPTO_SPARKLE_KMAC_H
25 
26 #include "sparkle-hash.h"
27 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
50 #define ESCH_256_KMAC_SIZE ESCH_256_HASH_SIZE
51 
55 #define ESCH_384_KMAC_SIZE ESCH_384_HASH_SIZE
56 
61 
77 void esch_256_kmac
78  (const unsigned char *key, size_t keylen,
79  const unsigned char *in, size_t inlen,
80  const unsigned char *custom, size_t customlen,
81  unsigned char *out, size_t outlen);
82 
95  (esch_256_kmac_state_t *state, const unsigned char *key, size_t keylen,
96  const unsigned char *custom, size_t customlen);
97 
108  (esch_256_kmac_state_t *state, const unsigned char *in, size_t inlen);
109 
121  (esch_256_kmac_state_t *state, size_t outlen);
122 
138  (esch_256_kmac_state_t *state, unsigned char *out, size_t outlen);
139 
154  (esch_256_kmac_state_t *state, unsigned char out[ESCH_256_KMAC_SIZE]);
155 
160 
176 void esch_384_kmac
177  (const unsigned char *key, size_t keylen,
178  const unsigned char *in, size_t inlen,
179  const unsigned char *custom, size_t customlen,
180  unsigned char *out, size_t outlen);
181 
194  (esch_384_kmac_state_t *state, const unsigned char *key, size_t keylen,
195  const unsigned char *custom, size_t customlen);
196 
207  (esch_384_kmac_state_t *state, const unsigned char *in, size_t inlen);
208 
220  (esch_384_kmac_state_t *state, size_t outlen);
221 
237  (esch_384_kmac_state_t *state, unsigned char *out, size_t outlen);
238 
253  (esch_384_kmac_state_t *state, unsigned char out[ESCH_384_KMAC_SIZE]);
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif
void esch_256_kmac_squeeze(esch_256_kmac_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an incremental XOEsch256-KMAC state.
#define ESCH_256_KMAC_SIZE
Default size of the output for XOEsch256-KMAC.
Definition: sparkle-kmac.h:50
void esch_256_kmac_finalize(esch_256_kmac_state_t *state, unsigned char out[ESCH_256_KMAC_SIZE])
Squeezes fixed-length data from an incremental XOEsch256-KMAC state and finalizes the KMAC process...
esch_384_hash_state_t esch_384_kmac_state_t
State information for the XOEsch384-KMAC incremental mode.
Definition: sparkle-kmac.h:159
Hash algorithms based on the SPARKLE permutation.
void esch_384_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 the XOEsch384 XOF mode.
void esch_256_kmac_absorb(esch_256_kmac_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an incremental XOEsch256-KMAC state.
void esch_256_kmac_set_output_length(esch_256_kmac_state_t *state, size_t outlen)
Sets the desired output length for an incremental XOEsch256-KMAC state.
State information for the Esch384 incremental hash mod ande the XOEsch384 increment XOF mode...
Definition: sparkle-hash.h:90
void esch_384_kmac_absorb(esch_384_kmac_state_t *state, const unsigned char *in, size_t inlen)
Absorbs more input data into an incremental XOEsch384-KMAC state.
void esch_384_kmac_squeeze(esch_384_kmac_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from an incremental XOEsch384-KMAC state.
void esch_384_kmac_set_output_length(esch_384_kmac_state_t *state, size_t outlen)
Sets the desired output length for an incremental XOEsch384-KMAC state.
#define ESCH_384_KMAC_SIZE
Default size of the output for XOEsch384-KMAC.
Definition: sparkle-kmac.h:55
void esch_384_kmac_finalize(esch_384_kmac_state_t *state, unsigned char out[ESCH_384_KMAC_SIZE])
Squeezes fixed-length data from an incremental XOEsch384-KMAC state and finalizes the KMAC process...
void esch_384_kmac_init(esch_384_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen)
Initializes an incremental KMAC state using the XOEsch384 XOF mode.
State information for the Esch256 incremental hash mode and the XOEsch256 increment XOF mode...
Definition: sparkle-hash.h:74
esch_256_hash_state_t esch_256_kmac_state_t
State information for the XOEsch256-KMAC incremental mode.
Definition: sparkle-kmac.h:60
void esch_256_kmac_init(esch_256_kmac_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *custom, size_t customlen)
Initializes an incremental KMAC state using the XOEsch256 XOF mode.
void esch_256_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 the XOEsch256 XOF mode.