diff options
author | Pauli <paul.dale@oracle.com> | 2017-06-12 10:01:17 +1000 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-06-16 16:15:31 -0400 |
commit | 3791646202bb4da21992b0aecae253d394507a9e (patch) | |
tree | cc1f33ab05144ec2442df45366fac1175fcaca16 /test/igetest.c | |
parent | 5511101ad86fdd5bc3ad4f27143e93ae14737bfe (diff) |
Add output routines to allow consistent formatting of memory, strings
and bignums. These have been refactored into their own file, along with
their error displays. The formatting follows the output format used
on error, except that bignums of sixty four bits or less are displayed
in a more compact one line form.
Added a TEST_note function for producing output without file and line
information.
Update the three tests that call BN_print so they use the new test
infrastructure instead.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3655)
Diffstat (limited to 'test/igetest.c')
-rw-r--r-- | test/igetest.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/test/igetest.c b/test/igetest.c index f6972b6b0a..a0fc623a64 100644 --- a/test/igetest.c +++ b/test/igetest.c @@ -27,19 +27,6 @@ static unsigned char rkey2[16]; static unsigned char plaintext[BIG_TEST_SIZE]; static unsigned char saved_iv[AES_BLOCK_SIZE * 4]; -static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) -{ - int n = 0; - - fprintf(f, "%s", title); - for (; n < l; ++n) { - if ((n % 16) == 0) - fprintf(f, "\n%04x", n); - fprintf(f, " %02x", s[n]); - } - fprintf(f, "\n"); -} - #define MAX_VECTOR_SIZE 64 struct ige_test { @@ -174,9 +161,9 @@ static int test_ige_vectors(int n) if (!TEST_mem_eq(v->out, v->length, buf, v->length)) { TEST_info("IGE test vector %d failed", n); - hexdump(stderr, "key", v->key, sizeof v->key); - hexdump(stderr, "iv", v->iv, sizeof v->iv); - hexdump(stderr, "in", v->in, v->length); + test_output_memory("key", v->key, sizeof v->key); + test_output_memory("iv", v->iv, sizeof v->iv); + test_output_memory("in", v->in, v->length); testresult = 0; } @@ -187,9 +174,9 @@ static int test_ige_vectors(int n) if (!TEST_mem_eq(v->out, v->length, buf, v->length)) { TEST_info("IGE test vector %d failed (with in == out)", n); - hexdump(stderr, "key", v->key, sizeof v->key); - hexdump(stderr, "iv", v->iv, sizeof v->iv); - hexdump(stderr, "in", v->in, v->length); + test_output_memory("key", v->key, sizeof v->key); + test_output_memory("iv", v->iv, sizeof v->iv); + test_output_memory("in", v->in, v->length); testresult = 0; } @@ -218,10 +205,10 @@ static int test_bi_ige_vectors(int n) v->encrypt); if (!TEST_mem_eq(v->out, v->length, buf, v->length)) { - hexdump(stderr, "key 1", v->key1, sizeof v->key1); - hexdump(stderr, "key 2", v->key2, sizeof v->key2); - hexdump(stderr, "iv", v->iv, sizeof v->iv); - hexdump(stderr, "in", v->in, v->length); + test_output_memory("key 1", v->key1, sizeof v->key1); + test_output_memory("key 2", v->key2, sizeof v->key2); + test_output_memory("iv", v->iv, sizeof v->iv); + test_output_memory("in", v->in, v->length); return 0; } |