|
| 1 | +CC ?= /usr/bin/cc |
| 2 | +CFLAGS += -Wall -Wextra -Wpedantic -Wmissing-prototypes -Wredundant-decls \ |
| 3 | + -Wshadow -Wpointer-arith -O3 -fomit-frame-pointer -z noexecstack |
| 4 | +NISTFLAGS += -Wno-unused-result -O3 -fomit-frame-pointer |
| 5 | +RM = /bin/rm |
| 6 | + |
| 7 | +SOURCES = kem.c indcpa.c polyvec.c poly.c ntt.c cbd.c reduce.c verify.c |
| 8 | +SOURCESKECCAK = $(SOURCES) fips202.c symmetric-shake.c |
| 9 | +HEADERS = params.h kem.h indcpa.h polyvec.h poly.h ntt.h cbd.h reduce.c verify.h symmetric.h |
| 10 | +HEADERSKECCAK = $(HEADERS) fips202.h |
| 11 | + |
| 12 | +.PHONY: all speed shared clean |
| 13 | + |
| 14 | +all: test speed shared nistkat |
| 15 | + |
| 16 | +test: \ |
| 17 | + test/test_kyber512 \ |
| 18 | + test/test_kyber768 \ |
| 19 | + test/test_kyber1024 \ |
| 20 | + test/test_vectors512 \ |
| 21 | + test/test_vectors768 \ |
| 22 | + test/test_vectors1024 \ |
| 23 | + |
| 24 | +speed: \ |
| 25 | + test/test_speed512 \ |
| 26 | + test/test_speed768 \ |
| 27 | + test/test_speed1024 \ |
| 28 | + |
| 29 | +shared: \ |
| 30 | + lib/libpqcrystals_kyber512_ref.so \ |
| 31 | + lib/libpqcrystals_kyber768_ref.so \ |
| 32 | + lib/libpqcrystals_kyber1024_ref.so \ |
| 33 | + lib/libpqcrystals_fips202_ref.so \ |
| 34 | + |
| 35 | +nistkat: \ |
| 36 | + nistkat/PQCgenKAT_kem512 \ |
| 37 | + nistkat/PQCgenKAT_kem768 \ |
| 38 | + nistkat/PQCgenKAT_kem1024 \ |
| 39 | + |
| 40 | + |
| 41 | +lib/libpqcrystals_fips202_ref.so: fips202.c fips202.h |
| 42 | + mkdir -p lib |
| 43 | + $(CC) -shared -fPIC $(CFLAGS) fips202.c -o $@ |
| 44 | + |
| 45 | +lib/libpqcrystals_kyber512_ref.so: $(SOURCES) $(HEADERS) symmetric-shake.c |
| 46 | + mkdir -p lib |
| 47 | + $(CC) -shared -fPIC $(CFLAGS) -DKYBER_K=2 $(SOURCES) symmetric-shake.c -o $@ |
| 48 | + |
| 49 | +lib/libpqcrystals_kyber768_ref.so: $(SOURCES) $(HEADERS) symmetric-shake.c |
| 50 | + mkdir -p lib |
| 51 | + $(CC) -shared -fPIC $(CFLAGS) -DKYBER_K=3 $(SOURCES) symmetric-shake.c -o $@ |
| 52 | + |
| 53 | +lib/libpqcrystals_kyber1024_ref.so: $(SOURCES) $(HEADERS) symmetric-shake.c |
| 54 | + mkdir -p lib |
| 55 | + $(CC) -shared -fPIC $(CFLAGS) -DKYBER_K=4 $(SOURCES) symmetric-shake.c -o $@ |
| 56 | + |
| 57 | +test/test_kyber512: $(SOURCESKECCAK) $(HEADERSKECCAK) test/test_kyber.c randombytes.c |
| 58 | + $(CC) $(CFLAGS) -DKYBER_K=2 $(SOURCESKECCAK) randombytes.c test/test_kyber.c -o $@ |
| 59 | + |
| 60 | +test/test_kyber768: $(SOURCESKECCAK) $(HEADERSKECCAK) test/test_kyber.c randombytes.c |
| 61 | + $(CC) $(CFLAGS) -DKYBER_K=3 $(SOURCESKECCAK) randombytes.c test/test_kyber.c -o $@ |
| 62 | + |
| 63 | +test/test_kyber1024: $(SOURCESKECCAK) $(HEADERSKECCAK) test/test_kyber.c randombytes.c |
| 64 | + $(CC) $(CFLAGS) -DKYBER_K=4 $(SOURCESKECCAK) randombytes.c test/test_kyber.c -o $@ |
| 65 | + |
| 66 | +test/test_vectors512: $(SOURCESKECCAK) $(HEADERSKECCAK) test/test_vectors.c |
| 67 | + $(CC) $(CFLAGS) -DKYBER_K=2 $(SOURCESKECCAK) test/test_vectors.c -o $@ |
| 68 | + |
| 69 | +test/test_vectors768: $(SOURCESKECCAK) $(HEADERSKECCAK) test/test_vectors.c |
| 70 | + $(CC) $(CFLAGS) -DKYBER_K=3 $(SOURCESKECCAK) test/test_vectors.c -o $@ |
| 71 | + |
| 72 | +test/test_vectors1024: $(SOURCESKECCAK) $(HEADERSKECCAK) test/test_vectors.c |
| 73 | + $(CC) $(CFLAGS) -DKYBER_K=4 $(SOURCESKECCAK) test/test_vectors.c -o $@ |
| 74 | + |
| 75 | +test/test_speed512: $(SOURCESKECCAK) $(HEADERSKECCAK) test/cpucycles.h test/cpucycles.c test/speed_print.h test/speed_print.c test/test_speed.c randombytes.c |
| 76 | + $(CC) $(CFLAGS) -DKYBER_K=2 $(SOURCESKECCAK) randombytes.c test/cpucycles.c test/speed_print.c test/test_speed.c -o $@ |
| 77 | + |
| 78 | +test/test_speed768: $(SOURCESKECCAK) $(HEADERSKECCAK) test/cpucycles.h test/cpucycles.c test/speed_print.h test/speed_print.c test/test_speed.c randombytes.c |
| 79 | + $(CC) $(CFLAGS) -DKYBER_K=3 $(SOURCESKECCAK) randombytes.c test/cpucycles.c test/speed_print.c test/test_speed.c -o $@ |
| 80 | + |
| 81 | +test/test_speed1024: $(SOURCESKECCAK) $(HEADERSKECCAK) test/cpucycles.h test/cpucycles.c test/speed_print.h test/speed_print.c test/test_speed.c randombytes.c |
| 82 | + $(CC) $(CFLAGS) -DKYBER_K=4 $(SOURCESKECCAK) randombytes.c test/cpucycles.c test/speed_print.c test/test_speed.c -o $@ |
| 83 | + |
| 84 | +nistkat/PQCgenKAT_kem512: $(SOURCESKECCAK) $(HEADERSKECCAK) nistkat/PQCgenKAT_kem.c nistkat/rng.c nistkat/rng.h |
| 85 | + $(CC) $(NISTFLAGS) -DKYBER_K=2 -o $@ $(SOURCESKECCAK) nistkat/rng.c nistkat/PQCgenKAT_kem.c $(LDFLAGS) -lcrypto |
| 86 | + |
| 87 | +nistkat/PQCgenKAT_kem768: $(SOURCESKECCAK) $(HEADERSKECCAK) nistkat/PQCgenKAT_kem.c nistkat/rng.c nistkat/rng.h |
| 88 | + $(CC) $(NISTFLAGS) -DKYBER_K=3 -o $@ $(SOURCESKECCAK) nistkat/rng.c nistkat/PQCgenKAT_kem.c $(LDFLAGS) -lcrypto |
| 89 | + |
| 90 | +nistkat/PQCgenKAT_kem1024: $(SOURCESKECCAK) $(HEADERSKECCAK) nistkat/PQCgenKAT_kem.c nistkat/rng.c nistkat/rng.h |
| 91 | + $(CC) $(NISTFLAGS) -DKYBER_K=4 -o $@ $(SOURCESKECCAK) nistkat/rng.c nistkat/PQCgenKAT_kem.c $(LDFLAGS) -lcrypto |
| 92 | + |
| 93 | +clean: |
| 94 | + -$(RM) -f *.gcno *.gcda *.lcov *.o *.so |
| 95 | + -$(RM) -f test/test_kyber512 |
| 96 | + -$(RM) -f test/test_kyber768 |
| 97 | + -$(RM) -f test/test_kyber1024 |
| 98 | + -$(RM) -f test/test_vectors512 |
| 99 | + -$(RM) -f test/test_vectors768 |
| 100 | + -$(RM) -f test/test_vectors1024 |
| 101 | + -$(RM) -f test/test_speed512 |
| 102 | + -$(RM) -f test/test_speed768 |
| 103 | + -$(RM) -f test/test_speed1024 |
| 104 | + -$(RM) -f nistkat/PQCgenKAT_kem512 |
| 105 | + -$(RM) -f nistkat/PQCgenKAT_kem768 |
| 106 | + -$(RM) -f nistkat/PQCgenKAT_kem1024 |
| 107 | + -$(RM) -f nistkat/*.req |
| 108 | + -$(RM) -f nistkat/*.rsp |
| 109 | + -$(RM) -rf lib/ |
| 110 | + |
0 commit comments