aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/s2n/pq-crypto/kyber_r3/kyber512r3_fips202.h
blob: 1f4f395f72dbb2e5dbd29b331b1ff5dadf6af521 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once

#include <stddef.h>
#include <stdint.h>
#include "kyber512r3_params.h"

#define S2N_KYBER_512_R3_SHAKE128_RATE 168
#define S2N_KYBER_512_R3_SHAKE256_RATE 136
#define S2N_KYBER_512_R3_SHA3_256_RATE 136
#define S2N_KYBER_512_R3_SHA3_384_RATE 104
#define S2N_KYBER_512_R3_SHA3_512_RATE 72

#define S2N_KYBER_512_R3_PQC_SHAKECTX_SIZE 25

/* Context for non-incremental API */
#define shake128ctx S2N_KYBER_512_R3_NAMESPACE(shake128ctx)
typedef struct {
    uint64_t ctx[S2N_KYBER_512_R3_PQC_SHAKECTX_SIZE];
} shake128ctx;

/* Context for non-incremental API */
#define shake256ctx S2N_KYBER_512_R3_NAMESPACE(shake256ctx)
typedef struct {
    uint64_t ctx[S2N_KYBER_512_R3_PQC_SHAKECTX_SIZE];
} shake256ctx;

/* Initialize the state and absorb the provided input.
 *
 * This function does not support being called multiple times
 * with the same state.
 */
#define shake128_absorb S2N_KYBER_512_R3_NAMESPACE(shake128_absorb)
void shake128_absorb(shake128ctx *state, const uint8_t *input, size_t inlen);
/* Squeeze output out of the sponge.
 *
 * Supports being called multiple times
 */
#define shake128_squeezeblocks S2N_KYBER_512_R3_NAMESPACE(shake128_squeezeblocks)
void shake128_squeezeblocks(uint8_t *output, size_t nblocks, shake128ctx *state);

/* Copy the state. */
#define shake128_ctx_clone S2N_KYBER_512_R3_NAMESPACE(shake128_ctx_clone)
void shake128_ctx_clone(shake128ctx *dest, const shake128ctx *src);

/* Initialize the state and absorb the provided input.
 *
 * This function does not support being called multiple times
 * with the same state.
 */
#define shake256_absorb S2N_KYBER_512_R3_NAMESPACE(shake256_absorb)
void shake256_absorb(shake256ctx *state, const uint8_t *input, size_t inlen);
/* Squeeze output out of the sponge.
 *
 * Supports being called multiple times
 */
#define shake256_squeezeblocks S2N_KYBER_512_R3_NAMESPACE(shake256_squeezeblocks)
void shake256_squeezeblocks(uint8_t *output, size_t nblocks, shake256ctx *state);

/* One-stop SHAKE256 call */
#define shake256 S2N_KYBER_512_R3_NAMESPACE(shake256)
void shake256(uint8_t *output, size_t outlen, const uint8_t *input, size_t inlen);

#define sha3_256 S2N_KYBER_512_R3_NAMESPACE(sha3_256)
void sha3_256(uint8_t *output, const uint8_t *input, size_t inlen);

/* One-stop SHA3-512 shop */
#define sha3_512 S2N_KYBER_512_R3_NAMESPACE(sha3_512)
void sha3_512(uint8_t *output, const uint8_t *input, size_t inlen);