Skip to content

Commit 4b83264

Browse files
committed
more namespacing changes
1 parent 7187798 commit 4b83264

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+496
-682
lines changed

avx2/Makefile

Lines changed: 68 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ NISTFLAGS += -Wno-unused-result -march=native -mtune=native -O3
66
SOURCES = sign.c packing.c polyvec.c poly.c ntt.S invntt.S pointwise.S \
77
consts.c rejsample.c reduce.S
88
HEADERS = config.h params.h api.h sign.h packing.h polyvec.h poly.h ntt.h \
9-
consts.h shuffle.inc rejsample.h reduce.h rounding.h symmetric.h
9+
consts.h shuffle.inc rejsample.h reduce.h rounding.h symmetric.h randombytes.h
1010
KECCAK_SOURCES = $(SOURCES) fips202.c fips202x4.c symmetric-shake.c \
1111
keccak4x/KeccakP-1600-times4-SIMD256.o
1212
KECCAK_HEADERS = $(HEADERS) fips202.h fips202x4.h
1313
AES_SOURCES = $(SOURCES) fips202.c aes256ctr.c
1414
AES_HEADERS = $(HEADERS) fips202.h aes256ctr.h
1515

16+
.PHONY: all shared clean
17+
1618
all: \
1719
test/test_dilithium2 \
1820
test/test_dilithium3 \
@@ -40,15 +42,15 @@ all: \
4042
PQCgenKAT_sign4aes
4143

4244
shared: \
43-
dilithium2_avx2.so \
44-
dilithium3_avx2.so \
45-
dilithium4_avx2.so \
46-
dilithium2aes_avx2.so \
47-
dilithium3aes_avx2.so \
48-
dilithium4aes_avx2.so \
49-
pqcrystals_ref.so \
50-
pqcrystals_avx2.so \
51-
pqcrystals_avx2_aes256ctr.so
45+
libpqcrystals_dilithium2_avx2.so \
46+
libpqcrystals_dilithium3_avx2.so \
47+
libpqcrystals_dilithium4_avx2.so \
48+
libpqcrystals_dilithium2aes_avx2.so \
49+
libpqcrystals_dilithium3aes_avx2.so \
50+
libpqcrystals_dilithium4aes_avx2.so \
51+
libpqcrystals_fips202_ref.so \
52+
libpqcrystals_fips202x4_avx2.so \
53+
libpqcrystals_aes256ctr_avx2.so
5254

5355
keccak4x/KeccakP-1600-times4-SIMD256.o: \
5456
keccak4x/KeccakP-1600-times4-SIMD256.c \
@@ -59,189 +61,177 @@ keccak4x/KeccakP-1600-times4-SIMD256.o: \
5961
keccak4x/brg_endian.h
6062
$(CC) $(CFLAGS) -c $< -o $@
6163

62-
pqcrystals_ref.so: fips202.c fips202.h
64+
libpqcrystals_fips202_ref.so: fips202.c fips202.h
6365
$(CC) -shared -fPIC $(CFLAGS) -o $@ $<
6466

65-
pqcrystals_avx2.so: fips202x4.c fips202x4.h \
67+
libpqcrystals_fips202x4_avx2.so: fips202x4.c fips202x4.h \
6668
keccak4x/KeccakP-1600-times4-SIMD256.o
6769
$(CC) -shared -fPIC $(CFLAGS) -o $@ $< \
6870
keccak4x/KeccakP-1600-times4-SIMD256.o
6971

70-
pqcrystals_avx2_aes256ctr.so: aes256ctr.c aes256ctr.h
72+
libpqcrystals_aes256ctr_avx2.so: aes256ctr.c aes256ctr.h
7173
$(CC) -shared -fPIC $(CFLAGS) -o $@ $<
7274

73-
dilithium2_avx2.so: $(SOURCES) $(HEADERS) symmetric-shake.c
75+
libpqcrystals_dilithium2_avx2.so: $(SOURCES) $(HEADERS) symmetric-shake.c
7476
$(CC) -shared -fPIC $(CFLAGS) -DDILITHIUM_MODE=2 \
7577
-o $@ $(SOURCES) symmetric-shake.c
7678

