diff --git a/coverage.sh b/coverage.sh index 14dcd5a..d089ff6 100755 --- a/coverage.sh +++ b/coverage.sh @@ -31,7 +31,7 @@ fi ./sizes ./constants -./multi + for i in $(./hashsum | tail -n +3 | awk '{print $1}' | sort); do echo -n "$i: " && ./hashsum $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 diff --git a/demos/test.c b/demos/test.c index ac812c2..4c7a332 100644 --- a/demos/test.c +++ b/demos/test.c @@ -25,6 +25,7 @@ static const struct { LTC_TEST_FN(dsa_test), LTC_TEST_FN(katja_test), LTC_TEST_FN(file_test), + LTC_TEST_FN(multi_test), }; int main(int argc, char **argv) diff --git a/makefile b/makefile index 4ce3bf2..9fb0113 100644 --- a/makefile +++ b/makefile @@ -351,7 +351,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) $(MULTI) $(TIMING) $(TEST) + rm -f $(TV) $(SMALL) $(CRYPT) $(HASH) $(TIMING) $(TEST) rm -f $(SIZES) $(CONSTANTS) rm -rf doc/doxygen rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs` diff --git a/makefile.icc b/makefile.icc index 6c04ba8..c68a52e 100644 --- a/makefile.icc +++ b/makefile.icc @@ -77,7 +77,6 @@ CRYPT=encrypt SMALL=small PROF=x86_prof TV=tv_gen -MULTI=multi TIMING=timing TEST=test diff --git a/makefile.include b/makefile.include index 4d71000..a2256c6 100644 --- a/makefile.include +++ b/makefile.include @@ -75,13 +75,12 @@ HASH=hashsum CRYPT=encrypt SMALL=small TV=tv_gen -MULTI=multi TIMING=timing TEST=test SIZES=sizes CONSTANTS=constants -DEMOS=hashsum crypt small tv_gen multi sizes constants +DEMOS=hashsum crypt small tv_gen sizes constants TIMINGS=demos/timing.o TESTS=demos/test.o diff --git a/makefile.mingw b/makefile.mingw index ece1491..71a450b 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -23,7 +23,6 @@ CRYPT=encrypt SMALL=small PROF=x86_prof TV=tv_gen -MULTI=multi TIMING=timing TEST=test @@ -197,7 +196,6 @@ HASHOBJECTS=demos/hashsum.o CRYPTOBJECTS=demos/encrypt.o SMALLOBJECTS=demos/small.o TVS=demos/tv_gen.o -MULTIS=demos/multi.o TIMINGS=demos/timing.o TESTS=demos/test.o @@ -246,9 +244,6 @@ small: library $(SMALLOBJECTS) tv_gen: library $(TVS) $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) -multi: library $(MULTIS) - $(CC) $(MULTIS) $(LIBNAME) $(EXTRALIBS) -o $(MULTI) - timing: library testprof/$(LIBTEST) $(TIMINGS) $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) @@ -256,7 +251,7 @@ timing: library testprof/$(LIBTEST) $(TIMINGS) test: library testprof/$(LIBTEST) $(TESTS) $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) -all_test: test tv_gen hashsum crypt small multi timing +all_test: test tv_gen hashsum crypt small timing install: library cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)" diff --git a/makefile.unix b/makefile.unix index 0f6b9a9..f23efb3 100644 --- a/makefile.unix +++ b/makefile.unix @@ -22,7 +22,6 @@ CRYPT=encrypt SMALL=small PROF=x86_prof TV=tv_gen -MULTI=multi TIMING=timing TEST=test @@ -202,7 +201,6 @@ HASHOBJECTS=demos/hashsum.o CRYPTOBJECTS=demos/encrypt.o SMALLOBJECTS=demos/small.o TVS=demos/tv_gen.o -MULTIS=demos/multi.o TIMINGS=demos/timing.o TESTS=demos/test.o @@ -254,9 +252,6 @@ small: library $(SMALLOBJECTS) tv_gen: library $(TVS) $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) -multi: library $(MULTIS) - $(CC) $(MULTIS) $(LIBNAME) $(EXTRALIBS) -o $(MULTI) - timing: library testprof/$(LIBTEST) $(TIMINGS) $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) @@ -264,7 +259,7 @@ timing: library testprof/$(LIBTEST) $(TIMINGS) test: library testprof/$(LIBTEST) $(TESTS) $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) -all_test: test tv_gen hashsum crypt small multi timing +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 diff --git a/testprof/makefile b/testprof/makefile index 78d54c8..db7bbd9 100644 --- a/testprof/makefile +++ b/testprof/makefile @@ -20,7 +20,7 @@ endif 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 +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 diff --git a/testprof/makefile.icc b/testprof/makefile.icc index acd90c7..6ce7b08 100644 --- a/testprof/makefile.icc +++ b/testprof/makefile.icc @@ -4,7 +4,7 @@ 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 +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 diff --git a/testprof/makefile.mingw b/testprof/makefile.mingw index b454d12..5d17df2 100644 --- a/testprof/makefile.mingw +++ b/testprof/makefile.mingw @@ -7,7 +7,7 @@ CFLAGS = $(CFLAGS_OPTS) -I../src/headers -I../../libtommath -I. -Wall -Wextra -D 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 +pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o default: $(LIBTEST_S) diff --git a/testprof/makefile.msvc b/testprof/makefile.msvc index 1b361a6..72d32db 100644 --- a/testprof/makefile.msvc +++ b/testprof/makefile.msvc @@ -4,7 +4,7 @@ OBJECTS=base64_test.obj cipher_hash_test.obj der_tests.obj no_prng.obj file_test 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 +pkcs_1_emsa_test.obj pkcs_1_eme_test.obj multi_test.obj .c.obj: $(CC) $(CFLAGS) /c $< /Fo$@ diff --git a/testprof/multi_test.c b/testprof/multi_test.c index 31d1799..dc899c0 100644 --- a/testprof/multi_test.c +++ b/testprof/multi_test.c @@ -1,7 +1,7 @@ /* test the multi helpers... */ -#include +#include -int main(void) +int multi_test(void) { unsigned char key[32], buf[2][MAXBLOCKSIZE]; unsigned long len, len2; @@ -17,19 +17,19 @@ int main(void) hash_memory_multi(find_hash("sha256"), buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); hash_memory_multi(find_hash("sha256"), buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL, 0); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); hash_memory_multi(find_hash("sha256"), buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #ifdef LTC_HMAC @@ -39,19 +39,19 @@ int main(void) hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -62,19 +62,19 @@ int main(void) omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -85,19 +85,19 @@ int main(void) pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -108,19 +108,19 @@ int main(void) xcbc_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); xcbc_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); xcbc_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -131,19 +131,19 @@ int main(void) f9_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); f9_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); f9_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -158,19 +158,19 @@ int main(void) poly1305_memory_multi(key, 32, buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); poly1305_memory_multi(key, 32, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = sizeof(buf[0]); poly1305_memory_multi(key, 32, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -181,19 +181,19 @@ int main(void) blake2smac_memory_multi(key, 16, buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = 32; blake2smac_memory_multi(key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = 32; blake2smac_memory_multi(key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif @@ -204,27 +204,21 @@ int main(void) blake2bmac_memory_multi(key, 16, buf[1], &len2, (unsigned char*)"hello", 5, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = 64; blake2bmac_memory_multi(key, 16, buf[1], &len2, (unsigned char*)"he", 2UL, "llo", 3UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } len2 = 64; blake2bmac_memory_multi(key, 16, buf[1], &len2, (unsigned char*)"h", 1UL, "e", 1UL, "l", 1UL, "l", 1UL, "o", 1UL, NULL); if (len != len2 || memcmp(buf[0], buf[1], len)) { printf("Failed: %d %lu %lu\n", __LINE__, len, len2); - return EXIT_FAILURE; + return CRYPT_FAIL_TESTVECTOR; } #endif - printf("All passed\n"); - return EXIT_SUCCESS; + return CRYPT_OK; } - - -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ diff --git a/testprof/tomcrypt_test.h b/testprof/tomcrypt_test.h index 9e4dce4..64f2c23 100644 --- a/testprof/tomcrypt_test.h +++ b/testprof/tomcrypt_test.h @@ -66,6 +66,7 @@ int der_tests(void); int misc_test(void); int base64_test(void); int file_test(void); +int multi_test(void); /* timing */ #define KTIMES 25