new multi_test

This commit is contained in:
Karel Miko 2017-04-23 22:04:39 +02:00
parent 08ea7fc0f4
commit 3ea8a00ecd
13 changed files with 41 additions and 57 deletions

View File

@ -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

View File

@ -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)

View File

@ -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`

View File

@ -77,7 +77,6 @@ CRYPT=encrypt
SMALL=small
PROF=x86_prof
TV=tv_gen
MULTI=multi
TIMING=timing
TEST=test

View File

@ -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

View File

@ -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)"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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$@

View File

@ -1,7 +1,7 @@
/* test the multi helpers... */
#include <tomcrypt.h>
#include <tomcrypt_test.h>
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$ */

View File

@ -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