diff --git a/testprof/tomcrypt_test.h b/testprof/tomcrypt_test.h index abb5fc8..776580e 100644 --- a/testprof/tomcrypt_test.h +++ b/testprof/tomcrypt_test.h @@ -81,6 +81,7 @@ extern const struct ltc_prng_descriptor no_prng_desc; #endif void print_hex(const char* what, const void* v, const unsigned long l); +int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which); int sorter(const void *a, const void *b); void tally_results(int type); ulong64 rdtsc (void); diff --git a/testprof/x86_prof.c b/testprof/x86_prof.c index baf03d2..451a58c 100644 --- a/testprof/x86_prof.c +++ b/testprof/x86_prof.c @@ -16,6 +16,23 @@ void print_hex(const char* what, const void* v, const unsigned long l) fprintf(stderr, "\n"); } +int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which) +{ + int res = 0; + if(is_len != should_len) + res = is_len > should_len ? -1 : 1; + else + res = XMEMCMP(is, should, MAX(is_len, should_len)); + + if (res != 0) { + fprintf(stderr, "Testvector #%i of %s failed:\n", which, what); + print_hex("SHOULD", should, should_len); + print_hex("IS ", is, is_len); + } + + return res; +} + struct list results[100]; int no_results; int sorter(const void *a, const void *b)