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.
Files changed (191) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +21 -0
  4. data/README.md +174 -0
  5. data/Rakefile +57 -0
  6. data/THIRD_PARTY_NOTICES.md +53 -0
  7. data/ext/kpqc/aimer128f/extconf.rb +4 -0
  8. data/ext/kpqc/aimer128s/extconf.rb +4 -0
  9. data/ext/kpqc/aimer192f/extconf.rb +4 -0
  10. data/ext/kpqc/aimer192s/extconf.rb +4 -0
  11. data/ext/kpqc/aimer256f/extconf.rb +4 -0
  12. data/ext/kpqc/aimer256s/extconf.rb +4 -0
  13. data/ext/kpqc/extconf_helper.rb +93 -0
  14. data/ext/kpqc/haetae2/extconf.rb +4 -0
  15. data/ext/kpqc/haetae3/extconf.rb +4 -0
  16. data/ext/kpqc/haetae5/extconf.rb +4 -0
  17. data/ext/kpqc/module.c +195 -0
  18. data/ext/kpqc/ntruplus1152/extconf.rb +4 -0
  19. data/ext/kpqc/ntruplus768/extconf.rb +4 -0
  20. data/ext/kpqc/ntruplus864/extconf.rb +4 -0
  21. data/ext/kpqc/randombytes.c +107 -0
  22. data/ext/kpqc/smaugt128/extconf.rb +4 -0
  23. data/ext/kpqc/smaugt192/extconf.rb +4 -0
  24. data/ext/kpqc/smaugt256/extconf.rb +4 -0
  25. data/ext/kpqc/timer/extconf.rb +4 -0
  26. data/kpqc.gemspec +41 -0
  27. data/lib/kpqc/aimer.rb +38 -0
  28. data/lib/kpqc/api.rb +129 -0
  29. data/lib/kpqc/haetae.rb +25 -0
  30. data/lib/kpqc/ntruplus.rb +25 -0
  31. data/lib/kpqc/smaugt.rb +29 -0
  32. data/lib/kpqc/types.rb +103 -0
  33. data/lib/kpqc/version.rb +6 -0
  34. data/lib/kpqc.rb +33 -0
  35. data/test/algorithm_test.rb +111 -0
  36. data/test/api_test.rb +52 -0
  37. data/test/interop.mjs +34 -0
  38. data/test/interop_test.rb +82 -0
  39. data/test/kat/aimer128f.rsp +10 -0
  40. data/test/kat/aimer128s.rsp +10 -0
  41. data/test/kat/aimer192f.rsp +10 -0
  42. data/test/kat/aimer192s.rsp +10 -0
  43. data/test/kat/aimer256f.rsp +10 -0
  44. data/test/kat/aimer256s.rsp +10 -0
  45. data/test/kat/haetae2.rsp +10 -0
  46. data/test/kat/haetae3.rsp +10 -0
  47. data/test/kat/haetae5.rsp +10 -0
  48. data/test/kat/ntruplus1152.rsp +8 -0
  49. data/test/kat/ntruplus768.rsp +8 -0
  50. data/test/kat/ntruplus864.rsp +8 -0
  51. data/test/kat/smaugt128.rsp +8 -0
  52. data/test/kat/smaugt192.rsp +8 -0
  53. data/test/kat/smaugt256.rsp +8 -0
  54. data/test/kat/timer.rsp +8 -0
  55. data/test/kat_drbg.rb +155 -0
  56. data/test/kat_test.rb +99 -0
  57. data/test/test_helper.rb +21 -0
  58. data/vendor/AIMer/LICENSE +21 -0
  59. data/vendor/AIMer/aim2.c +163 -0
  60. data/vendor/AIMer/aim2.h +36 -0
  61. data/vendor/AIMer/aim2_constant.h +74 -0
  62. data/vendor/AIMer/api.h +42 -0
  63. data/vendor/AIMer/common/crypto_declassify.h +7 -0
  64. data/vendor/AIMer/common/fips202.c +878 -0
  65. data/vendor/AIMer/common/fips202.h +166 -0
  66. data/vendor/AIMer/common/rng.h +56 -0
  67. data/vendor/AIMer/field.h +43 -0
  68. data/vendor/AIMer/field128.c +454 -0
  69. data/vendor/AIMer/field192.c +485 -0
  70. data/vendor/AIMer/field256.c +564 -0
  71. data/vendor/AIMer/hash.c +50 -0
  72. data/vendor/AIMer/hash.h +37 -0
  73. data/vendor/AIMer/params/params-aimer-128f.h +34 -0
  74. data/vendor/AIMer/params/params-aimer-128s.h +34 -0
  75. data/vendor/AIMer/params/params-aimer-192f.h +34 -0
  76. data/vendor/AIMer/params/params-aimer-192s.h +34 -0
  77. data/vendor/AIMer/params/params-aimer-256f.h +34 -0
  78. data/vendor/AIMer/params/params-aimer-256s.h +34 -0
  79. data/vendor/AIMer/params.h +5 -0
  80. data/vendor/AIMer/sign.c +631 -0
  81. data/vendor/AIMer/sign.h +40 -0
  82. data/vendor/AIMer/tree.c +75 -0
  83. data/vendor/AIMer/tree.h +26 -0
  84. data/vendor/HAETAE/LICENSE +22 -0
  85. data/vendor/HAETAE/include/api.h +54 -0
  86. data/vendor/HAETAE/include/common.h +12 -0
  87. data/vendor/HAETAE/include/config.h +42 -0
  88. data/vendor/HAETAE/include/decompose.h +19 -0
  89. data/vendor/HAETAE/include/encoding.h +20 -0
  90. data/vendor/HAETAE/include/fft.h +26 -0
  91. data/vendor/HAETAE/include/fips202.h +40 -0
  92. data/vendor/HAETAE/include/fixpoint.h +125 -0
  93. data/vendor/HAETAE/include/ntt.h +16 -0
  94. data/vendor/HAETAE/include/packing.h +58 -0
  95. data/vendor/HAETAE/include/params.h +117 -0
  96. data/vendor/HAETAE/include/poly.h +65 -0
  97. data/vendor/HAETAE/include/polyfix.h +65 -0
  98. data/vendor/HAETAE/include/polymat.h +32 -0
  99. data/vendor/HAETAE/include/polyvec.h +131 -0
  100. data/vendor/HAETAE/include/randombytes.h +39 -0
  101. data/vendor/HAETAE/include/rans_byte.h +335 -0
  102. data/vendor/HAETAE/include/reduce.h +31 -0
  103. data/vendor/HAETAE/include/sampler.h +23 -0
  104. data/vendor/HAETAE/include/symmetric.h +52 -0
  105. data/vendor/HAETAE/src/decompose.c +73 -0
  106. data/vendor/HAETAE/src/encoding.c +700 -0
  107. data/vendor/HAETAE/src/fft.c +235 -0
  108. data/vendor/HAETAE/src/fips202.c +745 -0
  109. data/vendor/HAETAE/src/fixpoint.c +143 -0
  110. data/vendor/HAETAE/src/ntt.c +98 -0
  111. data/vendor/HAETAE/src/packing.c +595 -0
  112. data/vendor/HAETAE/src/poly.c +371 -0
  113. data/vendor/HAETAE/src/polyfix.c +298 -0
  114. data/vendor/HAETAE/src/polymat.c +82 -0
  115. data/vendor/HAETAE/src/polyvec.c +534 -0
  116. data/vendor/HAETAE/src/reduce.c +96 -0
  117. data/vendor/HAETAE/src/sampler.c +310 -0
  118. data/vendor/HAETAE/src/sign.c +558 -0
  119. data/vendor/HAETAE/src/symmetric-shake.c +50 -0
  120. data/vendor/NTRUplus/LICENSE +21 -0
  121. data/vendor/NTRUplus/NTRU+1152/api.h +24 -0
  122. data/vendor/NTRUplus/NTRU+1152/fips202/fips202.c +878 -0
  123. data/vendor/NTRUplus/NTRU+1152/fips202/fips202.h +166 -0
  124. data/vendor/NTRUplus/NTRU+1152/kem.c +286 -0
  125. data/vendor/NTRUplus/NTRU+1152/ntt.c +394 -0
  126. data/vendor/NTRUplus/NTRU+1152/ntt.h +16 -0
  127. data/vendor/NTRUplus/NTRU+1152/params.h +18 -0
  128. data/vendor/NTRUplus/NTRU+1152/poly.c +318 -0
  129. data/vendor/NTRUplus/NTRU+1152/poly.h +31 -0
  130. data/vendor/NTRUplus/NTRU+1152/randombytes.h +9 -0
  131. data/vendor/NTRUplus/NTRU+1152/symmetric.c +39 -0
  132. data/vendor/NTRUplus/NTRU+1152/symmetric.h +12 -0
  133. data/vendor/NTRUplus/NTRU+768/api.h +24 -0
  134. data/vendor/NTRUplus/NTRU+768/fips202/fips202.c +878 -0
  135. data/vendor/NTRUplus/NTRU+768/fips202/fips202.h +166 -0
  136. data/vendor/NTRUplus/NTRU+768/kem.c +286 -0
  137. data/vendor/NTRUplus/NTRU+768/ntt.c +379 -0
  138. data/vendor/NTRUplus/NTRU+768/ntt.h +16 -0
  139. data/vendor/NTRUplus/NTRU+768/params.h +18 -0
  140. data/vendor/NTRUplus/NTRU+768/poly.c +320 -0
  141. data/vendor/NTRUplus/NTRU+768/poly.h +31 -0
  142. data/vendor/NTRUplus/NTRU+768/randombytes.h +9 -0
  143. data/vendor/NTRUplus/NTRU+768/symmetric.c +39 -0
  144. data/vendor/NTRUplus/NTRU+768/symmetric.h +12 -0
  145. data/vendor/NTRUplus/NTRU+864/api.h +24 -0
  146. data/vendor/NTRUplus/NTRU+864/fips202/fips202.c +878 -0
  147. data/vendor/NTRUplus/NTRU+864/fips202/fips202.h +166 -0
  148. data/vendor/NTRUplus/NTRU+864/kem.c +286 -0
  149. data/vendor/NTRUplus/NTRU+864/ntt.c +383 -0
  150. data/vendor/NTRUplus/NTRU+864/ntt.h +16 -0
  151. data/vendor/NTRUplus/NTRU+864/params.h +18 -0
  152. data/vendor/NTRUplus/NTRU+864/poly.c +314 -0
  153. data/vendor/NTRUplus/NTRU+864/poly.h +31 -0
  154. data/vendor/NTRUplus/NTRU+864/randombytes.h +9 -0
  155. data/vendor/NTRUplus/NTRU+864/symmetric.c +39 -0
  156. data/vendor/NTRUplus/NTRU+864/symmetric.h +12 -0
  157. data/vendor/SMAUG-T/LICENSE +22 -0
  158. data/vendor/SMAUG-T/include/api.h +37 -0
  159. data/vendor/SMAUG-T/include/cbd.h +15 -0
  160. data/vendor/SMAUG-T/include/ciphertext.h +45 -0
  161. data/vendor/SMAUG-T/include/common.h +12 -0
  162. data/vendor/SMAUG-T/include/config.h +48 -0
  163. data/vendor/SMAUG-T/include/dg.h +28 -0
  164. data/vendor/SMAUG-T/include/fips202.h +41 -0
  165. data/vendor/SMAUG-T/include/hash.h +21 -0
  166. data/vendor/SMAUG-T/include/hwt.h +28 -0
  167. data/vendor/SMAUG-T/include/indcpa.h +33 -0
  168. data/vendor/SMAUG-T/include/key.h +34 -0
  169. data/vendor/SMAUG-T/include/pack.h +78 -0
  170. data/vendor/SMAUG-T/include/packring.h +50 -0
  171. data/vendor/SMAUG-T/include/params.h +84 -0
  172. data/vendor/SMAUG-T/include/poly.h +41 -0
  173. data/vendor/SMAUG-T/include/randombytes.h +11 -0
  174. data/vendor/SMAUG-T/include/toomcook.h +14 -0
  175. data/vendor/SMAUG-T/include/verify.h +16 -0
  176. data/vendor/SMAUG-T/src/cbd.c +159 -0
  177. data/vendor/SMAUG-T/src/ciphertext.c +95 -0
  178. data/vendor/SMAUG-T/src/dg.c +112 -0
  179. data/vendor/SMAUG-T/src/fips202.c +745 -0
  180. data/vendor/SMAUG-T/src/hash.c +15 -0
  181. data/vendor/SMAUG-T/src/hwt.c +121 -0
  182. data/vendor/SMAUG-T/src/indcpa.c +187 -0
  183. data/vendor/SMAUG-T/src/kem.c +194 -0
  184. data/vendor/SMAUG-T/src/key.c +102 -0
  185. data/vendor/SMAUG-T/src/pack.c +349 -0
  186. data/vendor/SMAUG-T/src/packring.c +503 -0
  187. data/vendor/SMAUG-T/src/poly.c +200 -0
  188. data/vendor/SMAUG-T/src/toomcook.c +256 -0
  189. data/vendor/SMAUG-T/src/verify.c +48 -0
  190. data/vendor/SOURCES.json +130 -0
  191. metadata +280 -0
