aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/s2n/pq-crypto/kyber_r3/kyber512r3_consts_avx2.c
blob: cdc0b817df0288670173c2c20e2decc01dc3f107 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "kyber512r3_align_avx2.h"
#include "kyber512r3_consts_avx2.h"

#if defined(S2N_KYBER512R3_AVX2_BMI2)
#define Q S2N_KYBER_512_R3_Q
#define MONT -1044 // 2^16 mod q
#define QINV -3327 // q^-1 mod 2^16
#define V 20159 // floor(2^26/q + 0.5)
#define FHI 1441 // mont^2/128
#define FLO -10079 // qinv*FHI
#define MONTSQHI 1353 // mont^2
#define MONTSQLO 20553 // qinv*MONTSQHI
#define MASK 4095
#define SHIFT 32

const qdata_t qdata = {{
#define _16XQ 0
  Q, Q, Q, Q, Q, Q, Q, Q, Q, Q, Q, Q, Q, Q, Q, Q,

#define _16XQINV 16
  QINV, QINV, QINV, QINV, QINV, QINV, QINV, QINV,
  QINV, QINV, QINV, QINV, QINV, QINV, QINV, QINV,

#define _16XV 32
  V, V, V, V, V, V, V, V, V, V, V, V, V, V, V, V,

#define _16XFLO 48
  FLO, FLO, FLO, FLO, FLO, FLO, FLO, FLO,
  FLO, FLO, FLO, FLO, FLO, FLO, FLO, FLO,

#define _16XFHI 64
  FHI, FHI, FHI, FHI, FHI, FHI, FHI, FHI,
  FHI, FHI, FHI, FHI, FHI, FHI, FHI, FHI,

#define _16XMONTSQLO 80
  MONTSQLO, MONTSQLO, MONTSQLO, MONTSQLO,
  MONTSQLO, MONTSQLO, MONTSQLO, MONTSQLO,
  MONTSQLO, MONTSQLO, MONTSQLO, MONTSQLO,
  MONTSQLO, MONTSQLO, MONTSQLO, MONTSQLO,

#define _16XMONTSQHI 96
  MONTSQHI, MONTSQHI, MONTSQHI, MONTSQHI,
  MONTSQHI, MONTSQHI, MONTSQHI, MONTSQHI,
  MONTSQHI, MONTSQHI, MONTSQHI, MONTSQHI,
  MONTSQHI, MONTSQHI, MONTSQHI, MONTSQHI,

#define _16XMASK 112
  MASK, MASK, MASK, MASK, MASK, MASK, MASK, MASK,
  MASK, MASK, MASK, MASK, MASK, MASK, MASK, MASK,

#define _REVIDXB 128
  3854, 3340, 2826, 2312, 1798, 1284, 770, 256,
  3854, 3340, 2826, 2312, 1798, 1284, 770, 256,

#define _REVIDXD 144
  7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 0, 0,

#define _ZETAS_EXP 160
   31498,  31498,  31498,  31498,   -758,   -758,   -758,   -758,
    5237,   5237,   5237,   5237,   1397,   1397,   1397,   1397,
   14745,  14745,  14745,  14745,  14745,  14745,  14745,  14745,
   14745,  14745,  14745,  14745,  14745,  14745,  14745,  14745,
    -359,   -359,   -359,   -359,   -359,   -359,   -359,   -359,
    -359,   -359,   -359,   -359,   -359,   -359,   -359,   -359,
   13525,  13525,  13525,  13525,  13525,  13525,  13525,  13525,
  -12402, -12402, -12402, -12402, -12402, -12402, -12402, -12402,
    1493,   1493,   1493,   1493,   1493,   1493,   1493,   1493,
    1422,   1422,   1422,   1422,   1422,   1422,   1422,   1422,
  -20907, -20907, -20907, -20907,  27758,  27758,  27758,  27758,
   -3799,  -3799,  -3799,  -3799, -15690, -15690, -15690, -15690,
    -171,   -171,   -171,   -171,    622,    622,    622,    622,
    1577,   1577,   1577,   1577,    182,    182,    182,    182,
   -5827,  -5827,  17363,  17363, -26360, -26360, -29057, -29057,
    5571,   5571,  -1102,  -1102,  21438,  21438, -26242, -26242,
     573,    573,  -1325,  -1325,    264,    264,    383,    383,
    -829,   -829,   1458,   1458,  -1602,  -1602,   -130,   -130,
   -5689,  -6516,   1496,  30967, -23565,  20179,  20710,  25080,
  -12796,  26616,  16064, -12442,   9134,   -650, -25986,  27837,
    1223,    652,   -552,   1015,  -1293,   1491,   -282,  -1544,
     516,     -8,   -320,   -666,  -1618,  -1162,    126,   1469,
    -335, -11477, -32227,  20494, -27738,    945, -14883,   6182,
   32010,  10631,  29175, -28762, -18486,  17560, -14430,  -5276,
   -1103,    555,  -1251,   1550,    422,    177,   -291,   1574,
    -246,   1159,   -777,   -602,  -1590,   -872,    418,   -156,
   11182,  13387, -14233, -21655,  13131,  -4587,  23092,   5493,
  -32502,  30317, -18741,  12639,  20100,  18525,  19529, -12619,
     430,    843,    871,    105,    587,   -235,   -460,   1653,
     778,   -147,   1483,   1119,    644,    349,    329,    -75,
     787,    787,    787,    787,    787,    787,    787,    787,
     787,    787,    787,    787,    787,    787,    787,    787,
   -1517,  -1517,  -1517,  -1517,  -1517,  -1517,  -1517,  -1517,
   -1517,  -1517,  -1517,  -1517,  -1517,  -1517,  -1517,  -1517,
   28191,  28191,  28191,  28191,  28191,  28191,  28191,  28191,
  -16694, -16694, -16694, -16694, -16694, -16694, -16694, -16694,
     287,    287,    287,    287,    287,    287,    287,    287,
     202,    202,    202,    202,    202,    202,    202,    202,
   10690,  10690,  10690,  10690,   1358,   1358,   1358,   1358,
  -11202, -11202, -11202, -11202,  31164,  31164,  31164,  31164,
     962,    962,    962,    962,  -1202,  -1202,  -1202,  -1202,
   -1474,  -1474,  -1474,  -1474,   1468,   1468,   1468,   1468,
  -28073, -28073,  24313,  24313, -10532, -10532,   8800,   8800,
   18426,  18426,   8859,   8859,  26675,  26675, -16163, -16163,
    -681,   -681,   1017,   1017,    732,    732,    608,    608,
   -1542,  -1542,    411,    411,   -205,   -205,  -1571,  -1571,
   19883, -28250, -15887,  -8898, -28309,   9075, -30199,  18249,
   13426,  14017, -29156, -12757,  16832,   4311, -24155, -17915,
    -853,    -90,   -271,    830,    107,  -1421,   -247,   -951,
    -398,    961,  -1508,   -725,    448,  -1065,    677,  -1275,
  -31183,  25435,  -7382,  24391, -20927,  10946,  24214,  16989,
   10335,  -7934, -22502,  10906,  31636,  28644,  23998, -17422,
     817,    603,   1322,  -1465,  -1215,   1218,   -874,  -1187,
   -1185,  -1278,  -1510,   -870,   -108,    996,    958,   1522,
   20297,   2146,  15355, -32384,  -6280, -14903, -11044,  14469,
  -21498, -20198,  23210, -17442, -23860, -20257,   7756,  23132,
    1097,    610,  -1285,    384,   -136,  -1335,    220,  -1659,
   -1530,    794,   -854,    478,   -308,    991,  -1460,   1628,

#define _16XSHIFT 624
  SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT,
  SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT
}};
#endif