2019-02-14 03:25:34 +00:00
|
|
|
# This Makefile can be used with GNU Make or BSD Make
|
|
|
|
|
|
|
|
# override as desired
|
|
|
|
TYPE=kem
|
|
|
|
SCHEME=kyber768
|
|
|
|
IMPLEMENTATION=clean
|
|
|
|
|
|
|
|
SCHEME_DIR="../crypto_$(TYPE)/$(SCHEME)/$(IMPLEMENTATION)"
|
2019-03-22 02:56:28 +00:00
|
|
|
SCHEME_UPPERCASE=$(shell echo $(SCHEME) | tr a-z A-Z | sed 's/-//g')
|
|
|
|
IMPLEMENTATION_UPPERCASE=$(shell echo $(IMPLEMENTATION) | tr a-z A-Z | sed 's/-//g')
|
2019-02-14 03:25:34 +00:00
|
|
|
|
2019-07-26 09:26:14 +01:00
|
|
|
TEST_COMMON_DIR=../test/common
|
2019-02-14 03:25:34 +00:00
|
|
|
COMMON_DIR=../common
|
2019-06-07 10:46:55 +01:00
|
|
|
COMMON_FILES=$(COMMON_DIR)/aes.c $(COMMON_DIR)/sha2.c $(COMMON_DIR)/fips202.c $(COMMON_DIR)/sp800-185.c
|
2019-04-10 15:02:45 +01:00
|
|
|
COMMON_HEADERS=$(COMMON_DIR)/*.h
|
2019-02-14 03:25:34 +00:00
|
|
|
DEST_DIR=../bin
|
|
|
|
|
2019-02-28 13:05:55 +00:00
|
|
|
# This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
|
2019-04-24 12:52:02 +01:00
|
|
|
CFLAGS=-O3 -Wall -Wextra -Wpedantic -Wvla -Werror -std=c99 \
|
2019-04-13 16:47:29 +01:00
|
|
|
-Wundef -Wshadow -Wcast-align -Wpointer-arith -Wmissing-prototypes\
|
2019-03-01 11:15:51 +00:00
|
|
|
-fstrict-aliasing -fno-common -pipe \
|
|
|
|
-I$(COMMON_DIR) $(EXTRAFLAGS)
|
2019-02-14 03:25:34 +00:00
|
|
|
|
2019-04-18 10:21:30 +01:00
|
|
|
# Number of tests run for functests
|
|
|
|
NTESTS=1
|
|
|
|
|
2019-04-05 16:04:37 +01:00
|
|
|
all: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION) \
|
|
|
|
$(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION) \
|
|
|
|
$(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
|
2019-02-14 03:25:34 +00:00
|
|
|
|
2019-02-27 10:29:39 +00:00
|
|
|
.PHONY: build-scheme
|
|
|
|
build-scheme:
|
|
|
|
cd $(SCHEME_DIR) && $(MAKE)
|
2019-02-18 14:06:46 +00:00
|
|
|
|
2019-02-27 11:44:21 +00:00
|
|
|
.PHONY: clean-scheme
|
|
|
|
clean-scheme:
|
|
|
|
cd $(SCHEME_DIR) && $(MAKE) clean
|
|
|
|
|
|
|
|
.PHONY: functest
|
|
|
|
functest: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
|
|
|
|
|
|
|
|
.PHONY: testvectors
|
|
|
|
testvectors: $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
|
|
|
|
|
2019-04-05 16:04:37 +01:00
|
|
|
.PHONY: printparams
|
|
|
|
printparams: $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
|
|
|
|
|
2019-04-14 22:17:11 +01:00
|
|
|
.PHONY: nistkat
|
|
|
|
nistkat: $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION)
|
|
|
|
|
2019-07-26 09:26:14 +01:00
|
|
|
$(DEST_DIR)/test_common_aes: test_common/aes.c $(COMMON_FILES)
|
2019-05-29 14:10:11 +01:00
|
|
|
mkdir -p $(DEST_DIR)
|
|
|
|
$(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
|
2019-07-26 09:26:14 +01:00
|
|
|
$(DEST_DIR)/test_common_fips202: test_common/fips202.c $(COMMON_FILES)
|
2019-05-29 14:10:11 +01:00
|
|
|
mkdir -p $(DEST_DIR)
|
|
|
|
$(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
|
2019-07-26 09:26:14 +01:00
|
|
|
$(DEST_DIR)/test_common_sha2: test_common/sha2.c $(COMMON_FILES)
|
2019-03-11 13:41:11 +00:00
|
|
|
mkdir -p $(DEST_DIR)
|
|
|
|
$(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
|
2019-07-26 09:26:14 +01:00
|
|
|
$(DEST_DIR)/test_common_sp800-185: test_common/sp800-185.c $(COMMON_FILES)
|
2019-06-07 10:46:55 +01:00
|
|
|
mkdir -p $(DEST_DIR)
|
|
|
|
$(CC) $(CFLAGS) $< $(COMMON_FILES) -o $@
|
2019-03-11 13:41:11 +00:00
|
|
|
|
2019-02-27 10:29:39 +00:00
|
|
|
$(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/functest.c $(COMMON_FILES) $(COMMON_DIR)/randombytes.c $(COMMON_HEADERS)
|
2019-02-14 03:25:34 +00:00
|
|
|
mkdir -p $(DEST_DIR)
|
2019-07-26 09:26:14 +01:00
|
|
|
$(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)
|
2019-02-18 15:07:01 +00:00
|
|
|
|
2019-07-26 09:26:14 +01:00
|
|
|
$(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/testvectors.c $(COMMON_FILES) $(TEST_COMMON_DIR)/notrandombytes.c $(COMMON_HEADERS)
|
2019-02-18 15:07:01 +00:00
|
|
|
mkdir -p $(DEST_DIR)
|
2019-07-26 09:26:14 +01:00
|
|
|
$(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)
|
2019-02-14 03:25:34 +00:00
|
|
|
|
2019-09-06 11:01:44 +01:00
|
|
|
$(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION): crypto_$(TYPE)/printparams.c
|
2019-04-05 16:04:37 +01:00
|
|
|
mkdir -p $(DEST_DIR)
|
|
|
|
$(CC) $(CFLAGS) -DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE)_$(IMPLEMENTATION_UPPERCASE) -I$(SCHEME_DIR) crypto_$(TYPE)/printparams.c -o $@
|
|
|
|
|
2019-07-26 09:26:14 +01:00
|
|
|
$(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION): build-scheme crypto_$(TYPE)/nistkat.c $(COMMON_FILES) $(TEST_COMMON_DIR)/nistkatrng.c $(COMMON_HEADERS)
|
2019-04-14 22:17:11 +01:00
|
|
|
mkdir -p $(DEST_DIR)
|
2019-07-26 09:26:14 +01:00
|
|
|
$(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)
|
2019-04-14 22:17:11 +01:00
|
|
|
|
2019-02-18 15:23:08 +00:00
|
|
|
.PHONY: clean
|
2019-02-14 03:25:34 +00:00
|
|
|
clean:
|
|
|
|
$(RM) $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION)
|
2019-02-18 15:07:01 +00:00
|
|
|
$(RM) $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
|
2019-04-14 22:17:11 +01:00
|
|
|
$(RM) $(DEST_DIR)/printparams_$(SCHEME)_$(IMPLEMENTATION)
|
|
|
|
$(RM) $(DEST_DIR)/nistkat_$(SCHEME)_$(IMPLEMENTATION)
|
2019-04-10 16:43:04 +01:00
|
|
|
$(RM) $(DEST_DIR)/test_aes
|
2019-03-07 15:21:49 +00:00
|
|
|
$(RM) $(DEST_DIR)/test_fips202
|
2019-03-11 13:41:11 +00:00
|
|
|
$(RM) $(DEST_DIR)/test_sha2
|
2019-06-07 10:46:55 +01:00
|
|
|
$(RM) $(DEST_DIR)/test_sp800-185
|
2019-04-16 09:35:48 +01:00
|
|
|
|
|
|
|
.PHONY: distclean
|
|
|
|
distclean:
|
|
|
|
$(RM) -r $(DEST_DIR)
|