@@ -0,0 +1,163 @@
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
+ }
@@ -0,0 +1,36 @@
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
@@ -0,0 +1,74 @@
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
@@ -0,0 +1,42 @@
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 API_H
10
+ #define API_H
11
+
12
+ #include "params.h"
13
+ #include <stddef.h>
14
+ #include <stdint.h>
15
+
16
+ #define CRYPTO_PUBLICKEYBYTES AIMER_PK_BYTES
17
+ #define CRYPTO_SECRETKEYBYTES AIMER_SK_BYTES
18
+ #define CRYPTO_BYTES AIMER_SIG_BYTES
19
+ #define CRYPTO_ALGNAME "aimer-" xstr(PARAMS)
20
+
21
+ #define crypto_sign_keypair AIMER_NAMESPACE(crypto_sign_keypair)
22
+ int crypto_sign_keypair(uint8_t *pk, uint8_t *sk);
23
+
24
+ #define crypto_sign_signature AIMER_NAMESPACE(crypto_sign_signature)
25
+ int crypto_sign_signature(uint8_t *sig, size_t *siglen,
26
+ const uint8_t *m, size_t mlen,
27
+ const uint8_t *ctx, size_t ctxlen, const uint8_t *sk);
28
+
29
+ #define crypto_sign AIMER_NAMESPACE(crypto_sign)
30
+ int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
31
+ const uint8_t *ctx, size_t ctxlen, const uint8_t *sk);
32
+
33
+ #define crypto_sign_verify AIMER_NAMESPACE(crypto_sign_verify)
34
+ int crypto_sign_verify(const uint8_t *sig, size_t siglen,
35
+ const uint8_t *m, size_t mlen,
36
+ const uint8_t *ctx, size_t ctxlen, const uint8_t *pk);
37
+
38
+ #define crypto_sign_open AIMER_NAMESPACE(crypto_sign_open)
39
+ int crypto_sign_open(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen,
40
+ const uint8_t *ctx, size_t ctxlen, const uint8_t *pk);
41
+
42
+ #endif
@@ -0,0 +1,7 @@
1
+ #ifndef PQCLEAN_CRYPTO_DECLASSIFY
2
+ #define PQCLEAN_CRYPTO_DECLASSIFY
3
+
4
+ /* EMPTY MACRO DEFINITION */
5
+ #define crypto_declassify(x, y)
6
+
7
+ #endif