77-
dilithium3_avx2.so: $(SOURCES) $(HEADERS) symmetric-shake.c
79+
libpqcrystals_dilithium3_avx2.so: $(SOURCES) $(HEADERS) symmetric-shake.c
7880
$(CC) -shared -fPIC $(CFLAGS) -DDILITHIUM_MODE=3 \
7981
-o $@ $(SOURCES) symmetric-shake.c
8082

81-
dilithium4_avx2.so: $(SOURCES) $(HEADERS) symmetric-shake.c
83+
libpqcrystals_dilithium4_avx2.so: $(SOURCES) $(HEADERS) symmetric-shake.c
8284
$(CC) -shared -fPIC $(CFLAGS) -DDILITHIUM_MODE=4 \
8385
-o $@ $(SOURCES) symmetric-shake.c
8486

85-
dilithium2aes_avx2.so: $(SOURCES) $(HEADERS)
87+
libpqcrystals_dilithium2aes_avx2.so: $(SOURCES) $(HEADERS)
8688
$(CC) -shared -fPIC $(CFLAGS) -DDILITHIUM_MODE=2 -DDILITHIUM_USE_AES \
8789
-o $@ $(SOURCES)
8890

89-
dilithium3aes_avx2.so: $(SOURCES) $(HEADERS)
91+
libpqcrystals_dilithium3aes_avx2.so: $(SOURCES) $(HEADERS)
9092
$(CC) -shared -fPIC $(CFLAGS) -DDILITHIUM_MODE=3 -DDILITHIUM_USE_AES \
9193
-o $@ $(SOURCES)
9294

93-
dilithium4aes_avx2.so: $(SOURCES) $(HEADERS)
95+
libpqcrystals_dilithium4aes_avx2.so: $(SOURCES) $(HEADERS)
9496
$(CC) -shared -fPIC $(CFLAGS) -DDILITHIUM_MODE=4 -DDILITHIUM_USE_AES \
9597
-o $@ $(SOURCES)
9698

9799
test/test_dilithium2: test/test_dilithium.c randombytes.c $(KECCAK_SOURCES) \
98-
randombytes.h $(KECCAK_HEADERS)
100+
$(KECCAK_HEADERS)
99101
$(CC) $(CFLAGS) -DDILITHIUM_MODE=2 \
100102
-o $@ $< randombytes.c $(KECCAK_SOURCES)
101103

102104
test/test_dilithium3: test/test_dilithium.c randombytes.c $(KECCAK_SOURCES) \
103-
randombytes.h $(KECCAK_HEADERS)
105+
$(KECCAK_HEADERS)
104106
$(CC) $(CFLAGS) -DDILITHIUM_MODE=3 \
105107
-o $@ $< randombytes.c $(KECCAK_SOURCES)
106108

107109
test/test_dilithium4: test/test_dilithium.c randombytes.c $(KECCAK_SOURCES) \
108-
randombytes.h $(KECCAK_HEADERS)
110+
$(KECCAK_HEADERS)
109111
$(CC) $(CFLAGS) -DDILITHIUM_MODE=4 \
110112
-o $@ $< randombytes.c $(KECCAK_SOURCES)
111113

112114
test/test_dilithium2aes: test/test_dilithium.c randombytes.c $(AES_SOURCES) \
113-
randombytes.h $(AES_HEADERS)
115+
$(AES_HEADERS)
114116
$(CC) $(CFLAGS) -DDILITHIUM_MODE=2 -DDILITHIUM_USE_AES \
115117
-o $@ $< randombytes.c $(AES_SOURCES)
116118

117119
test/test_dilithium3aes: test/test_dilithium.c randombytes.c $(AES_SOURCES) \
118-
randombytes.h $(AES_HEADERS)
120+
$(AES_HEADERS)
119121
$(CC) $(CFLAGS) -DDILITHIUM_MODE=3 -DDILITHIUM_USE_AES \
120122
-o $@ $< randombytes.c $(AES_SOURCES)
121123

122124
test/test_dilithium4aes: test/test_dilithium.c randombytes.c $(AES_SOURCES) \
123-
randombytes.h $(AES_HEADERS)
125+
$(AES_HEADERS)
124126
$(CC) $(CFLAGS) -DDILITHIUM_MODE=4 -DDILITHIUM_USE_AES \
125127
-o $@ $< randombytes.c $(AES_SOURCES)
126128

