kpqc 0.1.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +9 -6
- data/THIRD_PARTY_NOTICES.md +14 -47
- data/ext/kpqc/extconf_helper.rb +6 -3
- data/ext/kpqc/secure_clear.c +8 -0
- data/kpqc.gemspec +4 -2
- data/lib/kpqc/aimer.rb +6 -6
- data/lib/kpqc/version.rb +1 -1
- data/test/kat/aimer128f.rsp +4 -4
- data/test/kat/aimer128s.rsp +4 -4
- data/test/kat/aimer192f.rsp +4 -4
- data/test/kat/aimer192s.rsp +4 -4
- data/test/kat/aimer256f.rsp +4 -4
- data/test/kat/aimer256s.rsp +4 -4
- data/test/kat/haetae2.rsp +1 -1
- data/test/kat/haetae3.rsp +1 -1
- data/test/kat/haetae5.rsp +1 -1
- data/vendor/AIMer/LICENSE +1 -1
- data/vendor/AIMer/aim3.c +227 -0
- data/vendor/AIMer/aim3.h +63 -0
- data/vendor/AIMer/field.h +12 -4
- data/vendor/AIMer/field128.c +24 -381
- data/vendor/AIMer/field192.c +24 -400
- data/vendor/AIMer/field256.c +28 -447
- data/vendor/AIMer/field_common.c +98 -0
- data/vendor/AIMer/field_internal.h +218 -0
- data/vendor/AIMer/params/params-aimer-128f.h +8 -8
- data/vendor/AIMer/params/params-aimer-128s.h +8 -8
- data/vendor/AIMer/params/params-aimer-192f.h +8 -8
- data/vendor/AIMer/params/params-aimer-192s.h +8 -8
- data/vendor/AIMer/params/params-aimer-256f.h +8 -8
- data/vendor/AIMer/params/params-aimer-256s.h +8 -8
- data/vendor/AIMer/params.h +5 -0
- data/vendor/AIMer/sign.c +246 -167
- data/vendor/AIMer/sign.h +6 -6
- data/vendor/AIMer/tree.c +10 -4
- data/vendor/AIMer/tree.h +1 -1
- data/vendor/HAETAE/include/fixpoint.h +14 -14
- data/vendor/HAETAE/include/rans_byte.h +10 -9
- data/vendor/HAETAE/src/decompose.c +8 -4
- data/vendor/HAETAE/src/encoding.c +5 -5
- data/vendor/HAETAE/src/fft.c +1 -1
- data/vendor/HAETAE/src/fips202.c +26 -14
- data/vendor/HAETAE/src/fixpoint.c +21 -18
- data/vendor/HAETAE/src/ntt.c +2 -0
- data/vendor/HAETAE/src/packing.c +15 -15
- data/vendor/HAETAE/src/poly.c +30 -3
- data/vendor/HAETAE/src/polyfix.c +2 -2
- data/vendor/HAETAE/src/polymat.c +2 -2
- data/vendor/HAETAE/src/polyvec.c +7 -5
- data/vendor/HAETAE/src/reduce.c +2 -0
- data/vendor/HAETAE/src/sampler.c +231 -47
- data/vendor/HAETAE/src/sign.c +11 -10
- data/vendor/NTRUplus/NTRU+1152/api.h +27 -8
- data/vendor/NTRUplus/NTRU+1152/fips202/fips202.c +12 -269
- data/vendor/NTRUplus/NTRU+1152/fips202/fips202.h +4 -113
- data/vendor/NTRUplus/NTRU+1152/kem.c +110 -40
- data/vendor/NTRUplus/NTRU+1152/ntt.c +50 -54
- data/vendor/NTRUplus/NTRU+1152/poly.c +21 -13
- data/vendor/NTRUplus/NTRU+1152/poly.h +3 -3
- data/vendor/NTRUplus/NTRU+1152/randombytes.h +1 -0
- data/vendor/NTRUplus/NTRU+1152/symmetric.c +3 -9
- data/vendor/NTRUplus/NTRU+1152/symmetric.h +13 -3
- data/vendor/NTRUplus/NTRU+1152/util.h +15 -0
- data/vendor/NTRUplus/NTRU+768/api.h +27 -8
- data/vendor/NTRUplus/NTRU+768/fips202/fips202.c +12 -269
- data/vendor/NTRUplus/NTRU+768/fips202/fips202.h +4 -113
- data/vendor/NTRUplus/NTRU+768/kem.c +110 -40
- data/vendor/NTRUplus/NTRU+768/ntt.c +50 -54
- data/vendor/NTRUplus/NTRU+768/poly.c +23 -13
- data/vendor/NTRUplus/NTRU+768/poly.h +3 -3
- data/vendor/NTRUplus/NTRU+768/randombytes.h +1 -0
- data/vendor/NTRUplus/NTRU+768/symmetric.c +3 -9
- data/vendor/NTRUplus/NTRU+768/symmetric.h +13 -3
- data/vendor/NTRUplus/NTRU+768/util.h +15 -0
- data/vendor/NTRUplus/NTRU+864/api.h +27 -8
- data/vendor/NTRUplus/NTRU+864/fips202/fips202.c +12 -269
- data/vendor/NTRUplus/NTRU+864/fips202/fips202.h +4 -113
- data/vendor/NTRUplus/NTRU+864/kem.c +110 -40
- data/vendor/NTRUplus/NTRU+864/ntt.c +24 -28
- data/vendor/NTRUplus/NTRU+864/poly.c +26 -12
- data/vendor/NTRUplus/NTRU+864/poly.h +3 -3
- data/vendor/NTRUplus/NTRU+864/randombytes.h +1 -0
- data/vendor/NTRUplus/NTRU+864/symmetric.c +3 -9
- data/vendor/NTRUplus/NTRU+864/symmetric.h +13 -3
- data/vendor/NTRUplus/NTRU+864/util.h +15 -0
- data/vendor/SMAUG-T/src/cbd.c +4 -4
- data/vendor/SMAUG-T/src/ciphertext.c +2 -2
- data/vendor/SMAUG-T/src/dg.c +2 -2
- data/vendor/SMAUG-T/src/hwt.c +4 -4
- data/vendor/SMAUG-T/src/indcpa.c +5 -5
- data/vendor/SMAUG-T/src/kem.c +9 -7
- data/vendor/SMAUG-T/src/key.c +2 -2
- data/vendor/SMAUG-T/src/pack.c +8 -8
- metadata +16 -13
- data/vendor/AIMer/aim2.c +0 -163
- data/vendor/AIMer/aim2.h +0 -36
- data/vendor/AIMer/aim2_constant.h +0 -74
- data/vendor/SOURCES.json +0 -130
data/vendor/SMAUG-T/src/indcpa.c
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* - uint8_t *seed: pointer to input seed (of length
|
|
20
20
|
* SMAUGT_DELTA_BYTES)
|
|
21
21
|
*
|
|
22
|
-
* Specification: Implements Algorithm 5, ExpandR
|
|
22
|
+
* Specification: Implements @[KS X 123456, Algorithm 5, ExpandR]
|
|
23
23
|
**************************************************/
|
|
24
24
|
void expand_r(polyvec *r, const uint8_t *seed) {
|
|
25
25
|
unsigned int i;
|
|
@@ -49,7 +49,7 @@ void expand_r(polyvec *r, const uint8_t *seed) {
|
|
|
49
49
|
* private key
|
|
50
50
|
* - uint8_t seed[SMAUGT_CRYPTO_BYTES]: pointer to input seed
|
|
51
51
|
*
|
|
52
|
-
* Specification: Implements Algorithm 25, SMAUGT-T.PKE.KeyGen
|
|
52
|
+
* Specification: Implements @[KS X 123456, Algorithm 25, SMAUGT-T.PKE.KeyGen]
|
|
53
53
|
**************************************************/
|
|
54
54
|
void indcpa_keypair(uint8_t pk[SMAUGT_PUBLICKEY_BYTES],
|
|
55
55
|
uint8_t sk[SMAUGT_PKE_SECRETKEY_BYTES],
|
|
@@ -94,7 +94,7 @@ void indcpa_keypair(uint8_t pk[SMAUGT_PUBLICKEY_BYTES],
|
|
|
94
94
|
* message
|
|
95
95
|
* - const uint8_t seed[SMAUGT_DELTA_BYTES]: pointer to input seed
|
|
96
96
|
*
|
|
97
|
-
* Specification: Implements Algorithm 26, SMAUGT-T.PKE.Enc
|
|
97
|
+
* Specification: Implements @[KS X 123456, Algorithm 26, SMAUGT-T.PKE.Enc]
|
|
98
98
|
**************************************************/
|
|
99
99
|
void indcpa_enc(uint8_t ctxt[SMAUGT_CIPHERTEXT_BYTES],
|
|
100
100
|
const uint8_t pk[SMAUGT_PUBLICKEY_BYTES],
|
|
@@ -110,7 +110,7 @@ void indcpa_enc(uint8_t ctxt[SMAUGT_CIPHERTEXT_BYTES],
|
|
|
110
110
|
memset(&r, 0, sizeof(polyvec));
|
|
111
111
|
|
|
112
112
|
if (seed == NULL)
|
|
113
|
-
|
|
113
|
+
randombytes(seed_r, SMAUGT_DELTA_BYTES);
|
|
114
114
|
else
|
|
115
115
|
cmov(seed_r, seed, SMAUGT_DELTA_BYTES, 1);
|
|
116
116
|
expand_r(&r, seed_r);
|
|
@@ -139,7 +139,7 @@ void indcpa_enc(uint8_t ctxt[SMAUGT_CIPHERTEXT_BYTES],
|
|
|
139
139
|
* - const uint8_t ctxt[SMAUGT_CIPHERTEXT_BYTES]: pointer to input
|
|
140
140
|
* ciphertext
|
|
141
141
|
*
|
|
142
|
-
* Specification: Implements Algorithm 28, SMAUGT-T.PKE.Dec
|
|
142
|
+
* Specification: Implements @[KS X 123456, Algorithm 28, SMAUGT-T.PKE.Dec]
|
|
143
143
|
**************************************************/
|
|
144
144
|
void indcpa_dec(uint8_t mu[SMAUGT_MSG_BYTES],
|
|
145
145
|
const uint8_t sk[SMAUGT_PKE_SECRETKEY_BYTES],
|
data/vendor/SMAUG-T/src/kem.c
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* kpqc-py: propagate OS entropy failures (2026-09-06). */
|
|
2
1
|
// SPDX-License-Identifier: MIT
|
|
3
2
|
|
|
4
3
|
#include "api.h"
|
|
@@ -25,7 +24,8 @@
|
|
|
25
24
|
*
|
|
26
25
|
* Return: 0 on success, 1 on failure
|
|
27
26
|
*
|
|
28
|
-
* Specification: Implements Algorithm 33,
|
|
27
|
+
* Specification: Implements @[KS X 123456, Algorithm 33,
|
|
28
|
+
* SMAUG-T.KEM.EncapInternal]
|
|
29
29
|
**************************************************/
|
|
30
30
|
int crypto_kem_keypair_internal(uint8_t *pk, uint8_t *sk,
|
|
31
31
|
uint8_t d[SMAUGT_T_BYTES],
|
|
@@ -51,7 +51,7 @@ int crypto_kem_keypair_internal(uint8_t *pk, uint8_t *sk,
|
|
|
51
51
|
*
|
|
52
52
|
* Return: 0 on success, 1 on failure
|
|
53
53
|
*
|
|
54
|
-
* Specification: Implements Algorithm 30, SMAUG-T.KEM.KeyGen
|
|
54
|
+
* Specification: Implements @[KS X 123456, Algorithm 30, SMAUG-T.KEM.KeyGen]
|
|
55
55
|
**************************************************/
|
|
56
56
|
int crypto_kem_keypair(uint8_t *pk, uint8_t *sk) {
|
|
57
57
|
int ret = 0;
|
|
@@ -81,7 +81,8 @@ int crypto_kem_keypair(uint8_t *pk, uint8_t *sk) {
|
|
|
81
81
|
*
|
|
82
82
|
* Return: 0 on success, 1 on failure
|
|
83
83
|
*
|
|
84
|
-
* Specification: Implements Algorithm 34,
|
|
84
|
+
* Specification: Implements @[KS X 123456, Algorithm 34,
|
|
85
|
+
* SMAUG-T.KEM.EncapInternal]
|
|
85
86
|
**************************************************/
|
|
86
87
|
int crypto_kem_enc_internal(uint8_t *ctxt, uint8_t *ss, const uint8_t *pk,
|
|
87
88
|
const uint8_t *mu) {
|
|
@@ -111,7 +112,7 @@ int crypto_kem_enc_internal(uint8_t *ctxt, uint8_t *ss, const uint8_t *pk,
|
|
|
111
112
|
*
|
|
112
113
|
* Return: 0 on success, 1 on failure
|
|
113
114
|
*
|
|
114
|
-
* Specification: Implements Algorithm 31, SMAUG-T.KEM.Encap
|
|
115
|
+
* Specification: Implements @[KS X 123456, Algorithm 31, SMAUG-T.KEM.Encap]
|
|
115
116
|
**************************************************/
|
|
116
117
|
int crypto_kem_enc(uint8_t *ctxt, uint8_t *ss, const uint8_t *pk) {
|
|
117
118
|
int ret = 0;
|
|
@@ -136,7 +137,8 @@ int crypto_kem_enc(uint8_t *ctxt, uint8_t *ss, const uint8_t *pk) {
|
|
|
136
137
|
*
|
|
137
138
|
* Return: 0 on success, 1 on failure
|
|
138
139
|
*
|
|
139
|
-
* Specification: Implements Algorithm 35,
|
|
140
|
+
* Specification: Implements @[KS X 123456, Algorithm 35,
|
|
141
|
+
* SMAUG-T.KEM.DecapInternal]
|
|
140
142
|
**************************************************/
|
|
141
143
|
int crypto_kem_dec_internal(uint8_t *ss, const uint8_t *ctxt,
|
|
142
144
|
const uint8_t *sk) {
|
|
@@ -185,7 +187,7 @@ int crypto_kem_dec_internal(uint8_t *ss, const uint8_t *ctxt,
|
|
|
185
187
|
*
|
|
186
188
|
* Return: 0 on success, 1 on failure
|
|
187
189
|
*
|
|
188
|
-
* Specification: Implements Algorithm 32, SMAUG-T.KEM.Decap
|
|
190
|
+
* Specification: Implements @[KS X 123456, Algorithm 32, SMAUG-T.KEM.Decap]
|
|
189
191
|
**************************************************/
|
|
190
192
|
int crypto_kem_dec(uint8_t *ss, const uint8_t *ctxt, const uint8_t *sk) {
|
|
191
193
|
int ret = 0;
|
data/vendor/SMAUG-T/src/key.c
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Arguments: - polyvec A[SMAUGT_K]: pointer to output matrix A
|
|
19
19
|
* - const uint8_t seed[SMAUGT_PKSEED_BYTES]: pointer to input seed
|
|
20
20
|
*
|
|
21
|
-
* Specification: Implements Algorithm 1, ExpandA
|
|
21
|
+
* Specification: Implements @[KS X 123456, Algorithm 1, ExpandA]
|
|
22
22
|
**************************************************/
|
|
23
23
|
void expand_A(polyvec A[SMAUGT_K], const uint8_t seed[SMAUGT_PKSEED_BYTES]) {
|
|
24
24
|
unsigned int i, j;
|
|
@@ -65,7 +65,7 @@ void expand_b(polyvec *b, const polyvec A[SMAUGT_K], const polyvec *s,
|
|
|
65
65
|
* - const uint8_t seed[SMAUGT_CRYPTO_BYTES]: pointer to input seed
|
|
66
66
|
* of s(x)
|
|
67
67
|
*
|
|
68
|
-
* Specification: Implements Algorithm 2, ExpandS
|
|
68
|
+
* Specification: Implements @[KS X 123456, Algorithm 2, ExpandS]
|
|
69
69
|
**************************************************/
|
|
70
70
|
void expand_s(secret_key *sk, const uint8_t seed[SMAUGT_CRYPTO_BYTES]) {
|
|
71
71
|
unsigned int i, j;
|
data/vendor/SMAUG-T/src/pack.c
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Arguments: - uint8_t *output: pointer to output byte array
|
|
14
14
|
* - const public_key *pk: pointer to input public key
|
|
15
15
|
*
|
|
16
|
-
* Specification: Implements Algorithm 14, PackEncK
|
|
16
|
+
* Specification: Implements @[KS X 123456, Algorithm 14, PackEncK]
|
|
17
17
|
**************************************************/
|
|
18
18
|
void pack_enck(uint8_t *output, const public_key *pk) {
|
|
19
19
|
memcpy(output, pk->seed, sizeof(uint8_t) * SMAUGT_PKSEED_BYTES);
|
|
@@ -28,7 +28,7 @@ void pack_enck(uint8_t *output, const public_key *pk) {
|
|
|
28
28
|
* Arguments: - public_key *pk: pointer to output public key
|
|
29
29
|
* - const uint8_t *input: pointer to input byte array
|
|
30
30
|
*
|
|
31
|
-
* Specification: Implements Algorithm 15, UnpackEncK
|
|
31
|
+
* Specification: Implements @[KS X 123456, Algorithm 15, UnpackEncK]
|
|
32
32
|
**************************************************/
|
|
33
33
|
void unpack_enck(public_key *pk, const uint8_t *input) {
|
|
34
34
|
memcpy(pk->seed, input, SMAUGT_PKSEED_BYTES);
|
|
@@ -44,7 +44,7 @@ void unpack_enck(public_key *pk, const uint8_t *input) {
|
|
|
44
44
|
* Arguments: - uint8_t *output: pointer to output byte array
|
|
45
45
|
* - const secret_key *sk: pointer to input private key
|
|
46
46
|
*
|
|
47
|
-
* Specification: Implements Algorithm 16, PackDecK
|
|
47
|
+
* Specification: Implements @[KS X 123456, Algorithm 16, PackDecK]
|
|
48
48
|
**************************************************/
|
|
49
49
|
void pack_deck(uint8_t *output, const secret_key *sk) {
|
|
50
50
|
for (size_t i = 0; i < SMAUGT_K; ++i)
|
|
@@ -59,7 +59,7 @@ void pack_deck(uint8_t *output, const secret_key *sk) {
|
|
|
59
59
|
* Arguments: - secret_key *sk: pointer to output private key
|
|
60
60
|
* - const uint8_t *input: pointer to input byte array
|
|
61
61
|
*
|
|
62
|
-
* Specification: Implements Algorithm 17, UnpackDecK
|
|
62
|
+
* Specification: Implements @[KS X 123456, Algorithm 17, UnpackDecK]
|
|
63
63
|
**************************************************/
|
|
64
64
|
void unpack_deck(secret_key *sk, const uint8_t *input) {
|
|
65
65
|
for (size_t i = 0; i < SMAUGT_K; ++i)
|
|
@@ -74,7 +74,7 @@ void unpack_deck(secret_key *sk, const uint8_t *input) {
|
|
|
74
74
|
* Arguments: - uint8_t *bytes: pointer to output bytes
|
|
75
75
|
* - const poly *s: pointer to input poly in Sn
|
|
76
76
|
*
|
|
77
|
-
* Specification: Implements Algorithm 18, PackSPoly
|
|
77
|
+
* Specification: Implements @[KS X 123456, Algorithm 18, PackSPoly]
|
|
78
78
|
**************************************************/
|
|
79
79
|
void pack_s_poly(uint8_t *bytes, const poly *s) {
|
|
80
80
|
unsigned int i;
|
|
@@ -96,7 +96,7 @@ void pack_s_poly(uint8_t *bytes, const poly *s) {
|
|
|
96
96
|
* Arguments: - poly *s: pointer to output poly in Sn
|
|
97
97
|
* - const uint8_t *bytes: pointer to input bytes
|
|
98
98
|
*
|
|
99
|
-
* Specification: Implements Algorithm 19, UnpackSPoly
|
|
99
|
+
* Specification: Implements @[KS X 123456, Algorithm 19, UnpackSPoly]
|
|
100
100
|
**************************************************/
|
|
101
101
|
void unpack_s_poly(poly *s, const uint8_t *bytes) {
|
|
102
102
|
unsigned int i;
|
|
@@ -123,7 +123,7 @@ void unpack_s_poly(poly *s, const uint8_t *bytes) {
|
|
|
123
123
|
* Arguments: - uint8_t *output: pointer to output byte array
|
|
124
124
|
* - const ciphertext *ctxt: pointer to input ciphertext
|
|
125
125
|
*
|
|
126
|
-
* Specification: Implements Algorithm 20, PackCT
|
|
126
|
+
* Specification: Implements @[KS X 123456, Algorithm 20, PackCT]
|
|
127
127
|
* **************************************************/
|
|
128
128
|
void pack_ct(uint8_t *output, const ciphertext *ctxt) {
|
|
129
129
|
pack_ring_p_vec(output, &(ctxt->c1));
|
|
@@ -138,7 +138,7 @@ void pack_ct(uint8_t *output, const ciphertext *ctxt) {
|
|
|
138
138
|
* Arguments: - ciphertext *ctxt: pointer to output ciphertext
|
|
139
139
|
* - const uint8_t *input: pointer to input byte array
|
|
140
140
|
*
|
|
141
|
-
* Specification: Implements Algorithm 21, UnpackCT
|
|
141
|
+
* Specification: Implements @[KS X 123456, Algorithm 21, UnpackCT]
|
|
142
142
|
**************************************************/
|
|
143
143
|
void unpack_ct(ciphertext *ctxt, const uint8_t *input) {
|
|
144
144
|
unpack_ring_p_vec(&(ctxt->c1), input);
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kpqc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- osuolfou
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Synchronous Ruby bindings for the bundled AIMer and HAETAE signature
|
|
14
13
|
schemes and NTRU+ and SMAUG-T key-encapsulation mechanisms.
|
|
@@ -34,6 +33,7 @@ extensions:
|
|
|
34
33
|
- ext/kpqc/timer/extconf.rb
|
|
35
34
|
extra_rdoc_files: []
|
|
36
35
|
files:
|
|
36
|
+
- CHANGELOG.md
|
|
37
37
|
- Gemfile
|
|
38
38
|
- LICENSE
|
|
39
39
|
- README.md
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- ext/kpqc/ntruplus768/extconf.rb
|
|
55
55
|
- ext/kpqc/ntruplus864/extconf.rb
|
|
56
56
|
- ext/kpqc/randombytes.c
|
|
57
|
+
- ext/kpqc/secure_clear.c
|
|
57
58
|
- ext/kpqc/smaugt128/extconf.rb
|
|
58
59
|
- ext/kpqc/smaugt192/extconf.rb
|
|
59
60
|
- ext/kpqc/smaugt256/extconf.rb
|
|
@@ -91,9 +92,8 @@ files:
|
|
|
91
92
|
- test/kat_test.rb
|
|
92
93
|
- test/test_helper.rb
|
|
93
94
|
- vendor/AIMer/LICENSE
|
|
94
|
-
- vendor/AIMer/
|
|
95
|
-
- vendor/AIMer/
|
|
96
|
-
- vendor/AIMer/aim2_constant.h
|
|
95
|
+
- vendor/AIMer/aim3.c
|
|
96
|
+
- vendor/AIMer/aim3.h
|
|
97
97
|
- vendor/AIMer/api.h
|
|
98
98
|
- vendor/AIMer/common/crypto_declassify.h
|
|
99
99
|
- vendor/AIMer/common/fips202.c
|
|
@@ -103,6 +103,8 @@ files:
|
|
|
103
103
|
- vendor/AIMer/field128.c
|
|
104
104
|
- vendor/AIMer/field192.c
|
|
105
105
|
- vendor/AIMer/field256.c
|
|
106
|
+
- vendor/AIMer/field_common.c
|
|
107
|
+
- vendor/AIMer/field_internal.h
|
|
106
108
|
- vendor/AIMer/hash.c
|
|
107
109
|
- vendor/AIMer/hash.h
|
|
108
110
|
- vendor/AIMer/params.h
|
|
@@ -165,6 +167,7 @@ files:
|
|
|
165
167
|
- vendor/NTRUplus/NTRU+1152/randombytes.h
|
|
166
168
|
- vendor/NTRUplus/NTRU+1152/symmetric.c
|
|
167
169
|
- vendor/NTRUplus/NTRU+1152/symmetric.h
|
|
170
|
+
- vendor/NTRUplus/NTRU+1152/util.h
|
|
168
171
|
- vendor/NTRUplus/NTRU+768/api.h
|
|
169
172
|
- vendor/NTRUplus/NTRU+768/fips202/fips202.c
|
|
170
173
|
- vendor/NTRUplus/NTRU+768/fips202/fips202.h
|
|
@@ -177,6 +180,7 @@ files:
|
|
|
177
180
|
- vendor/NTRUplus/NTRU+768/randombytes.h
|
|
178
181
|
- vendor/NTRUplus/NTRU+768/symmetric.c
|
|
179
182
|
- vendor/NTRUplus/NTRU+768/symmetric.h
|
|
183
|
+
- vendor/NTRUplus/NTRU+768/util.h
|
|
180
184
|
- vendor/NTRUplus/NTRU+864/api.h
|
|
181
185
|
- vendor/NTRUplus/NTRU+864/fips202/fips202.c
|
|
182
186
|
- vendor/NTRUplus/NTRU+864/fips202/fips202.h
|
|
@@ -189,6 +193,7 @@ files:
|
|
|
189
193
|
- vendor/NTRUplus/NTRU+864/randombytes.h
|
|
190
194
|
- vendor/NTRUplus/NTRU+864/symmetric.c
|
|
191
195
|
- vendor/NTRUplus/NTRU+864/symmetric.h
|
|
196
|
+
- vendor/NTRUplus/NTRU+864/util.h
|
|
192
197
|
- vendor/SMAUG-T/LICENSE
|
|
193
198
|
- vendor/SMAUG-T/include/api.h
|
|
194
199
|
- vendor/SMAUG-T/include/cbd.h
|
|
@@ -222,15 +227,14 @@ files:
|
|
|
222
227
|
- vendor/SMAUG-T/src/poly.c
|
|
223
228
|
- vendor/SMAUG-T/src/toomcook.c
|
|
224
229
|
- vendor/SMAUG-T/src/verify.c
|
|
225
|
-
|
|
226
|
-
homepage: https://github.com/osuolfou/kpqc-rb
|
|
230
|
+
homepage: https://github.com/KpqC/kpqc-ruby
|
|
227
231
|
licenses:
|
|
228
232
|
- MIT
|
|
229
233
|
metadata:
|
|
230
|
-
source_code_uri: https://github.com/
|
|
231
|
-
bug_tracker_uri: https://github.com/
|
|
234
|
+
source_code_uri: https://github.com/KpqC/kpqc-ruby
|
|
235
|
+
bug_tracker_uri: https://github.com/KpqC/kpqc-ruby/issues
|
|
236
|
+
changelog_uri: https://github.com/KpqC/kpqc-ruby/blob/main/CHANGELOG.md
|
|
232
237
|
rubygems_mfa_required: 'true'
|
|
233
|
-
post_install_message:
|
|
234
238
|
rdoc_options: []
|
|
235
239
|
require_paths:
|
|
236
240
|
- lib
|
|
@@ -245,8 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
245
249
|
- !ruby/object:Gem::Version
|
|
246
250
|
version: '0'
|
|
247
251
|
requirements: []
|
|
248
|
-
rubygems_version:
|
|
249
|
-
signing_key:
|
|
252
|
+
rubygems_version: 4.0.20
|
|
250
253
|
specification_version: 4
|
|
251
254
|
summary: Ruby APIs for AIMer, HAETAE, NTRU+, and SMAUG-T.
|
|
252
255
|
test_files: []
|
data/vendor/AIMer/aim2.c
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
#include "aim2.h"
|
|
4
|
-
#include "field.h"
|
|
5
|
-
#include "hash.h"
|
|
6
|
-
#include "params.h"
|
|
7
|
-
#include <stddef.h>
|
|
8
|
-
#include <stdint.h>
|
|
9
|
-
|
|
10
|
-
static void generate_matrices_L_and_U(
|
|
11
|
-
gf matrix_L[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD],
|
|
12
|
-
gf matrix_U[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD],
|
|
13
|
-
gf vector_b,
|
|
14
|
-
const uint8_t iv[AIM2_IV_SIZE])
|
|
15
|
-
{
|
|
16
|
-
uint8_t buf[AIM2_NUM_BYTES_FIELD];
|
|
17
|
-
uint64_t ormask, lmask, umask;
|
|
18
|
-
hash_instance ctx;
|
|
19
|
-
gf temp = {0,};
|
|
20
|
-
|
|
21
|
-
// initialize hash
|
|
22
|
-
hash_init(&ctx);
|
|
23
|
-
hash_update(&ctx, iv, AIM2_IV_SIZE);
|
|
24
|
-
hash_final(&ctx);
|
|
25
|
-
|
|
26
|
-
for (size_t ell = 0; ell < AIM2_NUM_INPUT_SBOX; ell++)
|
|
27
|
-
{
|
|
28
|
-
for (size_t row = 0; row < AIM2_NUM_BITS_FIELD; row++)
|
|
29
|
-
{
|
|
30
|
-
hash_squeeze(&ctx, buf, AIM2_NUM_BYTES_FIELD);
|
|
31
|
-
gf_from_bytes(temp, buf);
|
|
32
|
-
|
|
33
|
-
ormask = ((uint64_t)1) << (row % 64);
|
|
34
|
-
lmask = ((uint64_t)-1) << (row % 64);
|
|
35
|
-
umask = ~lmask;
|
|
36
|
-
|
|
37
|
-
size_t inter = row / 64;
|
|
38
|
-
size_t col_word;
|
|
39
|
-
for (col_word = 0; col_word < inter; col_word++)
|
|
40
|
-
{
|
|
41
|
-
// L is zero, U is full
|
|
42
|
-
matrix_L[ell][row][col_word] = 0;
|
|
43
|
-
matrix_U[ell][row][col_word] = temp[col_word];
|
|
44
|
-
}
|
|
45
|
-
matrix_L[ell][row][inter] = (temp[inter] & lmask) | ormask;
|
|
46
|
-
matrix_U[ell][row][inter] = (temp[inter] & umask) | ormask;
|
|
47
|
-
for (col_word = inter + 1; col_word < AIM2_NUM_WORDS_FIELD; col_word++)
|
|
48
|
-
{
|
|
49
|
-
// L is full, U is zero
|
|
50
|
-
matrix_L[ell][row][col_word] = temp[col_word];
|
|
51
|
-
matrix_U[ell][row][col_word] = 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
hash_squeeze(&ctx, (uint8_t *)vector_b, AIM2_NUM_BYTES_FIELD);
|
|
57
|
-
hash_ctx_release(&ctx);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
void aim2_generate_linear(gf matrix_A[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD],
|
|
61
|
-
gf vector_b,
|
|
62
|
-
const uint8_t iv[AIM2_IV_SIZE])
|
|
63
|
-
{
|
|
64
|
-
gf matrix_L[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD];
|
|
65
|
-
gf matrix_U[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD];
|
|
66
|
-
|
|
67
|
-
generate_matrices_L_and_U(matrix_L, matrix_U, vector_b, iv);
|
|
68
|
-
|
|
69
|
-
for (size_t ell = 0; ell < AIM2_NUM_INPUT_SBOX; ell++)
|
|
70
|
-
{
|
|
71
|
-
for (size_t i = 0; i < AIM2_NUM_BITS_FIELD; i++)
|
|
72
|
-
{
|
|
73
|
-
gf_mat_vec_mul(matrix_A[ell][i], matrix_U[ell][i],
|
|
74
|
-
(const gf *)matrix_L[ell]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
void aim2(uint8_t ct[AIM2_NUM_BYTES_FIELD],
|
|
80
|
-
const uint8_t pt[AIM2_NUM_BYTES_FIELD],
|
|
81
|
-
const uint8_t iv[AIM2_IV_SIZE])
|
|
82
|
-
{
|
|
83
|
-
gf matrix_L[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD];
|
|
84
|
-
gf matrix_U[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD];
|
|
85
|
-
gf vector_b = {0,};
|
|
86
|
-
|
|
87
|
-
gf state[AIM2_NUM_INPUT_SBOX];
|
|
88
|
-
gf pt_gf = {0,}, ct_gf = {0,};
|
|
89
|
-
gf_from_bytes(pt_gf, pt);
|
|
90
|
-
|
|
91
|
-
// generate random matrix
|
|
92
|
-
generate_matrices_L_and_U(matrix_L, matrix_U, vector_b, iv);
|
|
93
|
-
|
|
94
|
-
for (size_t i = 0; i < AIMER_L; i++)
|
|
95
|
-
{
|
|
96
|
-
// linear component: constant addition
|
|
97
|
-
gf_add(state[i], pt_gf, aim2_constants[i]);
|
|
98
|
-
|
|
99
|
-
// non-linear component: inverse Mersenne S-box
|
|
100
|
-
gf_exp(state[i], state[i], aim2_sbox_exponents[i]);
|
|
101
|
-
|
|
102
|
-
// linear component: affine layer
|
|
103
|
-
gf_mat_vec_mul(state[i], state[i], (const gf *)matrix_U[i]);
|
|
104
|
-
gf_mat_vec_mul(state[i], state[i], (const gf *)matrix_L[i]);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
for (size_t i = 1; i < AIMER_L; i++)
|
|
108
|
-
{
|
|
109
|
-
gf_add(state[0], state[0], state[i]);
|
|
110
|
-
}
|
|
111
|
-
gf_add(state[0], state[0], vector_b);
|
|
112
|
-
|
|
113
|
-
// non-linear component: Mersenne S-box
|
|
114
|
-
gf_exp(state[0], state[0], aim2_sbox_exponents[AIMER_L]);
|
|
115
|
-
|
|
116
|
-
// linear component: feed-forward
|
|
117
|
-
gf_add(ct_gf, state[0], pt_gf);
|
|
118
|
-
|
|
119
|
-
gf_to_bytes(ct, ct_gf);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
void aim2_sbox_outputs(gf sbox_outputs[AIM2_NUM_INPUT_SBOX], const gf pt)
|
|
123
|
-
{
|
|
124
|
-
for (size_t i = 0; i < AIMER_L; i ++)
|
|
125
|
-
{
|
|
126
|
-
// linear component: constant addition
|
|
127
|
-
gf_add(sbox_outputs[i], pt, aim2_constants[i]);
|
|
128
|
-
|
|
129
|
-
// non-linear component: inverse Mersenne S-box
|
|
130
|
-
gf_exp(sbox_outputs[i], sbox_outputs[i], aim2_sbox_exponents[i]);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
void aim2_mpc(mult_chk_t *mult_chk,
|
|
135
|
-
const gf matrix_A[AIMER_L][AIM2_NUM_BITS_FIELD],
|
|
136
|
-
const gf ct_gf)
|
|
137
|
-
{
|
|
138
|
-
// pt + c = t ^ {2 ^ e - 1}
|
|
139
|
-
// --> t ^ {2 ^ e} + t * c = t * pt
|
|
140
|
-
// --> z = x * pt
|
|
141
|
-
for (size_t ell = 0; ell < AIMER_L; ell++)
|
|
142
|
-
{
|
|
143
|
-
gf_sqr(mult_chk->z_shares[ell], mult_chk->x_shares[ell]);
|
|
144
|
-
for (size_t i = 1; i < aim2_exponents[ell]; i++)
|
|
145
|
-
{
|
|
146
|
-
gf_sqr(mult_chk->z_shares[ell], mult_chk->z_shares[ell]);
|
|
147
|
-
}
|
|
148
|
-
gf_mul_add(mult_chk->z_shares[ell], mult_chk->x_shares[ell],
|
|
149
|
-
aim2_constants[ell]);
|
|
150
|
-
gf_mat_vec_mul_add(mult_chk->x_shares[AIMER_L],
|
|
151
|
-
mult_chk->x_shares[ell], matrix_A[ell]);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// x ^ {2 ^ e - 1} = pt + ct
|
|
155
|
-
// --> x ^ {2 ^ e} + x * ct = x * pt
|
|
156
|
-
// --> z = x * pt
|
|
157
|
-
gf_sqr(mult_chk->z_shares[AIMER_L], mult_chk->x_shares[AIMER_L]);
|
|
158
|
-
for (size_t i = 1; i < aim2_exponents[AIMER_L]; i++)
|
|
159
|
-
{
|
|
160
|
-
gf_sqr(mult_chk->z_shares[AIMER_L], mult_chk->z_shares[AIMER_L]);
|
|
161
|
-
}
|
|
162
|
-
gf_mul_add(mult_chk->z_shares[AIMER_L], mult_chk->x_shares[AIMER_L], ct_gf);
|
|
163
|
-
}
|
data/vendor/AIMer/aim2.h
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
#ifndef AIM2_H
|
|
4
|
-
#define AIM2_H
|
|
5
|
-
|
|
6
|
-
#include "aim2_constant.h"
|
|
7
|
-
#include "field.h"
|
|
8
|
-
#include "params.h"
|
|
9
|
-
#include <stdint.h>
|
|
10
|
-
|
|
11
|
-
typedef struct mult_chk_t
|
|
12
|
-
{
|
|
13
|
-
gf pt_share;
|
|
14
|
-
gf x_shares[AIMER_L + 1];
|
|
15
|
-
gf z_shares[AIMER_L + 1];
|
|
16
|
-
} mult_chk_t;
|
|
17
|
-
|
|
18
|
-
#define aim2_generate_linear AIMER_NAMESPACE(aim2_generate_linear)
|
|
19
|
-
void aim2_generate_linear(gf matrix_A[AIM2_NUM_INPUT_SBOX][AIM2_NUM_BITS_FIELD],
|
|
20
|
-
gf vector_b,
|
|
21
|
-
const uint8_t iv[AIM2_IV_SIZE]);
|
|
22
|
-
|
|
23
|
-
#define aim2_sbox_outputs AIMER_NAMESPACE(aim2_sbox_outputs)
|
|
24
|
-
void aim2_sbox_outputs(gf sbox_outputs[AIM2_NUM_INPUT_SBOX], const gf pt);
|
|
25
|
-
|
|
26
|
-
#define aim2 AIMER_NAMESPACE(aim2)
|
|
27
|
-
void aim2(uint8_t ct[AIM2_NUM_BYTES_FIELD],
|
|
28
|
-
const uint8_t pt[AIM2_NUM_BYTES_FIELD],
|
|
29
|
-
const uint8_t iv[AIM2_IV_SIZE]);
|
|
30
|
-
|
|
31
|
-
#define aim2_mpc AIMER_NAMESPACE(aim2_mpc)
|
|
32
|
-
void aim2_mpc(mult_chk_t *mult_chk,
|
|
33
|
-
const gf matrix_A[AIMER_L][AIM2_NUM_BITS_FIELD],
|
|
34
|
-
const gf ct_gf);
|
|
35
|
-
|
|
36
|
-
#endif // AIM2_H
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
#ifndef AIM2_CONSTANT_H
|
|
4
|
-
#define AIM2_CONSTANT_H
|
|
5
|
-
|
|
6
|
-
#include "field.h"
|
|
7
|
-
#include "params.h"
|
|
8
|
-
#include <stdint.h>
|
|
9
|
-
|
|
10
|
-
#if SECURITY_BITS == 128
|
|
11
|
-
static const gf aim2_constants[AIM2_NUM_INPUT_SBOX] =
|
|
12
|
-
{
|
|
13
|
-
{0x13198a2e03707344, 0x243f6a8885a308d3},
|
|
14
|
-
{0x082efa98ec4e6c89, 0xa4093822299f31d0},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
static const uint64_t
|
|
18
|
-
aim2_sbox_exponents[AIM2_NUM_INPUT_SBOX + 1][AIM2_NUM_WORDS_FIELD] =
|
|
19
|
-
{
|
|
20
|
-
{0x6b6b6d6dadadb5b5, 0xb6b6d6d6dadb5b5b},
|
|
21
|
-
{0x6d6db6d6db6b6db5, 0xb6db5b6dadb6dadb},
|
|
22
|
-
{7, 0}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
static const size_t aim2_exponents[AIM2_NUM_INPUT_SBOX + 1] =
|
|
26
|
-
{
|
|
27
|
-
49, 91, 3
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
#elif SECURITY_BITS == 192
|
|
31
|
-
static const gf aim2_constants[AIM2_NUM_INPUT_SBOX] =
|
|
32
|
-
{
|
|
33
|
-
{0xc0ac29b7c97c50dd, 0xbe5466cf34e90c6c, 0x452821e638d01377},
|
|
34
|
-
{0xd1310ba698dfb5ac, 0x9216d5d98979fb1b, 0x3f84d5b5b5470917}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
static const uint64_t
|
|
38
|
-
aim2_sbox_exponents[AIM2_NUM_INPUT_SBOX + 1][AIM2_NUM_WORDS_FIELD] =
|
|
39
|
-
{
|
|
40
|
-
{0xd6ad6b56b5ab5ad5, 0x6ad6b56b5ab5ad5a, 0xad6b56b5ab5ad5ad},
|
|
41
|
-
{0x7776eeeeeeeeeeed, 0xbbbbbbbb77777777, 0xddddddddddddbbbb},
|
|
42
|
-
{31, 0, 0}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
static const size_t aim2_exponents[AIM2_NUM_INPUT_SBOX + 1] =
|
|
46
|
-
{
|
|
47
|
-
17, 47, 5
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
#else
|
|
51
|
-
static const gf aim2_constants[AIM2_NUM_INPUT_SBOX] =
|
|
52
|
-
{
|
|
53
|
-
{0x24a19947b3916cf7,0xba7c9045f12c7f99,0xb8e1afed6a267e96,0x2ffd72dbd01adfb7},
|
|
54
|
-
{0x0d95748f728eb658,0xa458fea3f4933d7e,0x636920d871574e69,0x0801f2e2858efc16},
|
|
55
|
-
{0xc5d1b023286085f0,0x9c30d5392af26013,0x7b54a41dc25a59b5,0x718bcd5882154aee}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
static const uint64_t
|
|
59
|
-
aim2_sbox_exponents[AIM2_NUM_INPUT_SBOX + 1][AIM2_NUM_WORDS_FIELD] =
|
|
60
|
-
{
|
|
61
|
-
{0xdadb5b6b6d6dadb5,0x6b6d6dadb5b6b6d6,0xadb5b6b6d6dadb5b,0xb6d6dadb5b6b6d6d},
|
|
62
|
-
{0x1112224444889111,0x8891112224444889,0x4448889112222444,0x2224448889112222},
|
|
63
|
-
{0xeddbb76eddbb76ed,0x76eddbb76eddbb76,0xbb76eddbb76eddbb,0xddbb76eddbb76edd},
|
|
64
|
-
{7, 0, 0, 0}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
static const size_t aim2_exponents[AIM2_NUM_INPUT_SBOX + 1] =
|
|
68
|
-
{
|
|
69
|
-
11, 141, 7, 3
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
#endif
|
|
73
|
-
|
|
74
|
-
#endif // AIM2_CONSTANT_H
|