Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
sparkle-hash.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_HASH_H
24 #define LWCRYPTO_SPARKLE_HASH_H
25 
26 #include <stddef.h>
27 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 #define ESCH_256_HASH_SIZE 32
54 
58 #define ESCH_256_RATE 16
59 
63 #define ESCH_384_HASH_SIZE 48
64 
68 #define ESCH_384_RATE 16
69 
74 typedef union
75 {
76  struct {
77  unsigned char state[48];
78  unsigned char block[16];
79  unsigned char count;
80  unsigned char mode;
81  } s;
82  unsigned long long align;
85 
90 typedef union
91 {
92  struct {
93  unsigned char state[64];
94  unsigned char block[16];
95  unsigned char count;
96  unsigned char mode;
97  } s;
98  unsigned long long align;
101 
113 int esch_256_hash(unsigned char *out, const unsigned char *in, size_t inlen);
114 
127 int esch_256_xof(unsigned char *out, const unsigned char *in, size_t inlen);
128 
138 
149  (esch_256_hash_state_t *state, const unsigned char *in, size_t inlen);
150 
163  (esch_256_hash_state_t *state, unsigned char *out);
164 
175  (esch_256_hash_state_t *state, unsigned char *out, size_t outlen);
176 
188 int esch_384_hash(unsigned char *out, const unsigned char *in, size_t inlen);
189 
202 int esch_384_xof(unsigned char *out, const unsigned char *in, size_t inlen);
203 
213 
224  (esch_384_hash_state_t *state, const unsigned char *in, size_t inlen);
225 
238  (esch_384_hash_state_t *state, unsigned char *out);
239 
250  (esch_384_hash_state_t *state, unsigned char *out, size_t outlen);
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif
unsigned char mode
Definition: sparkle-hash.h:96
void esch_384_hash_finalize(esch_384_hash_state_t *state, unsigned char *out)
Returns the final hash value from an Esch384 hashing operation.
Definition: sparkle-hash.c:388
void esch_256_hash_update(esch_256_hash_state_t *state, const unsigned char *in, size_t inlen)
Updates an Esch256 or XOEsch256 state with more input data.
Definition: sparkle-hash.c:148
void esch_384_hash_init(esch_384_hash_state_t *state)
Initializes the state for an Esch384 hashing or a XOEsch384 XOF operation.
Definition: sparkle-hash.c:355
unsigned char count
Definition: sparkle-hash.h:95
int esch_256_xof(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with XOEsch256 to generate an XOF output value.
Definition: sparkle-hash.c:112
int esch_384_hash(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with Esch384 to generate a hash value.
Definition: sparkle-hash.c:291
int esch_384_xof(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with XOEsch384 to generate an XOF output value.
Definition: sparkle-hash.c:323
void esch_256_hash_squeeze(esch_256_hash_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from a XOEsch256 XOF state.
Definition: sparkle-hash.c:197
unsigned char mode
Definition: sparkle-hash.h:80
State information for the Esch384 incremental hash mod ande the XOEsch384 increment XOF mode...
Definition: sparkle-hash.h:90
void esch_256_hash_finalize(esch_256_hash_state_t *state, unsigned char *out)
Returns the final hash value from an Esch256 hashing operation.
Definition: sparkle-hash.c:175
unsigned char count
Definition: sparkle-hash.h:79
void esch_384_hash_squeeze(esch_384_hash_state_t *state, unsigned char *out, size_t outlen)
Squeezes output data from a XOEsch384 XOF state.
Definition: sparkle-hash.c:412
State information for the Esch256 incremental hash mode and the XOEsch256 increment XOF mode...
Definition: sparkle-hash.h:74
unsigned long long align
Definition: sparkle-hash.h:98
unsigned long long align
Definition: sparkle-hash.h:82
void esch_384_hash_update(esch_384_hash_state_t *state, const unsigned char *in, size_t inlen)
Updates an Esch384 state with more input data.
Definition: sparkle-hash.c:361
int esch_256_hash(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with Esch256 to generate a hash value.
Definition: sparkle-hash.c:82
void esch_256_hash_init(esch_256_hash_state_t *state)
Initializes the state for an Esch256 hashing or a XOEsch256 XOF operation.
Definition: sparkle-hash.c:142