-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (61 loc) · 2.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
PARAMETER_SET ?= 65
IMPLEMENTATION_TYPE ?= ref
COMMON = $(IMPLEMENTATION_TYPE)/common
IMPLEMENTATION = $(IMPLEMENTATION_TYPE)/ml_dsa_$(PARAMETER_SET)
# --------------------------------------------------------------------
JASMINC ?= jasminc
JASMINC_FLAGS ?= -I Common:$(COMMON)
JASMINCT ?= jasmin-ct
# --------------------------------------------------------------------
IMPLEMENTATION_SOURCES = $(IMPLEMENTATION)/ml_dsa.jazz \
$(wildcard $(IMPLEMENTATION)/*.jinc) \
$(wildcard $(IMPLEMENTATION)/arithmetic/*.jinc) \
$(wildcard $(IMPLEMENTATION)/encoding/*.jinc) \
$(wildcard $(IMPLEMENTATION)/sample/*.jinc) \
$(wildcard $(COMMON)/*.jinc) \
$(wildcard $(COMMON)/arithmetic/*.jinc) \
$(wildcard $(COMMON)/encoding/*.jinc) \
$(wildcard $(COMMON)/keccak/*.jinc) \
$(wildcard $(COMMON)/sample/*.jinc)
OUTPUT_FILE_NAME = ml_dsa_$(PARAMETER_SET)_$(IMPLEMENTATION_TYPE)
$(OUTPUT_FILE_NAME).s: $(IMPLEMENTATION_SOURCES)
$(JASMINC) $(JASMINC_FLAGS) -o $@ $<
# --------------------------------------------------------------------
.PHONY: test
test: $(OUTPUT_FILE_NAME).so
python3 -m pytest \
--parameter-set=$(PARAMETER_SET) \
--implementation-type=$(IMPLEMENTATION_TYPE) \
tests/
.PHONY: nist-drbg-kat-test
nist-drbg-kat-test: $(OUTPUT_FILE_NAME).so
python3 -m pytest \
--parameter-set=$(PARAMETER_SET) \
--implementation-type=$(IMPLEMENTATION_TYPE) \
tests/test_nist_drbg_kats.py
$(OUTPUT_FILE_NAME).so: $(OUTPUT_FILE_NAME).s
$(CC) $^ -fPIC -shared -o $@
.PHONY: check-ct
check-ct: $(IMPLEMENTATION)/ml_dsa.jazz
env JASMINPATH="Common=$(COMMON)" $(JASMINCT) $^
.PHONY: check-sct
check-sct: $(IMPLEMENTATION)/ml_dsa.jazz
env JASMINPATH="Common=$(COMMON)" $(JASMINCT) --speculative $^
.PHONY: check-rsb
check-rsb: $(IMPLEMENTATION)/ml_dsa.jazz
env JASMINPATH="Common=$(COMMON)" $(RSB_CHECKER) --speculative $^
.PHONY: run-interpreter
run-interpreter: $(IMPLEMENTATION)/example.jazz $(IMPLEMENTATION)/ml_dsa.jazz
$(JASMINC) $(JASMINC_FLAGS) $< | grep 'true'
# --------------------------------------------------------------------
bench.o: $(OUTPUT_FILE_NAME).s bench/bench.c bench/notrandombytes.c $(IMPLEMENTATION)/api.h
$(CC) -Wall -Werror \
-DIMPLEMENTATION_TYPE=$(IMPLEMENTATION_TYPE) \
-DKEYGEN=ml_dsa_$(PARAMETER_SET)_keygen \
-DSIGN=ml_dsa_$(PARAMETER_SET)_sign \
-DVERIFY=ml_dsa_$(PARAMETER_SET)_verify \
$^ -I $(IMPLEMENTATION) -o $@
# --------------------------------------------------------------------
.PHONY: clean
clean:
rm -fr *.s *.so *.o