127-
test/test_vectors2: test/test_vectors.c rng.c $(KECCAK_SOURCES) \
128-
rng.h $(KECCAK_HEADERS)
129+
test/test_vectors2: test/test_vectors.c rng.c rng.h $(KECCAK_SOURCES) \
130+
$(KECCAK_HEADERS)
129131
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=2 \
130132
-o $@ $< rng.c $(KECCAK_SOURCES) -lcrypto
131133

132-
test/test_vectors3: test/test_vectors.c rng.c $(KECCAK_SOURCES) \
133-
rng.h $(KECCAK_HEADERS)
134+
test/test_vectors3: test/test_vectors.c rng.c rng.h $(KECCAK_SOURCES) \
135+
$(KECCAK_HEADERS)
134136
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=3 \
135137
-o $@ $< rng.c $(KECCAK_SOURCES) -lcrypto
136138

137-
test/test_vectors4: test/test_vectors.c rng.c $(KECCAK_SOURCES) \
138-
rng.h $(KECCAK_HEADERS)
139+
test/test_vectors4: test/test_vectors.c rng.c rng.h $(KECCAK_SOURCES) \
140+
$(KECCAK_HEADERS)
139141
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=4 \
140142
-o $@ $< rng.c $(KECCAK_SOURCES) -lcrypto
141143

142-
test/test_vectors2aes: test/test_vectors.c rng.c $(AES_SOURCES) \
143-
rng.h $(AES_HEADERS)
144+
test/test_vectors2aes: test/test_vectors.c rng.c rng.h $(AES_SOURCES) \
145+
$(AES_HEADERS)
144146
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=2 -DDILITHIUM_USE_AES \
145147
-o $@ $< rng.c $(AES_SOURCES) -lcrypto
146148

147-
test/test_vectors3aes: test/test_vectors.c rng.c $(AES_SOURCES) \
148-
rng.h $(AES_HEADERS)
149+
test/test_vectors3aes: test/test_vectors.c rng.c rng.h $(AES_SOURCES) \
150+
$(AES_HEADERS)
149151
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=3 -DDILITHIUM_USE_AES \
150152
-o $@ $< rng.c $(AES_SOURCES) -lcrypto
151153

152-
test/test_vectors4aes: test/test_vectors.c rng.c $(AES_SOURCES) \
153-
rng.h $(AES_HEADERS)
154+
test/test_vectors4aes: test/test_vectors.c rng.c rng.h $(AES_SOURCES) \
155+
$(AES_HEADERS)
154156
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=4 -DDILITHIUM_USE_AES \
155157
-o $@ $< rng.c $(AES_SOURCES) -lcrypto
156158

157-
test/test_speed2: test/test_speed.c test/speed_print.c test/cpucycles.c \
158-
randombytes.c $(KECCAK_SOURCES) \
159-
test/speed_print.h test/cpucycles.h randombytes.h $(KECCAK_HEADERS)
159+
test/test_speed2: test/test_speed.c test/speed_print.c test/speed_print.h \
160+
test/cpucycles.c test/cpucycles.h randombytes.c $(KECCAK_SOURCES) \
161+
$(KECCAK_HEADERS)
160162
$(CC) $(CFLAGS) -DDILITHIUM_MODE=2 \
161163
-o $@ $< test/speed_print.c test/cpucycles.c randombytes.c \
162164
$(KECCAK_SOURCES)
163165

164-
test/test_speed3: test/test_speed.c test/speed_print.c test/cpucycles.c \
165-
randombytes.c $(KECCAK_SOURCES) \
166-
test/speed_print.h test/cpucycles.h randombytes.h $(KECCAK_HEADERS)
166+
test/test_speed3: test/test_speed.c test/speed_print.c test/speed_print.h \
167+
test/cpucycles.c test/cpucycles.h randombytes.c $(KECCAK_SOURCES) \
168+
$(KECCAK_HEADERS)
167169
$(CC) $(CFLAGS) -DDILITHIUM_MODE=3 \
168170
-o $@ $< test/speed_print.c test/cpucycles.c randombytes.c \
169171
$(KECCAK_SOURCES)
170172

