chiark / gitweb /
crypto tests: Wire into Makefiles
authorMark Wooding <mdw@distorted.org.uk>
Wed, 1 Jan 2020 23:56:39 +0000 (23:56 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 2 Jan 2020 01:02:37 +0000 (01:02 +0000)
We make every .o file depend on $(cat_CATS) because that's easier than
trying to write out a list of which ones need the includes from
Catacomb.

(This is largely a commit by Mark Wooding supplied to me as a
work-in-progress, but I (Ian Jackson) have edited it to fit in with
the new subdirmk build system etc.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Dir.sd.mk
cat/Dir.sd.mk

index 55f526d1304e0800aec9ffbf560b947d7fe4ac01..29c7c1aafce89b3955c0df5a2df2ed385da9c22a 100644 (file)
--- a/Dir.sd.mk
+++ b/Dir.sd.mk
@@ -39,7 +39,7 @@ datarootdir:=@datarootdir@
 transform:=@program_transform_name@
 mandir:=@mandir@
 
-ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
+ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. -Icat $(CFLAGS) $(EXTRA_CFLAGS)
 CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
 LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
 LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
@@ -63,7 +63,11 @@ OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
 PYMODULES := ipaddrset.py argparseactionnoyes.py base91.py
 
 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
-               eax-test.o aes.o
+               eax-test.o aes.o x25519-test.o x448-test.o
+
+TEST_OBJECTS += crypto-test.o
+TEST_OBJECTS += keccak1600-test.o sha3-test.o
+TEST_OBJECTS += ed25519-test.o ed448-test.o
 
 ifeq (version.o,$(MAKECMDGOALS))
 OBJECTS:=
@@ -84,7 +88,7 @@ STALE_PYTHON_FILES=   $(foreach e, py pyc, \
 %.tab.c %.tab.h:       %.y
        bison -d -o $@ $<
 
-%.o: %.c
+%.o: %.c $(cat_CATS)
        $(CC) $(CPPFLAGS) $(ALL_CFLAGS) $(CDEPS_CFLAGS) -c $< -o $@
 
 $(OBJECTS): conffile.yy.h pubkeys.yy.h base91s/base91.h
@@ -125,8 +129,12 @@ endif
 
 TESTDIRS=stest mtest
 
+CRYPTO_TESTS = keccak1600 sha3 f25519 x25519 ed25519 fgoldi x448 ed448
+
 &TARGETS_check = eax-aes.tconfirm eax-serpent.tconfirm \
-       eax-serpentbe.tconfirm ipaddrset.tconfirm
+       eax-serpentbe.tconfirm ipaddrset.tconfirm \
+       x25519.tconfirm x448.tconfirm \
+       $(foreach c,$(CRYPTO_TESTS),$c.tconfirm)
 
 &TARGETS_fullcheck += $(&TARGETS_check)
 &TARGETS_fullcheck += msgcode.tconfirm
@@ -182,6 +190,14 @@ ipaddrset.tconfirm: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
        diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
        touch $@
 
+$(foreach c,$(CRYPTO_TESTS),$c.trun): %.trun: %-test.o crypto-test.o
+       $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
+
+$(foreach c,$(CRYPTO_TESTS),$c.tconfirm): \
+               %.tconfirm: %.trun cat/%-tests.in
+       ./$*.trun <cat/$*-tests.in
+       touch $@
+
 &CLEAN += & pubkeys.fl
 
 pubkeys.fl: ${srcdir}/pubkeys.fl.pl
@@ -222,6 +238,8 @@ clean::
        $(RM) -f *.pyc *~ eax-*.tconfirm eax-*.trun
        $(RM) -rf __pycache__
        $(RM) -f msgcode.tconfirm msgcode.trun
+       $(RM) -f $(addsuffix .trun, $(CRYPTO_TESTS))
+       $(RM) -f $(addsuffix .tconfirm, $(CRYPTO_TESTS))
 
 realclean::    clean
        $(RM) -f *~ Makefile config.h \
index 2646553f8205714b73ae464f0f591b1603979fb3..718ff1eb8e606a42cbd1fa7d5b33048d552f08ad 100644 (file)
 
 &cat-converted: $(addprefix &~catacomb-import/, $(CATACOMB_IMPORT_DONORS))
 
-&CLEAN += & secnet-import.auto.mk.compare
+keccak1600.trun: & keccak1600.o
+sha3.trun: & sha3.o keccak1600.o
+f25519.trun: & f25519.o
+x25519.trun: & x25519.o f25519.o
+ed25519.trun: sha512.o & f25519.o scaf.o ed25519.o
+fgoldi.trun: & fgoldi.o
+x448.trun: & x448.o fgoldi.o
+ed448.trun: & keccak1600.o sha3.o fgoldi.o scaf.o ed448.o
+
+f25519-test.o: ec-field-test.c &$CATS
+       $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DFIELD=f25519 $< -o $@
+fgoldi-test.o: ec-field-test.c &$CATS
+       $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DFIELD=fgoldi $< -o $@
+x25519-test.o: xdh-test.c &$CATS
+       $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DXDH=x25519 -DFIELD=f25519 $< -o $@
+x448-test.o: xdh-test.c &$CATS
+       $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DXDH=x448 -DFIELD=fgoldi $< -o $@
+
+&CLEAN += & secnet-import.auto.mk.compare *.o .*.d