sha3.h
Go to the documentation of this file.
1 /*-
2  * Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
3  * Joan Daemen, MichaĆ«l Peeters, Gilles Van Assche and Ronny Van Keer, hereby
4  * denoted as "the implementer".
5  *
6  * RIOT-OS adaptation by Mathias Tausig
7  *
8  * This software is released under the Creative Commons CC0 1.0 license.
9  * To the extent possible under law, the implementer has waived all copyright
10  * and related or neighboring rights to the source code in this file.
11  * For more information see: http://creativecommons.org/publicdomain/zero/1.0/
12  */
13 
27 #ifndef HASHES_SHA3_H
28 #define HASHES_SHA3_H
29 
30 #include <stdlib.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 #define SHA3_256_DIGEST_LENGTH 32
40 
44 #define SHA3_384_DIGEST_LENGTH 48
45 
49 #define SHA3_512_DIGEST_LENGTH 64
50 
54 typedef struct {
56  unsigned char state[200];
58  unsigned int i;
60  unsigned char delimitedSuffix;
62  unsigned int rate;
64  unsigned int capacity;
66  unsigned int rateInBytes;
68 
77 void Keccak_init(keccak_state_t *ctx, unsigned int rate, unsigned int capacity,
78  unsigned char delimitedSuffix);
79 
87 void Keccak_update(keccak_state_t *ctx, const unsigned char *input,
88  unsigned long long int inputByteLen);
89 
97 void Keccak_final(keccak_state_t *ctx, unsigned char *output,
98  unsigned long long int outputByteLen);
99 
105 void sha3_256_init(keccak_state_t *ctx);
106 
114 void sha3_update(keccak_state_t *ctx, const void *data, size_t len);
115 
122 void sha3_256_final(keccak_state_t *ctx, void *digest);
123 
129 void sha3_384_init(keccak_state_t *ctx);
130 
137 void sha3_384_final(keccak_state_t *ctx, void *digest);
138 
144 void sha3_512_init(keccak_state_t *ctx);
145 
153 void sha3_512_final(keccak_state_t *ctx, void *digest);
154 
164 void sha3_256(void *digest, const void *data, size_t len);
165 
175 void sha3_384(void *digest, const void *data, size_t len);
176 
186 void sha3_512(void *digest, const void *data, size_t len);
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif /* HASHES_SHA3_H */
193 
Keccak_update
void Keccak_update(keccak_state_t *ctx, const unsigned char *input, unsigned long long int inputByteLen)
Absorbs data into a sponge.
sha3_512
void sha3_512(void *digest, const void *data, size_t len)
A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-512 from ...
keccak_state_t::rateInBytes
unsigned int rateInBytes
The rate in bytes of the sponge.
Definition: sha3.h:66
sha3_256_final
void sha3_256_final(keccak_state_t *ctx, void *digest)
SHA3-256 finalization.
sha3_update
void sha3_update(keccak_state_t *ctx, const void *data, size_t len)
Add bytes into the hash.
sha3_512_init
void sha3_512_init(keccak_state_t *ctx)
SHA3-512 initialization.
sha3_256_init
void sha3_256_init(keccak_state_t *ctx)
SHA3-256 initialization.
Keccak_init
void Keccak_init(keccak_state_t *ctx, unsigned int rate, unsigned int capacity, unsigned char delimitedSuffix)
Initialise a sponge based on a keccak-1600 permutation.
keccak_state_t::i
unsigned int i
Current position within the state.
Definition: sha3.h:58
sha3_384_init
void sha3_384_init(keccak_state_t *ctx)
SHA3-384 initialization.
keccak_state_t::delimitedSuffix
unsigned char delimitedSuffix
The suffix used for padding.
Definition: sha3.h:60
keccak_state_t::rate
unsigned int rate
The bitrate of the sponge.
Definition: sha3.h:62
keccak_state_t::capacity
unsigned int capacity
The capacity in bits of the sponge.
Definition: sha3.h:64
sha3_384
void sha3_384(void *digest, const void *data, size_t len)
A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-384 from ...
keccak_state_t
Context for operations on a sponge with keccak permutation.
Definition: sha3.h:54
sha3_384_final
void sha3_384_final(keccak_state_t *ctx, void *digest)
SHA3-384 finalization.
sha3_512_final
void sha3_512_final(keccak_state_t *ctx, void *digest)
SHA3-512 finalization.
Keccak_final
void Keccak_final(keccak_state_t *ctx, unsigned char *output, unsigned long long int outputByteLen)
Squeeze data from a sponge.
sha3_256
void sha3_256(void *digest, const void *data, size_t len)
A wrapper function to simplify the generation of a hash, this is useful for generating SHA3-256 from ...