From d21d01bcb58d6588707b8c49c480e9d2658ace19 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 2 May 2017 10:33:39 +0200 Subject: [PATCH 01/51] consolidate makefiles a bit --- makefile | 5 ----- makefile.include | 7 +++++++ makefile.shared | 9 +++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/makefile b/makefile index 64ec249..ea18e67 100644 --- a/makefile +++ b/makefile @@ -5,11 +5,6 @@ include makefile.include -# The version -VERSION=1.17 - -PLATFORM := $(shell uname | sed -e 's/_.*//') - ifeq ($V,1) silent= silent_stdout= diff --git a/makefile.include b/makefile.include index a2256c6..1d1cfde 100644 --- a/makefile.include +++ b/makefile.include @@ -2,6 +2,13 @@ # Include makefile for libtomcrypt # +# The version +VERSION=1.17 +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +VERSION_LT=0:117 + +PLATFORM := $(shell uname | sed -e 's/_.*//') + # Compiler and Linker Names ifndef PREFIX PREFIX:= diff --git a/makefile.shared b/makefile.shared index 2932dda..4101e5d 100644 --- a/makefile.shared +++ b/makefile.shared @@ -7,9 +7,6 @@ include makefile.include -# The version -# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -VERSION=0:117 LT ?= libtool @@ -212,13 +209,13 @@ library: $(LIBNAME) .PHONY: testprof/$(LIBTEST) testprof/$(LIBTEST): - cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) LT=$(LT) CC="$(CC)" make -f makefile.shared + cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION_LT) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) LT=$(LT) CC="$(CC)" make -f makefile.shared .c.o: $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $< $(LIBNAME): $(OBJECTS) - $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION) + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LT) install: $(LIBNAME) install -d $(DESTDIR)$(LIBPATH) @@ -232,7 +229,7 @@ install: $(LIBNAME) install_test: testprof/$(LIBTEST) install -d $(DESTDIR)$(LIBPATH) install -d $(DESTDIR)$(INCPATH) - cd testprof ; CFLAGS="$(CFLAGS)" VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) LT=$(LT) CC=$(CC) make -f makefile.shared install + cd testprof ; CFLAGS="$(CFLAGS)" VERSION=$(VERSION_LT) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) LT=$(LT) CC=$(CC) make -f makefile.shared install .PHONY: test From 7898864b2408627e9a640fdd90351934b25803d3 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 2 May 2017 10:34:16 +0200 Subject: [PATCH 02/51] use glibtool on Macs --- makefile.shared | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/makefile.shared b/makefile.shared index 4101e5d..e96a051 100644 --- a/makefile.shared +++ b/makefile.shared @@ -8,8 +8,13 @@ include makefile.include - -LT ?= libtool +ifndef LT + ifeq ($(PLATFORM), Darwin) + LT:=glibtool + else + LT:=libtool + endif +endif LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) From 7ac857686d62ed01c25583ac6dfb001de13c2e6a Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 2 May 2017 10:35:00 +0200 Subject: [PATCH 03/51] add git version as compile flag --- demos/test.c | 6 +++++- makefile.include | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/demos/test.c b/demos/test.c index 689b976..3474f7e 100644 --- a/demos/test.c +++ b/demos/test.c @@ -1,5 +1,9 @@ #include +#ifndef GIT_VERSION +#define GIT_VERSION "Undefined version" +#endif + #define LTC_TEST_FN(f) { f, #f } static const struct { @@ -37,7 +41,7 @@ int main(int argc, char **argv) long delta, dur = 0; reg_algs(); - printf("build == \n%s\n", crypt_build_settings); + printf("build == %s\n%s\n", GIT_VERSION, crypt_build_settings); #ifdef USE_LTM ltc_mp = ltm_desc; diff --git a/makefile.include b/makefile.include index 1d1cfde..0e090c0 100644 --- a/makefile.include +++ b/makefile.include @@ -78,6 +78,12 @@ CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare endif +GIT_VERSION := $(shell [ -e .git ] && { echo -n git- ; git describe --tags --always --dirty ; } || echo $(VERSION)) +ifneq ($(GIT_VERSION),) +CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" +endif + + HASH=hashsum CRYPT=encrypt SMALL=small From 93067e189a146f5667f020c46392aa3054ec6cd8 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 2 May 2017 10:43:56 +0200 Subject: [PATCH 04/51] fix testprof/makefile.shared --- testprof/makefile.shared | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testprof/makefile.shared b/testprof/makefile.shared index e030236..fc22f59 100644 --- a/testprof/makefile.shared +++ b/testprof/makefile.shared @@ -7,9 +7,9 @@ LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) CFLAGS += -I../src/headers -I./ -Wall -Wsign-compare -W -Wshadow -Wno-unused-parameter OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o \ -dsa_test.o ecc_test.o mac_test.o modes_test.o pkcs_1_test.o rsa_test.o \ -store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o misc_test.o \ -pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o +dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o \ +store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o \ +pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o ifndef LIBTEST LIBTEST=libtomcrypt_prof.la From 2c97498554a22a673c419365bca1c3896276bb3c Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 2 May 2017 20:45:41 +0200 Subject: [PATCH 05/51] wipe out testprof/makefile* --- testprof/makefile | 43 ---------------------------------------- testprof/makefile.icc | 21 -------------------- testprof/makefile.mingw | 22 -------------------- testprof/makefile.msvc | 15 -------------- testprof/makefile.shared | 27 ------------------------- 5 files changed, 128 deletions(-) delete mode 100644 testprof/makefile delete mode 100644 testprof/makefile.icc delete mode 100644 testprof/makefile.mingw delete mode 100644 testprof/makefile.msvc delete mode 100644 testprof/makefile.shared diff --git a/testprof/makefile b/testprof/makefile deleted file mode 100644 index db7bbd9..0000000 --- a/testprof/makefile +++ /dev/null @@ -1,43 +0,0 @@ -CFLAGS += -I../src/headers -I./ -Wall -W - -# ranlib tools -ifndef RANLIB - RANLIB=ranlib -endif - -ifeq ($V,1) -silent= -else -silent=@ -endif - -%.o: %.c -ifneq ($V,1) - @echo " * ${CC} $@" -endif - ${silent} ${CC} ${CFLAGS} -c $< -o $@ - -OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o \ -dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o \ -store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o \ -pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o - -ifndef LIBTEST_S - LIBTEST_S=libtomcrypt_prof.a -endif - -default: $(LIBTEST_S) - -$(LIBTEST_S): $(OBJECTS) -ifneq ($V,1) - @echo " * ${AR} $@" -endif - ${silent} $(AR) $(ARFLAGS) $@ $(OBJECTS) -ifneq ($V,1) - @echo " * ${RANLIB} $@" -endif - ${silent} $(RANLIB) $@ - -clean: - rm -f *.o *.a *.gcov *.gcda *.gcno - diff --git a/testprof/makefile.icc b/testprof/makefile.icc deleted file mode 100644 index 6ce7b08..0000000 --- a/testprof/makefile.icc +++ /dev/null @@ -1,21 +0,0 @@ -CFLAGS += -I../src/headers -I./ -CC?=icc - -OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o \ -dsa_test.o ecc_test.o mac_test.o modes_test.o pkcs_1_test.o rsa_test.o \ -store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o misc_test.o \ -pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o - -ifndef LIBTEST_S - LIBTEST_S = libtomcrypt_prof.a -endif - -default: $(LIBTEST_S) - -$(LIBTEST_S): $(OBJECTS) - $(AR) $(ARFLAGS) $@ $(OBJECTS) - ranlib $@ - -clean: - rm -f *.o *.a - diff --git a/testprof/makefile.mingw b/testprof/makefile.mingw deleted file mode 100644 index 5d17df2..0000000 --- a/testprof/makefile.mingw +++ /dev/null @@ -1,22 +0,0 @@ -# MAKEFILE for use with MS Windows gcc compiler + GNU make (aka mingw32-make) - -# BEWARE: do not run make from testprof directory, run 'gmake ... test' from libtomcrypt root dir - -CFLAGS = $(CFLAGS_OPTS) -I../src/headers -I../../libtommath -I. -Wall -Wextra -DUSE_LTM -DLTM_DESC - -OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o \ -dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o \ -store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o pkcs_1_pss_test.o \ -pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o - -default: $(LIBTEST_S) - -%.o: %.c - ${CC} ${CFLAGS} -c $< -o $@ - -$(LIBTEST_S): $(OBJECTS) - $(AR) $(ARFLAGS) $@ $(OBJECTS) - $(RANLIB) $@ - -clean: - cmd /c del /Q *.o *.a diff --git a/testprof/makefile.msvc b/testprof/makefile.msvc deleted file mode 100644 index 72d32db..0000000 --- a/testprof/makefile.msvc +++ /dev/null @@ -1,15 +0,0 @@ -CFLAGS = /I../src/headers/ /I./ /Ox /DWIN32 /DLTC_SOURCE /DUSE_LTM /W3 - -OBJECTS=base64_test.obj cipher_hash_test.obj der_tests.obj no_prng.obj file_test.obj \ -dsa_test.obj ecc_test.obj mac_test.obj modes_test.obj pkcs_1_test.obj \ -rsa_test.obj store_test.obj rotate_test.obj test_driver.obj x86_prof.obj katja_test.obj \ -dh_test.obj misc_test.obj pkcs_1_pss_test.obj pkcs_1_oaep_test.obj \ -pkcs_1_emsa_test.obj pkcs_1_eme_test.obj multi_test.obj - -.c.obj: - $(CC) $(CFLAGS) /c $< /Fo$@ - -tomcrypt_prof.lib: $(OBJECTS) - lib /out:tomcrypt_prof.lib $(OBJECTS) - - diff --git a/testprof/makefile.shared b/testprof/makefile.shared deleted file mode 100644 index fc22f59..0000000 --- a/testprof/makefile.shared +++ /dev/null @@ -1,27 +0,0 @@ -ifeq ($(CC),cc) - CC = gcc -endif -LT ?= libtool -LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) - -CFLAGS += -I../src/headers -I./ -Wall -Wsign-compare -W -Wshadow -Wno-unused-parameter - -OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o \ -dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o \ -store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o \ -pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o - -ifndef LIBTEST - LIBTEST=libtomcrypt_prof.la -endif - -default: $(LIBTEST) - -.c.o: - $(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $< - -$(LIBTEST): $(OBJECTS) - $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) `find . -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION) - -install: $(LIBTEST) - $(LT) --mode=install install -c $(LIBTEST) $(DESTDIR)$(LIBPATH)/$(LIBTEST) From bf45ea66e5b95b993c616bb00f741c6c27771084 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 2 May 2017 20:47:00 +0200 Subject: [PATCH 06/51] drop the need for testprof/makefile* --- helper.pl | 75 ++++++++++++++++++++++++++--------------------- libtomcrypt.pc.in | 6 ++-- makefile | 63 ++++++++++++++++++++++++--------------- makefile.icc | 46 +++++++++++++++++------------ makefile.include | 23 +++++---------- makefile.mingw | 48 ++++++++++++++++++------------ makefile.msvc | 26 +++++++++------- makefile.shared | 47 +++++++++++++++++------------ 8 files changed, 189 insertions(+), 145 deletions(-) diff --git a/helper.pl b/helper.pl index 95b59a6..b871e67 100755 --- a/helper.pl +++ b/helper.pl @@ -201,24 +201,27 @@ sub prepare_msvc_files_xml { } sub patch_makefile { - my ($in_ref, $out_ref, $data) = @_; - open(my $src, '<', $in_ref); - open(my $dst, '>', $out_ref); - my $l = 0; - while (<$src>) { - if ($_ =~ /START_INS/) { - print {$dst} $_; - $l = 1; - print {$dst} $data; - } elsif ($_ =~ /END_INS/) { - print {$dst} $_; - $l = 0; - } elsif ($l == 0) { - print {$dst} $_; + my ($content, @variables) = @_; + for my $v (@variables) { + if ($v =~ /^([A-Z0-9_]+)\s*=.*$/si) { + my $name = $1; + $content =~ s/\n\Q$name\E\b.*?[^\\]\n/\n$v\n/s; + } + else { + die "patch_makefile failed: " . substr($v, 0, 30) . ".."; } } - close $dst; - close $src; + return $content; +} + +sub version_form_tomcrypt_h { + my $h = read_file(shift); + if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)"/s) { + return "VERSION_MAJ=$1", "VERSION_MIN=$2", "VERSION=$1.$2", "VERSION_LT=0:$1$2"; + } + else { + die "#define SCRYPT not found in tomcrypt.h"; + } } sub process_makefiles { @@ -230,12 +233,20 @@ sub process_makefiles { find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src'); my @all = (); find({ no_chdir => 1, wanted => sub { push @all, $_ if -f $_ && $_ =~ /\.(c|h)$/ } }, 'src'); + my @t = qw(); + find({ no_chdir => 1, wanted => sub { push @t, $_ if $_ =~ /(no_prng|test_driver|x86_prof|_tests?).c$/ } }, 'testprof'); my @o = sort ('src/ciphers/aes/aes_enc.o', map { $_ =~ s/\.c$/.o/; $_ } @c); - my $var_o = prepare_variable("OBJECTS", @o); + my $var_o = prepare_variable("OBJECTS", @o); + my $var_h = prepare_variable("HEADERS", (sort @h)); (my $var_obj = $var_o) =~ s/\.o\b/.obj/sg; - my $var_h = prepare_variable("HEADERS", (sort @h, 'testprof/tomcrypt_test.h')); + my $var_to = prepare_variable("TOBJECTS", sort map { $_ =~ s/\.c$/.o/; $_ } @t); + (my $var_tobj = $var_to) =~ s/\.o\b/.obj/sg; + + my @ver_version = version_form_tomcrypt_h("src/headers/tomcrypt.h"); + + # update MSVC project files my $msvc_files = prepare_msvc_files_xml(\@all, qr/tab\.c$/, ['Debug|Win32', 'Release|Win32', 'Debug|x64', 'Release|x64']); for my $m (qw/libtomcrypt_VS2008.vcproj/) { my $old = read_file($m); @@ -248,22 +259,18 @@ sub process_makefiles { } } - my @makefiles = qw( makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc ); - for my $m (@makefiles) { + # update OBJECTS + HEADERS in makefile* + for my $m (qw/ makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) { my $old = read_file($m); - my $new; - if ($m eq 'makefile.msvc') { - patch_makefile(\$old, \$new, "$var_obj\n\n$var_h\n\n"); - } - else { - patch_makefile(\$old, \$new, "$var_o\n\n$var_h\n\n"); - } + my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_to, @ver_version) + : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version); if ($old ne $new) { write_file($m, $new) if $write; warn "changed: $m\n"; $changed_count++; } } + if ($write) { return 0; # no failures } @@ -283,13 +290,13 @@ sub die_usage { MARKER } -GetOptions( "check-source" => \my $check_source, - "check-defines" => \my $check_defines, - "check-hashes" => \my $check_hashes, - "check-makefiles" => \my $check_makefiles, - "check-all" => \my $check_all, - "update-makefiles" => \my $update_makefiles, - "help" => \my $help +GetOptions( "s|check-source" => \my $check_source, + "d|check-defines" => \my $check_defines, + "h|check-hashes" => \my $check_hashes, + "m|check-makefiles" => \my $check_makefiles, + "a|check-all" => \my $check_all, + "u|update-makefiles" => \my $update_makefiles, + "h|help" => \my $help ) or die_usage; my $failure; diff --git a/libtomcrypt.pc.in b/libtomcrypt.pc.in index a0e889f..714f060 100644 --- a/libtomcrypt.pc.in +++ b/libtomcrypt.pc.in @@ -1,10 +1,10 @@ -prefix=/usr +prefix=@to-be-replaced@ exec_prefix=${prefix} -libdir=@LIBDIR@ +libdir=${exec_prefix}/lib includedir=${prefix}/include Name: LibTomCrypt Description: public domain open source cryptographic toolkit -Version: 1.17 +Version: @to-be-replaced@ Libs: -L${libdir} -ltomcrypt Cflags: -I${includedir} diff --git a/makefile b/makefile index ea18e67..2206e00 100644 --- a/makefile +++ b/makefile @@ -35,10 +35,8 @@ endif ifndef LIBTEST LIBTEST=libtomcrypt_prof.a endif -LIBTEST_S=$(LIBTEST) -#List of objects to compile. -#START_INS +# List of objects to compile (all goes to libtomcrypt.a) OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ @@ -190,13 +188,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o +# List of test objects to compile (all goes to libtomcrypt_prof.a) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h - -#END_INS +src/headers/tomcrypt_prng.h #Files left over from making the crypt.pdf. LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof @@ -223,7 +228,9 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c #This rule makes the libtomcrypt library. library: $(LIBNAME) +#Dependencies on *.h $(OBJECTS): $(HEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h $(LIBNAME): $(OBJECTS) ifneq ($V,1) @@ -235,22 +242,27 @@ ifneq ($V,1) endif ${silent} $(RANLIB) $@ -.PHONY: testprof/$(LIBTEST) -testprof/$(LIBTEST): - ${silent} CFLAGS="$(CFLAGS)" LIBTEST_S=$(LIBTEST_S) CC="$(CC)" LD="$(LD)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" RANLIB="$(RANLIB)" V="$(V)" $(MAKE) -C testprof +$(LIBTEST): $(TOBJECTS) +ifneq ($V,1) + @echo " * ${AR} $@" +endif + ${silent} $(AR) $(ARFLAGS) $@ $(TOBJECTS) +ifneq ($V,1) + @echo " * ${RANLIB} $@" +endif + ${silent} $(RANLIB) $@ -timing: library testprof/$(LIBTEST) $(TIMINGS) +timing: library $(LIBTEST) $(TIMINGS) ifneq ($V,1) @echo " * ${CC} $@" endif - ${silent} $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING) + ${silent} $(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING) -.PHONY: test -test: library testprof/$(LIBTEST) $(TESTS) +test: library $(LIBTEST) $(TESTS) ifneq ($V,1) @echo " * ${CC} $@" endif - ${silent} $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST) + ${silent} $(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST) # build the demos from a template define DEMO_template @@ -277,19 +289,20 @@ install: library docs else install: library endif - install -d $(DESTDIR)$(LIBPATH) - install -d $(DESTDIR)$(INCPATH) - install -d $(DESTDIR)$(DATAPATH) - install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH) - install -m 644 $(HEADERS) $(DESTDIR)$(INCPATH) + install -d $(LIBPATH) + install -d $(INCPATH) + install -d $(DATAPATH) + install -m 644 $(LIBNAME) $(LIBPATH) + install -m 644 $(HEADERS) $(INCPATH) ifndef NODOCS - install -m 644 doc/crypt.pdf $(DESTDIR)$(DATAPATH) + install -m 644 doc/crypt.pdf $(DATAPATH) endif -install_test: testprof/$(LIBTEST) - install -d $(DESTDIR)$(LIBPATH) - install -d $(DESTDIR)$(INCPATH) - install -m 644 testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH) +install_test: $(LIBTEST) + install -d $(LIBPATH) + install -d $(INCPATH) + install -m 644 $(LIBTEST) $(LIBPATH) + install -m 644 testprof/tomcrypt_test.h $(INCPATH) install_hooks: for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done @@ -342,6 +355,8 @@ clean: rm -f `find . -type f -name "*.obj" | xargs` rm -f `find . -type f -name "*.lib" | xargs` rm -f `find . -type f -name "*.exe" | xargs` + rm -f `find . -type f -name "*.dll" | xargs` + rm -f `find . -type f -name "*.so" | xargs` rm -f `find . -type f -name "*.gcov" | xargs` rm -f `find . -type f -name "*.gcda" | xargs` rm -f `find . -type f -name "*.gcno" | xargs` diff --git a/makefile.icc b/makefile.icc index 590c075..445069e 100644 --- a/makefile.icc +++ b/makefile.icc @@ -70,7 +70,6 @@ ifndef LIBNAME endif ifndef LIBTEST LIBTEST=libtomcrypt_prof.a - LIBTEST_S=$(LIBTEST) endif HASH=hashsum CRYPT=encrypt @@ -96,8 +95,7 @@ ifndef DATAPATH DATAPATH=/usr/share/doc/libtomcrypt/pdf endif -#List of objects to compile. -#START_INS +# List of objects to compile (all goes to libtomcrypt.a) OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ @@ -249,13 +247,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o +# List of test objects to compile (all goes to libtomcrypt_prof.a) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h - -#END_INS +src/headers/tomcrypt_prng.h #Who do we install as? ifdef INSTALL_USER @@ -297,9 +302,13 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c #This rule makes the libtomcrypt library. library: $(LIBNAME) -.PHONY: testprof/$(LIBTEST) -testprof/$(LIBTEST): - cd testprof ; LIBTEST_S=$(LIBTEST) CFLAGS="$(CFLAGS)" CC="$(CC)" AR="$(AR)" $(MAKE) -f makefile.icc +#Dependencies on *.h +$(OBJECTS): $(HEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h + +$(LIBTEST): $(TOBJECTS) + $(AR) $(ARFLAGS) $@ $(TOBJECTS) + $(RANLIB) $@ $(LIBNAME): $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS) @@ -320,12 +329,11 @@ small: library $(SMALLOBJECTS) tv_gen: library $(TVS) $(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) -timing: library $(TIMINGS) testprof/$(LIBTEST) - $(CC) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) +timing: library $(TIMINGS) $(LIBTEST) + $(CC) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) -.PHONY: test -test: library $(TESTS) testprof/$(LIBTEST) - $(CC) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) +test: library $(TESTS) $(LIBTEST) + $(CC) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) all_test: test tv_gen hashsum crypt small timing @@ -333,11 +341,11 @@ all_test: test tv_gen hashsum crypt small timing #as root in order to have a high enough permission to write to the correct #directories and to set the owner and group to root. install: library - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) - install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH) - install -g $(GROUP) -o $(USER) $(LIBTEST) $(DESTDIR)$(LIBPATH) - install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH) + install -d -g $(GROUP) -o $(USER) $(LIBPATH) + install -d -g $(GROUP) -o $(USER) $(INCPATH) + install -g $(GROUP) -o $(USER) $(LIBNAME) $(LIBPATH) + install -g $(GROUP) -o $(USER) $(LIBTEST) $(LIBPATH) + install -g $(GROUP) -o $(USER) $(HEADERS) $(INCPATH) # $Source$ # $Revision$ diff --git a/makefile.include b/makefile.include index 0e090c0..d1103ac 100644 --- a/makefile.include +++ b/makefile.include @@ -98,22 +98,13 @@ DEMOS=hashsum crypt small tv_gen sizes constants TIMINGS=demos/timing.o TESTS=demos/test.o -#LIBPATH-The directory for libtomcrypt to be installed to. -#INCPATH-The directory to install the header files for libtomcrypt. -#DATAPATH-The directory to install the pdf docs. -ifndef DESTDIR - DESTDIR= -endif - -ifndef LIBPATH - LIBPATH=/usr/lib -endif -ifndef INCPATH - INCPATH=/usr/include -endif -ifndef DATAPATH - DATAPATH=/usr/share/doc/libtomcrypt/pdf -endif +#LIBPATH The directory for libtomcrypt to be installed to. +#INCPATH The directory to install the header files for libtomcrypt. +#DATAPATH The directory to install the pdf docs. +DESTDIR ?= /usr/local +LIBPATH ?= $(DESTDIR)/lib +INCPATH ?= $(DESTDIR)/include +DATAPATH ?= $(DESTDIR)/share/doc/libtomcrypt/pdf #Who do we install as? ifdef INSTALL_USER diff --git a/makefile.mingw b/makefile.mingw index b1eaa2f..67a4ffc 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -32,8 +32,7 @@ INSTPREFIX=c:\devel-libtom LIBPATH=$(INSTPREFIX)\lib INCPATH=$(INSTPREFIX)\include -#List of objects to compile. -#START_INS +# List of objects to compile (all goes to libtomcrypt.a) OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ @@ -185,13 +184,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o +# List of test objects to compile (all goes to libtomcrypt_prof.a) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h - -#END_INS +src/headers/tomcrypt_prng.h TESTOBJECTS=demos/test.o HASHOBJECTS=demos/hashsum.o @@ -220,9 +226,13 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c #This rule makes the libtomcrypt library. library: $(LIBNAME) -.PHONY: testprof/$(LIBTEST) -testprof/$(LIBTEST): - $(MAKE) -C testprof -f makefile.mingw LIBTEST_S=$(LIBTEST) CC=$(CC) LD=$(LD) AR=$(AR) ARFLAGS=$(ARFLAGS) RANLIB=$(RANLIB) +#Dependencies on *.h +$(OBJECTS): $(HEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h + +$(LIBTEST): $(TOBJECTS) + $(AR) $(ARFLAGS) $@ $(TOBJECTS) + $(RANLIB) $@ %.o: %.c ${CC} ${CFLAGS} -c $< -o $@ @@ -246,24 +256,24 @@ small: library $(SMALLOBJECTS) tv_gen: library $(TVS) $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) -timing: library testprof/$(LIBTEST) $(TIMINGS) - $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) +timing: library $(LIBTEST) $(TIMINGS) + $(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) .PHONY: test -test: library testprof/$(LIBTEST) $(TESTS) - $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) +test: library $(LIBTEST) $(TESTS) + $(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) all_test: test tv_gen hashsum crypt small timing install: library - cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)" - cmd /c if not exist "$(DESTDIR)$(INCPATH)" mkdir "$(DESTDIR)$(INCPATH)" - copy /Y $(LIBNAME) "$(DESTDIR)$(LIBPATH)" - copy /Y src\headers\tomcrypt*.h "$(DESTDIR)$(INCPATH)" + cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)" + cmd /c if not exist "$(INCPATH)" mkdir "$(INCPATH)" + copy /Y $(LIBNAME) "$(LIBPATH)" + copy /Y src\headers\tomcrypt*.h "$(INCPATH)" -install_test: testprof/$(LIBTEST) - cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)" - copy /Y testprof\$(LIBTEST) "$(DESTDIR)$(LIBPATH)" +install_test: $(LIBTEST) + cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)" + copy /Y testprof\$(LIBTEST) "$(LIBPATH)" clean: cmd /c del /Q /S *.o *.a *.exe diff --git a/makefile.msvc b/makefile.msvc index e4894c7..eae515f 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -8,7 +8,7 @@ EXTRAINCLUDE=../libtommath CFLAGS = /nologo /Isrc/headers/ /I$(EXTRAINCLUDE) /Itestprof/ /Ox /D_CRT_SECURE_NO_WARNINGS /DUSE_LTM /DLTM_DESC /DLTC_SOURCE /DLTC_NO_PROTOTYPES /W3 $(CF) -#START_INS +# List of objects to compile (all goes to libtomcrypt.lib) OBJECTS=src/ciphers/aes/aes.obj src/ciphers/aes/aes_enc.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \ src/ciphers/camellia.obj src/ciphers/cast5.obj src/ciphers/des.obj src/ciphers/kasumi.obj src/ciphers/khazad.obj \ src/ciphers/kseed.obj src/ciphers/multi2.obj src/ciphers/noekeon.obj src/ciphers/rc2.obj src/ciphers/rc5.obj \ @@ -160,13 +160,20 @@ src/stream/chacha/chacha_keystream.obj src/stream/chacha/chacha_setup.obj src/st src/stream/rc4/rc4.obj src/stream/rc4/rc4_test.obj src/stream/sober128/sober128.obj \ src/stream/sober128/sober128_test.obj +# List of test objects to compile (all goes to libtomcrypt_prof.lib) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h - -#END_INS +src/headers/tomcrypt_prng.h default: library @@ -177,11 +184,9 @@ default: library src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c $(CC) $(CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj -library: $(OBJECTS) +library: $(OBJECTS) $(TOBJECTS) lib /out:tomcrypt.lib $(OBJECTS) - cd testprof - nmake -f makefile.msvc - cd .. + lib /out:tomcrypt_prof.lib $(TOBJECTS) tv_gen: demos/tv_gen.c library cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS) @@ -189,12 +194,11 @@ tv_gen: demos/tv_gen.c library hashsum: demos/hashsum.c library cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS) -.PHONY: test test: demos/test.c library - cl $(CFLAGS) demos/test.c testprof/tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS) + cl $(CFLAGS) demos/test.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS) timing: demos/timing.c library - cl $(CFLAGS) demos/timing.c testprof/tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS) + cl $(CFLAGS) demos/timing.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS) all_test: test tv_gen hashsum timing diff --git a/makefile.shared b/makefile.shared index e96a051..3e888c5 100644 --- a/makefile.shared +++ b/makefile.shared @@ -185,11 +185,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o +# List of test objects to compile (all goes to libtomcrypt_prof.a) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h +src/headers/tomcrypt_prng.h #END_INS @@ -198,7 +207,7 @@ default:library #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c - $(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o + $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o #These are the rules to make certain object files. src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c @@ -212,39 +221,39 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c #This rule makes the libtomcrypt library. library: $(LIBNAME) -.PHONY: testprof/$(LIBTEST) -testprof/$(LIBTEST): - cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION_LT) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) LT=$(LT) CC="$(CC)" make -f makefile.shared +#Dependencies on *.h +$(OBJECTS): $(HEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h .c.o: $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $< $(LIBNAME): $(OBJECTS) - $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LT) + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) + +$(LIBTEST): $(TOBJECTS) + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./testprof -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) install: $(LIBNAME) - install -d $(DESTDIR)$(LIBPATH) - $(LT) --mode=install install -c libtomcrypt.la $(DESTDIR)$(LIBPATH)/libtomcrypt.la - install -d $(DESTDIR)$(INCPATH) - install -m 644 $(HEADERS) $(DESTDIR)$(INCPATH) - install -d $(DESTDIR)$(LIBPATH)/pkgconfig - sed 's,@LIBDIR@,$(LIBPATH),g' libtomcrypt.pc.in > libtomcrypt.pc - install -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc + install -d $(LIBPATH)/pkgconfig + install -d $(INCPATH) + $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME) + install -m 644 $(HEADERS) $(INCPATH) + sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc + install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc install_test: testprof/$(LIBTEST) - install -d $(DESTDIR)$(LIBPATH) - install -d $(DESTDIR)$(INCPATH) - cd testprof ; CFLAGS="$(CFLAGS)" VERSION=$(VERSION_LT) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) LT=$(LT) CC=$(CC) make -f makefile.shared install + install -d $(LIBPATH) + install -d $(INCPATH) + install -m 644 testprof/tomcrypt_test.h $(INCPATH) + $(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST) - -.PHONY: test test: library testprof/$(LIBTEST) $(TESTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) timing: library testprof/$(LIBTEST) $(TIMINGS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) - # build the demos from a template define DEMO_template $(1): demos/$(1).o library From bb4a051e400c5f070006db8c78f3c88b9934e03d Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 2 May 2017 20:54:41 +0200 Subject: [PATCH 07/51] makefile.unix facelift --- makefile.unix | 201 ++++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 96 deletions(-) diff --git a/makefile.unix b/makefile.unix index ddced57..cda26ea 100644 --- a/makefile.unix +++ b/makefile.unix @@ -1,44 +1,46 @@ -# MAKEFILE for bsd make +# MAKEFILE that is intended to be compatible with any kind of make (GNU make, BDS make , ...) # -# Tom St Denis +# Please do not use here neither any special make syntax nor any unusual tools/utilities! -# Compiler and Linker Names -CC=cc -LD=ld +### USAGE: +# +# make -f makefile.unix all +# ./test +# make -f makefile.unix install +# +#OR: +# +# make -f makefile.unix CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -I/path/to/libtommath" EXTRALIBS=/path/to/libtommath/libtommath.a all +# ./test +# make -f makefile.unix DESTDIR=/opt/libtom install +# -# Archiver [makes .a files] -AR=ar -ARFLAGS=r +#The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs" +CC ?= cc +LD ?= ld +AR ?= ar +ARFLAGS ?= r +RANLIB ?= ranlib +CFLAGS ?= -O2 -DUSE_LTM -DLTM_DESC -I../libtommath +EXTRALIBS ?= ../libtommath/libtommath.a +DESTDIR ?= /usr/local -# Compilation flags. Note the += does not write over the user's CFLAGS! -CFLAGS = -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2 ${CFLAGS_OPTS} -o $@ +#Compilation flags +LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE +LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) +VERSION=1.17 +VERSION_MAJ=1 +VERSION_MIN=17 -LIBNAME=libtomcrypt.a -LIBTEST=libtomcrypt_prof.a -LIBTEST_S=$(LIBTEST) +#Libraries to be created +LIBMAIN_S =libtomcrypt.a +LIBTEST_S =libtomcrypt_prof.a +LIBMAIN_D =libtomcrypt.so.0.0.$(VERSION_MAJ)$(VERSION_MIN) +#The following will be symlinks to $(LIBMAIN_D) +LIBMAIN_L1=libtomcrypt.so.0 +LIBMAIN_L2=libtomcrypt.so -HASH=hashsum -CRYPT=encrypt -SMALL=small -PROF=x86_prof -TV=tv_gen -TIMING=timing -TEST=test - -#LIBPATH-The directory for libtomcrypt to be installed to. -#INCPATH-The directory to install the header files for libtomcrypt. -#DATAPATH-The directory to install the pdf docs. -LIBPATH=/usr/local/lib -INCPATH=/usr/local/include -DATAPATH=/usr/local/share/doc/libtomcrypt/pdf - -#Who do we install as? -USER=root - -GROUP=wheel - -#List of objects to compile. -#START_INS +# List of objects to compile (all goes to libtomcrypt.a) OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ @@ -190,36 +192,35 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o +# List of test objects to compile (all goes to libtomcrypt_prof.a) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h +src/headers/tomcrypt_prng.h -#END_INS +#this is necessary for compatibility with BSD make (namely on OpenBSD) +.SUFFIXES: .o .c -TESTOBJECTS=demos/test.o -HASHOBJECTS=demos/hashsum.o -CRYPTOBJECTS=demos/encrypt.o -SMALLOBJECTS=demos/small.o -TVS=demos/tv_gen.o -TIMINGS=demos/timing.o -TESTS=demos/test.o +.c.o: + $(CC) $(LTC_CFLAGS) -c $< -o $@ -#Files left over from making the crypt.pdf. -LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out +#The default rule for make builds the libtomcrypt.a library (static) +default: $(LIBMAIN_S) -#Compressed filenames -COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip - -#The default rule for make builds the libtomcrypt library. -default:library - -#ciphers come in two flavours... enc+dec and enc +#SPECIAL: AES come in two flavours... enc+dec and enc-only src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c - $(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o + $(CC) $(LTC_CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o -#These are the rules to make certain object files. +#SPECIAL: these are the rules to make certain object files src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c @@ -228,56 +229,64 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c -#This rule makes the libtomcrypt library. -library: $(LIBNAME) +#Dependencies on *.h +$(OBJECTS): $(HEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h -.PHONY: testprof/$(LIBTEST) -testprof/$(LIBTEST): - cd testprof ; CFLAGS="$(CFLAGS)" LIBTEST_S=$(LIBTEST_S) CC="$(CC)" LD="$(LD)" AR="$(AR)" RANLIB="$(RANLIB)" $(MAKE) +#Create libtomcrypt_prof.a +$(LIBTEST_S): $(TOBJECTS) + $(AR) $(ARFLAGS) $@ $(TOBJECTS) + $(RANLIB) $@ -$(LIBNAME): $(OBJECTS) +#Create libtomcrypt.a +$(LIBMAIN_S): $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS) $(RANLIB) $@ -#This rule makes the hash program included with libtomcrypt -hashsum: library $(HASHOBJECTS) - $(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN) +#Create libtomcrypt.so +$(LIBMAIN_D): $(OBJECTS) + $(CC) -shared -Wl,-soname=$(LIBMAIN_L1) $(OBJECTS) $(LTC_LDFLAGS) -o $@ -#makes the crypt program -crypt: library $(CRYPTOBJECTS) - $(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN) +#Demo tools/utilities +hashsum: demos/hashsum.o $(LIBMAIN_S) + $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +crypt: demos/crypt.o $(LIBMAIN_S) + $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +small: demos/small.o $(LIBMAIN_S) + $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +tv_gen: demos/tv_gen.o $(LIBMAIN_S) + $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ -#makes the small program -small: library $(SMALLOBJECTS) - $(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN) - -tv_gen: library $(TVS) - $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) +#Tests + timing tests +timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) + $(CC) $< $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + @echo "NOTICE: start the timing tests by: ./timing" +test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) + $(CC) $< $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + @echo "NOTICE: start the tests by: ./test" -timing: library testprof/$(LIBTEST) $(TIMINGS) - $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) +all: $(LIBMAIN_S) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test -.PHONY: test -test: library testprof/$(LIBTEST) $(TESTS) - $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) +#NOTE: as this makefile works also on cygwin, thus we need to delete *.exe +clean: + -@rm -f $(OBJECTS) + -@rm -f $(LIBMAIN_S) $(LIBMAIN_D) $(LIBTEST_S) + -@rm -f testprof/*.o demos/*.o lib*.so lib*.so.* + -@rm -f test tv_gen hashsum crypt small timing + -@rm -f test.exe tv_gen.exe hashsum.exe crypt.exe small.exe timing.exe -all_test: test tv_gen hashsum crypt small timing +install_static: $(LIBMAIN_S) $(HEADERS) + @mkdir -p $(DESTDIR)/include $(DESTDIR)/lib/pkgconfig + @cp $(LIBMAIN_S) $(DESTDIR)/lib/ + @cp $(HEADERS) $(DESTDIR)/include/ + @sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/lib/pkgconfig/libtomcrypt.pc -#This rule installs the library and the header files. This must be run -#as root in order to have a high enough permission to write to the correct -#directories and to set the owner and group to root. -install: library - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(DATAPATH) - install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH) - install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH) +install_dynamic: $(LIBMAIN_D) $(HEADERS) + @mkdir -p $(DESTDIR)/include $(DESTDIR)/lib/pkgconfig + @cp $(LIBMAIN_D) $(DESTDIR)/lib/ + @cp $(HEADERS) $(DESTDIR)/include/ + @ln -sf $(LIBMAIN_D) $(DESTDIR)/lib/$(LIBMAIN_L1) + @ln -sf $(LIBMAIN_D) $(DESTDIR)/lib/$(LIBMAIN_L2) + @sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/lib/pkgconfig/libtomcrypt.pc -install_test: testprof/$(LIBTEST) - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) - install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) - install -g $(GROUP) -o $(USER) testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH) - -# $Source$ -# $Revision$ -# $Date$ +install: install_static install_dynamic From 3540eedb4a3808a688f63d5011279dadc1d9341b Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 2 May 2017 21:07:21 +0200 Subject: [PATCH 08/51] HP-UX make does not like ?= and $< --- makefile.unix | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/makefile.unix b/makefile.unix index cda26ea..6006858 100644 --- a/makefile.unix +++ b/makefile.unix @@ -16,14 +16,14 @@ # #The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs" -CC ?= cc -LD ?= ld -AR ?= ar -ARFLAGS ?= r -RANLIB ?= ranlib -CFLAGS ?= -O2 -DUSE_LTM -DLTM_DESC -I../libtommath -EXTRALIBS ?= ../libtommath/libtommath.a -DESTDIR ?= /usr/local +CC = cc +LD = ld +AR = ar +ARFLAGS = r +RANLIB = ranlib +CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath +EXTRALIBS = ../libtommath/libtommath.a +DESTDIR = /usr/local #Compilation flags LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE @@ -249,20 +249,20 @@ $(LIBMAIN_D): $(OBJECTS) #Demo tools/utilities hashsum: demos/hashsum.o $(LIBMAIN_S) - $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ crypt: demos/crypt.o $(LIBMAIN_S) - $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ small: demos/small.o $(LIBMAIN_S) - $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ tv_gen: demos/tv_gen.o $(LIBMAIN_S) - $(CC) $< $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ #Tests + timing tests timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) - $(CC) $< $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ @echo "NOTICE: start the timing tests by: ./timing" test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) - $(CC) $< $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ @echo "NOTICE: start the tests by: ./test" all: $(LIBMAIN_S) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test From ceb7332631eb07390b67a591e0d698c6b4a1ceee Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 2 May 2017 21:42:07 +0200 Subject: [PATCH 09/51] typo --- makefile.unix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile.unix b/makefile.unix index 6006858..b70deef 100644 --- a/makefile.unix +++ b/makefile.unix @@ -1,4 +1,4 @@ -# MAKEFILE that is intended to be compatible with any kind of make (GNU make, BDS make , ...) +# MAKEFILE that is intended to be compatible with any kind of make (GNU make, BSD make, ...) # # Please do not use here neither any special make syntax nor any unusual tools/utilities! From c225f22a2360808383883de4423111338d2c9926 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Wed, 3 May 2017 07:35:43 +0200 Subject: [PATCH 10/51] remove building dynamic libs from makefile.unix --- makefile.unix | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/makefile.unix b/makefile.unix index b70deef..26c43e6 100644 --- a/makefile.unix +++ b/makefile.unix @@ -1,6 +1,9 @@ # MAKEFILE that is intended to be compatible with any kind of make (GNU make, BSD make, ...) +# works on: Linux, *BSD, Cygwin, AIX, HP-UX and hopefully other UNIX systems # # Please do not use here neither any special make syntax nor any unusual tools/utilities! +# +# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh ### USAGE: # @@ -16,31 +19,24 @@ # #The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs" +DESTDIR = /usr/local CC = cc -LD = ld AR = ar ARFLAGS = r RANLIB = ranlib CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath EXTRALIBS = ../libtommath/libtommath.a -DESTDIR = /usr/local #Compilation flags LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) VERSION=1.17 -VERSION_MAJ=1 -VERSION_MIN=17 -#Libraries to be created +#Libraries to be created (this makefile builds only static libraries) LIBMAIN_S =libtomcrypt.a LIBTEST_S =libtomcrypt_prof.a -LIBMAIN_D =libtomcrypt.so.0.0.$(VERSION_MAJ)$(VERSION_MIN) -#The following will be symlinks to $(LIBMAIN_D) -LIBMAIN_L1=libtomcrypt.so.0 -LIBMAIN_L2=libtomcrypt.so -# List of objects to compile (all goes to libtomcrypt.a) +#List of objects to compile (all goes to libtomcrypt.a) OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ @@ -192,7 +188,7 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o -# List of test objects to compile (all goes to libtomcrypt_prof.a) +#List of test objects to compile (all goes to libtomcrypt_prof.a) TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ @@ -200,14 +196,14 @@ testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o -# The following headers will be installed by "make install" +#The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -#this is necessary for compatibility with BSD make (namely on OpenBSD) +#This is necessary for compatibility with BSD make (namely on OpenBSD) .SUFFIXES: .o .c .c.o: @@ -216,7 +212,7 @@ src/headers/tomcrypt_prng.h #The default rule for make builds the libtomcrypt.a library (static) default: $(LIBMAIN_S) -#SPECIAL: AES come in two flavours... enc+dec and enc-only +#SPECIAL: AES comes in two flavours - enc+dec and enc-only src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c $(CC) $(LTC_CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o @@ -243,10 +239,6 @@ $(LIBMAIN_S): $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS) $(RANLIB) $@ -#Create libtomcrypt.so -$(LIBMAIN_D): $(OBJECTS) - $(CC) -shared -Wl,-soname=$(LIBMAIN_L1) $(OBJECTS) $(LTC_LDFLAGS) -o $@ - #Demo tools/utilities hashsum: demos/hashsum.o $(LIBMAIN_S) $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ @@ -265,28 +257,18 @@ test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) $(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ @echo "NOTICE: start the tests by: ./test" -all: $(LIBMAIN_S) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test +all: $(LIBMAIN_S) $(LIBTEST_S) hashsum crypt small tv_gen timing test -#NOTE: as this makefile works also on cygwin, thus we need to delete *.exe +#NOTE: this makefile works also on cygwin, thus we need to delete *.exe clean: -@rm -f $(OBJECTS) - -@rm -f $(LIBMAIN_S) $(LIBMAIN_D) $(LIBTEST_S) - -@rm -f testprof/*.o demos/*.o lib*.so lib*.so.* + -@rm -f $(LIBMAIN_S) $(LIBTEST_S) + -@rm -f testprof/*.o demos/*.o -@rm -f test tv_gen hashsum crypt small timing -@rm -f test.exe tv_gen.exe hashsum.exe crypt.exe small.exe timing.exe -install_static: $(LIBMAIN_S) $(HEADERS) +install: $(LIBMAIN_S) $(HEADERS) @mkdir -p $(DESTDIR)/include $(DESTDIR)/lib/pkgconfig @cp $(LIBMAIN_S) $(DESTDIR)/lib/ @cp $(HEADERS) $(DESTDIR)/include/ @sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/lib/pkgconfig/libtomcrypt.pc - -install_dynamic: $(LIBMAIN_D) $(HEADERS) - @mkdir -p $(DESTDIR)/include $(DESTDIR)/lib/pkgconfig - @cp $(LIBMAIN_D) $(DESTDIR)/lib/ - @cp $(HEADERS) $(DESTDIR)/include/ - @ln -sf $(LIBMAIN_D) $(DESTDIR)/lib/$(LIBMAIN_L1) - @ln -sf $(LIBMAIN_D) $(DESTDIR)/lib/$(LIBMAIN_L2) - @sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/lib/pkgconfig/libtomcrypt.pc - -install: install_static install_dynamic From f544418d56cc4cc0d87995c9037dd03206ccb6c9 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Wed, 3 May 2017 07:36:05 +0200 Subject: [PATCH 11/51] re-work makefile.mingw in the same style as makefile.unix --- makefile.mingw | 160 ++++++++++++++++++++++++------------------------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/makefile.mingw b/makefile.mingw index 67a4ffc..75215c8 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -1,38 +1,42 @@ +# MAKEFILE for MS Windows (mingw + gcc + gmake) # -# open a command prompt with gcc + gmake in PATH -# and start: gmake -f makefile.mingw +# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh + +### USAGE: +# Open a command prompt with gcc + gmake in PATH and start: +# +# gmake -f makefile.mingw all +# test.exe +# gmake -f makefile.mingw install +# +#OR: +# +# gmake -f makefile.mingw CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -Ic:/path/to/libtommath" EXTRALIBS="-Lc:/path/to/libtommath -ltommath" all +# test.exe +# gmake -f makefile.mingw DESTDIR=c:\devel\libtom install # -EXTRALIBS=../libtommath/libtommath.a -EXTRAINCLUDE=../libtommath +#The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs +DESTDIR = c:\mingw +CC = gcc +AR = ar +ARFLAGS = r +RANLIB = ranlib +STRIP = strip +CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath +EXTRALIBS = -L../libtommath -ltommath -CFLAGS = -Wall -Wextra -c -I./src/headers -I$(EXTRAINCLUDE) -I./testprof -DUSE_LTM -DLTM_DESC -DLTC_SOURCE -DLTC_NO_PROTOTYPES -O2 ${CFLAGS_OPTS} +#Compilation flags +LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE +LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) -# Compiler and Linker Names -CC=gcc -LD=ld -AR=ar -ARFLAGS=rc -RANLIB=ranlib +#Libraries to be created +LIBMAIN_S =libtomcrypt.a +LIBMAIN_I =libtomcrypt.dll.a +LIBMAIN_D =libtomcrypt.dll +LIBTEST_S =libtomcrypt_prof.a -LIBNAME=libtomcrypt.a -LIBTEST=libtomcrypt_prof.a - -HASH=hashsum -CRYPT=encrypt -SMALL=small -PROF=x86_prof -TV=tv_gen -TIMING=timing -TEST=test - -#LIBPATH-The directory for libtomcrypt to be installed to. -#INCPATH-The directory to install the header files for libtomcrypt. -INSTPREFIX=c:\devel-libtom -LIBPATH=$(INSTPREFIX)\lib -INCPATH=$(INSTPREFIX)\include - -# List of objects to compile (all goes to libtomcrypt.a) +#List of objects to compile (all goes to libtomcrypt.a) OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ @@ -184,7 +188,7 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/sober128/sober128_test.o -# List of test objects to compile (all goes to libtomcrypt_prof.a) +#List of test objects to compile (all goes to libtomcrypt_prof.a) TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ @@ -192,29 +196,24 @@ testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o -# The following headers will be installed by "make install" +#The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -TESTOBJECTS=demos/test.o -HASHOBJECTS=demos/hashsum.o -CRYPTOBJECTS=demos/encrypt.o -SMALLOBJECTS=demos/small.o -TVS=demos/tv_gen.o -TIMINGS=demos/timing.o -TESTS=demos/test.o +.c.o: + $(CC) $(LTC_CFLAGS) -c $< -o $@ -#The default rule for make builds the libtomcrypt library. -default:library +#The default rule for make builds the libtomcrypt.a library (static) +default: $(LIBMAIN_S) -#ciphers come in two flavours... enc+dec and enc +#SPECIAL: AES comes in two flavours - enc+dec and enc-only src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c - $(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o + $(CC) $(LTC_CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o -#These are the rules to make certain object files. +#SPECIAL: these are the rules to make certain object files src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c @@ -223,58 +222,53 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c -#This rule makes the libtomcrypt library. -library: $(LIBNAME) - #Dependencies on *.h $(OBJECTS): $(HEADERS) $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h -$(LIBTEST): $(TOBJECTS) +#Create libtomcrypt_prof.a +$(LIBTEST_S): $(TOBJECTS) $(AR) $(ARFLAGS) $@ $(TOBJECTS) $(RANLIB) $@ -%.o: %.c - ${CC} ${CFLAGS} -c $< -o $@ - -$(LIBNAME): $(OBJECTS) +#Create libtomcrypt.a +$(LIBMAIN_S): $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS) $(RANLIB) $@ -#This rule makes the hash program included with libtomcrypt -hashsum: library $(HASHOBJECTS) - $(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN) +#Create DLL + import library libtomcrypt.dll.a +$(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS) + $(CC) -s -shared -o $(LIBMAIN_D) $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBMAIN_I) $(LTC_LDFLAGS) + $(STRIP) -S $(LIBMAIN_D) -#makes the crypt program -crypt: library $(CRYPTOBJECTS) - $(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN) +#Demo tools/utilities +hashsum: demos/hashsum.o $(LIBMAIN_S) + $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +crypt: demos/crypt.o $(LIBMAIN_S) + $(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +small: demos/small.o $(LIBMAIN_S) + $(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +tv_gen: demos/tv_gen.o $(LIBMAIN_S) + $(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ -#makes the small program -small: library $(SMALLOBJECTS) - $(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN) +#Tests + timing tests +timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) + $(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + @echo NOTICE: start the tests by: timing.exe +test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) + $(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + @echo NOTICE: start the tests by: test.exe -tv_gen: library $(TVS) - $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) - -timing: library $(LIBTEST) $(TIMINGS) - $(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) - -.PHONY: test -test: library $(LIBTEST) $(TESTS) - $(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) - -all_test: test tv_gen hashsum crypt small timing - -install: library - cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)" - cmd /c if not exist "$(INCPATH)" mkdir "$(INCPATH)" - copy /Y $(LIBNAME) "$(LIBPATH)" - copy /Y src\headers\tomcrypt*.h "$(INCPATH)" - -install_test: $(LIBTEST) - cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)" - copy /Y testprof\$(LIBTEST) "$(LIBPATH)" +all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test clean: - cmd /c del /Q /S *.o *.a *.exe - $(MAKE) -C testprof -f makefile.mingw clean + @cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul + +install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) + cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin" + cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib" + cmd /c if not exist "$(DESTDIR)\include" mkdir "$(DESTDIR)\include" + copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib" + copy /Y $(LIBMAIN_I) "$(DESTDIR)\lib" + copy /Y $(LIBMAIN_D) "$(DESTDIR)\bin" + copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include" From 85dc39483f27ccfb96508099fcf0a6d5ed369c84 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 26 Apr 2017 01:00:50 +0200 Subject: [PATCH 12/51] rename crypt to ltcrypt a binary called crypt already exists and creates a name-clash as we won't implement the entire CLI even if this tool implements similar functionality --- .gitignore | 4 ++-- demos/{crypt.c => ltcrypt.c} | 0 makefile | 3 +-- makefile.include | 8 +------- 4 files changed, 4 insertions(+), 11 deletions(-) rename demos/{crypt.c => ltcrypt.c} (100%) diff --git a/.gitignore b/.gitignore index 353266c..acba152 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,8 @@ doc/refman.pdf # *nix/windows test executables constants constants.exe -crypt -crypt.exe +ltcrypt +ltcrypt.exe hashsum hashsum.exe multi diff --git a/demos/crypt.c b/demos/ltcrypt.c similarity index 100% rename from demos/crypt.c rename to demos/ltcrypt.c diff --git a/makefile b/makefile index 2206e00..aa5e933 100644 --- a/makefile +++ b/makefile @@ -365,8 +365,7 @@ clean: rm -f `find . -type f -name "*.dpi" | xargs` rm -rf `find . -type d -name "*.libs" | xargs` rm -f crypt.aux crypt.dvi crypt.idx crypt.ilg crypt.ind crypt.log crypt.toc - rm -f $(TV) $(SMALL) $(CRYPT) $(HASH) $(TIMING) $(TEST) - rm -f $(SIZES) $(CONSTANTS) + rm -f $(TIMING) $(TEST) $(DEMOS) rm -rf doc/doxygen rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs` rm -f *.txt diff --git a/makefile.include b/makefile.include index d1103ac..e426156 100644 --- a/makefile.include +++ b/makefile.include @@ -84,16 +84,10 @@ CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" endif -HASH=hashsum -CRYPT=encrypt -SMALL=small -TV=tv_gen TIMING=timing TEST=test -SIZES=sizes -CONSTANTS=constants -DEMOS=hashsum crypt small tv_gen sizes constants +DEMOS=hashsum ltcrypt small tv_gen sizes constants TIMINGS=demos/timing.o TESTS=demos/test.o From 90daad0764f839195422a3b2fb4e7a57cae6b7a8 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 1 May 2017 11:17:23 +0200 Subject: [PATCH 13/51] add new make-target 'bins' so you can easily build the useful demos --- makefile | 2 ++ makefile.include | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index aa5e933..7cff821 100644 --- a/makefile +++ b/makefile @@ -275,6 +275,8 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) +bins: $(USEFUL_DEMOS) + all_test: test tv_gen $(DEMOS) ifeq ($(COVERAGE),1) all_test: LIB_PRE = -Wl,--whole-archive diff --git a/makefile.include b/makefile.include index e426156..5dadaba 100644 --- a/makefile.include +++ b/makefile.include @@ -87,7 +87,8 @@ endif TIMING=timing TEST=test -DEMOS=hashsum ltcrypt small tv_gen sizes constants +USEFUL_DEMOS=hashsum +DEMOS=$(USEFUL_DEMOS) ltcrypt small tv_gen sizes constants TIMINGS=demos/timing.o TESTS=demos/test.o From 3fd1771d3542f9206d5a59e2373e4c8d16338e6f Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 3 May 2017 18:36:35 +0200 Subject: [PATCH 14/51] also install useful demos --- makefile | 6 ++++-- makefile.include | 2 ++ makefile.shared | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 7cff821..792383e 100644 --- a/makefile +++ b/makefile @@ -289,14 +289,16 @@ endif ifndef NODOCS install: library docs else -install: library +install: library $(USEFUL_DEMOS) endif install -d $(LIBPATH) install -d $(INCPATH) - install -d $(DATAPATH) + install -d $(BINPATH) install -m 644 $(LIBNAME) $(LIBPATH) install -m 644 $(HEADERS) $(INCPATH) + install -m 644 $(USEFUL_DEMOS) $(BINPATH) ifndef NODOCS + install -d $(DATAPATH) install -m 644 doc/crypt.pdf $(DATAPATH) endif diff --git a/makefile.include b/makefile.include index 5dadaba..c1cd7d5 100644 --- a/makefile.include +++ b/makefile.include @@ -96,10 +96,12 @@ TESTS=demos/test.o #LIBPATH The directory for libtomcrypt to be installed to. #INCPATH The directory to install the header files for libtomcrypt. #DATAPATH The directory to install the pdf docs. +#BINPATH The directory to install the binaries provided. DESTDIR ?= /usr/local LIBPATH ?= $(DESTDIR)/lib INCPATH ?= $(DESTDIR)/include DATAPATH ?= $(DESTDIR)/share/doc/libtomcrypt/pdf +BINPATH ?= $(DESTDIR)/bin #Who do we install as? ifdef INSTALL_USER diff --git a/makefile.shared b/makefile.shared index 3e888c5..1506ba7 100644 --- a/makefile.shared +++ b/makefile.shared @@ -234,11 +234,13 @@ $(LIBNAME): $(OBJECTS) $(LIBTEST): $(TOBJECTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./testprof -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) -install: $(LIBNAME) +install: $(LIBNAME) $(USEFUL_DEMOS) install -d $(LIBPATH)/pkgconfig install -d $(INCPATH) + install -d $(BINPATH) $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME) install -m 644 $(HEADERS) $(INCPATH) + install -m 775 $(USEFUL_DEMOS) $(BINPATH) sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc From 5c2bea093a64d23c083c087bc8a7a449e574f858 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Thu, 4 May 2017 16:01:56 +0200 Subject: [PATCH 15/51] zipup target facelift --- .gitattributes | 6 ++++++ .gitignore | 4 ++++ makefile | 34 ++++++++++++++++------------------ mess.sh | 4 ---- 4 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 .gitattributes delete mode 100755 mess.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c76e0d2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.* export-ignore +/hooks export-ignore +doc/*.html export-ignore +coverity.sh export-ignore + +/** export-subst diff --git a/.gitignore b/.gitignore index acba152..f74c428 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,10 @@ /MSVC_* .libs/ +# release files +/libtomcrypt-* +/crypt-* + # suppress output of build process gcc_[12].txt testok.txt diff --git a/makefile b/makefile index 792383e..1a76fd0 100644 --- a/makefile +++ b/makefile @@ -387,7 +387,8 @@ doxy: doxygen #from the clean command! This is because most people would like to keep the #nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to #delete it if we are rebuilding it. -docs: crypt.tex +docs: doc/crypt.pdf +doc/crypt.pdf: crypt.tex rm -f doc/crypt.pdf $(LEFTOVERS) cp crypt.tex crypt.bak touch --reference=crypt.tex crypt.bak @@ -418,24 +419,21 @@ docdvi: crypt.tex latex crypt $(silent_stdout) latex crypt $(silent_stdout) -#zipup the project (take that!) -no_oops: clean - cd .. ; cvs commit - echo Scanning for scratch/dirty files - find . -type f | grep -v CVS | xargs -n 1 bash mess.sh - -zipup: no_oops docs - cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \ - cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; \ - cd libtomcrypt-$(VERSION) ; rm -rf `find . -type d | grep CVS | xargs` ; cd .. ; \ - tar -cjvf crypt-$(VERSION).tar.bz2 libtomcrypt-$(VERSION) ; \ - zip -9r crypt-$(VERSION).zip libtomcrypt-$(VERSION) ; \ - gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip ; \ - mv -fv crypt* ~ ; rm -rf libtomcrypt-$(VERSION) +zipup: doc/crypt.pdf + @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) + @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) + rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* + # files/dirs excluded from "git archive" are defined in .gitattributes + git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x + mkdir -p libtomcrypt-$(VERSION)/doc + cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf + tar -cjf libtomcrypt-$(VERSION).tar.bz2 libtomcrypt-$(VERSION) + zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) + rm -rf libtomcrypt-$(VERSION) + gpg -b -a libtomcrypt-$(VERSION).tar.bz2 + gpg -b -a libtomcrypt-$(VERSION).zip perlcritic: perlcritic *.pl -# $Source$ -# $Revision$ -# $Date$ +# git commit: $Format:%h$ $Format:%ai$ $Format:%ci$ diff --git a/mess.sh b/mess.sh deleted file mode 100755 index bd8dc19..0000000 --- a/mess.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -if cvs log $1 >/dev/null 2>/dev/null; then exit 0; else echo "$1 shouldn't be here, removed"; rm -f $1 ; fi - - From 9a3db508bb320bdb059fad5fb0f47c88ac93373c Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 09:28:05 +0200 Subject: [PATCH 16/51] typo in "git commit: .." --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index 1a76fd0..217f85e 100644 --- a/makefile +++ b/makefile @@ -436,4 +436,4 @@ zipup: doc/crypt.pdf perlcritic: perlcritic *.pl -# git commit: $Format:%h$ $Format:%ai$ $Format:%ci$ +# git commit: $Format:%h$ $Format:%ai$ From 31cf7960118631cdcf2ec2c607592deb26a65889 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 10:18:15 +0200 Subject: [PATCH 17/51] updated makefile.unix should work fine with Intel C compiler, so no need to keep an extra clone - makefile.icc --- makefile.icc | 352 -------------------------------------------------- makefile.unix | 6 +- 2 files changed, 5 insertions(+), 353 deletions(-) delete mode 100644 makefile.icc diff --git a/makefile.icc b/makefile.icc deleted file mode 100644 index 445069e..0000000 --- a/makefile.icc +++ /dev/null @@ -1,352 +0,0 @@ -# MAKEFILE for linux ICC (Intel C compiler) -# -# Tested with ICC v8.... -# -# Be aware that ICC isn't quite as stable as GCC and several optimization switches -# seem to break the code (that GCC and MSVC compile just fine). In particular -# "-ip" and "-x*" seem to break the code (ROL/ROR macro problems). As the makefile -# is shipped the code will build and execute properly. -# -# Also note that ICC often makes code that is slower than GCC. This is probably due to -# a mix of not being able to use "-ip" and just having fewer optimization algos than GCC. -# -# Tom St Denis - -# Compiler and Linker Names -CC=icc - -#LD=ld - -# Archiver [makes .a files] -# With compile option "-ipo" it can be necessary to archive with 'xiar' -#AR=ar -#ARFLAGS=r - -ifndef MAKE - MAKE=make -endif - -# Compilation flags. Note the += does not write over the user's CFLAGS! -CFLAGS += -c -I./testprof/ -I./src/headers/ -Wall -Wsign-compare -W -Wshadow -Wno-unused-parameter -DLTC_SOURCE - -#The default rule for make builds the libtomcrypt library. -default:library - -# optimize for SPEED -# -# -mcpu= can be pentium, pentiumpro (covers PII through PIII) or pentium4 -# -a? specifies make code specifically for ? but compatible with IA-32 -# -? specifies compile solely for ? [not specifically IA-32 compatible] -# -# where ? is -# mia - PIII; has only option "-mia32", no "-amia32" -# msse2 - first P4 [Willamette]; has only option "-msse2", no "-amsse2" -# xSSE2 - P4 Northwood -# xSSE3 - P4 Prescott -# -# The easiest way - when compiling on one architecture, only for -# this architecture - is to enable the compiler option "-fast", which enables -# "all possible" optimizations for this architecture. -# ICC 14.0.3 20140422 says "-fast" resolves to -# "-xHOST -O3 -ipo -no-prec-div -static" -# -# Default to just generic max opts -ifdef LTC_SMALL -CFLAGS += -O1 -endif - -ifndef IGNORE_SPEED -CFLAGS += -O3 -endif - -# want to see stuff? -#CFLAGS += -opt_report - -#These flags control how the library gets built. - -#Output filenames for various targets. -ifndef LIBNAME - LIBNAME=libtomcrypt.a -endif -ifndef LIBTEST - LIBTEST=libtomcrypt_prof.a -endif -HASH=hashsum -CRYPT=encrypt -SMALL=small -PROF=x86_prof -TV=tv_gen -TIMING=timing -TEST=test - -#LIBPATH-The directory for libtomcrypt to be installed to. -#INCPATH-The directory to install the header files for libtomcrypt. -#DATAPATH-The directory to install the pdf docs. -ifndef DESTDIR - DESTDIR= -endif -ifndef LIBPATH - LIBPATH=/usr/lib -endif -ifndef INCPATH - INCPATH=/usr/include -endif -ifndef DATAPATH - DATAPATH=/usr/share/doc/libtomcrypt/pdf -endif - -# List of objects to compile (all goes to libtomcrypt.a) -OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ -src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ -src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ -src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \ -src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \ -src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \ -src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \ -src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \ -src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \ -src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \ -src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \ -src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \ -src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \ -src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \ -src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \ -src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \ -src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \ -src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \ -src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \ -src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \ -src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \ -src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \ -src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \ -src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \ -src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \ -src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \ -src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o \ -src/encauth/ocb3/ocb3_int_aad_add_block.o src/encauth/ocb3/ocb3_int_calc_offset_zero.o \ -src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o \ -src/hashes/blake2b.o src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \ -src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \ -src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \ -src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \ -src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \ -src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \ -src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \ -src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \ -src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \ -src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \ -src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \ -src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \ -src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \ -src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \ -src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \ -src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \ -src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \ -src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \ -src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \ -src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \ -src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \ -src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \ -src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \ -src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \ -src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \ -src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \ -src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \ -src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crc32.o \ -src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \ -src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_constants.o \ -src/misc/crypt/crypt_find_cipher.o src/misc/crypt/crypt_find_cipher_any.o \ -src/misc/crypt/crypt_find_cipher_id.o src/misc/crypt/crypt_find_hash.o \ -src/misc/crypt/crypt_find_hash_any.o src/misc/crypt/crypt_find_hash_id.o \ -src/misc/crypt/crypt_find_hash_oid.o src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o \ -src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \ -src/misc/crypt/crypt_inits.o src/misc/crypt/crypt_ltc_mp_descriptor.o \ -src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \ -src/misc/crypt/crypt_prng_rng_descriptor.o src/misc/crypt/crypt_register_cipher.o \ -src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \ -src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \ -src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \ -src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \ -src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \ -src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \ -src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \ -src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \ -src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \ -src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \ -src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \ -src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \ -src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \ -src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \ -src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \ -src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \ -src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \ -src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \ -src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \ -src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \ -src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \ -src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \ -src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \ -src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \ -src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \ -src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \ -src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \ -src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \ -src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \ -src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \ -src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \ -src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \ -src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \ -src/pk/asn1/der/object_identifier/der_length_object_identifier.o \ -src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \ -src/pk/asn1/der/octet/der_length_octet_string.o \ -src/pk/asn1/der/printable_string/der_decode_printable_string.o \ -src/pk/asn1/der/printable_string/der_encode_printable_string.o \ -src/pk/asn1/der/printable_string/der_length_printable_string.o \ -src/pk/asn1/der/sequence/der_decode_sequence_ex.o \ -src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \ -src/pk/asn1/der/sequence/der_decode_sequence_multi.o \ -src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \ -src/pk/asn1/der/sequence/der_encode_sequence_ex.o \ -src/pk/asn1/der/sequence/der_encode_sequence_multi.o \ -src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \ -src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \ -src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \ -src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \ -src/pk/asn1/der/short_integer/der_encode_short_integer.o \ -src/pk/asn1/der/short_integer/der_length_short_integer.o \ -src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \ -src/pk/asn1/der/teletex_string/der_length_teletex_string.o \ -src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \ -src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \ -src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \ -src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \ -src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \ -src/pk/dsa/dsa_import_radix.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \ -src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \ -src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \ -src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \ -src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \ -src/pk/ecc/ecc_sign_hash.o src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \ -src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \ -src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \ -src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \ -src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \ -src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \ -src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \ -src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \ -src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \ -src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \ -src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \ -src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_radix.o src/pk/rsa/rsa_import_x509.o \ -src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_sign_hash.o src/pk/rsa/rsa_sign_saltlen_get.o \ -src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \ -src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \ -src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \ -src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \ -src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \ -src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ -src/stream/sober128/sober128_test.o - -# List of test objects to compile (all goes to libtomcrypt_prof.a) -TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ -testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ -testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ -testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ -testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ -testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o - -# The following headers will be installed by "make install" -HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ -src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ -src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ -src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h - -#Who do we install as? -ifdef INSTALL_USER -USER=$(INSTALL_USER) -else -USER=root -endif - -ifdef INSTALL_GROUP -GROUP=$(INSTALL_GROUP) -else -GROUP=wheel -endif - -#ciphers come in two flavours... enc+dec and enc -aes_enc.o: aes.c aes_tab.c - $(CC) $(CFLAGS) -DENCRYPT_ONLY -c aes.c -o aes_enc.o - -HASHOBJECTS=demos/hashsum.o -CRYPTOBJECTS=demos/encrypt.o -SMALLOBJECTS=demos/small.o -TVS=demos/tv_gen.o -TIMINGS=demos/timing.o -TESTS=demos/test.o - -#ciphers come in two flavours... enc+dec and enc -src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c - $(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o - -#These are the rules to make certain object files. -src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c -src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c -src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c -src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c -src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c -src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c -src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c - -#This rule makes the libtomcrypt library. -library: $(LIBNAME) - -#Dependencies on *.h -$(OBJECTS): $(HEADERS) -$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h - -$(LIBTEST): $(TOBJECTS) - $(AR) $(ARFLAGS) $@ $(TOBJECTS) - $(RANLIB) $@ - -$(LIBNAME): $(OBJECTS) - $(AR) $(ARFLAGS) $@ $(OBJECTS) - ranlib $@ - -#This rule makes the hash program included with libtomcrypt -hashsum: library $(HASHOBJECTS) - $(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN) - -#makes the crypt program -crypt: library $(CRYPTOBJECTS) - $(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN) - -#makes the small program -small: library $(SMALLOBJECTS) - $(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN) - -tv_gen: library $(TVS) - $(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) - -timing: library $(TIMINGS) $(LIBTEST) - $(CC) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) - -test: library $(TESTS) $(LIBTEST) - $(CC) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) - -all_test: test tv_gen hashsum crypt small timing - -#This rule installs the library and the header files. This must be run -#as root in order to have a high enough permission to write to the correct -#directories and to set the owner and group to root. -install: library - install -d -g $(GROUP) -o $(USER) $(LIBPATH) - install -d -g $(GROUP) -o $(USER) $(INCPATH) - install -g $(GROUP) -o $(USER) $(LIBNAME) $(LIBPATH) - install -g $(GROUP) -o $(USER) $(LIBTEST) $(LIBPATH) - install -g $(GROUP) -o $(USER) $(HEADERS) $(INCPATH) - -# $Source$ -# $Revision$ -# $Date$ diff --git a/makefile.unix b/makefile.unix index 26c43e6..1acae9d 100644 --- a/makefile.unix +++ b/makefile.unix @@ -11,12 +11,16 @@ # ./test # make -f makefile.unix install # -#OR: +#Or: # # make -f makefile.unix CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -I/path/to/libtommath" EXTRALIBS=/path/to/libtommath/libtommath.a all # ./test # make -f makefile.unix DESTDIR=/opt/libtom install # +#Or if you are using Intel C compiler you might need something like: +# +# make -f makefile.unix CC=icc AR=xiar CFLAGS="-fast -DUSE_LTM -DLTM_DESC -I/path/to/libtommath" EXTRALIBS=/path/to/libtommath/libtommath.a all +# #The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs" DESTDIR = /usr/local From 3176103c156cdb4672c8d84f28c444822852f16c Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 10:35:36 +0200 Subject: [PATCH 18/51] fix makefile.icc in makefile update scripts --- helper.pl | 2 +- updatemakes.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helper.pl b/helper.pl index b871e67..bc52302 100755 --- a/helper.pl +++ b/helper.pl @@ -260,7 +260,7 @@ sub process_makefiles { } # update OBJECTS + HEADERS in makefile* - for my $m (qw/ makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) { + for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) { my $old = read_file($m); my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_to, @ver_version) : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version); diff --git a/updatemakes.sh b/updatemakes.sh index 070bab3..8975c4b 100755 --- a/updatemakes.sh +++ b/updatemakes.sh @@ -2,7 +2,7 @@ ./helper.pl --update-makefiles || exit 1 -makefiles=(makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc) +makefiles=(makefile makefile.shared makefile.unix makefile.mingw makefile.msvc) vcproj=(libtomcrypt_VS2008.vcproj libtomcrypt_VS2005.vcproj) if [ $# -eq 1 ] && [ "$1" == "-c" ]; then From 1300c5ade53a44c65543e013f5d76fb12b0ca4fe Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 10:36:23 +0200 Subject: [PATCH 19/51] make fixupind.pl part of helper.pl --- fixupind.pl | 16 ---------------- helper.pl | 9 +++++++++ makefile | 4 ++-- 3 files changed, 11 insertions(+), 18 deletions(-) delete mode 100755 fixupind.pl diff --git a/fixupind.pl b/fixupind.pl deleted file mode 100755 index ddefbd7..0000000 --- a/fixupind.pl +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -open(my $in, '<', 'crypt.ind'); -open(my $out, '>', 'crypt.ind.tmp'); -my $a = <$in>; -print {$out} "$a\n\\addcontentsline{toc}{chapter}{Index}\n"; -while (<$in>) { - print {$out} $_; -} -close $out; -close $in; -system("mv -f crypt.ind.tmp crypt.ind"); - diff --git a/helper.pl b/helper.pl index bc52302..b71569f 100755 --- a/helper.pl +++ b/helper.pl @@ -287,6 +287,7 @@ sub die_usage { $0 --check-makefiles $0 --check-all $0 --update-makefiles + $0 --fixupind crypt.ind MARKER } @@ -296,9 +297,17 @@ GetOptions( "s|check-source" => \my $check_source, "m|check-makefiles" => \my $check_makefiles, "a|check-all" => \my $check_all, "u|update-makefiles" => \my $update_makefiles, + "f|fixupind=s" => \my $fixupind, "h|help" => \my $help ) or die_usage; +if ($fixupind) { + my $txt = read_file($fixupind); + $txt =~ s/^([^\n]*\n)/$1\n\\addcontentsline{toc}{chapter}{Index}\n/s; + write_file($fixupind, $txt); + exit 0; +} + my $failure; $failure ||= check_source() if $check_all || $check_source; $failure ||= check_defines() if $check_all || $check_defines; diff --git a/makefile b/makefile index 217f85e..33d552c 100644 --- a/makefile +++ b/makefile @@ -403,7 +403,7 @@ doc/crypt.pdf: crypt.tex latex crypt $(silent_stdout) latex crypt $(silent_stdout) makeindex crypt.idx $(silent_stdout) - perl fixupind.pl + perl helper.pl --fixupind crypt.ind pdflatex crypt $(silent_stdout) sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf mv -ivf crypt.pdf doc/crypt.pdf @@ -415,7 +415,7 @@ docdvi: crypt.tex latex crypt $(silent_stdout) latex crypt $(silent_stdout) makeindex crypt.idx - perl fixupind.pl + perl helper.pl --fixupind crypt.ind latex crypt $(silent_stdout) latex crypt $(silent_stdout) From ee17cc2e67882fc43f770b28a46ca835c58f2d9d Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 14:34:01 +0200 Subject: [PATCH 20/51] compress archive to xz --- makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 33d552c..97100db 100644 --- a/makefile +++ b/makefile @@ -427,10 +427,10 @@ zipup: doc/crypt.pdf git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x mkdir -p libtomcrypt-$(VERSION)/doc cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf - tar -cjf libtomcrypt-$(VERSION).tar.bz2 libtomcrypt-$(VERSION) + tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) rm -rf libtomcrypt-$(VERSION) - gpg -b -a libtomcrypt-$(VERSION).tar.bz2 + gpg -b -a libtomcrypt-$(VERSION).tar.xz gpg -b -a libtomcrypt-$(VERSION).zip perlcritic: From 544f7cc6ced25cdb281bcf47e49d92516abe0085 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 15:03:17 +0200 Subject: [PATCH 21/51] ignore eclipse special files --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f74c428..02a1ffd 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,11 @@ timing.exe *.idb *.pdb +# Eclipse special files +.project +.cproject +.settings/ + # oops ;) but we don't want them to appear in the repository... *.stackdump *.core From 1b71e23e424b01db384197bff2362e94bb19023c Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 15:07:18 +0200 Subject: [PATCH 22/51] fix some testprof related errors --- makefile | 1 - makefile.shared | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 97100db..6caaf22 100644 --- a/makefile +++ b/makefile @@ -373,7 +373,6 @@ clean: rm -rf doc/doxygen rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs` rm -f *.txt - cd testprof ; $(MAKE) clean #build the doxy files (requires Doxygen, tetex and patience) doxygen: diff --git a/makefile.shared b/makefile.shared index 1506ba7..8d9e964 100644 --- a/makefile.shared +++ b/makefile.shared @@ -244,17 +244,17 @@ install: $(LIBNAME) $(USEFUL_DEMOS) sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc -install_test: testprof/$(LIBTEST) +install_test: $(LIBTEST) install -d $(LIBPATH) install -d $(INCPATH) install -m 644 testprof/tomcrypt_test.h $(INCPATH) $(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST) -test: library testprof/$(LIBTEST) $(TESTS) - $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) +test: library $(LIBTEST) $(TESTS) + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -timing: library testprof/$(LIBTEST) $(TIMINGS) - $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) +timing: library $(LIBTEST) $(TIMINGS) + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) # build the demos from a template define DEMO_template From 8ee458b625944574328f40c387ff972fb5c3be7b Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 15:24:50 +0200 Subject: [PATCH 23/51] don't include testprof for library build ...well msvc still does it as I can't test it... --- makefile | 6 +++++- makefile.include | 9 ++++++++- makefile.mingw | 16 ++++++++++++++-- makefile.msvc | 2 +- makefile.shared | 9 +++++++-- makefile.unix | 29 +++++++++++++++++++++-------- 6 files changed, 56 insertions(+), 15 deletions(-) diff --git a/makefile b/makefile index 6caaf22..dc8fe39 100644 --- a/makefile +++ b/makefile @@ -225,12 +225,16 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c +$(DOBJECTS): CFLAGS += -Itestprof +$(TOBJECTS): CFLAGS += -Itestprof + #This rule makes the libtomcrypt library. library: $(LIBNAME) #Dependencies on *.h $(OBJECTS): $(HEADERS) -$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h +$(DOBJECTS): $(HEADERS) $(THEADERS) +$(TOBJECTS): $(HEADERS) $(THEADERS) $(LIBNAME): $(OBJECTS) ifneq ($V,1) diff --git a/makefile.include b/makefile.include index c1cd7d5..081254a 100644 --- a/makefile.include +++ b/makefile.include @@ -30,7 +30,7 @@ endif # Compilation flags. Note the += does not write over the user's CFLAGS! -CFLAGS += -I./testprof/ -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE +CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE ifdef OLD_GCC CFLAGS += -W @@ -84,6 +84,13 @@ CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" endif +#List of demo objects +DSOURCES != ls demos/*.c +DOBJECTS = ${DSOURCES:.c=.o} + +#List of testprof headers +THEADERS != ls testprof/*.h + TIMING=timing TEST=test diff --git a/makefile.mingw b/makefile.mingw index 75215c8..bcf033a 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -27,7 +27,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath EXTRALIBS = -L../libtommath -ltommath #Compilation flags -LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE +LTC_CFLAGS = $(CFLAGS) -Isrc/headers -DLTC_SOURCE LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) #Libraries to be created @@ -203,6 +203,16 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h +THEADERS != ls testprof/*.h + +#List of demo objects (only used to create a special rule to extend LTC_CFLAGS) +DSOURCES != ls demos/*.c +DOBJECTS = ${DSOURCES:.c=.o} + +#SPECIAL: demo- and test-objects required include-path "testprof" +$(DOBJECTS): LTC_CFLAGS += -Itestprof +$(TOBJECTS): LTC_CFLAGS += -Itestprof + .c.o: $(CC) $(LTC_CFLAGS) -c $< -o $@ @@ -222,9 +232,11 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c + #Dependencies on *.h $(OBJECTS): $(HEADERS) -$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h +$(DOBJECTS): $(HEADERS) $(THEADERS) +$(TOBJECTS): $(HEADERS) $(THEADERS) #Create libtomcrypt_prof.a $(LIBTEST_S): $(TOBJECTS) diff --git a/makefile.msvc b/makefile.msvc index eae515f..3036336 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -186,7 +186,7 @@ src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c library: $(OBJECTS) $(TOBJECTS) lib /out:tomcrypt.lib $(OBJECTS) - lib /out:tomcrypt_prof.lib $(TOBJECTS) + lib /out:tomcrypt_prof.lib $(TOBJECTS) tv_gen: demos/tv_gen.c library cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS) diff --git a/makefile.shared b/makefile.shared index 8d9e964..748bf05 100644 --- a/makefile.shared +++ b/makefile.shared @@ -203,7 +203,7 @@ src/headers/tomcrypt_prng.h #END_INS #The default rule for make builds the libtomcrypt library. -default:library +default: library #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c @@ -223,7 +223,12 @@ library: $(LIBNAME) #Dependencies on *.h $(OBJECTS): $(HEADERS) -$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h +$(DOBJECTS): $(HEADERS) $(THEADERS) +$(TOBJECTS): $(HEADERS) $(THEADERS) + +#SPECIAL: demo- and test-objects required include-path "testprof" +$(DOBJECTS): CFLAGS += -Itestprof +$(TOBJECTS): CFLAGS += -Itestprof .c.o: $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $< diff --git a/makefile.unix b/makefile.unix index 1acae9d..17f3abb 100644 --- a/makefile.unix +++ b/makefile.unix @@ -32,7 +32,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath EXTRALIBS = ../libtommath/libtommath.a #Compilation flags -LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE +LTC_CFLAGS = $(CFLAGS) -Isrc/headers -DLTC_SOURCE LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) VERSION=1.17 @@ -207,14 +207,10 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -#This is necessary for compatibility with BSD make (namely on OpenBSD) -.SUFFIXES: .o .c - -.c.o: - $(CC) $(LTC_CFLAGS) -c $< -o $@ +THEADERS != ls testprof/*.h #The default rule for make builds the libtomcrypt.a library (static) -default: $(LIBMAIN_S) +default: library #SPECIAL: AES comes in two flavours - enc+dec and enc-only src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c @@ -229,9 +225,26 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c +#List of demo objects (only used to create a special rule to extend LTC_CFLAGS) +DSOURCES != ls demos/*.c +DOBJECTS = ${DSOURCES:.c=.o} + +#This rule makes the libtomcrypt library. +library: $(LIBMAIN_S) + #Dependencies on *.h $(OBJECTS): $(HEADERS) -$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h +$(DOBJECTS): $(HEADERS) $(THEADERS) +$(TOBJECTS): $(HEADERS) $(THEADERS) + +#SPECIAL: demo- and test-objects required include-path "testprof" +$(DOBJECTS): LTC_CFLAGS += -Itestprof +$(TOBJECTS): LTC_CFLAGS += -Itestprof + +#This is necessary for compatibility with BSD make (namely on OpenBSD) +.SUFFIXES: .o .c +.c.o: + $(CC) $(LTC_CFLAGS) -c $< -o $@ #Create libtomcrypt_prof.a $(LIBTEST_S): $(TOBJECTS) From c0abe2a5dc0cb830659c0f245e1f2279bc01efcc Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 15:28:02 +0200 Subject: [PATCH 24/51] crypt doesn't exist anymore --- makefile.unix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makefile.unix b/makefile.unix index 17f3abb..57e1e3a 100644 --- a/makefile.unix +++ b/makefile.unix @@ -259,8 +259,8 @@ $(LIBMAIN_S): $(OBJECTS) #Demo tools/utilities hashsum: demos/hashsum.o $(LIBMAIN_S) $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ -crypt: demos/crypt.o $(LIBMAIN_S) - $(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +ltcrypt: demos/ltcrypt.o $(LIBMAIN_S) + $(CC) demos/ltcrypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ small: demos/small.o $(LIBMAIN_S) $(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ tv_gen: demos/tv_gen.o $(LIBMAIN_S) @@ -274,7 +274,7 @@ test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) $(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ @echo "NOTICE: start the tests by: ./test" -all: $(LIBMAIN_S) $(LIBTEST_S) hashsum crypt small tv_gen timing test +all: $(LIBMAIN_S) $(LIBTEST_S) hashsum ltcrypt small tv_gen timing test #NOTE: this makefile works also on cygwin, thus we need to delete *.exe clean: From 6e484cd4204e32316d5c0a25a60ee6e92677d19b Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 15:35:06 +0200 Subject: [PATCH 25/51] use make internal macros --- makefile.mingw | 12 ++++++------ makefile.shared | 4 ++-- makefile.unix | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/makefile.mingw b/makefile.mingw index bcf033a..1270dea 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -255,20 +255,20 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS) #Demo tools/utilities hashsum: demos/hashsum.o $(LIBMAIN_S) - $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ crypt: demos/crypt.o $(LIBMAIN_S) - $(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ small: demos/small.o $(LIBMAIN_S) - $(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ tv_gen: demos/tv_gen.o $(LIBMAIN_S) - $(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ #Tests + timing tests timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) - $(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ @echo NOTICE: start the tests by: timing.exe test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) - $(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ @echo NOTICE: start the tests by: test.exe all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test diff --git a/makefile.shared b/makefile.shared index 748bf05..c14647f 100644 --- a/makefile.shared +++ b/makefile.shared @@ -263,11 +263,11 @@ timing: library $(LIBTEST) $(TIMINGS) # build the demos from a template define DEMO_template -$(1): demos/$(1).o library +$(1): demos/$(1).o $$(LIBNAME) ifneq ($V,1) @echo " * $${CC} $$@" endif - $$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) -o $(1) $$< $$(LIBNAME) $$(EXTRALIBS) + $$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) $$^ $$(EXTRALIBS) -o $(1) endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) diff --git a/makefile.unix b/makefile.unix index 57e1e3a..7d0d3a0 100644 --- a/makefile.unix +++ b/makefile.unix @@ -258,20 +258,20 @@ $(LIBMAIN_S): $(OBJECTS) #Demo tools/utilities hashsum: demos/hashsum.o $(LIBMAIN_S) - $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ ltcrypt: demos/ltcrypt.o $(LIBMAIN_S) - $(CC) demos/ltcrypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ small: demos/small.o $(LIBMAIN_S) - $(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ tv_gen: demos/tv_gen.o $(LIBMAIN_S) - $(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ #Tests + timing tests timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) - $(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ + $(CC) $? $(LTC_LDFLAGS) -o $@ @echo "NOTICE: start the timing tests by: ./timing" -test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) - $(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@ +test: demos/test.o $(LIBTEST_S) $(LIBMAIN_S) + $(CC) $? $(LTC_LDFLAGS) -o $@ @echo "NOTICE: start the tests by: ./test" all: $(LIBMAIN_S) $(LIBTEST_S) hashsum ltcrypt small tv_gen timing test From b35ce0467b6f0ddbe3c52d6d1d1207c2d53bed81 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 16:10:33 +0200 Subject: [PATCH 26/51] move documentation-related files to doc folder --- Doxyfile => doc/Doxyfile | 12 ++++----- crypt.tex => doc/crypt.tex | 0 doc/makefile | 54 ++++++++++++++++++++++++++++++++++++++ makefile | 47 ++++----------------------------- 4 files changed, 65 insertions(+), 48 deletions(-) rename Doxyfile => doc/Doxyfile (99%) rename crypt.tex => doc/crypt.tex (100%) create mode 100644 doc/makefile diff --git a/Doxyfile b/doc/Doxyfile similarity index 99% rename from Doxyfile rename to doc/Doxyfile index 3f927c8..a740dd8 100644 --- a/Doxyfile +++ b/doc/Doxyfile @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = doc/doxygen +OUTPUT_DIRECTORY = doxygen # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -161,7 +161,7 @@ STRIP_FROM_PATH = src # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = src/headers +STRIP_FROM_INC_PATH = ../src/headers # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -754,7 +754,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = src +INPUT = ../src/ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -1046,7 +1046,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = doc/header.html +HTML_HEADER = header.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1056,7 +1056,7 @@ HTML_HEADER = doc/header.html # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = doc/footer.html +HTML_FOOTER = footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1924,7 +1924,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = src/headers +INCLUDE_PATH = ../src//headers # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the diff --git a/crypt.tex b/doc/crypt.tex similarity index 100% rename from crypt.tex rename to doc/crypt.tex diff --git a/doc/makefile b/doc/makefile new file mode 100644 index 0000000..8a80854 --- /dev/null +++ b/doc/makefile @@ -0,0 +1,54 @@ +ifeq ($V,1) +silent= +silent_stdout= +else +silent=@ +silent_stdout= > /dev/null +endif + +#Files left over from making the crypt.pdf. +LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof + +#build the doxy files (requires Doxygen, tetex and patience) +.PHONY: doxygen +doxygen: + doxygen $(silent_stdout) + +doxy: doxygen + ${MAKE} -C doxygen/latex $(silent_stdout) && mv -f doxygen/latex/refman.pdf . + @echo The huge doxygen PDF should be available as doc/refman.pdf + +#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed +#from the clean command! This is because most people would like to keep the +#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to +#delete it if we are rebuilding it. +.PHONY: crypt.pdf +crypt.pdf: crypt.tex + rm -f crypt.pdf $(LEFTOVERS) + cp crypt.tex crypt.bak + touch --reference=crypt.tex crypt.bak + (printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y crypt.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > crypt-deterministic.tex + printf "%s\n" "\pdfinfo{" >> crypt-deterministic.tex + printf "%s\n" " /CreationDate (\fixedpdfdate)" >> crypt-deterministic.tex + printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> crypt-deterministic.tex + cat crypt.tex >> crypt-deterministic.tex + mv crypt-deterministic.tex crypt.tex + touch --reference=crypt.bak crypt.tex + echo "hello" > crypt.ind + latex crypt $(silent_stdout) + latex crypt $(silent_stdout) + makeindex crypt.idx $(silent_stdout) + perl ../helper.pl --fixupind crypt.ind + pdflatex crypt $(silent_stdout) + sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf + mv crypt.bak crypt.tex + rm -f $(LEFTOVERS) + +docdvi: crypt.tex + echo hello > crypt.ind + latex crypt $(silent_stdout) + latex crypt $(silent_stdout) + makeindex crypt.idx + perl ../helper.pl --fixupind crypt.ind + latex crypt $(silent_stdout) + latex crypt $(silent_stdout) diff --git a/makefile b/makefile index dc8fe39..e5a0fa2 100644 --- a/makefile +++ b/makefile @@ -203,9 +203,6 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -#Files left over from making the crypt.pdf. -LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof - #Compressed filenames COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip @@ -380,47 +377,13 @@ clean: #build the doxy files (requires Doxygen, tetex and patience) doxygen: - doxygen $(silent_stdout) + $(MAKE) -C doc/ doxygen V=$(V) -doxy: doxygen - cd doc/doxygen/latex ; ${MAKE} $(silent_stdout) ; mv -f refman.pdf ../../. - @echo The huge doxygen PDF should be available as doc/refman.pdf +doxy: + $(MAKE) -C doc/ doxy V=$(V) -#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed -#from the clean command! This is because most people would like to keep the -#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to -#delete it if we are rebuilding it. -docs: doc/crypt.pdf -doc/crypt.pdf: crypt.tex - rm -f doc/crypt.pdf $(LEFTOVERS) - cp crypt.tex crypt.bak - touch --reference=crypt.tex crypt.bak - (printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y crypt.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > crypt-deterministic.tex - printf "%s\n" "\pdfinfo{" >> crypt-deterministic.tex - printf "%s\n" " /CreationDate (\fixedpdfdate)" >> crypt-deterministic.tex - printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> crypt-deterministic.tex - cat crypt.tex >> crypt-deterministic.tex - mv crypt-deterministic.tex crypt.tex - touch --reference=crypt.bak crypt.tex - echo "hello" > crypt.ind - latex crypt $(silent_stdout) - latex crypt $(silent_stdout) - makeindex crypt.idx $(silent_stdout) - perl helper.pl --fixupind crypt.ind - pdflatex crypt $(silent_stdout) - sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf - mv -ivf crypt.pdf doc/crypt.pdf - mv crypt.bak crypt.tex - rm -f $(LEFTOVERS) - -docdvi: crypt.tex - echo hello > crypt.ind - latex crypt $(silent_stdout) - latex crypt $(silent_stdout) - makeindex crypt.idx - perl helper.pl --fixupind crypt.ind - latex crypt $(silent_stdout) - latex crypt $(silent_stdout) +docs: + $(MAKE) -C doc/ crypt.pdf V=$(V) zipup: doc/crypt.pdf @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) From c93bee957592fad5c9705b4605f7e3295fc75fbc Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 16:14:10 +0200 Subject: [PATCH 27/51] rename perlcritic make target & also run `helper.pl -a` --- makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index e5a0fa2..0ead01d 100644 --- a/makefile +++ b/makefile @@ -399,7 +399,8 @@ zipup: doc/crypt.pdf gpg -b -a libtomcrypt-$(VERSION).tar.xz gpg -b -a libtomcrypt-$(VERSION).zip -perlcritic: +codecheck: + perl helper.pl -a perlcritic *.pl # git commit: $Format:%h$ $Format:%ai$ From 5e4415427a58e3ea4fd6abd1899307b9df9ab155 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 16:25:20 +0200 Subject: [PATCH 28/51] OSX `touch` has no "--reference" long-option, only "-r" --- doc/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/makefile b/doc/makefile index 8a80854..8becfef 100644 --- a/doc/makefile +++ b/doc/makefile @@ -26,14 +26,14 @@ doxy: doxygen crypt.pdf: crypt.tex rm -f crypt.pdf $(LEFTOVERS) cp crypt.tex crypt.bak - touch --reference=crypt.tex crypt.bak + touch -r crypt.tex crypt.bak (printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y crypt.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > crypt-deterministic.tex printf "%s\n" "\pdfinfo{" >> crypt-deterministic.tex printf "%s\n" " /CreationDate (\fixedpdfdate)" >> crypt-deterministic.tex printf "%s\n}\n" " /ModDate (\fixedpdfdate)" >> crypt-deterministic.tex cat crypt.tex >> crypt-deterministic.tex mv crypt-deterministic.tex crypt.tex - touch --reference=crypt.bak crypt.tex + touch -r crypt.bak crypt.tex echo "hello" > crypt.ind latex crypt $(silent_stdout) latex crypt $(silent_stdout) From add3495bfc47c1bc76d0c820176cd34a0526cde5 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 17:14:18 +0200 Subject: [PATCH 29/51] fix perlcritics warnings in helper.pl --- helper.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helper.pl b/helper.pl index b71569f..30b1b38 100755 --- a/helper.pl +++ b/helper.pl @@ -72,7 +72,7 @@ sub check_defines { my $cryp_c = read_file("src/misc/crypt/crypt.c"); $cust_h =~ s|/\*.*?\*/||sg; # remove comments $cryp_c =~ s|/\*.*?\*/||sg; # remove comments - my %def = map { $_ => 1 } map { $_ =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $_ } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h; + my %def = map { $_ => 1 } map { my $x = $_; $x =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $x } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h; for my $d (sort keys %def) { next if $d =~ /^LTC_(DH\d+|ECC\d+|ECC_\S+|MPI|MUTEX_\S+\(x\)|NO_\S+)$/; warn "$d missing in src/misc/crypt/crypt.c\n" and $fails++ if $cryp_c !~ /\Q$d\E/; @@ -86,7 +86,7 @@ sub check_hashes { my @descriptors; find({ wanted => sub { push @src, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, './src/hashes/'); for my $f (@src) { - my @n = map { $_ =~ s/^.*?ltc_hash_descriptor\s+(\S+).*$/$1/; $_ } grep { $_ =~ /ltc_hash_descriptor/ } split /\n/, read_file($f); + my @n = map { my $x = $_; $x =~ s/^.*?ltc_hash_descriptor\s+(\S+).*$/$1/; $x } grep { $_ =~ /ltc_hash_descriptor/ } split /\n/, read_file($f); push @descriptors, @n if @n; } my $fails = 0; @@ -236,12 +236,12 @@ sub process_makefiles { my @t = qw(); find({ no_chdir => 1, wanted => sub { push @t, $_ if $_ =~ /(no_prng|test_driver|x86_prof|_tests?).c$/ } }, 'testprof'); - my @o = sort ('src/ciphers/aes/aes_enc.o', map { $_ =~ s/\.c$/.o/; $_ } @c); + my @o = sort ('src/ciphers/aes/aes_enc.o', map { my $x = $_; $x =~ s/\.c$/.o/; $x } @c); my $var_o = prepare_variable("OBJECTS", @o); my $var_h = prepare_variable("HEADERS", (sort @h)); (my $var_obj = $var_o) =~ s/\.o\b/.obj/sg; - my $var_to = prepare_variable("TOBJECTS", sort map { $_ =~ s/\.c$/.o/; $_ } @t); + my $var_to = prepare_variable("TOBJECTS", sort map { my $x = $_; $x =~ s/\.c$/.o/; $x } @t); (my $var_tobj = $var_to) =~ s/\.o\b/.obj/sg; my @ver_version = version_form_tomcrypt_h("src/headers/tomcrypt.h"); From 85197a485a5eb35a80dddf56931fccb215bc0824 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 17:15:56 +0200 Subject: [PATCH 30/51] do not exclude anything during make zipup --- .gitattributes | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index c76e0d2..5238953 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,3 @@ -/.* export-ignore -/hooks export-ignore -doc/*.html export-ignore -coverity.sh export-ignore +#/.* export-ignore /** export-subst From ab34b0bd93188f2f6b9b0778bcf3bbdd6f9720ad Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 17:17:05 +0200 Subject: [PATCH 31/51] or perhaps exclude .git* --- .gitattributes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 5238953..2861792 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ -#/.* export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore /** export-subst From 39f12dafc4a5421cec5f1a4777e901fd5a90afa2 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 18:58:30 +0200 Subject: [PATCH 32/51] make travis build a bit more verbose --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c62c21a..1117067 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: c compiler: - gcc - clang -script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a" +script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile V=1" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a" env: - | BUILDSCRIPT="check_source.sh" @@ -95,6 +95,7 @@ after_failure: - cat test_std.txt - cat test_err.txt after_script: + - cat gcc_1.txt - cat gcc_2.txt notifications: irc: "chat.freenode.net#libtom-notifications" From 12cf50d4e220028e9692f5c8754d927ce66f5411 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 19:11:16 +0200 Subject: [PATCH 33/51] move translation rule after modifications of CFLAGS --- makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 0ead01d..70f2c66 100644 --- a/makefile +++ b/makefile @@ -13,12 +13,6 @@ silent=@ silent_stdout= > /dev/null endif -%.o: %.c -ifneq ($V,1) - @echo " * ${CC} $@" -endif - ${silent} ${CC} ${CFLAGS} -c $< -o $@ - # ranlib tools ifndef RANLIB ifeq ($(PLATFORM), Darwin) @@ -233,6 +227,12 @@ $(OBJECTS): $(HEADERS) $(DOBJECTS): $(HEADERS) $(THEADERS) $(TOBJECTS): $(HEADERS) $(THEADERS) +.c.o: +ifneq ($V,1) + @echo " * ${CC} $@" +endif + ${silent} ${CC} ${CFLAGS} -c $< -o $@ + $(LIBNAME): $(OBJECTS) ifneq ($V,1) @echo " * ${AR} $@" From 37fa03829c4afc78dfecf3c9ca8ae645d59abf92 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 5 May 2017 19:39:55 +0200 Subject: [PATCH 34/51] use gnu-make `wildcard` to get source files --- makefile.include | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefile.include b/makefile.include index 081254a..6af569f 100644 --- a/makefile.include +++ b/makefile.include @@ -85,8 +85,8 @@ endif #List of demo objects -DSOURCES != ls demos/*.c -DOBJECTS = ${DSOURCES:.c=.o} +DSOURCES = $(wildcard demos/*.c) +DOBJECTS = $(DSOURCES:.c=.o) #List of testprof headers THEADERS != ls testprof/*.h From 7ed5a832b02daf9fa54f061c4445d9e8e69b72fb Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 5 May 2017 21:10:28 +0200 Subject: [PATCH 35/51] tuning makefile.msvc+mingw --- helper.pl | 2 +- makefile.mingw | 20 +++++----- makefile.msvc | 102 ++++++++++++++++++++++++++++++++----------------- 3 files changed, 79 insertions(+), 45 deletions(-) diff --git a/helper.pl b/helper.pl index 30b1b38..8f729fb 100755 --- a/helper.pl +++ b/helper.pl @@ -262,7 +262,7 @@ sub process_makefiles { # update OBJECTS + HEADERS in makefile* for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) { my $old = read_file($m); - my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_to, @ver_version) + my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_tobj, @ver_version) : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version); if ($old ne $new) { write_file($m, $new) if $write; diff --git a/makefile.mingw b/makefile.mingw index 1270dea..52b0c24 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -7,13 +7,11 @@ # # gmake -f makefile.mingw all # test.exe -# gmake -f makefile.mingw install +# gmake -f makefile.mingw DESTDIR=c:\devel\libtom install # #OR: # # gmake -f makefile.mingw CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -Ic:/path/to/libtommath" EXTRALIBS="-Lc:/path/to/libtommath -ltommath" all -# test.exe -# gmake -f makefile.mingw DESTDIR=c:\devel\libtom install # #The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs @@ -254,24 +252,26 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS) $(STRIP) -S $(LIBMAIN_D) #Demo tools/utilities -hashsum: demos/hashsum.o $(LIBMAIN_S) +hashsum.exe: demos/hashsum.o $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ -crypt: demos/crypt.o $(LIBMAIN_S) +ltcrypt.exe: demos/ltcrypt.o $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ -small: demos/small.o $(LIBMAIN_S) +small.exe: demos/small.o $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ -tv_gen: demos/tv_gen.o $(LIBMAIN_S) +tv_gen.exe: demos/tv_gen.o $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ #Tests + timing tests -timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) +timing.exe: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ @echo NOTICE: start the tests by: timing.exe -test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) +test.exe: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) $(CC) $? $(LTC_LDFLAGS) -o $@ @echo NOTICE: start the tests by: test.exe -all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test +all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe + +test: test.exe clean: @cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul diff --git a/makefile.msvc b/makefile.msvc index 3036336..8a64783 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -1,14 +1,33 @@ +# MAKEFILE for MS Windows (nmake + Windows SDK) # -# open a command prompt with WinSDK variables set -# and start: nmake -f makefile.msvc +# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh + +### USAGE: +# Open a command prompt with WinSDK variables set and start: +# +# nmake -f makefile.msvc all +# test.exe +# nmake -f makefile.msvc DESTDIR=c:\devel\libtom install +# +#OR: +# +# nmake -f makefile.msvc CFLAGS="/DUSE_LTM /DLTM_DESC /Ic:\path\to\libtommath" EXTRALIBS="c:\path\to\libtommath\tommath.lib" all # -EXTRALIBS=../libtommath/tommath.lib -EXTRAINCLUDE=../libtommath +#The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs +DESTDIR = c:\devel +CFLAGS = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath +EXTRALIBS = ../libtommath/tommath.lib -CFLAGS = /nologo /Isrc/headers/ /I$(EXTRAINCLUDE) /Itestprof/ /Ox /D_CRT_SECURE_NO_WARNINGS /DUSE_LTM /DLTM_DESC /DLTC_SOURCE /DLTC_NO_PROTOTYPES /W3 $(CF) +#Compilation flags +LTC_CFLAGS = $(CFLAGS) /nologo /Isrc/headers/ /Itestprof/ /D_CRT_SECURE_NO_WARNINGS /DLTC_SOURCE /W3 +LTC_LDFLAGS = advapi32.lib $(EXTRALIBS) -# List of objects to compile (all goes to libtomcrypt.lib) +#Libraries to be created +LIBMAIN_S =tomcrypt.lib +LIBTEST_S =tomcrypt_prof.lib + +#List of objects to compile (all goes to tomcrypt.lib) OBJECTS=src/ciphers/aes/aes.obj src/ciphers/aes/aes_enc.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \ src/ciphers/camellia.obj src/ciphers/cast5.obj src/ciphers/des.obj src/ciphers/kasumi.obj src/ciphers/khazad.obj \ src/ciphers/kseed.obj src/ciphers/multi2.obj src/ciphers/noekeon.obj src/ciphers/rc2.obj src/ciphers/rc5.obj \ @@ -160,51 +179,66 @@ src/stream/chacha/chacha_keystream.obj src/stream/chacha/chacha_setup.obj src/st src/stream/rc4/rc4.obj src/stream/rc4/rc4_test.obj src/stream/sober128/sober128.obj \ src/stream/sober128/sober128_test.obj -# List of test objects to compile (all goes to libtomcrypt_prof.lib) -TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ -testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ -testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ -testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ -testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ -testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o +#List of test objects to compile (all goes to tomcrypt_prof.lib) +TOBJECTS=testprof/base64_test.obj testprof/cipher_hash_test.obj testprof/der_tests.obj testprof/dh_test.obj \ +testprof/dsa_test.obj testprof/ecc_test.obj testprof/file_test.obj testprof/katja_test.obj testprof/mac_test.obj \ +testprof/misc_test.obj testprof/modes_test.obj testprof/multi_test.obj testprof/no_prng.obj \ +testprof/pkcs_1_eme_test.obj testprof/pkcs_1_emsa_test.obj testprof/pkcs_1_oaep_test.obj \ +testprof/pkcs_1_pss_test.obj testprof/pkcs_1_test.obj testprof/rotate_test.obj testprof/rsa_test.obj \ +testprof/store_test.obj testprof/test_driver.obj testprof/x86_prof.obj -# The following headers will be installed by "make install" +#The following headers will be installed by "make install" HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -default: library - .c.obj: - $(CC) $(CFLAGS) /c $< /Fo$@ + $(CC) $(LTC_CFLAGS) /c $< /Fo$@ + +#The default rule for make builds the tomcrypt.lib library (static) +default: $(LIBMAIN_S) #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c - $(CC) $(CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj + $(CC) $(LTC_CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj -library: $(OBJECTS) $(TOBJECTS) - lib /out:tomcrypt.lib $(OBJECTS) - lib /out:tomcrypt_prof.lib $(TOBJECTS) +$(LIBMAIN_S): $(OBJECTS) + lib /out:$(LIBMAIN_S) $(OBJECTS) -tv_gen: demos/tv_gen.c library - cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS) +$(LIBTEST_S): $(TOBJECTS) + lib /out:$(LIBTEST_S) $(TOBJECTS) -hashsum: demos/hashsum.c library - cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS) +tv_gen.exe: demos/tv_gen.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/tv_gen.c $(LIBMAIN_S) $(LTC_LDFLAGS) -test: demos/test.c library - cl $(CFLAGS) demos/test.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS) +hashsum.exe: demos/hashsum.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/hashsum.c $(LIBMAIN_S) $(LTC_LDFLAGS) -timing: demos/timing.c library - cl $(CFLAGS) demos/timing.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS) +ltcrypt.exe: demos/ltcrypt.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/ltcrypt.c $(LIBMAIN_S) $(LTC_LDFLAGS) -all_test: test tv_gen hashsum timing +small.exe: demos/small.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/small.c $(LIBMAIN_S) $(LTC_LDFLAGS) + +test.exe: demos/test.c $(LIBMAIN_S) $(LIBTEST_S) + cl $(LTC_CFLAGS) demos/test.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) + +timing.exe: demos/timing.c $(LIBMAIN_S) $(LIBTEST_S) + cl $(LTC_CFLAGS) demos/timing.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) + +all: $(LIBMAIN_S) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe + +test: test.exe clean: - cmd /c del /Q /S *.OBJ *.LIB *.EXE + @cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul -# $Source$ -# $Revision$ -# $Date$ +install: $(LIBMAIN_S) $(LIBTEST_S) + cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin" + cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib" + cmd /c if not exist "$(DESTDIR)\include" mkdir "$(DESTDIR)\include" + copy /Y hashsum.exe "$(DESTDIR)\bin" + copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib" + copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include" \ No newline at end of file From 3c5ec6b6996d03cf032b68d904b6ce9cfacabd0e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 7 May 2017 22:30:59 +0200 Subject: [PATCH 36/51] split-out binary installation in separate install target --- makefile | 8 +++++--- makefile.shared | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 70f2c66..283e0ce 100644 --- a/makefile +++ b/makefile @@ -290,19 +290,21 @@ endif ifndef NODOCS install: library docs else -install: library $(USEFUL_DEMOS) +install: library endif install -d $(LIBPATH) install -d $(INCPATH) - install -d $(BINPATH) install -m 644 $(LIBNAME) $(LIBPATH) install -m 644 $(HEADERS) $(INCPATH) - install -m 644 $(USEFUL_DEMOS) $(BINPATH) ifndef NODOCS install -d $(DATAPATH) install -m 644 doc/crypt.pdf $(DATAPATH) endif +install_bins: $(USEFUL_DEMOS) + install -d $(BINPATH) + install -m 775 $(USEFUL_DEMOS) $(BINPATH) + install_test: $(LIBTEST) install -d $(LIBPATH) install -d $(INCPATH) diff --git a/makefile.shared b/makefile.shared index c14647f..d890b1b 100644 --- a/makefile.shared +++ b/makefile.shared @@ -239,16 +239,18 @@ $(LIBNAME): $(OBJECTS) $(LIBTEST): $(TOBJECTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./testprof -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) -install: $(LIBNAME) $(USEFUL_DEMOS) +install: $(LIBNAME) install -d $(LIBPATH)/pkgconfig install -d $(INCPATH) - install -d $(BINPATH) $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME) install -m 644 $(HEADERS) $(INCPATH) - install -m 775 $(USEFUL_DEMOS) $(BINPATH) sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc +install_bins: $(USEFUL_DEMOS) + install -d $(BINPATH) + $(LT) --mode=install install -c $(USEFUL_DEMOS) $(BINPATH) + install_test: $(LIBTEST) install -d $(LIBPATH) install -d $(INCPATH) From ee0874b50b97d1916bcf4977f66dc5441d410420 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 7 May 2017 23:01:27 +0200 Subject: [PATCH 37/51] minor improvements --- makefile | 9 +++------ makefile.include | 2 +- makefile.shared | 8 +++++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/makefile b/makefile index 283e0ce..599633f 100644 --- a/makefile +++ b/makefile @@ -197,9 +197,6 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -#Compressed filenames -COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip - #The default rule for make builds the libtomcrypt library. default:library @@ -253,13 +250,13 @@ ifneq ($V,1) endif ${silent} $(RANLIB) $@ -timing: library $(LIBTEST) $(TIMINGS) +timing: $(LIBNAME) $(LIBTEST) $(TIMINGS) ifneq ($V,1) @echo " * ${CC} $@" endif ${silent} $(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING) -test: library $(LIBTEST) $(TESTS) +test: $(LIBNAME) $(LIBTEST) $(TESTS) ifneq ($V,1) @echo " * ${CC} $@" endif @@ -267,7 +264,7 @@ endif # build the demos from a template define DEMO_template -$(1): demos/$(1).o library +$(1): demos/$(1).o $$(LIBNAME) ifneq ($V,1) @echo " * $${CC} $$@" endif diff --git a/makefile.include b/makefile.include index 6af569f..7fe26a7 100644 --- a/makefile.include +++ b/makefile.include @@ -89,7 +89,7 @@ DSOURCES = $(wildcard demos/*.c) DOBJECTS = $(DSOURCES:.c=.o) #List of testprof headers -THEADERS != ls testprof/*.h +THEADERS = $(wildcard testprof/*.h) TIMING=timing TEST=test diff --git a/makefile.shared b/makefile.shared index d890b1b..637927d 100644 --- a/makefile.shared +++ b/makefile.shared @@ -203,7 +203,7 @@ src/headers/tomcrypt_prng.h #END_INS #The default rule for make builds the libtomcrypt library. -default: library +default: $(LIBNAME) #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c @@ -257,10 +257,10 @@ install_test: $(LIBTEST) install -m 644 testprof/tomcrypt_test.h $(INCPATH) $(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST) -test: library $(LIBTEST) $(TESTS) +test: $(LIBNAME) $(LIBTEST) $(TESTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -timing: library $(LIBTEST) $(TIMINGS) +timing: $(LIBNAME) $(LIBTEST) $(TIMINGS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) # build the demos from a template @@ -274,6 +274,8 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) +bins: $(USEFUL_DEMOS) + all_test: test tv_gen $(DEMOS) # $Source$ From abe9116de57dbd58b7d86db541814c47a22504b3 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 7 May 2017 23:07:57 +0200 Subject: [PATCH 38/51] introduce makefile.common --- makefile | 60 +---------------------------------------------- makefile.common | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ makefile.shared | 4 +--- 3 files changed, 64 insertions(+), 62 deletions(-) create mode 100644 makefile.common diff --git a/makefile b/makefile index 599633f..a917931 100644 --- a/makefile +++ b/makefile @@ -273,9 +273,6 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) -bins: $(USEFUL_DEMOS) - -all_test: test tv_gen $(DEMOS) ifeq ($(COVERAGE),1) all_test: LIB_PRE = -Wl,--whole-archive all_test: LIB_POST = -Wl,--no-whole-archive @@ -308,9 +305,6 @@ install_test: $(LIBTEST) install -m 644 $(LIBTEST) $(LIBPATH) install -m 644 testprof/tomcrypt_test.h $(INCPATH) -install_hooks: - for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done - profile: CFLAGS="$(CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov" ./timing @@ -345,61 +339,9 @@ coverage: LIB_POST = -Wl,--no-whole-archive coverage: test ./test - # cleans everything - coverage output and standard 'clean' cleancov: cleancov-clean clean -#This rule cleans the source tree of all compiled code, not including the pdf -#documentation. -clean: - rm -f `find . -type f -name "*.o" | xargs` - rm -f `find . -type f -name "*.lo" | xargs` - rm -f `find . -type f -name "*.a" | xargs` - rm -f `find . -type f -name "*.la" | xargs` - rm -f `find . -type f -name "*.obj" | xargs` - rm -f `find . -type f -name "*.lib" | xargs` - rm -f `find . -type f -name "*.exe" | xargs` - rm -f `find . -type f -name "*.dll" | xargs` - rm -f `find . -type f -name "*.so" | xargs` - rm -f `find . -type f -name "*.gcov" | xargs` - rm -f `find . -type f -name "*.gcda" | xargs` - rm -f `find . -type f -name "*.gcno" | xargs` - rm -f `find . -type f -name "*.il" | xargs` - rm -f `find . -type f -name "*.dyn" | xargs` - rm -f `find . -type f -name "*.dpi" | xargs` - rm -rf `find . -type d -name "*.libs" | xargs` - rm -f crypt.aux crypt.dvi crypt.idx crypt.ilg crypt.ind crypt.log crypt.toc - rm -f $(TIMING) $(TEST) $(DEMOS) - rm -rf doc/doxygen - rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs` - rm -f *.txt - -#build the doxy files (requires Doxygen, tetex and patience) -doxygen: - $(MAKE) -C doc/ doxygen V=$(V) - -doxy: - $(MAKE) -C doc/ doxy V=$(V) - -docs: - $(MAKE) -C doc/ crypt.pdf V=$(V) - -zipup: doc/crypt.pdf - @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) - @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) - rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* - # files/dirs excluded from "git archive" are defined in .gitattributes - git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x - mkdir -p libtomcrypt-$(VERSION)/doc - cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf - tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) - zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) - rm -rf libtomcrypt-$(VERSION) - gpg -b -a libtomcrypt-$(VERSION).tar.xz - gpg -b -a libtomcrypt-$(VERSION).zip - -codecheck: - perl helper.pl -a - perlcritic *.pl +include makefile.common # git commit: $Format:%h$ $Format:%ai$ diff --git a/makefile.common b/makefile.common new file mode 100644 index 0000000..95a4d19 --- /dev/null +++ b/makefile.common @@ -0,0 +1,62 @@ +#common make targets shared over multiple makefiles + +bins: $(USEFUL_DEMOS) + +all_test: test tv_gen $(DEMOS) + +#build the doxy files (requires Doxygen, tetex and patience) +doxygen: + $(MAKE) -C doc/ doxygen V=$(V) + +doxy: + $(MAKE) -C doc/ doxy V=$(V) + +docs: + $(MAKE) -C doc/ crypt.pdf V=$(V) + +install_hooks: + for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done + +#This rule cleans the source tree of all compiled code, not including the pdf +#documentation. +clean: + rm -f `find . -type f -name "*.o" | xargs` + rm -f `find . -type f -name "*.lo" | xargs` + rm -f `find . -type f -name "*.a" | xargs` + rm -f `find . -type f -name "*.la" | xargs` + rm -f `find . -type f -name "*.obj" | xargs` + rm -f `find . -type f -name "*.lib" | xargs` + rm -f `find . -type f -name "*.exe" | xargs` + rm -f `find . -type f -name "*.dll" | xargs` + rm -f `find . -type f -name "*.so" | xargs` + rm -f `find . -type f -name "*.gcov" | xargs` + rm -f `find . -type f -name "*.gcda" | xargs` + rm -f `find . -type f -name "*.gcno" | xargs` + rm -f `find . -type f -name "*.il" | xargs` + rm -f `find . -type f -name "*.dyn" | xargs` + rm -f `find . -type f -name "*.dpi" | xargs` + rm -rf `find . -type d -name "*.libs" | xargs` + rm -f crypt.aux crypt.dvi crypt.idx crypt.ilg crypt.ind crypt.log crypt.toc + rm -f $(TIMING) $(TEST) $(DEMOS) + rm -rf doc/doxygen + rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs` + rm -f *.txt + rm -f *.pc + +zipup: docs + @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) + @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) + rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* + # files/dirs excluded from "git archive" are defined in .gitattributes + git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x + mkdir -p libtomcrypt-$(VERSION)/doc + cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf + tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) + zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) + rm -rf libtomcrypt-$(VERSION) + gpg -b -a libtomcrypt-$(VERSION).tar.xz + gpg -b -a libtomcrypt-$(VERSION).zip + +codecheck: + perl helper.pl -a + perlcritic *.pl diff --git a/makefile.shared b/makefile.shared index 637927d..2bcd9f1 100644 --- a/makefile.shared +++ b/makefile.shared @@ -274,9 +274,7 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) -bins: $(USEFUL_DEMOS) - -all_test: test tv_gen $(DEMOS) +include makefile.common # $Source$ # $Revision$ From 794a416715f0c58336f3864b51c61d3cb5dff358 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 8 May 2017 17:36:55 +0200 Subject: [PATCH 39/51] fix libtomcrypt.pc installation --- .gitignore | 1 + makefile.shared | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 02a1ffd..b845ffc 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ timing.exe *.gcda *.gcno *.gcov +libtomcrypt.pc coverage/ coverage*.info diff --git a/makefile.shared b/makefile.shared index 2bcd9f1..43b2efa 100644 --- a/makefile.shared +++ b/makefile.shared @@ -244,7 +244,7 @@ install: $(LIBNAME) install -d $(INCPATH) $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME) install -m 644 $(HEADERS) $(INCPATH) - sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc + sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > libtomcrypt.pc install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc install_bins: $(USEFUL_DEMOS) From 0cd9e94736d7a408641b99de09a2c3b806dcfb23 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 8 May 2017 18:09:45 +0200 Subject: [PATCH 40/51] Partially revert "don't include testprof for library build" This partially reverts commit 3a1cbcfee2a16d15167876423b6ca720458e801a. --- makefile.mingw | 16 ++-------------- makefile.unix | 15 ++------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/makefile.mingw b/makefile.mingw index 52b0c24..12d75b4 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -25,7 +25,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath EXTRALIBS = -L../libtommath -ltommath #Compilation flags -LTC_CFLAGS = $(CFLAGS) -Isrc/headers -DLTC_SOURCE +LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) #Libraries to be created @@ -201,16 +201,6 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -THEADERS != ls testprof/*.h - -#List of demo objects (only used to create a special rule to extend LTC_CFLAGS) -DSOURCES != ls demos/*.c -DOBJECTS = ${DSOURCES:.c=.o} - -#SPECIAL: demo- and test-objects required include-path "testprof" -$(DOBJECTS): LTC_CFLAGS += -Itestprof -$(TOBJECTS): LTC_CFLAGS += -Itestprof - .c.o: $(CC) $(LTC_CFLAGS) -c $< -o $@ @@ -230,11 +220,9 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c - #Dependencies on *.h $(OBJECTS): $(HEADERS) -$(DOBJECTS): $(HEADERS) $(THEADERS) -$(TOBJECTS): $(HEADERS) $(THEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h #Create libtomcrypt_prof.a $(LIBTEST_S): $(TOBJECTS) diff --git a/makefile.unix b/makefile.unix index 7d0d3a0..708d911 100644 --- a/makefile.unix +++ b/makefile.unix @@ -32,7 +32,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath EXTRALIBS = ../libtommath/libtommath.a #Compilation flags -LTC_CFLAGS = $(CFLAGS) -Isrc/headers -DLTC_SOURCE +LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) VERSION=1.17 @@ -207,8 +207,6 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -THEADERS != ls testprof/*.h - #The default rule for make builds the libtomcrypt.a library (static) default: library @@ -225,21 +223,12 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c -#List of demo objects (only used to create a special rule to extend LTC_CFLAGS) -DSOURCES != ls demos/*.c -DOBJECTS = ${DSOURCES:.c=.o} - #This rule makes the libtomcrypt library. library: $(LIBMAIN_S) #Dependencies on *.h $(OBJECTS): $(HEADERS) -$(DOBJECTS): $(HEADERS) $(THEADERS) -$(TOBJECTS): $(HEADERS) $(THEADERS) - -#SPECIAL: demo- and test-objects required include-path "testprof" -$(DOBJECTS): LTC_CFLAGS += -Itestprof -$(TOBJECTS): LTC_CFLAGS += -Itestprof +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h #This is necessary for compatibility with BSD make (namely on OpenBSD) .SUFFIXES: .o .c From 2b9dbb4ff7feff2d4fbc5f822881ab2d9362a9fa Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 9 May 2017 18:27:47 +0200 Subject: [PATCH 41/51] cosmetics in makefile.unix|mingw|msvc --- makefile.mingw | 23 ++++++++++++---- makefile.msvc | 73 +++++++++++++++++++++++++++++++++----------------- makefile.unix | 20 +++++++++----- 3 files changed, 81 insertions(+), 35 deletions(-) diff --git a/makefile.mingw b/makefile.mingw index 12d75b4..5b1cbc2 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -9,7 +9,7 @@ # test.exe # gmake -f makefile.mingw DESTDIR=c:\devel\libtom install # -#OR: +#Or: # # gmake -f makefile.mingw CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -Ic:/path/to/libtommath" EXTRALIBS="-Lc:/path/to/libtommath -ltommath" all # @@ -27,6 +27,7 @@ EXTRALIBS = -L../libtommath -ltommath #Compilation flags LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS) +VERSION=1.17 #Libraries to be created LIBMAIN_S =libtomcrypt.a @@ -201,9 +202,6 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -.c.o: - $(CC) $(LTC_CFLAGS) -c $< -o $@ - #The default rule for make builds the libtomcrypt.a library (static) default: $(LIBMAIN_S) @@ -224,6 +222,9 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c $(OBJECTS): $(HEADERS) $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h +.c.o: + $(CC) $(LTC_CFLAGS) -c $< -o $@ + #Create libtomcrypt_prof.a $(LIBTEST_S): $(TOBJECTS) $(AR) $(ARFLAGS) $@ $(TOBJECTS) @@ -253,7 +254,7 @@ tv_gen.exe: demos/tv_gen.o $(LIBMAIN_S) timing.exe: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ @echo NOTICE: start the tests by: timing.exe -test.exe: demos/test.o $(LIBMAIN_S) $(LIBTEST_S) +test.exe: demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(CC) $? $(LTC_LDFLAGS) -o $@ @echo NOTICE: start the tests by: test.exe @@ -262,8 +263,10 @@ all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum.exe ltcrypt.exe test: test.exe clean: + @cmd /c del /Q *_tv.txt 2>nul @cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul +#Install the library + headers install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin" cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib" @@ -272,3 +275,13 @@ install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) copy /Y $(LIBMAIN_I) "$(DESTDIR)\lib" copy /Y $(LIBMAIN_D) "$(DESTDIR)\bin" copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include" + +#Install useful tools +install_bins: hashsum + cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin" + copy /Y hashsum.exe "$(DESTDIR)\bin" + +#Install documentation +install_docs: doc/crypt.pdf + cmd /c if not exist "$(DESTDIR)\doc" mkdir "$(DESTDIR)\doc" + copy /Y doc\crypt.pdf "$(DESTDIR)\doc" diff --git a/makefile.msvc b/makefile.msvc index 8a64783..2c434af 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -9,9 +9,9 @@ # test.exe # nmake -f makefile.msvc DESTDIR=c:\devel\libtom install # -#OR: +#Or: # -# nmake -f makefile.msvc CFLAGS="/DUSE_LTM /DLTM_DESC /Ic:\path\to\libtommath" EXTRALIBS="c:\path\to\libtommath\tommath.lib" all +# nmake -f makefile.msvc CFLAGS="/DUSE_LTM /DLTM_DESC /Ic:\path\to\libtommath" EXTRALIBS=c:\path\to\libtommath\tommath.lib all # #The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs @@ -20,10 +20,11 @@ CFLAGS = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath EXTRALIBS = ../libtommath/tommath.lib #Compilation flags -LTC_CFLAGS = $(CFLAGS) /nologo /Isrc/headers/ /Itestprof/ /D_CRT_SECURE_NO_WARNINGS /DLTC_SOURCE /W3 +LTC_CFLAGS = $(CFLAGS) /nologo /Isrc/headers/ /Itestprof/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /DLTC_SOURCE /W3 LTC_LDFLAGS = advapi32.lib $(EXTRALIBS) +VERSION=1.17 -#Libraries to be created +#Libraries to be created (this makefile builds only static libraries) LIBMAIN_S =tomcrypt.lib LIBTEST_S =tomcrypt_prof.lib @@ -194,51 +195,75 @@ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_ma src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_prng.h -.c.obj: - $(CC) $(LTC_CFLAGS) /c $< /Fo$@ - #The default rule for make builds the tomcrypt.lib library (static) default: $(LIBMAIN_S) -#ciphers come in two flavours... enc+dec and enc +#SPECIAL: AES comes in two flavours - enc+dec and enc-only src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c $(CC) $(LTC_CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj -$(LIBMAIN_S): $(OBJECTS) - lib /out:$(LIBMAIN_S) $(OBJECTS) +#SPECIAL: these are the rules to make certain object files +src/ciphers/aes/aes.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c +src/ciphers/twofish/twofish.obj: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c +src/hashes/whirl/whirl.obj: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c +src/hashes/sha2/sha512.obj: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c +src/hashes/sha2/sha512_224.obj: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c +src/hashes/sha2/sha512_256.obj: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c +src/hashes/sha2/sha256.obj: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c +#Dependencies on *.h +$(OBJECTS): $(HEADERS) +$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h + +.c.obj: + $(CC) $(LTC_CFLAGS) /c $< /Fo$@ + +#Create tomcrypt_prof.lib $(LIBTEST_S): $(TOBJECTS) lib /out:$(LIBTEST_S) $(TOBJECTS) +#Create tomcrypt.lib +$(LIBMAIN_S): $(OBJECTS) + lib /out:$(LIBMAIN_S) $(OBJECTS) + +#Demo tools/utilities +hashsum.exe: demos/hashsum.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/hashsum.c $(LIBMAIN_S) $(LTC_LDFLAGS) +ltcrypt.exe: demos/ltcrypt.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/ltcrypt.c $(LIBMAIN_S) $(LTC_LDFLAGS) +small.exe: demos/small.c $(LIBMAIN_S) + cl $(LTC_CFLAGS) demos/small.c $(LIBMAIN_S) $(LTC_LDFLAGS) tv_gen.exe: demos/tv_gen.c $(LIBMAIN_S) cl $(LTC_CFLAGS) demos/tv_gen.c $(LIBMAIN_S) $(LTC_LDFLAGS) -hashsum.exe: demos/hashsum.c $(LIBMAIN_S) - cl $(LTC_CFLAGS) demos/hashsum.c $(LIBMAIN_S) $(LTC_LDFLAGS) - -ltcrypt.exe: demos/ltcrypt.c $(LIBMAIN_S) - cl $(LTC_CFLAGS) demos/ltcrypt.c $(LIBMAIN_S) $(LTC_LDFLAGS) - -small.exe: demos/small.c $(LIBMAIN_S) - cl $(LTC_CFLAGS) demos/small.c $(LIBMAIN_S) $(LTC_LDFLAGS) - -test.exe: demos/test.c $(LIBMAIN_S) $(LIBTEST_S) - cl $(LTC_CFLAGS) demos/test.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) - +#Tests + timing tests timing.exe: demos/timing.c $(LIBMAIN_S) $(LIBTEST_S) cl $(LTC_CFLAGS) demos/timing.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) +test.exe: demos/test.c $(LIBMAIN_S) $(LIBTEST_S) + cl $(LTC_CFLAGS) demos/test.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) all: $(LIBMAIN_S) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe test: test.exe clean: + @cmd /c del /Q *_tv.txt 2>nul @cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul +#Install the library + headers install: $(LIBMAIN_S) $(LIBTEST_S) cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin" cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib" cmd /c if not exist "$(DESTDIR)\include" mkdir "$(DESTDIR)\include" - copy /Y hashsum.exe "$(DESTDIR)\bin" copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib" - copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include" \ No newline at end of file + copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include" + +#Install useful tools +install_bins: hashsum + cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin" + copy /Y hashsum.exe "$(DESTDIR)\bin" + +#Install documentation +install_docs: doc/crypt.pdf + cmd /c if not exist "$(DESTDIR)\doc" mkdir "$(DESTDIR)\doc" + copy /Y doc\crypt.pdf "$(DESTDIR)\doc" diff --git a/makefile.unix b/makefile.unix index 708d911..b93315c 100644 --- a/makefile.unix +++ b/makefile.unix @@ -208,7 +208,7 @@ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs. src/headers/tomcrypt_prng.h #The default rule for make builds the libtomcrypt.a library (static) -default: library +default: $(LIBMAIN_S) #SPECIAL: AES comes in two flavours - enc+dec and enc-only src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c @@ -223,9 +223,6 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c -#This rule makes the libtomcrypt library. -library: $(LIBMAIN_S) - #Dependencies on *.h $(OBJECTS): $(HEADERS) $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h @@ -267,14 +264,25 @@ all: $(LIBMAIN_S) $(LIBTEST_S) hashsum ltcrypt small tv_gen timing test #NOTE: this makefile works also on cygwin, thus we need to delete *.exe clean: - -@rm -f $(OBJECTS) + -@rm -f $(OBJECTS) $(TOBJECTS) -@rm -f $(LIBMAIN_S) $(LIBTEST_S) - -@rm -f testprof/*.o demos/*.o + -@rm -f demos/*.o *_tv.txt -@rm -f test tv_gen hashsum crypt small timing -@rm -f test.exe tv_gen.exe hashsum.exe crypt.exe small.exe timing.exe +#Install the library + headers install: $(LIBMAIN_S) $(HEADERS) @mkdir -p $(DESTDIR)/include $(DESTDIR)/lib/pkgconfig @cp $(LIBMAIN_S) $(DESTDIR)/lib/ @cp $(HEADERS) $(DESTDIR)/include/ @sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/lib/pkgconfig/libtomcrypt.pc + +#Install useful tools +install_bins: hashsum + @mkdir -p $(DESTDIR)/bin + @cp hashsum $(DESTDIR)/bin/ + +#Install documentation +install_docs: doc/crypt.pdf + @mkdir -p $(DESTDIR)/share/doc/libtomcrypt/pdf + @cp doc/crypt.pdf $(DESTDIR)/share/doc/libtomcrypt/pdf/ From d99695813386cc15e5fb6e8be90fe0f5b303527b Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 9 May 2017 00:07:22 +0200 Subject: [PATCH 42/51] move biggest part of install rules to makefile.common --- makefile | 26 +++++--------------------- makefile.common | 28 ++++++++++++++++++++++++++++ makefile.shared | 21 ++++++--------------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/makefile b/makefile index a917931..e46d5ed 100644 --- a/makefile +++ b/makefile @@ -21,6 +21,8 @@ else RANLIB:=$(PREFIX)ranlib endif endif +INSTALL_CMD = install + #Output filenames for various targets. ifndef LIBNAME @@ -281,29 +283,11 @@ endif #This rule installs the library and the header files. This must be run #as root in order to have a high enough permission to write to the correct #directories and to set the owner and group to root. -ifndef NODOCS -install: library docs -else -install: library -endif - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 $(LIBNAME) $(LIBPATH) - install -m 644 $(HEADERS) $(INCPATH) -ifndef NODOCS - install -d $(DATAPATH) - install -m 644 doc/crypt.pdf $(DATAPATH) -endif +install: .common_install -install_bins: $(USEFUL_DEMOS) - install -d $(BINPATH) - install -m 775 $(USEFUL_DEMOS) $(BINPATH) +install_bins: .common_install_bins -install_test: $(LIBTEST) - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 $(LIBTEST) $(LIBPATH) - install -m 644 testprof/tomcrypt_test.h $(INCPATH) +install_test: .common_install_test profile: CFLAGS="$(CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov" diff --git a/makefile.common b/makefile.common index 95a4d19..c550cc2 100644 --- a/makefile.common +++ b/makefile.common @@ -1,5 +1,9 @@ #common make targets shared over multiple makefiles +ifndef INSTALL_CMD +$(error your makefile must define INSTALL_CMD) +endif + bins: $(USEFUL_DEMOS) all_test: test tv_gen $(DEMOS) @@ -14,6 +18,30 @@ doxy: docs: $(MAKE) -C doc/ crypt.pdf V=$(V) + +install_all: install install_bins install_docs install_test + + +.common_install: $(LIBNAME) + install -d $(INCPATH) + install -d $(LIBPATH) + $(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME) + install -m 644 $(HEADERS) $(INCPATH) + +.common_install_bins: $(USEFUL_DEMOS) + install -d $(BINPATH) + $(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH) + +.common_install_test: $(LIBTEST) + install -d $(LIBPATH) + install -d $(INCPATH) + install -m 644 testprof/tomcrypt_test.h $(INCPATH) + $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) + +install_docs: docs + install -d $(DATAPATH) + install -m 644 doc/crypt.pdf $(DATAPATH) + install_hooks: for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done diff --git a/makefile.shared b/makefile.shared index 43b2efa..ccc5a31 100644 --- a/makefile.shared +++ b/makefile.shared @@ -16,7 +16,7 @@ ifndef LT endif endif LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) - +INSTALL_CMD = $(LT) --mode=install install #Output filenames for various targets. ifndef LIBTEST_S @@ -239,23 +239,14 @@ $(LIBNAME): $(OBJECTS) $(LIBTEST): $(TOBJECTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./testprof -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) -install: $(LIBNAME) - install -d $(LIBPATH)/pkgconfig - install -d $(INCPATH) - $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME) - install -m 644 $(HEADERS) $(INCPATH) +install: .common_install sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > libtomcrypt.pc - install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc + install -d $(LIBPATH)/pkgconfig + install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/ -install_bins: $(USEFUL_DEMOS) - install -d $(BINPATH) - $(LT) --mode=install install -c $(USEFUL_DEMOS) $(BINPATH) +install_bins: .common_install_bins -install_test: $(LIBTEST) - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 testprof/tomcrypt_test.h $(INCPATH) - $(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST) +install_test: .common_install_test test: $(LIBNAME) $(LIBTEST) $(TESTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) From 6cd8f2504b75cabbe81d84157bd3e4e21d996d13 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 9 May 2017 11:59:35 +0200 Subject: [PATCH 43/51] clean-up some makefiles move shared variables between makefile and makefile.shared to makefile.include --- makefile | 190 ---------------------------------------------- makefile.include | 191 ++++++++++++++++++++++++++++++++++++++++++++++ makefile.shared | 194 ----------------------------------------------- updatemakes.sh | 2 +- 4 files changed, 192 insertions(+), 385 deletions(-) diff --git a/makefile b/makefile index e46d5ed..bfc5a4b 100644 --- a/makefile +++ b/makefile @@ -32,200 +32,10 @@ ifndef LIBTEST LIBTEST=libtomcrypt_prof.a endif -# List of objects to compile (all goes to libtomcrypt.a) -OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ -src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ -src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ -src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \ -src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \ -src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \ -src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \ -src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \ -src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \ -src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \ -src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \ -src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \ -src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \ -src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \ -src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \ -src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \ -src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \ -src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \ -src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \ -src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \ -src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \ -src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \ -src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \ -src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \ -src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \ -src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \ -src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o \ -src/encauth/ocb3/ocb3_int_aad_add_block.o src/encauth/ocb3/ocb3_int_calc_offset_zero.o \ -src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o \ -src/hashes/blake2b.o src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \ -src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \ -src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \ -src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \ -src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \ -src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \ -src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \ -src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \ -src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \ -src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \ -src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \ -src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \ -src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \ -src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \ -src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \ -src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \ -src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \ -src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \ -src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \ -src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \ -src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \ -src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \ -src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \ -src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \ -src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \ -src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \ -src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \ -src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crc32.o \ -src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \ -src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_constants.o \ -src/misc/crypt/crypt_find_cipher.o src/misc/crypt/crypt_find_cipher_any.o \ -src/misc/crypt/crypt_find_cipher_id.o src/misc/crypt/crypt_find_hash.o \ -src/misc/crypt/crypt_find_hash_any.o src/misc/crypt/crypt_find_hash_id.o \ -src/misc/crypt/crypt_find_hash_oid.o src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o \ -src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \ -src/misc/crypt/crypt_inits.o src/misc/crypt/crypt_ltc_mp_descriptor.o \ -src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \ -src/misc/crypt/crypt_prng_rng_descriptor.o src/misc/crypt/crypt_register_cipher.o \ -src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \ -src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \ -src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \ -src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \ -src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \ -src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \ -src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \ -src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \ -src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \ -src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \ -src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \ -src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \ -src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \ -src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \ -src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \ -src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \ -src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \ -src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \ -src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \ -src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \ -src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \ -src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \ -src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \ -src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \ -src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \ -src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \ -src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \ -src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \ -src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \ -src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \ -src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \ -src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \ -src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \ -src/pk/asn1/der/object_identifier/der_length_object_identifier.o \ -src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \ -src/pk/asn1/der/octet/der_length_octet_string.o \ -src/pk/asn1/der/printable_string/der_decode_printable_string.o \ -src/pk/asn1/der/printable_string/der_encode_printable_string.o \ -src/pk/asn1/der/printable_string/der_length_printable_string.o \ -src/pk/asn1/der/sequence/der_decode_sequence_ex.o \ -src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \ -src/pk/asn1/der/sequence/der_decode_sequence_multi.o \ -src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \ -src/pk/asn1/der/sequence/der_encode_sequence_ex.o \ -src/pk/asn1/der/sequence/der_encode_sequence_multi.o \ -src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \ -src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \ -src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \ -src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \ -src/pk/asn1/der/short_integer/der_encode_short_integer.o \ -src/pk/asn1/der/short_integer/der_length_short_integer.o \ -src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \ -src/pk/asn1/der/teletex_string/der_length_teletex_string.o \ -src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \ -src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \ -src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \ -src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \ -src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \ -src/pk/dsa/dsa_import_radix.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \ -src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \ -src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \ -src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \ -src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \ -src/pk/ecc/ecc_sign_hash.o src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \ -src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \ -src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \ -src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \ -src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \ -src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \ -src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \ -src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \ -src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \ -src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \ -src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \ -src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_radix.o src/pk/rsa/rsa_import_x509.o \ -src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_sign_hash.o src/pk/rsa/rsa_sign_saltlen_get.o \ -src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \ -src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \ -src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \ -src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \ -src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \ -src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ -src/stream/sober128/sober128_test.o - -# List of test objects to compile (all goes to libtomcrypt_prof.a) -TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ -testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ -testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ -testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ -testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ -testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o - -# The following headers will be installed by "make install" -HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ -src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ -src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ -src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h - -#The default rule for make builds the libtomcrypt library. -default:library - #AES comes in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c ${silent} ${CC} ${CFLAGS} -DENCRYPT_ONLY -c $< -o $@ -#These are the rules to make certain object files. -src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c -src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c -src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c -src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c -src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c -src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c -src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c - -$(DOBJECTS): CFLAGS += -Itestprof -$(TOBJECTS): CFLAGS += -Itestprof - -#This rule makes the libtomcrypt library. -library: $(LIBNAME) - -#Dependencies on *.h -$(OBJECTS): $(HEADERS) -$(DOBJECTS): $(HEADERS) $(THEADERS) -$(TOBJECTS): $(HEADERS) $(THEADERS) - .c.o: ifneq ($V,1) @echo " * ${CC} $@" diff --git a/makefile.include b/makefile.include index 7fe26a7..9da1429 100644 --- a/makefile.include +++ b/makefile.include @@ -122,3 +122,194 @@ GROUP=$(INSTALL_GROUP) else GROUP=wheel endif + +# List of objects to compile (all goes to libtomcrypt.a) +OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ +src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ +src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ +src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \ +src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \ +src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \ +src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \ +src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \ +src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \ +src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \ +src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \ +src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \ +src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \ +src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \ +src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \ +src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \ +src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \ +src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \ +src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \ +src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \ +src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \ +src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \ +src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \ +src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \ +src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \ +src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \ +src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o \ +src/encauth/ocb3/ocb3_int_aad_add_block.o src/encauth/ocb3/ocb3_int_calc_offset_zero.o \ +src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o \ +src/hashes/blake2b.o src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \ +src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \ +src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \ +src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \ +src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \ +src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \ +src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \ +src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \ +src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \ +src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \ +src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \ +src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \ +src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \ +src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \ +src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \ +src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \ +src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \ +src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \ +src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \ +src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \ +src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \ +src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \ +src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \ +src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \ +src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \ +src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \ +src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \ +src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crc32.o \ +src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \ +src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_constants.o \ +src/misc/crypt/crypt_find_cipher.o src/misc/crypt/crypt_find_cipher_any.o \ +src/misc/crypt/crypt_find_cipher_id.o src/misc/crypt/crypt_find_hash.o \ +src/misc/crypt/crypt_find_hash_any.o src/misc/crypt/crypt_find_hash_id.o \ +src/misc/crypt/crypt_find_hash_oid.o src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o \ +src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \ +src/misc/crypt/crypt_inits.o src/misc/crypt/crypt_ltc_mp_descriptor.o \ +src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \ +src/misc/crypt/crypt_prng_rng_descriptor.o src/misc/crypt/crypt_register_cipher.o \ +src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \ +src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \ +src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \ +src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \ +src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \ +src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \ +src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \ +src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \ +src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \ +src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \ +src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \ +src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \ +src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \ +src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \ +src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \ +src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \ +src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \ +src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \ +src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \ +src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \ +src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \ +src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \ +src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \ +src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \ +src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \ +src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \ +src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \ +src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \ +src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \ +src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \ +src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \ +src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \ +src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \ +src/pk/asn1/der/object_identifier/der_length_object_identifier.o \ +src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \ +src/pk/asn1/der/octet/der_length_octet_string.o \ +src/pk/asn1/der/printable_string/der_decode_printable_string.o \ +src/pk/asn1/der/printable_string/der_encode_printable_string.o \ +src/pk/asn1/der/printable_string/der_length_printable_string.o \ +src/pk/asn1/der/sequence/der_decode_sequence_ex.o \ +src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \ +src/pk/asn1/der/sequence/der_decode_sequence_multi.o \ +src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \ +src/pk/asn1/der/sequence/der_encode_sequence_ex.o \ +src/pk/asn1/der/sequence/der_encode_sequence_multi.o \ +src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \ +src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \ +src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \ +src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \ +src/pk/asn1/der/short_integer/der_encode_short_integer.o \ +src/pk/asn1/der/short_integer/der_length_short_integer.o \ +src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \ +src/pk/asn1/der/teletex_string/der_length_teletex_string.o \ +src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \ +src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \ +src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \ +src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \ +src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \ +src/pk/dsa/dsa_import_radix.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \ +src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \ +src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \ +src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \ +src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \ +src/pk/ecc/ecc_sign_hash.o src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \ +src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \ +src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \ +src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \ +src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \ +src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \ +src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \ +src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \ +src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \ +src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \ +src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \ +src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_radix.o src/pk/rsa/rsa_import_x509.o \ +src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_sign_hash.o src/pk/rsa/rsa_sign_saltlen_get.o \ +src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \ +src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \ +src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \ +src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \ +src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \ +src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ +src/stream/sober128/sober128_test.o + +# List of test objects to compile (all goes to libtomcrypt_prof.a) +TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ +testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ +testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ +testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ +testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ +testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o + +# The following headers will be installed by "make install" +HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ +src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ +src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ +src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ +src/headers/tomcrypt_prng.h + +#These are the rules to make certain object files. +src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c +src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c +src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c +src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c +src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c +src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c +src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c + + +#The default rule for make builds the libtomcrypt library. +default:library + +$(DOBJECTS): CFLAGS += -Itestprof +$(TOBJECTS): CFLAGS += -Itestprof + +#This rule makes the libtomcrypt library. +library: $(LIBNAME) + +#Dependencies on *.h +$(OBJECTS): $(HEADERS) +$(DOBJECTS): $(HEADERS) $(THEADERS) +$(TOBJECTS): $(HEADERS) $(THEADERS) diff --git a/makefile.shared b/makefile.shared index ccc5a31..9f72ed5 100644 --- a/makefile.shared +++ b/makefile.shared @@ -32,204 +32,10 @@ ifndef LIBNAME_S LIBNAME_S=libtomcrypt.a endif -#List of objects to compile. -#START_INS -OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ -src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ -src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ -src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \ -src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \ -src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \ -src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \ -src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \ -src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \ -src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \ -src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \ -src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \ -src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \ -src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \ -src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \ -src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \ -src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \ -src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \ -src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \ -src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \ -src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \ -src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \ -src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \ -src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \ -src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \ -src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \ -src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o \ -src/encauth/ocb3/ocb3_int_aad_add_block.o src/encauth/ocb3/ocb3_int_calc_offset_zero.o \ -src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o \ -src/hashes/blake2b.o src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \ -src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \ -src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \ -src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \ -src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \ -src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \ -src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \ -src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \ -src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \ -src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \ -src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \ -src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \ -src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \ -src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \ -src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \ -src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \ -src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \ -src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \ -src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \ -src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \ -src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \ -src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \ -src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \ -src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \ -src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \ -src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \ -src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \ -src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crc32.o \ -src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \ -src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_constants.o \ -src/misc/crypt/crypt_find_cipher.o src/misc/crypt/crypt_find_cipher_any.o \ -src/misc/crypt/crypt_find_cipher_id.o src/misc/crypt/crypt_find_hash.o \ -src/misc/crypt/crypt_find_hash_any.o src/misc/crypt/crypt_find_hash_id.o \ -src/misc/crypt/crypt_find_hash_oid.o src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o \ -src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \ -src/misc/crypt/crypt_inits.o src/misc/crypt/crypt_ltc_mp_descriptor.o \ -src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \ -src/misc/crypt/crypt_prng_rng_descriptor.o src/misc/crypt/crypt_register_cipher.o \ -src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \ -src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \ -src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \ -src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \ -src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \ -src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \ -src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \ -src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \ -src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \ -src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \ -src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \ -src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \ -src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \ -src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \ -src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \ -src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \ -src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \ -src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \ -src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \ -src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \ -src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \ -src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \ -src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \ -src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \ -src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \ -src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \ -src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \ -src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \ -src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \ -src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \ -src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \ -src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \ -src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \ -src/pk/asn1/der/object_identifier/der_length_object_identifier.o \ -src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \ -src/pk/asn1/der/octet/der_length_octet_string.o \ -src/pk/asn1/der/printable_string/der_decode_printable_string.o \ -src/pk/asn1/der/printable_string/der_encode_printable_string.o \ -src/pk/asn1/der/printable_string/der_length_printable_string.o \ -src/pk/asn1/der/sequence/der_decode_sequence_ex.o \ -src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \ -src/pk/asn1/der/sequence/der_decode_sequence_multi.o \ -src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \ -src/pk/asn1/der/sequence/der_encode_sequence_ex.o \ -src/pk/asn1/der/sequence/der_encode_sequence_multi.o \ -src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \ -src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \ -src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \ -src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \ -src/pk/asn1/der/short_integer/der_encode_short_integer.o \ -src/pk/asn1/der/short_integer/der_length_short_integer.o \ -src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \ -src/pk/asn1/der/teletex_string/der_length_teletex_string.o \ -src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \ -src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \ -src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \ -src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \ -src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \ -src/pk/dsa/dsa_import_radix.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \ -src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \ -src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \ -src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \ -src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \ -src/pk/ecc/ecc_sign_hash.o src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \ -src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \ -src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \ -src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \ -src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \ -src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \ -src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \ -src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \ -src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \ -src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \ -src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \ -src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_radix.o src/pk/rsa/rsa_import_x509.o \ -src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_sign_hash.o src/pk/rsa/rsa_sign_saltlen_get.o \ -src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \ -src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \ -src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \ -src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \ -src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \ -src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ -src/stream/sober128/sober128_test.o - -# List of test objects to compile (all goes to libtomcrypt_prof.a) -TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ -testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ -testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ -testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \ -testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ -testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o - -# The following headers will be installed by "make install" -HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ -src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ -src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ -src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ -src/headers/tomcrypt_prng.h - -#END_INS - -#The default rule for make builds the libtomcrypt library. -default: $(LIBNAME) - #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o -#These are the rules to make certain object files. -src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c -src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c -src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c -src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c -src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c -src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c -src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c - -#This rule makes the libtomcrypt library. -library: $(LIBNAME) - -#Dependencies on *.h -$(OBJECTS): $(HEADERS) -$(DOBJECTS): $(HEADERS) $(THEADERS) -$(TOBJECTS): $(HEADERS) $(THEADERS) - -#SPECIAL: demo- and test-objects required include-path "testprof" -$(DOBJECTS): CFLAGS += -Itestprof -$(TOBJECTS): CFLAGS += -Itestprof - .c.o: $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $< diff --git a/updatemakes.sh b/updatemakes.sh index 8975c4b..d50b605 100755 --- a/updatemakes.sh +++ b/updatemakes.sh @@ -2,7 +2,7 @@ ./helper.pl --update-makefiles || exit 1 -makefiles=(makefile makefile.shared makefile.unix makefile.mingw makefile.msvc) +makefiles=(makefile makefile.include makefile.shared makefile.unix makefile.mingw makefile.msvc) vcproj=(libtomcrypt_VS2008.vcproj libtomcrypt_VS2005.vcproj) if [ $# -eq 1 ] && [ "$1" == "-c" ]; then From ea67579298f04d09c5eb548ffe5d8e7be9efbe8e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 8 May 2017 23:30:39 +0200 Subject: [PATCH 44/51] further clean-up - improve doc generation - update version handling no need for VERSION_{MAJ,MIN} --- doc/makefile | 7 +++++-- helper.pl | 2 +- makefile.common | 49 ++++++++++++++++++++++-------------------------- makefile.include | 2 +- makefile.shared | 7 +------ printinfo.sh | 2 +- 6 files changed, 31 insertions(+), 38 deletions(-) diff --git a/doc/makefile b/doc/makefile index 8becfef..1222eb9 100644 --- a/doc/makefile +++ b/doc/makefile @@ -22,8 +22,7 @@ doxy: doxygen #from the clean command! This is because most people would like to keep the #nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to #delete it if we are rebuilding it. -.PHONY: crypt.pdf -crypt.pdf: crypt.tex +docs crypt.pdf: crypt.tex rm -f crypt.pdf $(LEFTOVERS) cp crypt.tex crypt.bak touch -r crypt.tex crypt.bak @@ -52,3 +51,7 @@ docdvi: crypt.tex perl ../helper.pl --fixupind crypt.ind latex crypt $(silent_stdout) latex crypt $(silent_stdout) + +clean: + rm -f $(LEFTOVERS) + rm -rf doxygen/ diff --git a/helper.pl b/helper.pl index 8f729fb..2db9ad8 100755 --- a/helper.pl +++ b/helper.pl @@ -217,7 +217,7 @@ sub patch_makefile { sub version_form_tomcrypt_h { my $h = read_file(shift); if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)"/s) { - return "VERSION_MAJ=$1", "VERSION_MIN=$2", "VERSION=$1.$2", "VERSION_LT=0:$1$2"; + return "VERSION=$1.$2", "VERSION_LT=0:$1$2"; } else { die "#define SCRYPT not found in tomcrypt.h"; diff --git a/makefile.common b/makefile.common index c550cc2..4da06bc 100644 --- a/makefile.common +++ b/makefile.common @@ -9,13 +9,10 @@ bins: $(USEFUL_DEMOS) all_test: test tv_gen $(DEMOS) #build the doxy files (requires Doxygen, tetex and patience) -doxygen: - $(MAKE) -C doc/ doxygen V=$(V) +doxygen doxy docs: + $(MAKE) -C doc/ $@ V=$(V) -doxy: - $(MAKE) -C doc/ doxy V=$(V) - -docs: +doc/crypt.pdf: $(MAKE) -C doc/ crypt.pdf V=$(V) @@ -38,7 +35,7 @@ install_all: install install_bins install_docs install_test install -m 644 testprof/tomcrypt_test.h $(INCPATH) $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) -install_docs: docs +install_docs: doc/crypt.pdf install -d $(DATAPATH) install -m 644 doc/crypt.pdf $(DATAPATH) @@ -48,28 +45,26 @@ install_hooks: #This rule cleans the source tree of all compiled code, not including the pdf #documentation. clean: - rm -f `find . -type f -name "*.o" | xargs` - rm -f `find . -type f -name "*.lo" | xargs` - rm -f `find . -type f -name "*.a" | xargs` - rm -f `find . -type f -name "*.la" | xargs` - rm -f `find . -type f -name "*.obj" | xargs` - rm -f `find . -type f -name "*.lib" | xargs` - rm -f `find . -type f -name "*.exe" | xargs` - rm -f `find . -type f -name "*.dll" | xargs` - rm -f `find . -type f -name "*.so" | xargs` - rm -f `find . -type f -name "*.gcov" | xargs` - rm -f `find . -type f -name "*.gcda" | xargs` - rm -f `find . -type f -name "*.gcno" | xargs` - rm -f `find . -type f -name "*.il" | xargs` - rm -f `find . -type f -name "*.dyn" | xargs` - rm -f `find . -type f -name "*.dpi" | xargs` - rm -rf `find . -type d -name "*.libs" | xargs` - rm -f crypt.aux crypt.dvi crypt.idx crypt.ilg crypt.ind crypt.log crypt.toc + find . -type f -name "*.o" \ + -o -name "*.lo" \ + -o -name "*.a" \ + -o -name "*.la" \ + -o -name "*.obj" \ + -o -name "*.lib" \ + -o -name "*.exe" \ + -o -name "*.dll" \ + -o -name "*.so" \ + -o -name "*.gcov"\ + -o -name "*.gcda"\ + -o -name "*.gcno"\ + -o -name "*.il" \ + -o -name "*.dyn" \ + -o -name "*.dpi" | xargs rm -f rm -f $(TIMING) $(TEST) $(DEMOS) - rm -rf doc/doxygen - rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs` - rm -f *.txt + rm -f *_tv.txt rm -f *.pc + rm -rf `find . -type d -name "*.libs" | xargs` + $(MAKE) -C doc/ clean zipup: docs @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) diff --git a/makefile.include b/makefile.include index 9da1429..ad15672 100644 --- a/makefile.include +++ b/makefile.include @@ -2,7 +2,7 @@ # Include makefile for libtomcrypt # -# The version +# The version - BEWARE: VERSION and VERSION_LT are updated via ./updatemakes.sh VERSION=1.17 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html VERSION_LT=0:117 diff --git a/makefile.shared b/makefile.shared index 9f72ed5..7e2f998 100644 --- a/makefile.shared +++ b/makefile.shared @@ -18,19 +18,14 @@ endif LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) INSTALL_CMD = $(LT) --mode=install install + #Output filenames for various targets. -ifndef LIBTEST_S - LIBTEST_S=libtomcrypt_prof.a -endif ifndef LIBTEST LIBTEST=libtomcrypt_prof.la endif ifndef LIBNAME LIBNAME=libtomcrypt.la endif -ifndef LIBNAME_S - LIBNAME_S=libtomcrypt.a -endif #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c diff --git a/printinfo.sh b/printinfo.sh index e6b7312..0af3bea 100644 --- a/printinfo.sh +++ b/printinfo.sh @@ -3,7 +3,7 @@ version=$(git describe --tags --always --dirty 2>/dev/null) if [ ! -e ".git" ] || [ -z $version ] then - version=$(grep "^VERSION=" makefile | sed "s/.*=//") + version=$(grep "^VERSION=" makefile.include | sed "s/.*=//") fi echo "Testing version:" $version #grep "VERSION=" makefile | perl -e "@a = split('=', <>); print @a[1];"` From 2c27aee5d40ef2849267fbd195f7638e573a6921 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 9 May 2017 16:15:30 +0200 Subject: [PATCH 45/51] fixup df733f79fa806f1a305b044c3108e2b7cabf9805 --- updatemakes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updatemakes.sh b/updatemakes.sh index d50b605..da513f2 100755 --- a/updatemakes.sh +++ b/updatemakes.sh @@ -3,7 +3,7 @@ ./helper.pl --update-makefiles || exit 1 makefiles=(makefile makefile.include makefile.shared makefile.unix makefile.mingw makefile.msvc) -vcproj=(libtomcrypt_VS2008.vcproj libtomcrypt_VS2005.vcproj) +vcproj=(libtomcrypt_VS2008.vcproj) if [ $# -eq 1 ] && [ "$1" == "-c" ]; then git add ${makefiles[@]} ${vcproj[@]} && git commit -m 'Update makefiles' From 7379c94f0aafab5eb388c7977950036e3579118c Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 10 May 2017 11:56:52 +0200 Subject: [PATCH 46/51] merge .include and .common makefiles --- helper.pl | 2 +- makefile | 11 +-- makefile.common | 85 ----------------------- makefile.shared | 12 ++-- makefile.include => makefile_include.mk | 92 ++++++++++++++++++++++++- 5 files changed, 103 insertions(+), 99 deletions(-) delete mode 100644 makefile.common rename makefile.include => makefile_include.mk (86%) diff --git a/helper.pl b/helper.pl index 2db9ad8..8126954 100755 --- a/helper.pl +++ b/helper.pl @@ -260,7 +260,7 @@ sub process_makefiles { } # update OBJECTS + HEADERS in makefile* - for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) { + for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile_include.mk /) { my $old = read_file($m); my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_tobj, @ver_version) : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version); diff --git a/makefile b/makefile index bfc5a4b..d4b086e 100644 --- a/makefile +++ b/makefile @@ -2,8 +2,8 @@ # # Tom St Denis # Modified by Clay Culver - -include makefile.include +# +# (GNU make only) ifeq ($V,1) silent= @@ -23,7 +23,6 @@ endif endif INSTALL_CMD = install - #Output filenames for various targets. ifndef LIBNAME LIBNAME=libtomcrypt.a @@ -32,6 +31,10 @@ ifndef LIBTEST LIBTEST=libtomcrypt_prof.a endif + +include makefile_include.mk + + #AES comes in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c ${silent} ${CC} ${CFLAGS} -DENCRYPT_ONLY -c $< -o $@ @@ -136,6 +139,4 @@ coverage: test # cleans everything - coverage output and standard 'clean' cleancov: cleancov-clean clean -include makefile.common - # git commit: $Format:%h$ $Format:%ai$ diff --git a/makefile.common b/makefile.common deleted file mode 100644 index 4da06bc..0000000 --- a/makefile.common +++ /dev/null @@ -1,85 +0,0 @@ -#common make targets shared over multiple makefiles - -ifndef INSTALL_CMD -$(error your makefile must define INSTALL_CMD) -endif - -bins: $(USEFUL_DEMOS) - -all_test: test tv_gen $(DEMOS) - -#build the doxy files (requires Doxygen, tetex and patience) -doxygen doxy docs: - $(MAKE) -C doc/ $@ V=$(V) - -doc/crypt.pdf: - $(MAKE) -C doc/ crypt.pdf V=$(V) - - -install_all: install install_bins install_docs install_test - - -.common_install: $(LIBNAME) - install -d $(INCPATH) - install -d $(LIBPATH) - $(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME) - install -m 644 $(HEADERS) $(INCPATH) - -.common_install_bins: $(USEFUL_DEMOS) - install -d $(BINPATH) - $(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH) - -.common_install_test: $(LIBTEST) - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 testprof/tomcrypt_test.h $(INCPATH) - $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) - -install_docs: doc/crypt.pdf - install -d $(DATAPATH) - install -m 644 doc/crypt.pdf $(DATAPATH) - -install_hooks: - for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done - -#This rule cleans the source tree of all compiled code, not including the pdf -#documentation. -clean: - find . -type f -name "*.o" \ - -o -name "*.lo" \ - -o -name "*.a" \ - -o -name "*.la" \ - -o -name "*.obj" \ - -o -name "*.lib" \ - -o -name "*.exe" \ - -o -name "*.dll" \ - -o -name "*.so" \ - -o -name "*.gcov"\ - -o -name "*.gcda"\ - -o -name "*.gcno"\ - -o -name "*.il" \ - -o -name "*.dyn" \ - -o -name "*.dpi" | xargs rm -f - rm -f $(TIMING) $(TEST) $(DEMOS) - rm -f *_tv.txt - rm -f *.pc - rm -rf `find . -type d -name "*.libs" | xargs` - $(MAKE) -C doc/ clean - -zipup: docs - @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) - @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) - rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* - # files/dirs excluded from "git archive" are defined in .gitattributes - git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x - mkdir -p libtomcrypt-$(VERSION)/doc - cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf - tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) - zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) - rm -rf libtomcrypt-$(VERSION) - gpg -b -a libtomcrypt-$(VERSION).tar.xz - gpg -b -a libtomcrypt-$(VERSION).zip - -codecheck: - perl helper.pl -a - perlcritic *.pl diff --git a/makefile.shared b/makefile.shared index 7e2f998..04e08e7 100644 --- a/makefile.shared +++ b/makefile.shared @@ -4,9 +4,8 @@ # # Thanks to Zed Shaw for helping debug this on BSD/OSX. # Tom St Denis - -include makefile.include - +# +# (GNU make only) ifndef LT ifeq ($(PLATFORM), Darwin) @@ -18,7 +17,6 @@ endif LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) INSTALL_CMD = $(LT) --mode=install install - #Output filenames for various targets. ifndef LIBTEST LIBTEST=libtomcrypt_prof.la @@ -27,6 +25,10 @@ ifndef LIBNAME LIBNAME=libtomcrypt.la endif + +include makefile_include.mk + + #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o @@ -66,8 +68,6 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) -include makefile.common - # $Source$ # $Revision$ # $Date$ diff --git a/makefile.include b/makefile_include.mk similarity index 86% rename from makefile.include rename to makefile_include.mk index ad15672..e4f1787 100644 --- a/makefile.include +++ b/makefile_include.mk @@ -1,6 +1,6 @@ # -# Include makefile for libtomcrypt -# +# Include makefile used by makefile + makefile.shared +# (GNU make only) # The version - BEWARE: VERSION and VERSION_LT are updated via ./updatemakes.sh VERSION=1.17 @@ -313,3 +313,91 @@ library: $(LIBNAME) $(OBJECTS): $(HEADERS) $(DOBJECTS): $(HEADERS) $(THEADERS) $(TOBJECTS): $(HEADERS) $(THEADERS) + +ifndef INSTALL_CMD +$(error your makefile must define INSTALL_CMD) +endif + +ifndef EXTRALIBS +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs) +endif + +bins: $(USEFUL_DEMOS) + +all_test: test tv_gen $(DEMOS) + +#build the doxy files (requires Doxygen, tetex and patience) +doxygen doxy docs: + $(MAKE) -C doc/ $@ V=$(V) + +doc/crypt.pdf: + $(MAKE) -C doc/ crypt.pdf V=$(V) + + +install_all: install install_bins install_docs install_test + + +.common_install: $(LIBNAME) + install -d $(INCPATH) + install -d $(LIBPATH) + $(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME) + install -m 644 $(HEADERS) $(INCPATH) + +.common_install_bins: $(USEFUL_DEMOS) + install -d $(BINPATH) + $(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH) + +.common_install_test: $(LIBTEST) + install -d $(LIBPATH) + install -d $(INCPATH) + install -m 644 testprof/tomcrypt_test.h $(INCPATH) + $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) + +install_docs: doc/crypt.pdf + install -d $(DATAPATH) + install -m 644 doc/crypt.pdf $(DATAPATH) + +install_hooks: + for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done + +#This rule cleans the source tree of all compiled code, not including the pdf +#documentation. +clean: + find . -type f -name "*.o" \ + -o -name "*.lo" \ + -o -name "*.a" \ + -o -name "*.la" \ + -o -name "*.obj" \ + -o -name "*.lib" \ + -o -name "*.exe" \ + -o -name "*.dll" \ + -o -name "*.so" \ + -o -name "*.gcov"\ + -o -name "*.gcda"\ + -o -name "*.gcno"\ + -o -name "*.il" \ + -o -name "*.dyn" \ + -o -name "*.dpi" | xargs rm -f + rm -f $(TIMING) $(TEST) $(DEMOS) + rm -f *_tv.txt + rm -f *.pc + rm -rf `find . -type d -name "*.libs" | xargs` + $(MAKE) -C doc/ clean + +zipup: docs + @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) + @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) + rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* + # files/dirs excluded from "git archive" are defined in .gitattributes + git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x + mkdir -p libtomcrypt-$(VERSION)/doc + cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf + tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) + zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) + rm -rf libtomcrypt-$(VERSION) + gpg -b -a libtomcrypt-$(VERSION).tar.xz + gpg -b -a libtomcrypt-$(VERSION).zip + +codecheck: + perl helper.pl -a + perlcritic *.pl From 81f02972856d44f93a64b0bdf22ee8586c8ffbfd Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 10 May 2017 13:54:05 +0200 Subject: [PATCH 47/51] small fix-ups --- .gitignore | 13 +++++++++++++ makefile | 4 +++- makefile_include.mk | 18 +++++++++++------- printinfo.sh | 2 +- updatemakes.sh | 2 +- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index b845ffc..ee4902f 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,19 @@ timing.exe *.gcov libtomcrypt.pc +# output from doc generation +doxygen/ +*.dvi +*.log +*.aux +*.toc +*.idx +*.ilg +*.ind +*.out +*.lof +*.bak + coverage/ coverage*.info diff --git a/makefile b/makefile index d4b086e..fd0ea19 100644 --- a/makefile +++ b/makefile @@ -139,4 +139,6 @@ coverage: test # cleans everything - coverage output and standard 'clean' cleancov: cleancov-clean clean -# git commit: $Format:%h$ $Format:%ai$ +# ref: $Format:%D$ +# git commit: $Format:%H$ +# commit time: $Format:%ai$ diff --git a/makefile_include.mk b/makefile_include.mk index e4f1787..9984fad 100644 --- a/makefile_include.mk +++ b/makefile_include.mk @@ -384,19 +384,23 @@ clean: rm -rf `find . -type d -name "*.libs" | xargs` $(MAKE) -C doc/ clean -zipup: docs +zipup: doc/crypt.pdf + @# Update the index, so diff-index won't fail in case the pdf has been created. + @# As the pdf creation modifies crypt.tex, git sometimes detects the + @# modified file, but misses that it's put back to its original version. + @git update-index --refresh @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) - rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* - # files/dirs excluded from "git archive" are defined in .gitattributes + rm -rf libtomcrypt-$(VERSION) crypt-$(VERSION).* + @# files/dirs excluded from "git archive" are defined in .gitattributes git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x mkdir -p libtomcrypt-$(VERSION)/doc cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf - tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) - zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) + tar -c libtomcrypt-$(VERSION)/ | xz -6e -c - > crypt-$(VERSION).tar.xz + zip -9rq crypt-$(VERSION).zip libtomcrypt-$(VERSION) rm -rf libtomcrypt-$(VERSION) - gpg -b -a libtomcrypt-$(VERSION).tar.xz - gpg -b -a libtomcrypt-$(VERSION).zip + gpg -b -a crypt-$(VERSION).tar.xz + gpg -b -a crypt-$(VERSION).zip codecheck: perl helper.pl -a diff --git a/printinfo.sh b/printinfo.sh index 0af3bea..213af5b 100644 --- a/printinfo.sh +++ b/printinfo.sh @@ -3,7 +3,7 @@ version=$(git describe --tags --always --dirty 2>/dev/null) if [ ! -e ".git" ] || [ -z $version ] then - version=$(grep "^VERSION=" makefile.include | sed "s/.*=//") + version=$(grep "^VERSION=" makefile_include.mk | sed "s/.*=//") fi echo "Testing version:" $version #grep "VERSION=" makefile | perl -e "@a = split('=', <>); print @a[1];"` diff --git a/updatemakes.sh b/updatemakes.sh index da513f2..3b747f2 100755 --- a/updatemakes.sh +++ b/updatemakes.sh @@ -2,7 +2,7 @@ ./helper.pl --update-makefiles || exit 1 -makefiles=(makefile makefile.include makefile.shared makefile.unix makefile.mingw makefile.msvc) +makefiles=(makefile makefile_include.mk makefile.shared makefile.unix makefile.mingw makefile.msvc) vcproj=(libtomcrypt_VS2008.vcproj) if [ $# -eq 1 ] && [ "$1" == "-c" ]; then From 6a4978ef5ed2208a4e1f63d4fb12ef6bdb9ed7f3 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 11 May 2017 15:40:50 +0200 Subject: [PATCH 48/51] better EXTRALIBS --- makefile_include.mk | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/makefile_include.mk b/makefile_include.mk index 9984fad..ff89df7 100644 --- a/makefile_include.mk +++ b/makefile_include.mk @@ -28,6 +28,20 @@ ifndef MAKE MAKE:=make endif +ifndef INSTALL_CMD +$(error your makefile must define INSTALL_CMD) +endif + +ifndef EXTRALIBS +ifneq ($(shell echo $(CFLAGS) | grep USE_LTM),) +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs) +else +ifneq ($(shell echo $(CFLAGS) | grep USE_TFM),) +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config tomsfastmath --libs) +endif +endif +endif + # Compilation flags. Note the += does not write over the user's CFLAGS! CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE @@ -314,14 +328,6 @@ $(OBJECTS): $(HEADERS) $(DOBJECTS): $(HEADERS) $(THEADERS) $(TOBJECTS): $(HEADERS) $(THEADERS) -ifndef INSTALL_CMD -$(error your makefile must define INSTALL_CMD) -endif - -ifndef EXTRALIBS -EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs) -endif - bins: $(USEFUL_DEMOS) all_test: test tv_gen $(DEMOS) From 56283c947acd56f18c1068405da9b1ed7802db5a Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 11 May 2017 15:53:22 +0200 Subject: [PATCH 49/51] improve coverage creation --- .travis.yml | 2 +- build.sh | 9 ++++++--- coverage.sh | 20 +++++--------------- coverage_more.sh | 24 ++++++++++++++++++++++++ makefile | 22 +++++++++++++++------- testme.sh | 39 ++++++++++++++++++++++----------------- 6 files changed, 73 insertions(+), 43 deletions(-) create mode 100755 coverage_more.sh diff --git a/.travis.yml b/.travis.yml index 1117067..6c79e17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,7 +90,7 @@ addons: - libtommath-dev before_script: - sudo apt-get update -qq - - sudo pip install cpp-coveralls + - sudo gem install coveralls-lcov after_failure: - cat test_std.txt - cat test_err.txt diff --git a/build.sh b/build.sh index 94f27bf..590fc44 100755 --- a/build.sh +++ b/build.sh @@ -42,11 +42,14 @@ if [ -a test ] && [ -f test ] && [ -x test ]; then fi fi -lcov_opts="--capture --no-external --directory src -q" -lcov_out=$(echo coverage_$1_$2_$3 | tr ' -=+' '_')".info" if [ -a testok.txt ] && [ -f testok.txt ]; then - [ "$LTC_COVERAGE" != "" ] && lcov $lcov_opts --output-file $lcov_out + if [ "$LTC_COVERAGE" != "" ]; then + ./coverage_more.sh > test_coverage_more.txt || exit 1 + lcov_opts="--capture --no-external --directory src -q" + lcov_out=$(echo coverage_$1_$2_$3 | tr ' -=+' '_')".info" + lcov $lcov_opts --output-file $lcov_out + fi exit 0 fi exit 1 diff --git a/coverage.sh b/coverage.sh index a17c97d..6686b44 100755 --- a/coverage.sh +++ b/coverage.sh @@ -20,7 +20,7 @@ fi # output version bash printinfo.sh -bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4 -fprofile-arcs -ftest-coverage " "$5 -lgcov" +bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4" "$5" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else @@ -29,24 +29,14 @@ else exit 1 fi -./sizes -./constants - -for i in $(for j in $(echo $(./hashsum -h | tail -n +3)); do echo $j; done | sort); do echo -n "$i: " && ./hashsum -a $i testprof/test.key ; done > hashsum_tv.txt -difftroubles=$(diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt | grep '^<') || true -if [ -n "$difftroubles" ]; then - echo "FAILURE: hashsum_tv.tx" - diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt - echo "hashsum failed" && rm -f testok.txt && exit 1 -else - echo "hashsum okay" -fi +./coverage_more.sh > test_coverage_more.txt || { rm -f testok.txt && exit 1 ; } +make lcov-single # if this was executed as './coverage.sh ...' create coverage locally if [[ "${0%% *}" == "./${0##*/}" ]]; then - make lcov-single + make lcov-html else - cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/' + coveralls-lcov coverage.info fi exit 0 diff --git a/coverage_more.sh b/coverage_more.sh new file mode 100755 index 0000000..c7eabab --- /dev/null +++ b/coverage_more.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +./sizes +./constants + +for i in $(for j in $(echo $(./hashsum -h | tail -n +3)); do echo $j; done | sort); do echo -n "$i: " && ./hashsum -a $i testprof/test.key ; done > hashsum_tv.txt +difftroubles=$(diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt | grep '^<') || true +if [ -n "$difftroubles" ]; then + echo "FAILURE: hashsum_tv.tx" + diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt + echo "hashsum failed" + exit 1 +else + echo "hashsum okay" +fi + + +exit 0 + +# $Source$ +# $Revision$ +# $Date$ diff --git a/makefile b/makefile index fd0ea19..aa569a4 100644 --- a/makefile +++ b/makefile @@ -34,6 +34,12 @@ endif include makefile_include.mk +ifeq ($(COVERAGE),1) +all_test: LIB_PRE = -Wl,--whole-archive +all_test: LIB_POST = -Wl,--no-whole-archive +CFLAGS += -fprofile-arcs -ftest-coverage +EXTRALIBS += -lgcov +endif #AES comes in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c @@ -88,10 +94,6 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) -ifeq ($(COVERAGE),1) -all_test: LIB_PRE = -Wl,--whole-archive -all_test: LIB_POST = -Wl,--no-whole-archive -endif #This rule installs the library and the header files. This must be run #as root in order to have a high enough permission to write to the correct @@ -117,14 +119,20 @@ cleancov-clean: rm -f `find . -type f -name "*.info" | xargs` rm -rf coverage/ +# merges all coverage_*.info files into coverage.info +coverage.info: + lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info + # generates html output from all coverage_*.info files -lcov: - lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info -q 2>/dev/null +lcov-html: coverage.info genhtml coverage.info --output-directory coverage -q # combines all necessary steps to create the coverage from a single testrun with e.g. # CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" make coverage -j9 -lcov-single: | cleancov-clean lcov-single-create lcov +lcov-single: + $(MAKE) cleancov-clean + $(MAKE) lcov-single-create + $(MAKE) coverage.info #make the code coverage of the library diff --git a/testme.sh b/testme.sh index c1b3c23..3f1605b 100755 --- a/testme.sh +++ b/testme.sh @@ -3,7 +3,8 @@ if [ $# -lt 3 ] then echo "usage is: ${0##*/} " - echo "e.g. \"${0##*/} \"makefile -j3\" \"-DUSE_LTM -DLTM_DESC -I/path/to/libtommath\" /path/to/libtommath/libtommath.a\"" + echo "e.g. \"${0##*/} \"makefile -j9\" \"-DUSE_LTM -DLTM_DESC -I../libtommath\" ../libtommath/libtommath.a\"" + echo "to create aggregate coverage: pre-pend with LTC_COVERAGE=1" exit -1 fi @@ -13,53 +14,57 @@ echo "date="`date` # check sources bash check_source.sh "CHECK_SOURCES" " " "$1" "$2" "$3" || exit 1 +mk="$1" + +[ "$LTC_COVERAGE" != "" ] && mk="$mk COVERAGE=1" + # stock build -bash run.sh "STOCK" " " "$1" "$2" "$3" || exit 1 +bash run.sh "STOCK" " " "$mk" "$2" "$3" || exit 1 # EASY build -bash run.sh "EASY" "-DLTC_EASY" "$1" "$2" "$3" || exit 1 +bash run.sh "EASY" "-DLTC_EASY" "$mk" "$2" "$3" || exit 1 # SMALL code -bash run.sh "SMALL" "-DLTC_SMALL_CODE" "$1" "$2" "$3" || exit 1 +bash run.sh "SMALL" "-DLTC_SMALL_CODE" "$mk" "$2" "$3" || exit 1 # NOTABLES -bash run.sh "NOTABLES" "-DLTC_NO_TABLES" "$1" "$2" "$3" || exit 1 +bash run.sh "NOTABLES" "-DLTC_NO_TABLES" "$mk" "$2" "$3" || exit 1 # SMALL+NOTABLES -bash run.sh "SMALL+NOTABLES" "-DLTC_SMALL_CODE -DLTC_NO_TABLES" "$1" "$2" "$3" || exit 1 +bash run.sh "SMALL+NOTABLES" "-DLTC_SMALL_CODE -DLTC_NO_TABLES" "$mk" "$2" "$3" || exit 1 # CLEANSTACK -bash run.sh "CLEANSTACK" "-DLTC_CLEAN_STACK" "$1" "$2" "$3" || exit 1 +bash run.sh "CLEANSTACK" "-DLTC_CLEAN_STACK" "$mk" "$2" "$3" || exit 1 # CLEANSTACK + SMALL -bash run.sh "CLEANSTACK+SMALL" "-DLTC_SMALL_CODE -DLTC_CLEAN_STACK" "$1" "$2" "$3" || exit 1 +bash run.sh "CLEANSTACK+SMALL" "-DLTC_SMALL_CODE -DLTC_CLEAN_STACK" "$mk" "$2" "$3" || exit 1 # CLEANSTACK + NOTABLES -bash run.sh "CLEANSTACK+NOTABLES" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK" "$1" "$2" "$3" || exit 1 +bash run.sh "CLEANSTACK+NOTABLES" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK" "$mk" "$2" "$3" || exit 1 # CLEANSTACK + NOTABLES + SMALL -bash run.sh "CLEANSTACK+NOTABLES+SMALL" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK -DLTC_SMALL_CODE" "$1" "$2" "$3" || exit 1 +bash run.sh "CLEANSTACK+NOTABLES+SMALL" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK -DLTC_SMALL_CODE" "$mk" "$2" "$3" || exit 1 # NO_FAST -bash run.sh "NO_FAST" "-DLTC_NO_FAST" "$1" "$2" "$3" || exit 1 +bash run.sh "NO_FAST" "-DLTC_NO_FAST" "$mk" "$2" "$3" || exit 1 # NO_FAST + NOTABLES -bash run.sh "NO_FAST+NOTABLES" "-DLTC_NO_FAST -DLTC_NO_TABLES" "$1" "$2" "$3" || exit 1 +bash run.sh "NO_FAST+NOTABLES" "-DLTC_NO_FAST -DLTC_NO_TABLES" "$mk" "$2" "$3" || exit 1 # NO_ASM -bash run.sh "NO_ASM" "-DLTC_NO_ASM" "$1" "$2" "$3" || exit 1 +bash run.sh "NO_ASM" "-DLTC_NO_ASM" "$mk" "$2" "$3" || exit 1 # NO_TIMING_RESISTANCE -bash run.sh "NO_TIMING_RESISTANCE" "-DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$1" "$2" "$3" || exit 1 +bash run.sh "NO_TIMING_RESISTANCE" "-DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$mk" "$2" "$3" || exit 1 # CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE -bash run.sh "CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE" "-DLTC_CLEAN_STACK -DLTC_NO_TABLES -DLTC_SMALL_CODE -DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$1" "$2" "$3" || exit 1 +bash run.sh "CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE" "-DLTC_CLEAN_STACK -DLTC_NO_TABLES -DLTC_SMALL_CODE -DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$mk" "$2" "$3" || exit 1 # test build with no testing -bash testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$1" "$2" "$3" || exit 1 +bash testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$mk" "$2" "$3" || exit 1 # test build with no file routines -bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$1" "$2" "$3" || exit 1 +bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$mk" "$2" "$3" || exit 1 # $Source$ # $Revision$ From 90d5fe5bdb00299413c0de0cfd74ce7b45d5de65 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 11 May 2017 16:32:03 +0200 Subject: [PATCH 50/51] re-format .travis.yml no sudo required to gem install --- .travis.yml | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c79e17..cc72699 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,28 @@ language: c + +addons: + apt: + sources: + - debian-sid + packages: + - binutils + - libtommath-dev + +before_script: + - gem install coveralls-lcov + +matrix: + fast_finish: true +branches: + only: + - develop + compiler: - gcc - clang + script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile V=1" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a" + env: - | BUILDSCRIPT="check_source.sh" @@ -76,26 +96,14 @@ env: BUILDSCRIPT="testbuild.sh" BUILDNAME="NOFILE" BUILDOPTIONS="-DLTC_NO_FILE" -matrix: - fast_finish: true -branches: - only: - - develop -addons: - apt: - sources: - - debian-sid - packages: - - binutils - - libtommath-dev -before_script: - - sudo apt-get update -qq - - sudo gem install coveralls-lcov + after_failure: - cat test_std.txt - cat test_err.txt + after_script: - cat gcc_1.txt - cat gcc_2.txt + notifications: irc: "chat.freenode.net#libtom-notifications" From a12b97f84e5356a02a60fdd4098f7db44b8df085 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 11 May 2017 16:37:14 +0200 Subject: [PATCH 51/51] travis doesn't seem to provide lcov... --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index cc72699..fd354ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ addons: before_script: - gem install coveralls-lcov + - curl http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz | tar xz + - export PATH=$PATH:`pwd`/lcov-1.11/bin matrix: fast_finish: true