Reference implementations of PQC
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

104 rader
4.3 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)/nistseedexpander.c $(COMMON_DIR)/sp800-185.c
  12. COMMON_HEADERS=$(COMMON_DIR)/*.h
  13. DEST_DIR=../bin
  14. SCHEME_LIBRARY=$(SCHEME_DIR)/lib$(SCHEME)_$(IMPLEMENTATION).a
  15. SCHEME_FILES=$(wildcard $(SCHEME_DIR)/*.[chsS])
  16. # This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
  17. CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -std=c99 \
  18. -Wundef -Wshadow -Wcast-align -Wpointer-arith -Wmissing-prototypes\
  19. -fstrict-aliasing -fno-common -pipe \
  20. -I$(COMMON_DIR) $(EXTRAFLAGS)
  21. # Number of tests run for functests
  22. NTESTS=1
  23. all: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION) \
  24. $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION) \
  25. $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
  26. .PHONY: build-scheme
  27. build-scheme: $(SCHEME_LIBRARY)
  28. $(SCHEME_LIBRARY): $(SCHEME_FILES)
  29. cd $(SCHEME_DIR) && $(MAKE)
  30. .PHONY: clean-scheme
  31. clean-scheme:
  32. cd $(SCHEME_DIR) && $(MAKE) clean
  33. .PHONY: functest
  34. functest: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
  35. .PHONY: testvectors
  36. testvectors: $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
  37. .PHONY: printparams
  38. printparams: $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
  39. .PHONY: nistkat
  40. nistkat: $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION)
  41. $(DEST_DIR)/test_common_aes: test_common/aes.c $(COMMON_FILES)
  42. mkdir -p $(DEST_DIR)
  43. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  44. $(DEST_DIR)/test_common_fips202: test_common/fips202.c $(COMMON_FILES)
  45. mkdir -p $(DEST_DIR)
  46. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  47. $(DEST_DIR)/test_common_sha2: test_common/sha2.c $(COMMON_FILES)
  48. mkdir -p $(DEST_DIR)
  49. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  50. $(DEST_DIR)/test_common_sp800-185: test_common/sp800-185.c $(COMMON_FILES)
  51. mkdir -p $(DEST_DIR)
  52. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  53. $(DEST_DIR)/test_common_nistseedexpander: test_common/sp800-185.c $(COMMON_FILES)
  54. mkdir -p $(DEST_DIR)
  55. $(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
  56. $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION): $(SCHEME_LIBRARY) crypto_$(TYPE)/functest.c $(COMMON_FILES) $(COMMON_DIR)/randombytes.c $(COMMON_HEADERS)
  57. mkdir -p $(DEST_DIR)
  58. $(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)
  59. $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION): $(SCHEME_LIBRARY) crypto_$(TYPE)/testvectors.c $(COMMON_FILES) $(TEST_COMMON_DIR)/notrandombytes.c $(COMMON_HEADERS)
  60. mkdir -p $(DEST_DIR)
  61. $(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)
  62. $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION): crypto_$(TYPE)/printparams.c
  63. mkdir -p $(DEST_DIR)
  64. $(CC) $(CFLAGS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/printparams.c -o $@
  65. $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION): $(SCHEME_LIBRARY) crypto_$(TYPE)/nistkat.c $(COMMON_FILES) $(TEST_COMMON_DIR)/nistkatrng.c $(COMMON_HEADERS)
  66. mkdir -p $(DEST_DIR)
  67. $(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)
  68. .PHONY: clean
  69. clean:
  70. $(RM) $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
  71. $(RM) $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
  72. $(RM) $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
  73. $(RM) $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION)
  74. $(RM) $(DEST_DIR)/test_common_aes
  75. $(RM) $(DEST_DIR)/test_common_fips202
  76. $(RM) $(DEST_DIR)/test_common_sha2
  77. $(RM) $(DEST_DIR)/test_common_sp800-185
  78. $(RM) $(DEST_DIR)/test_common_nistseedexpander
  79. .PHONY: distclean
  80. distclean:
  81. $(RM) -r $(DEST_DIR)