171-
test/test_speed4: test/test_speed.c test/speed_print.c test/cpucycles.c \
172-
randombytes.c $(KECCAK_SOURCES) \
173-
test/speed_print.h test/cpucycles.h randombytes.h $(KECCAK_HEADERS)
173+
test/test_speed4: test/test_speed.c test/speed_print.c test/speed_print.h \
174+
test/cpucycles.c test/cpucycles.h randombytes.c $(KECCAK_SOURCES) \
175+
$(KECCAK_HEADERS)
174176
$(CC) $(CFLAGS) -DDILITHIUM_MODE=4 \
175177
-o $@ $< test/speed_print.c test/cpucycles.c randombytes.c \
176178
$(KECCAK_SOURCES)
177179

178-
test/test_speed2aes: test/test_speed.c test/speed_print.c test/cpucycles.c \
179-
randombytes.c $(AES_SOURCES) \
180-
test/speed_print.h test/cpucycles.h randombytes.h $(AES_HEADERS)
180+
test/test_speed2aes: test/test_speed.c test/speed_print.c test/speed_print.h \
181+
test/cpucycles.c test/cpucycles.h randombytes.c $(AES_SOURCES) \
182+
$(AES_HEADERS)
181183
$(CC) $(CFLAGS) -DDILITHIUM_MODE=2 -DDILITHIUM_USE_AES \
182184
-o $@ $< test/speed_print.c test/cpucycles.c randombytes.c \
183185
$(AES_SOURCES)
184186

185-
test/test_speed3aes: test/test_speed.c test/speed_print.c test/cpucycles.c \
186-
randombytes.c $(AES_SOURCES) \
187-
test/speed_print.h test/cpucycles.h randombytes.h $(AES_HEADERS)
187+
test/test_speed3aes: test/test_speed.c test/speed_print.c test/speed_print.h \
188+
test/cpucycles.c test/cpucycles.h randombytes.c $(AES_SOURCES) \
189+
$(AES_HEADERS)
188190
$(CC) $(CFLAGS) -DDILITHIUM_MODE=3 -DDILITHIUM_USE_AES \
189191
-o $@ $< test/speed_print.c test/cpucycles.c randombytes.c \
190192
$(AES_SOURCES)
191193

192-
test/test_speed4aes: test/test_speed.c test/speed_print.c test/cpucycles.c \
193-
randombytes.c $(AES_SOURCES) \
194-
test/speed_print.h test/cpucycles.h randombytes.h $(AES_HEADERS)
194+
test/test_speed4aes: test/test_speed.c test/speed_print.c test/speed_print.h \
195+
test/cpucycles.c test/cpucycles.h randombytes.c $(AES_SOURCES) \
196+
$(AES_HEADERS)
195197
$(CC) $(CFLAGS) -DDILITHIUM_MODE=4 -DDILITHIUM_USE_AES \
196198
-o $@ $< test/speed_print.c test/cpucycles.c randombytes.c \
197199
$(AES_SOURCES)
198200

199201
test/test_mul: test/test_mul.c randombytes.c $(KECCAK_SOURCES) \
200-
randombytes.h $(KECCAK_HEADERS)
202+
$(KECCAK_HEADERS)
201203
$(CC) $(CFLAGS) -UDBENCH -o $@ $< randombytes.c $(KECCAK_SOURCES)
202204

203-
PQCgenKAT_sign2: PQCgenKAT_sign.c rng.c $(KECCAK_SOURCES) \
204-
rng.h $(KECCAK_HEADERS)
205+
PQCgenKAT_sign2: PQCgenKAT_sign.c rng.c rng.h $(KECCAK_SOURCES) \
206+
$(KECCAK_HEADERS)
205207
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=2 \
206208
-o $@ $< rng.c $(KECCAK_SOURCES) -lcrypto
207209

208-
PQCgenKAT_sign3: PQCgenKAT_sign.c rng.c $(KECCAK_SOURCES) \
209-
rng.h $(KECCAK_HEADERS)
210+
PQCgenKAT_sign3: PQCgenKAT_sign.c rng.c rng.h $(KECCAK_SOURCES) \
211+
$(KECCAK_HEADERS)
210212
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=3 \
211213
-o $@ $< rng.c $(KECCAK_SOURCES) -lcrypto
212214

