summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-04-12 09:27:33 -0400
committerRich Salz <rsalz@openssl.org>2017-04-12 11:20:48 -0400
commitf1e793cc974094da7da52c6958ad7b972b4a446d (patch)
tree90abed20172c2f707f211c77f2b5fa7e45e90c47
parente2a29ad6c5f6b42ce71400595cb504cbf8f3646a (diff)
Address review feedback (to be squashed)
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3189)
-rw-r--r--test/casttest.c19
-rw-r--r--test/x509aux.c37
2 files changed, 23 insertions, 33 deletions
diff --git a/test/casttest.c b/test/casttest.c
index 17faf9273a..175085824d 100644
--- a/test/casttest.c
+++ b/test/casttest.c
@@ -65,30 +65,29 @@ static unsigned char c_b[16] = {
static int cast_test(void)
{
- static char *hex = "0123456789ABCDEF";
long l;
- int i, z, testresult = 1;
+ int z, testresult = 1;
CAST_KEY key, key_b;
unsigned char out_a[16], out_b[16];
for (z = 0; z < 3; z++) {
CAST_set_key(&key, k_len[z], k);
CAST_ecb_encrypt(in, out, &key, CAST_ENCRYPT);
- if (!TEST_mem_eq(out, sizeof(c[z]), c[z], sizeof(c[z])))
+ if (!TEST_mem_eq(out, sizeof(c[z]), c[z], sizeof(c[z]))) {
+ TEST_info("CAST_ENCRYPT iteration %d failed (len=%d)", z, k_len[z]);
testresult = 0;
+ }
CAST_ecb_encrypt(out, out, &key, CAST_DECRYPT);
- if (!TEST_mem_eq(out, sizeof(in), in, sizeof(in)))
+ if (!TEST_mem_eq(out, sizeof(in), in, sizeof(in))) {
+ TEST_info("CAST_DECRYPT iteration %d failed (len=%d)", z, k_len[z]);
testresult = 0;
+ }
}
- if (testresult)
- TEST_info("ecb cast5 ok");
-
memcpy(out_a, in_a, sizeof(in_a));
memcpy(out_b, in_b, sizeof(in_b));
- i = 1;
for (l = 0; l < 1000000L; l++) {
CAST_set_key(&key_b, 16, out_b);
CAST_ecb_encrypt(&(out_a[0]), &(out_a[0]), &key_b, CAST_ENCRYPT);
@@ -96,10 +95,6 @@ static int cast_test(void)
CAST_set_key(&key, 16, out_a);
CAST_ecb_encrypt(&(out_b[0]), &(out_b[0]), &key, CAST_ENCRYPT);
CAST_ecb_encrypt(&(out_b[8]), &(out_b[8]), &key, CAST_ENCRYPT);
- if ((l & 0xffff) == 0xffff) {
- TEST_info("%c", hex[i & 0x0f]);
- i++;
- }
}
if (!TEST_mem_eq(out_a, sizeof(c_a), c_a, sizeof(c_a))
diff --git a/test/x509aux.c b/test/x509aux.c
index 2ad7b6d1cd..7030a13365 100644
--- a/test/x509aux.c
+++ b/test/x509aux.c
@@ -21,7 +21,11 @@
#include "test_main_custom.h"
#include "testutil.h"
-static int test_certs(BIO *fp)
+
+/* List of files, from argv */
+static char **files;
+
+static int test_certs(int num)
{
int count;
char *name = 0;
@@ -31,6 +35,10 @@ static int test_certs(BIO *fp)
typedef X509 *(*d2i_X509_t)(X509 **, const unsigned char **, long);
typedef int (*i2d_X509_t)(X509 *, unsigned char **);
int err = 0;
+ BIO *fp = BIO_new_file(files[num], "r");
+
+ if (!TEST_ptr(fp))
+ return 0;
for (count = 0;
!err && PEM_read_bio(fp, &name, &header, &data, &len);
@@ -140,6 +148,7 @@ static int test_certs(BIO *fp)
OPENSSL_free(header);
OPENSSL_free(data);
}
+ BIO_free(fp);
if (ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) {
/* Reached end of PEM file */
@@ -155,26 +164,12 @@ static int test_certs(BIO *fp)
int test_main(int argc, char *argv[])
{
- BIO *bio_err;
- int ret = 1;
-
- if (argc < 2)
+ if (argc < 2) {
TEST_error("usage: %s certfile...", argv[0]);
-
- bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
-
- for (argv++; *argv; argv++) {
- BIO *f = BIO_new_file(*argv, "r");
- int ok;
-
- TEST_check(f != NULL);
- ok = test_certs(f);
- BIO_free(f);
-
- if (!TEST_int_eq(ok, 1))
- break;
- ret = 0;
+ return 0;
}
- BIO_free(bio_err);
- return ret;
+
+ files = &argv[1];
+ ADD_ALL_TESTS(test_certs, argc - 1);
+ return run_tests(argv[0]);
}