diff --git a/testprof/rsa_test.c b/testprof/rsa_test.c index df0027a..ae27ec1 100644 --- a/testprof/rsa_test.c +++ b/testprof/rsa_test.c @@ -100,19 +100,6 @@ static int rsa_compat_test(void) return 0; } -static void _rsa_testPrint(const char* what, const unsigned char* p, const unsigned long l) -{ - unsigned long x; - fprintf(stderr, "%s contents: \n", what); - for (x = 0; x < l; ) { - fprintf(stderr, "%02x ", p[x]); - if (!(++x % 16)) { - fprintf(stderr, "\n"); - } - } - fprintf(stderr, "\n"); -} - int rsa_test(void) { unsigned char in[1024], out[1024], tmp[1024]; @@ -200,8 +187,8 @@ for (cnt = 0; cnt < len; ) { } if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) { fprintf(stderr, "\nrsa_decrypt_key mismatch, len %lu (second decrypt)\n", len2); - _rsa_testPrint("Original", in, rsa_msgsize); - _rsa_testPrint("Output", tmp, len2); + print_hex("Original", in, rsa_msgsize); + print_hex("Output", tmp, len2); return 1; } } @@ -230,8 +217,8 @@ for (cnt = 0; cnt < len; ) { } if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) { fprintf(stderr, "rsa_decrypt_key mismatch len %lu", len2); - _rsa_testPrint("Original", in, rsa_msgsize); - _rsa_testPrint("Output", tmp, len2); + print_hex("Original", in, rsa_msgsize); + print_hex("Output", tmp, len2); return 1; } } @@ -256,8 +243,8 @@ for (cnt = 0; cnt < len; ) { } if (memcmp(tmp, in, rsa_msgsize)) { fprintf(stderr, "rsa_decrypt_key_ex mismatch data"); - _rsa_testPrint("Original", in, rsa_msgsize); - _rsa_testPrint("Output", tmp, rsa_msgsize); + print_hex("Original", in, rsa_msgsize); + print_hex("Output", tmp, rsa_msgsize); return 1; } } diff --git a/testprof/tomcrypt_test.h b/testprof/tomcrypt_test.h index c51b126..f6951fc 100644 --- a/testprof/tomcrypt_test.h +++ b/testprof/tomcrypt_test.h @@ -80,6 +80,7 @@ extern int no_results; extern const struct ltc_prng_descriptor no_prng_desc; #endif +void print_hex(const char* what, const unsigned char* p, const unsigned long l); 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 c60aa82..9ade6b3 100644 --- a/testprof/x86_prof.c +++ b/testprof/x86_prof.c @@ -2,6 +2,19 @@ prng_state yarrow_prng; +void print_hex(const char* what, const unsigned char* p, const unsigned long l) +{ + unsigned long x; + fprintf(stderr, "%s contents: \n", what); + for (x = 0; x < l; ) { + fprintf(stderr, "%02x ", p[x]); + if (!(++x % 16)) { + fprintf(stderr, "\n"); + } + } + fprintf(stderr, "\n"); +} + struct list results[100]; int no_results; int sorter(const void *a, const void *b)