213-
PQCgenKAT_sign4: PQCgenKAT_sign.c rng.c $(KECCAK_SOURCES) \
214-
rng.h $(KECCAK_HEADERS)
215+
PQCgenKAT_sign4: PQCgenKAT_sign.c rng.c rng.h $(KECCAK_SOURCES) \
216+
$(KECCAK_HEADERS)
215217
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=4 \
216218
-o $@ $< rng.c $(KECCAK_SOURCES) -lcrypto
217219

218-
PQCgenKAT_sign2aes: PQCgenKAT_sign.c rng.c $(AES_SOURCES) \
219-
rng.h $(AES_HEADERS)
220+
PQCgenKAT_sign2aes: PQCgenKAT_sign.c rng.c rng.h $(AES_SOURCES) $(AES_HEADERS)
220221
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=2 -DDILITHIUM_USE_AES \
221222
-o $@ $< rng.c $(AES_SOURCES) -lcrypto
222223

223-
PQCgenKAT_sign3aes: PQCgenKAT_sign.c rng.c $(AES_SOURCES) \
224-
rng.h $(AES_HEADERS)
224+
PQCgenKAT_sign3aes: PQCgenKAT_sign.c rng.c rng.h $(AES_SOURCES) $(AES_HEADERS)
225225
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=3 -DDILITHIUM_USE_AES \
226226
-o $@ $< rng.c $(AES_SOURCES) -lcrypto
227227

228-
PQCgenKAT_sign4aes: PQCgenKAT_sign.c rng.c $(AES_SOURCES) \
229-
rng.h $(AES_HEADERS)
228+
PQCgenKAT_sign4aes: PQCgenKAT_sign.c rng.c rng.h $(AES_SOURCES) $(AES_HEADERS)
230229
$(CC) $(NISTFLAGS) -DDILITHIUM_MODE=4 -DDILITHIUM_USE_AES \
231230
-o $@ $< rng.c $(AES_SOURCES) -lcrypto
232231

233232
clean:
234-
rm -f *~ test/*~
235-
rm -f dilithium2_avx2.so
236-
rm -f dilithium3_avx2.so
237-
rm -f dilithium4_avx2.so
238-
rm -f dilithium2aes_avx2.so
239-
rm -f dilithium3aes_avx2.so
240-
rm -f dilithium4aes_avx2.so
233+
rm -f *.o *.a *.so
241234
rm -f keccak4x/KeccakP-1600-times4-SIMD256.o
242-
rm -f pqcrystals_ref.so
243-
rm -f pqcrystals_avx2.so
244-
rm -f pqcrystals_avx2_aes256ctr.so
245235
rm -f test/test_dilithium2
246236
rm -f test/test_dilithium3
247237
rm -f test/test_dilithium4

avx2/aes256ctr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ typedef struct {
1212
__m128i n;
1313
} aes256ctr_ctx;
1414

15-
#define aes256ctr_init pqcrystals_avx2_aes256ctr_init
15+
#define aes256ctr_init pqcrystals_aes256ctr_avx2_init
1616
void aes256ctr_init(aes256ctr_ctx *state,
1717
const uint8_t key[32],
1818
uint64_t nonce);
1919

20-
#define aes256ctr_squeezeblocks pqcrystals_avx2_aes256ctr_squeezeblocks
20+
#define aes256ctr_squeezeblocks pqcrystals_aes256ctr_avx2_squeezeblocks
2121
void aes256ctr_squeezeblocks(uint8_t *out,
2222
size_t nblocks,
2323
aes256ctr_ctx *state);
2424

25-
#define aes256ctr_prf pqcrystals_avx2_aes256ctr_prf
25+
#define aes256ctr_prf pqcrystals_aes256ctr_avx2_prf
2626
void aes256ctr_prf(uint8_t *out,
2727
size_t outlen,
2828
const uint8_t key[32],

avx2/api.h

Lines changed: 0 additions & 73 deletions
This file was deleted.

avx2/api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ref/api.h

0 commit comments

Comments
 (0)