Reference implementations of PQC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

94 lines
3.9 KiB

  1. # This Makefile can be used with GNU Make or BSD Make
  2. # override as desired
  3. TYPE=kem
  4. SCHEME=kyber768
  5. IMPLEMENTATION=clean
  6. SCHEME_DIR="../crypto_$(TYPE)/$(SCHEME)/$(IMPLEMENTATION)"
  7. SCHEME_UPPERCASE=$(shell echo $(SCHEME) | tr a-z A-Z | sed 's/-//g')
  8. IMPLEMENTATION_UPPERCASE=$(shell echo $(IMPLEMENTATION) | tr a-z A-Z | sed 's/-//g')
  9. TEST_COMMON_DIR=../test/common
  10. COMMON_DIR=../common
  11. COMMON_FILES=$(COMMON_DIR)/aes.c $(COMMON_DIR)/sha2.c $(COMMON_DIR)/fips202.c $(COMMON_DIR)/sp800-185.c
  12. COMMON_HEADERS=$(COMMON_DIR)/*.h
  13. DEST_DIR=../bin
  14. # This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
  15. CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -std=c99 \
  16. -Wundef -Wshadow -Wcast-align -Wpointer-arith -Wmissing-prototypes\
  17. -fstrict-aliasing -fno-common -pipe \
  18. -I$(COMMON_DIR) $(EXTRAFLAGS)
  19. # Number of tests run for functests
  20. NTESTS=1
  21. all: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION) \
  22. $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION) \
  23. $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
  24. .PHONY: build-scheme
  25. build-scheme:
  26. cd $(SCHEME_DIR) && $(MAKE)
  27. .PHONY: clean-scheme
  28. clean-scheme:
  29. cd $(SCHEME_DIR) && $(MAKE) clean
  30. .PHONY: functest
  31. functest: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
  32. .PHONY: testvectors
  33. testvectors: $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
  34. .PHONY: printparams
  35. printparams: $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
  36. .PHONY: nistkat
  37. nistkat: $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION)
  38. $(DEST_DIR)/test_common_aes: test_common/aes.c $(COMMON_FILES)
  39. mkdir -p $(DEST_DIR)
  40. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  41. $(DEST_DIR)/test_common_fips202: test_common/fips202.c $(COMMON_FILES)
  42. mkdir -p $(DEST_DIR)
  43. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  44. $(DEST_DIR)/test_common_sha2: test_common/sha2.c $(COMMON_FILES)
  45. mkdir -p $(DEST_DIR)
  46. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  47. $(DEST_DIR)/test_common_sp800-185: test_common/sp800-185.c $(COMMON_FILES)
  48. mkdir -p $(DEST_DIR)
  49. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  50. $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/functest.c $(COMMON_FILES) $(COMMON_DIR)/randombytes.c $(COMMON_HEADERS)
  51. mkdir -p $(DEST_DIR)
  52. $(CC) $(CFLAGS) -DNTESTS=$(NTESTS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/functest.c $(COMMON_FILES) $(COMMON_DIR)/randombytes.c -o $@ -L$(SCHEME_DIR) -l$(SCHEME)_$(IMPLEMENTATION)
  53. $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/testvectors.c $(COMMON_FILES) $(TEST_COMMON_DIR)/notrandombytes.c $(COMMON_HEADERS)
  54. mkdir -p $(DEST_DIR)
  55. $(CC) $(CFLAGS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/testvectors.c $(COMMON_FILES) $(TEST_COMMON_DIR)/notrandombytes.c -o $@ -L$(SCHEME_DIR) -l$(SCHEME)_$(IMPLEMENTATION)
  56. $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/printparams.c
  57. mkdir -p $(DEST_DIR)
  58. $(CC) $(CFLAGS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/printparams.c -o $@
  59. $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/nistkat.c $(COMMON_FILES) $(TEST_COMMON_DIR)/nistkatrng.c $(COMMON_HEADERS)
  60. mkdir -p $(DEST_DIR)
  61. $(CC) $(CFLAGS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/nistkat.c $(COMMON_FILES) $(TEST_COMMON_DIR)/nistkatrng.c -o $@ -L$(SCHEME_DIR) -l$(SCHEME)_$(IMPLEMENTATION)
  62. .PHONY: clean
  63. clean:
  64. $(RM) $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
  65. $(RM) $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
  66. $(RM) $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
  67. $(RM) $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION)
  68. $(RM) $(DEST_DIR)/test_aes
  69. $(RM) $(DEST_DIR)/test_fips202
  70. $(RM) $(DEST_DIR)/test_sha2
  71. $(RM) $(DEST_DIR)/test_sp800-185
  72. .PHONY: distclean
  73. distclean:
  74. $(RM) -r $(DEST_DIR)