Loading...
Searching...
No Matches
sha3.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Keccak, Keyak and Ketje Teams
3 * SPDX-FileCopyrightText: Guido Bertoni
4 * SPDX-FileCopyrightText: Joan Daemen
5 * SPDX-FileCopyrightText: Michaƫl Peeters
6 * SPDX-FileCopyrightText: Gilles Van Assche
7 * SPDX-FileCopyrightText: Ronny Van Keer
8 * SPDX-FileCopyrightText: 2017-2018 Mathias Tausig
9 * SPDX-License-Identifier: CC0-1.0
10 */
11
24
25#ifndef HASHES_SHA3_H
26#define HASHES_SHA3_H
27
28#include <stdlib.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37#define SHA3_256_DIGEST_LENGTH 32
38
42#define SHA3_384_DIGEST_LENGTH 48
43
47#define SHA3_512_DIGEST_LENGTH 64
48
52typedef struct {
54 unsigned char state[200];
56 unsigned int i;
58 unsigned char delimitedSuffix;
60 unsigned int rate;
62 unsigned int capacity;
64 unsigned int rateInBytes;
66
75void Keccak_init(keccak_state_t *ctx, unsigned int rate, unsigned int capacity,
76 unsigned char delimitedSuffix);
77
85void Keccak_update(keccak_state_t *ctx, const unsigned char *input,
86 unsigned long long int inputByteLen);
87
95void Keccak_final(keccak_state_t *ctx, unsigned char *output,
96 unsigned long long int outputByteLen);
97
104
112void sha3_update(keccak_state_t *ctx, const void *data, size_t len);
113
120void sha3_256_final(keccak_state_t *ctx, void *digest);
121
128
135void sha3_384_final(keccak_state_t *ctx, void *digest);
136
143
150
151void sha3_512_final(keccak_state_t *ctx, void *digest);
152
162void sha3_256(void *digest, const void *data, size_t len);
163
173void sha3_384(void *digest, const void *data, size_t len);
174
184void sha3_512(void *digest, const void *data, size_t len);
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif /* HASHES_SHA3_H */
void sha3_384_final(keccak_state_t *ctx, void *digest)
SHA3-384 finalization.
void sha3_256_init(keccak_state_t *ctx)
SHA3-256 initialization.
void Keccak_update(keccak_state_t *ctx, const unsigned char *input, unsigned long long int inputByteLen)
Absorbs data into a sponge.
void Keccak_final(keccak_state_t *ctx, unsigned char *output, unsigned long long int outputByteLen)
Squeeze data from a sponge.
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.
void sha3_384_init(keccak_state_t *ctx)
SHA3-384 initialization.
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 ...
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 ...
void sha3_512_final(keccak_state_t *ctx, void *digest)
SHA3-512 finalization.
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 ...
void sha3_update(keccak_state_t *ctx, const void *data, size_t len)
Add bytes into the hash.
void sha3_512_init(keccak_state_t *ctx)
SHA3-512 initialization.
void sha3_256_final(keccak_state_t *ctx, void *digest)
SHA3-256 finalization.
Context for operations on a sponge with keccak permutation.
Definition sha3.h:52
unsigned int rate
The bitrate of the sponge.
Definition sha3.h:60
unsigned int rateInBytes
The rate in bytes of the sponge.
Definition sha3.h:64
unsigned char state[200]
State of the Keccak sponge.
Definition sha3.h:54
unsigned int capacity
The capacity in bits of the sponge.
Definition sha3.h:62
unsigned char delimitedSuffix
The suffix used for padding.
Definition sha3.h:58
unsigned int i
Current position within the state.
Definition sha3.h:56