/*
- * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
#include <openssl/rand.h>
#include <stdio.h>
#include <string.h>
-#include "e_os.h"
+#include <internal/nelem.h>
#include "testutil.h"
#define TEST_SIZE 128
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 {
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;
}
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;
}
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;
}
return TEST_size_t_le(matches, sizeof checktext / 100);
}
-void register_tests(void)
+int setup_tests(void)
{
RAND_bytes(rkey, sizeof rkey);
RAND_bytes(rkey2, sizeof rkey2);
ADD_TEST(test_bi_ige_garble3);
ADD_ALL_TESTS(test_ige_vectors, OSSL_NELEM(ige_test_vectors));
ADD_ALL_TESTS(test_bi_ige_vectors, OSSL_NELEM(bi_ige_test_vectors));
+ return 1;
}