kpqc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +174 -0
- data/Rakefile +57 -0
- data/THIRD_PARTY_NOTICES.md +53 -0
- data/ext/kpqc/aimer128f/extconf.rb +4 -0
- data/ext/kpqc/aimer128s/extconf.rb +4 -0
- data/ext/kpqc/aimer192f/extconf.rb +4 -0
- data/ext/kpqc/aimer192s/extconf.rb +4 -0
- data/ext/kpqc/aimer256f/extconf.rb +4 -0
- data/ext/kpqc/aimer256s/extconf.rb +4 -0
- data/ext/kpqc/extconf_helper.rb +93 -0
- data/ext/kpqc/haetae2/extconf.rb +4 -0
- data/ext/kpqc/haetae3/extconf.rb +4 -0
- data/ext/kpqc/haetae5/extconf.rb +4 -0
- data/ext/kpqc/module.c +195 -0
- data/ext/kpqc/ntruplus1152/extconf.rb +4 -0
- data/ext/kpqc/ntruplus768/extconf.rb +4 -0
- data/ext/kpqc/ntruplus864/extconf.rb +4 -0
- data/ext/kpqc/randombytes.c +107 -0
- data/ext/kpqc/smaugt128/extconf.rb +4 -0
- data/ext/kpqc/smaugt192/extconf.rb +4 -0
- data/ext/kpqc/smaugt256/extconf.rb +4 -0
- data/ext/kpqc/timer/extconf.rb +4 -0
- data/kpqc.gemspec +41 -0
- data/lib/kpqc/aimer.rb +38 -0
- data/lib/kpqc/api.rb +129 -0
- data/lib/kpqc/haetae.rb +25 -0
- data/lib/kpqc/ntruplus.rb +25 -0
- data/lib/kpqc/smaugt.rb +29 -0
- data/lib/kpqc/types.rb +103 -0
- data/lib/kpqc/version.rb +6 -0
- data/lib/kpqc.rb +33 -0
- data/test/algorithm_test.rb +111 -0
- data/test/api_test.rb +52 -0
- data/test/interop.mjs +34 -0
- data/test/interop_test.rb +82 -0
- data/test/kat/aimer128f.rsp +10 -0
- data/test/kat/aimer128s.rsp +10 -0
- data/test/kat/aimer192f.rsp +10 -0
- data/test/kat/aimer192s.rsp +10 -0
- data/test/kat/aimer256f.rsp +10 -0
- data/test/kat/aimer256s.rsp +10 -0
- data/test/kat/haetae2.rsp +10 -0
- data/test/kat/haetae3.rsp +10 -0
- data/test/kat/haetae5.rsp +10 -0
- data/test/kat/ntruplus1152.rsp +8 -0
- data/test/kat/ntruplus768.rsp +8 -0
- data/test/kat/ntruplus864.rsp +8 -0
- data/test/kat/smaugt128.rsp +8 -0
- data/test/kat/smaugt192.rsp +8 -0
- data/test/kat/smaugt256.rsp +8 -0
- data/test/kat/timer.rsp +8 -0
- data/test/kat_drbg.rb +155 -0
- data/test/kat_test.rb +99 -0
- data/test/test_helper.rb +21 -0
- data/vendor/AIMer/LICENSE +21 -0
- data/vendor/AIMer/aim2.c +163 -0
- data/vendor/AIMer/aim2.h +36 -0
- data/vendor/AIMer/aim2_constant.h +74 -0
- data/vendor/AIMer/api.h +42 -0
- data/vendor/AIMer/common/crypto_declassify.h +7 -0
- data/vendor/AIMer/common/fips202.c +878 -0
- data/vendor/AIMer/common/fips202.h +166 -0
- data/vendor/AIMer/common/rng.h +56 -0
- data/vendor/AIMer/field.h +43 -0
- data/vendor/AIMer/field128.c +454 -0
- data/vendor/AIMer/field192.c +485 -0
- data/vendor/AIMer/field256.c +564 -0
- data/vendor/AIMer/hash.c +50 -0
- data/vendor/AIMer/hash.h +37 -0
- data/vendor/AIMer/params/params-aimer-128f.h +34 -0
- data/vendor/AIMer/params/params-aimer-128s.h +34 -0
- data/vendor/AIMer/params/params-aimer-192f.h +34 -0
- data/vendor/AIMer/params/params-aimer-192s.h +34 -0
- data/vendor/AIMer/params/params-aimer-256f.h +34 -0
- data/vendor/AIMer/params/params-aimer-256s.h +34 -0
- data/vendor/AIMer/params.h +5 -0
- data/vendor/AIMer/sign.c +631 -0
- data/vendor/AIMer/sign.h +40 -0
- data/vendor/AIMer/tree.c +75 -0
- data/vendor/AIMer/tree.h +26 -0
- data/vendor/HAETAE/LICENSE +22 -0
- data/vendor/HAETAE/include/api.h +54 -0
- data/vendor/HAETAE/include/common.h +12 -0
- data/vendor/HAETAE/include/config.h +42 -0
- data/vendor/HAETAE/include/decompose.h +19 -0
- data/vendor/HAETAE/include/encoding.h +20 -0
- data/vendor/HAETAE/include/fft.h +26 -0
- data/vendor/HAETAE/include/fips202.h +40 -0
- data/vendor/HAETAE/include/fixpoint.h +125 -0
- data/vendor/HAETAE/include/ntt.h +16 -0
- data/vendor/HAETAE/include/packing.h +58 -0
- data/vendor/HAETAE/include/params.h +117 -0
- data/vendor/HAETAE/include/poly.h +65 -0
- data/vendor/HAETAE/include/polyfix.h +65 -0
- data/vendor/HAETAE/include/polymat.h +32 -0
- data/vendor/HAETAE/include/polyvec.h +131 -0
- data/vendor/HAETAE/include/randombytes.h +39 -0
- data/vendor/HAETAE/include/rans_byte.h +335 -0
- data/vendor/HAETAE/include/reduce.h +31 -0
- data/vendor/HAETAE/include/sampler.h +23 -0
- data/vendor/HAETAE/include/symmetric.h +52 -0
- data/vendor/HAETAE/src/decompose.c +73 -0
- data/vendor/HAETAE/src/encoding.c +700 -0
- data/vendor/HAETAE/src/fft.c +235 -0
- data/vendor/HAETAE/src/fips202.c +745 -0
- data/vendor/HAETAE/src/fixpoint.c +143 -0
- data/vendor/HAETAE/src/ntt.c +98 -0
- data/vendor/HAETAE/src/packing.c +595 -0
- data/vendor/HAETAE/src/poly.c +371 -0
- data/vendor/HAETAE/src/polyfix.c +298 -0
- data/vendor/HAETAE/src/polymat.c +82 -0
- data/vendor/HAETAE/src/polyvec.c +534 -0
- data/vendor/HAETAE/src/reduce.c +96 -0
- data/vendor/HAETAE/src/sampler.c +310 -0
- data/vendor/HAETAE/src/sign.c +558 -0
- data/vendor/HAETAE/src/symmetric-shake.c +50 -0
- data/vendor/NTRUplus/LICENSE +21 -0
- data/vendor/NTRUplus/NTRU+1152/api.h +24 -0
- data/vendor/NTRUplus/NTRU+1152/fips202/fips202.c +878 -0
- data/vendor/NTRUplus/NTRU+1152/fips202/fips202.h +166 -0
- data/vendor/NTRUplus/NTRU+1152/kem.c +286 -0
- data/vendor/NTRUplus/NTRU+1152/ntt.c +394 -0
- data/vendor/NTRUplus/NTRU+1152/ntt.h +16 -0
- data/vendor/NTRUplus/NTRU+1152/params.h +18 -0
- data/vendor/NTRUplus/NTRU+1152/poly.c +318 -0
- data/vendor/NTRUplus/NTRU+1152/poly.h +31 -0
- data/vendor/NTRUplus/NTRU+1152/randombytes.h +9 -0
- data/vendor/NTRUplus/NTRU+1152/symmetric.c +39 -0
- data/vendor/NTRUplus/NTRU+1152/symmetric.h +12 -0
- data/vendor/NTRUplus/NTRU+768/api.h +24 -0
- data/vendor/NTRUplus/NTRU+768/fips202/fips202.c +878 -0
- data/vendor/NTRUplus/NTRU+768/fips202/fips202.h +166 -0
- data/vendor/NTRUplus/NTRU+768/kem.c +286 -0
- data/vendor/NTRUplus/NTRU+768/ntt.c +379 -0
- data/vendor/NTRUplus/NTRU+768/ntt.h +16 -0
- data/vendor/NTRUplus/NTRU+768/params.h +18 -0
- data/vendor/NTRUplus/NTRU+768/poly.c +320 -0
- data/vendor/NTRUplus/NTRU+768/poly.h +31 -0
- data/vendor/NTRUplus/NTRU+768/randombytes.h +9 -0
- data/vendor/NTRUplus/NTRU+768/symmetric.c +39 -0
- data/vendor/NTRUplus/NTRU+768/symmetric.h +12 -0
- data/vendor/NTRUplus/NTRU+864/api.h +24 -0
- data/vendor/NTRUplus/NTRU+864/fips202/fips202.c +878 -0
- data/vendor/NTRUplus/NTRU+864/fips202/fips202.h +166 -0
- data/vendor/NTRUplus/NTRU+864/kem.c +286 -0
- data/vendor/NTRUplus/NTRU+864/ntt.c +383 -0
- data/vendor/NTRUplus/NTRU+864/ntt.h +16 -0
- data/vendor/NTRUplus/NTRU+864/params.h +18 -0
- data/vendor/NTRUplus/NTRU+864/poly.c +314 -0
- data/vendor/NTRUplus/NTRU+864/poly.h +31 -0
- data/vendor/NTRUplus/NTRU+864/randombytes.h +9 -0
- data/vendor/NTRUplus/NTRU+864/symmetric.c +39 -0
- data/vendor/NTRUplus/NTRU+864/symmetric.h +12 -0
- data/vendor/SMAUG-T/LICENSE +22 -0
- data/vendor/SMAUG-T/include/api.h +37 -0
- data/vendor/SMAUG-T/include/cbd.h +15 -0
- data/vendor/SMAUG-T/include/ciphertext.h +45 -0
- data/vendor/SMAUG-T/include/common.h +12 -0
- data/vendor/SMAUG-T/include/config.h +48 -0
- data/vendor/SMAUG-T/include/dg.h +28 -0
- data/vendor/SMAUG-T/include/fips202.h +41 -0
- data/vendor/SMAUG-T/include/hash.h +21 -0
- data/vendor/SMAUG-T/include/hwt.h +28 -0
- data/vendor/SMAUG-T/include/indcpa.h +33 -0
- data/vendor/SMAUG-T/include/key.h +34 -0
- data/vendor/SMAUG-T/include/pack.h +78 -0
- data/vendor/SMAUG-T/include/packring.h +50 -0
- data/vendor/SMAUG-T/include/params.h +84 -0
- data/vendor/SMAUG-T/include/poly.h +41 -0
- data/vendor/SMAUG-T/include/randombytes.h +11 -0
- data/vendor/SMAUG-T/include/toomcook.h +14 -0
- data/vendor/SMAUG-T/include/verify.h +16 -0
- data/vendor/SMAUG-T/src/cbd.c +159 -0
- data/vendor/SMAUG-T/src/ciphertext.c +95 -0
- data/vendor/SMAUG-T/src/dg.c +112 -0
- data/vendor/SMAUG-T/src/fips202.c +745 -0
- data/vendor/SMAUG-T/src/hash.c +15 -0
- data/vendor/SMAUG-T/src/hwt.c +121 -0
- data/vendor/SMAUG-T/src/indcpa.c +187 -0
- data/vendor/SMAUG-T/src/kem.c +194 -0
- data/vendor/SMAUG-T/src/key.c +102 -0
- data/vendor/SMAUG-T/src/pack.c +349 -0
- data/vendor/SMAUG-T/src/packring.c +503 -0
- data/vendor/SMAUG-T/src/poly.c +200 -0
- data/vendor/SMAUG-T/src/toomcook.c +256 -0
- data/vendor/SMAUG-T/src/verify.c +48 -0
- data/vendor/SOURCES.json +130 -0
- metadata +280 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#ifndef FIPS202_H
|
|
2
|
+
#define FIPS202_H
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
7
|
+
#define SHAKE128_RATE 168
|
|
8
|
+
#define SHAKE256_RATE 136
|
|
9
|
+
#define SHA3_256_RATE 136
|
|
10
|
+
#define SHA3_384_RATE 104
|
|
11
|
+
#define SHA3_512_RATE 72
|
|
12
|
+
|
|
13
|
+
#define PQC_SHAKEINCCTX_BYTES (sizeof(uint64_t)*26)
|
|
14
|
+
#define PQC_SHAKECTX_BYTES (sizeof(uint64_t)*25)
|
|
15
|
+
|
|
16
|
+
// Context for incremental API
|
|
17
|
+
typedef struct {
|
|
18
|
+
uint64_t ctx[26];
|
|
19
|
+
} shake128incctx;
|
|
20
|
+
|
|
21
|
+
// Context for non-incremental API
|
|
22
|
+
typedef struct {
|
|
23
|
+
uint64_t ctx[25];
|
|
24
|
+
} shake128ctx;
|
|
25
|
+
|
|
26
|
+
// Context for incremental API
|
|
27
|
+
typedef struct {
|
|
28
|
+
uint64_t ctx[26];
|
|
29
|
+
} shake256incctx;
|
|
30
|
+
|
|
31
|
+
// Context for non-incremental API
|
|
32
|
+
typedef struct {
|
|
33
|
+
uint64_t ctx[25];
|
|
34
|
+
} shake256ctx;
|
|
35
|
+
|
|
36
|
+
// Context for incremental API
|
|
37
|
+
typedef struct {
|
|
38
|
+
uint64_t ctx[26];
|
|
39
|
+
} sha3_256incctx;
|
|
40
|
+
|
|
41
|
+
// Context for incremental API
|
|
42
|
+
typedef struct {
|
|
43
|
+
uint64_t ctx[26];
|
|
44
|
+
} sha3_384incctx;
|
|
45
|
+
|
|
46
|
+
// Context for incremental API
|
|
47
|
+
typedef struct {
|
|
48
|
+
uint64_t ctx[26];
|
|
49
|
+
} sha3_512incctx;
|
|
50
|
+
|
|
51
|
+
/* Initialize the state and absorb the provided input.
|
|
52
|
+
*
|
|
53
|
+
* This function does not support being called multiple times
|
|
54
|
+
* with the same state.
|
|
55
|
+
*/
|
|
56
|
+
void shake128_absorb(shake128ctx *state, const uint8_t *input, size_t inlen);
|
|
57
|
+
/* Squeeze output out of the sponge.
|
|
58
|
+
*
|
|
59
|
+
* Supports being called multiple times
|
|
60
|
+
*/
|
|
61
|
+
void shake128_squeezeblocks(uint8_t *output, size_t nblocks, shake128ctx *state);
|
|
62
|
+
/* Free the state */
|
|
63
|
+
void shake128_ctx_release(shake128ctx *state);
|
|
64
|
+
/* Copy the state. */
|
|
65
|
+
void shake128_ctx_clone(shake128ctx *dest, const shake128ctx *src);
|
|
66
|
+
|
|
67
|
+
/* Initialize incremental hashing API */
|
|
68
|
+
void shake128_inc_init(shake128incctx *state);
|
|
69
|
+
/* Absorb more information into the XOF.
|
|
70
|
+
*
|
|
71
|
+
* Can be called multiple times.
|
|
72
|
+
*/
|
|
73
|
+
void shake128_inc_absorb(shake128incctx *state, const uint8_t *input, size_t inlen);
|
|
74
|
+
/* Finalize the XOF for squeezing */
|
|
75
|
+
void shake128_inc_finalize(shake128incctx *state);
|
|
76
|
+
/* Squeeze output out of the sponge.
|
|
77
|
+
*
|
|
78
|
+
* Supports being called multiple times
|
|
79
|
+
*/
|
|
80
|
+
void shake128_inc_squeeze(uint8_t *output, size_t outlen, shake128incctx *state);
|
|
81
|
+
/* Copy the context of the SHAKE128 XOF */
|
|
82
|
+
void shake128_inc_ctx_clone(shake128incctx *dest, const shake128incctx *src);
|
|
83
|
+
/* Free the context of the SHAKE128 XOF */
|
|
84
|
+
void shake128_inc_ctx_release(shake128incctx *state);
|
|
85
|
+
|
|
86
|
+
/* Initialize the state and absorb the provided input.
|
|
87
|
+
*
|
|
88
|
+
* This function does not support being called multiple times
|
|
89
|
+
* with the same state.
|
|
90
|
+
*/
|
|
91
|
+
void shake256_absorb(shake256ctx *state, const uint8_t *input, size_t inlen);
|
|
92
|
+
/* Squeeze output out of the sponge.
|
|
93
|
+
*
|
|
94
|
+
* Supports being called multiple times
|
|
95
|
+
*/
|
|
96
|
+
void shake256_squeezeblocks(uint8_t *output, size_t nblocks, shake256ctx *state);
|
|
97
|
+
/* Free the context held by this XOF */
|
|
98
|
+
void shake256_ctx_release(shake256ctx *state);
|
|
99
|
+
/* Copy the context held by this XOF */
|
|
100
|
+
void shake256_ctx_clone(shake256ctx *dest, const shake256ctx *src);
|
|
101
|
+
|
|
102
|
+
/* Initialize incremental hashing API */
|
|
103
|
+
void shake256_inc_init(shake256incctx *state);
|
|
104
|
+
void shake256_inc_absorb(shake256incctx *state, const uint8_t *input, size_t inlen);
|
|
105
|
+
/* Prepares for squeeze phase */
|
|
106
|
+
void shake256_inc_finalize(shake256incctx *state);
|
|
107
|
+
/* Squeeze output out of the sponge.
|
|
108
|
+
*
|
|
109
|
+
* Supports being called multiple times
|
|
110
|
+
*/
|
|
111
|
+
void shake256_inc_squeeze(uint8_t *output, size_t outlen, shake256incctx *state);
|
|
112
|
+
/* Copy the state */
|
|
113
|
+
void shake256_inc_ctx_clone(shake256incctx *dest, const shake256incctx *src);
|
|
114
|
+
/* Free the state */
|
|
115
|
+
void shake256_inc_ctx_release(shake256incctx *state);
|
|
116
|
+
|
|
117
|
+
/* One-stop SHAKE128 call */
|
|
118
|
+
void shake128(uint8_t *output, size_t outlen,
|
|
119
|
+
const uint8_t *input, size_t inlen);
|
|
120
|
+
|
|
121
|
+
/* One-stop SHAKE256 call */
|
|
122
|
+
void shake256(uint8_t *output, size_t outlen,
|
|
123
|
+
const uint8_t *input, size_t inlen);
|
|
124
|
+
|
|
125
|
+
/* Initialize the incremental hashing state */
|
|
126
|
+
void sha3_256_inc_init(sha3_256incctx *state);
|
|
127
|
+
/* Absorb blocks into SHA3 */
|
|
128
|
+
void sha3_256_inc_absorb(sha3_256incctx *state, const uint8_t *input, size_t inlen);
|
|
129
|
+
/* Obtain the output of the function and free `state` */
|
|
130
|
+
void sha3_256_inc_finalize(uint8_t *output, sha3_256incctx *state);
|
|
131
|
+
/* Copy the context */
|
|
132
|
+
void sha3_256_inc_ctx_clone(sha3_256incctx *dest, const sha3_256incctx *src);
|
|
133
|
+
/* Release the state, don't use if `_finalize` has been used */
|
|
134
|
+
void sha3_256_inc_ctx_release(sha3_256incctx *state);
|
|
135
|
+
|
|
136
|
+
void sha3_256(uint8_t *output, const uint8_t *input, size_t inlen);
|
|
137
|
+
|
|
138
|
+
/* Initialize the incremental hashing state */
|
|
139
|
+
void sha3_384_inc_init(sha3_384incctx *state);
|
|
140
|
+
/* Absorb blocks into SHA3 */
|
|
141
|
+
void sha3_384_inc_absorb(sha3_384incctx *state, const uint8_t *input, size_t inlen);
|
|
142
|
+
/* Obtain the output of the function and free `state` */
|
|
143
|
+
void sha3_384_inc_finalize(uint8_t *output, sha3_384incctx *state);
|
|
144
|
+
/* Copy the context */
|
|
145
|
+
void sha3_384_inc_ctx_clone(sha3_384incctx *dest, const sha3_384incctx *src);
|
|
146
|
+
/* Release the state, don't use if `_finalize` has been used */
|
|
147
|
+
void sha3_384_inc_ctx_release(sha3_384incctx *state);
|
|
148
|
+
|
|
149
|
+
/* One-stop SHA3-384 shop */
|
|
150
|
+
void sha3_384(uint8_t *output, const uint8_t *input, size_t inlen);
|
|
151
|
+
|
|
152
|
+
/* Initialize the incremental hashing state */
|
|
153
|
+
void sha3_512_inc_init(sha3_512incctx *state);
|
|
154
|
+
/* Absorb blocks into SHA3 */
|
|
155
|
+
void sha3_512_inc_absorb(sha3_512incctx *state, const uint8_t *input, size_t inlen);
|
|
156
|
+
/* Obtain the output of the function and free `state` */
|
|
157
|
+
void sha3_512_inc_finalize(uint8_t *output, sha3_512incctx *state);
|
|
158
|
+
/* Copy the context */
|
|
159
|
+
void sha3_512_inc_ctx_clone(sha3_512incctx *dest, const sha3_512incctx *src);
|
|
160
|
+
/* Release the state, don't use if `_finalize` has been used */
|
|
161
|
+
void sha3_512_inc_ctx_release(sha3_512incctx *state);
|
|
162
|
+
|
|
163
|
+
/* One-stop SHA3-512 shop */
|
|
164
|
+
void sha3_512(uint8_t *output, const uint8_t *input, size_t inlen);
|
|
165
|
+
|
|
166
|
+
#endif
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
NIST-developed software is provided by NIST as a public service. You may use, copy, and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify, and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
|
|
3
|
+
|
|
4
|
+
NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT, OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
|
|
5
|
+
|
|
6
|
+
You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef rng_h
|
|
10
|
+
#define rng_h
|
|
11
|
+
|
|
12
|
+
#include <stdio.h>
|
|
13
|
+
|
|
14
|
+
#define RNG_SUCCESS 0
|
|
15
|
+
#define RNG_BAD_MAXLEN -1
|
|
16
|
+
#define RNG_BAD_OUTBUF -2
|
|
17
|
+
#define RNG_BAD_REQ_LEN -3
|
|
18
|
+
|
|
19
|
+
typedef struct {
|
|
20
|
+
unsigned char buffer[16];
|
|
21
|
+
int buffer_pos;
|
|
22
|
+
unsigned long length_remaining;
|
|
23
|
+
unsigned char key[32];
|
|
24
|
+
unsigned char ctr[16];
|
|
25
|
+
} AES_XOF_struct;
|
|
26
|
+
|
|
27
|
+
typedef struct {
|
|
28
|
+
unsigned char Key[32];
|
|
29
|
+
unsigned char V[16];
|
|
30
|
+
int reseed_counter;
|
|
31
|
+
} AES256_CTR_DRBG_struct;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
void
|
|
35
|
+
AES256_CTR_DRBG_Update(unsigned char *provided_data,
|
|
36
|
+
unsigned char *Key,
|
|
37
|
+
unsigned char *V);
|
|
38
|
+
|
|
39
|
+
int
|
|
40
|
+
seedexpander_init(AES_XOF_struct *ctx,
|
|
41
|
+
unsigned char *seed,
|
|
42
|
+
unsigned char *diversifier,
|
|
43
|
+
unsigned long maxlen);
|
|
44
|
+
|
|
45
|
+
int
|
|
46
|
+
seedexpander(AES_XOF_struct *ctx, unsigned char *x, unsigned long xlen);
|
|
47
|
+
|
|
48
|
+
void
|
|
49
|
+
randombytes_init(unsigned char *entropy_input,
|
|
50
|
+
unsigned char *personalization_string,
|
|
51
|
+
int security_strength);
|
|
52
|
+
|
|
53
|
+
int
|
|
54
|
+
randombytes(unsigned char *x, unsigned long long xlen);
|
|
55
|
+
|
|
56
|
+
#endif /* rng_h */
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
#ifndef FIELD_H
|
|
4
|
+
#define FIELD_H
|
|
5
|
+
|
|
6
|
+
#include "params.h"
|
|
7
|
+
#include <stddef.h>
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
#if SECURITY_BITS == 128
|
|
11
|
+
typedef uint64_t gf[2];
|
|
12
|
+
#elif SECURITY_BITS == 192
|
|
13
|
+
typedef uint64_t gf[3];
|
|
14
|
+
#else
|
|
15
|
+
typedef uint64_t gf[4];
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#define gf_set0 AIMER_NAMESPACE(gf_set0)
|
|
19
|
+
void gf_set0(gf a);
|
|
20
|
+
#define gf_copy AIMER_NAMESPACE(gf_copy)
|
|
21
|
+
void gf_copy(gf out, const gf in);
|
|
22
|
+
#define gf_to_bytes AIMER_NAMESPACE(gf_to_bytes)
|
|
23
|
+
void gf_to_bytes(uint8_t *out, const gf in);
|
|
24
|
+
#define gf_from_bytes AIMER_NAMESPACE(gf_from_bytes)
|
|
25
|
+
void gf_from_bytes(gf out, const uint8_t *in);
|
|
26
|
+
|
|
27
|
+
#define gf_add AIMER_NAMESPACE(gf_add)
|
|
28
|
+
void gf_add(gf c, const gf a, const gf b);
|
|
29
|
+
#define gf_mul AIMER_NAMESPACE(gf_mul)
|
|
30
|
+
void gf_mul(gf c, const gf a, const gf b);
|
|
31
|
+
#define gf_mul_add AIMER_NAMESPACE(gf_mul_add)
|
|
32
|
+
void gf_mul_add(gf c, const gf a, const gf b);
|
|
33
|
+
#define gf_sqr AIMER_NAMESPACE(gf_sqr)
|
|
34
|
+
void gf_sqr(gf c, const gf a);
|
|
35
|
+
#define gf_exp AIMER_NAMESPACE(gf_exp)
|
|
36
|
+
void gf_exp(gf out, const gf in, const uint64_t *exp);
|
|
37
|
+
|
|
38
|
+
#define gf_mat_vec_mul AIMER_NAMESPACE(gf_mat_vec_mul)
|
|
39
|
+
void gf_mat_vec_mul(gf c, const gf a, const gf b[AIM2_NUM_BITS_FIELD]);
|
|
40
|
+
#define gf_mat_vec_mul_add AIMER_NAMESPACE(gf_mat_vec_mul_add)
|
|
41
|
+
void gf_mat_vec_mul_add(gf c, const gf a, const gf b[AIM2_NUM_BITS_FIELD]);
|
|
42
|
+
|
|
43
|
+
#endif // FIELD_H
|