From 9ccc00ef6ea65567622e40c49aca43f2c6d79cdb Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Mon, 2 Feb 2015 11:11:34 -0500 Subject: [PATCH] Dead code cleanup: #if 0 dropped from tests Reviewed-by: Andy Polyakov --- crypto/bn/bntest.c | 140 ------------------------------------ crypto/cast/casttest.c | 28 -------- crypto/des/destest.c | 5 -- crypto/ec/ectest.c | 157 ----------------------------------------- crypto/ecdh/ecdhtest.c | 22 ------ crypto/evp/evp_test.c | 3 - ssl/ssltest.c | 12 +--- 7 files changed, 1 insertion(+), 366 deletions(-) diff --git a/crypto/bn/bntest.c b/crypto/bn/bntest.c index 4d109d8935..521858ae16 100644 --- a/crypto/bn/bntest.c +++ b/crypto/bn/bntest.c @@ -1174,19 +1174,6 @@ int test_gf2m_add(BIO *bp) a->neg = rand_neg(); b->neg = rand_neg(); BN_GF2m_add(c, a, b); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " ^ "); - BN_print(bp, b); - BIO_puts(bp, " = "); - } - BN_print(bp, c); - BIO_puts(bp, "\n"); - } -# endif /* Test that two added values have the correct parity. */ if ((BN_is_odd(a) && BN_is_odd(c)) || (!BN_is_odd(a) && !BN_is_odd(c))) { @@ -1229,19 +1216,6 @@ int test_gf2m_mod(BIO *bp) BN_bntest_rand(a, 1024, 0, 0); for (j = 0; j < 2; j++) { BN_GF2m_mod(c, a, b[j]); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " % "); - BN_print(bp, b[j]); - BIO_puts(bp, " - "); - BN_print(bp, c); - BIO_puts(bp, "\n"); - } - } -# endif BN_GF2m_add(d, a, c); BN_GF2m_mod(e, d, b[j]); /* Test that a + (a mod p) mod p == 0. */ @@ -1288,21 +1262,6 @@ int test_gf2m_mod_mul(BIO *bp, BN_CTX *ctx) BN_bntest_rand(d, 1024, 0, 0); for (j = 0; j < 2; j++) { BN_GF2m_mod_mul(e, a, c, b[j], ctx); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " * "); - BN_print(bp, c); - BIO_puts(bp, " % "); - BN_print(bp, b[j]); - BIO_puts(bp, " - "); - BN_print(bp, e); - BIO_puts(bp, "\n"); - } - } -# endif BN_GF2m_add(f, a, d); BN_GF2m_mod_mul(g, f, c, b[j], ctx); BN_GF2m_mod_mul(h, d, c, b[j], ctx); @@ -1352,21 +1311,6 @@ int test_gf2m_mod_sqr(BIO *bp, BN_CTX *ctx) BN_GF2m_mod_sqr(c, a, b[j], ctx); BN_copy(d, a); BN_GF2m_mod_mul(d, a, d, b[j], ctx); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " ^ 2 % "); - BN_print(bp, b[j]); - BIO_puts(bp, " = "); - BN_print(bp, c); - BIO_puts(bp, "; a * a = "); - BN_print(bp, d); - BIO_puts(bp, "\n"); - } - } -# endif BN_GF2m_add(d, c, d); /* Test that a*a = a^2. */ if (!BN_is_zero(d)) { @@ -1406,19 +1350,6 @@ int test_gf2m_mod_inv(BIO *bp, BN_CTX *ctx) for (j = 0; j < 2; j++) { BN_GF2m_mod_inv(c, a, b[j], ctx); BN_GF2m_mod_mul(d, a, c, b[j], ctx); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " * "); - BN_print(bp, c); - BIO_puts(bp, " - 1 % "); - BN_print(bp, b[j]); - BIO_puts(bp, "\n"); - } - } -# endif /* Test that ((1/a)*a) = 1. */ if (!BN_is_one(d)) { fprintf(stderr, "GF(2^m) modular inversion test failed!\n"); @@ -1461,21 +1392,6 @@ int test_gf2m_mod_div(BIO *bp, BN_CTX *ctx) BN_GF2m_mod_div(d, a, c, b[j], ctx); BN_GF2m_mod_mul(e, d, c, b[j], ctx); BN_GF2m_mod_div(f, a, e, b[j], ctx); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " = "); - BN_print(bp, c); - BIO_puts(bp, " * "); - BN_print(bp, d); - BIO_puts(bp, " % "); - BN_print(bp, b[j]); - BIO_puts(bp, "\n"); - } - } -# endif /* Test that ((a/c)*c)/a = 1. */ if (!BN_is_one(f)) { fprintf(stderr, "GF(2^m) modular division test failed!\n"); @@ -1523,25 +1439,6 @@ int test_gf2m_mod_exp(BIO *bp, BN_CTX *ctx) BN_GF2m_mod_mul(e, e, f, b[j], ctx); BN_add(f, c, d); BN_GF2m_mod_exp(f, a, f, b[j], ctx); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, a); - BIO_puts(bp, " ^ ("); - BN_print(bp, c); - BIO_puts(bp, " + "); - BN_print(bp, d); - BIO_puts(bp, ") = "); - BN_print(bp, e); - BIO_puts(bp, "; - "); - BN_print(bp, f); - BIO_puts(bp, " % "); - BN_print(bp, b[j]); - BIO_puts(bp, "\n"); - } - } -# endif BN_GF2m_add(f, e, f); /* Test that a^(c+d)=a^c*a^d. */ if (!BN_is_zero(f)) { @@ -1587,17 +1484,6 @@ int test_gf2m_mod_sqrt(BIO *bp, BN_CTX *ctx) BN_GF2m_mod(c, a, b[j]); BN_GF2m_mod_sqrt(d, a, b[j], ctx); BN_GF2m_mod_sqr(e, d, b[j], ctx); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, d); - BIO_puts(bp, " ^ 2 - "); - BN_print(bp, a); - BIO_puts(bp, "\n"); - } - } -# endif BN_GF2m_add(f, c, e); /* Test that d^2 = a, where d = sqrt(a). */ if (!BN_is_zero(f)) { @@ -1644,19 +1530,6 @@ int test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx) BN_GF2m_mod_sqr(d, c, b[j], ctx); BN_GF2m_add(d, c, d); BN_GF2m_mod(e, a, b[j]); -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BN_print(bp, c); - BIO_puts(bp, " is root of z^2 + z = "); - BN_print(bp, a); - BIO_puts(bp, " % "); - BN_print(bp, b[j]); - BIO_puts(bp, "\n"); - } - } -# endif BN_GF2m_add(e, e, d); /* * Test that solution of quadratic c satisfies c^2 + c = a. @@ -1667,19 +1540,6 @@ int test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx) goto err; } - } else { -# if 0 /* make test uses ouput in bc but bc can't - * handle GF(2^m) arithmetic */ - if (bp != NULL) { - if (!results) { - BIO_puts(bp, "There are no roots of z^2 + z = "); - BN_print(bp, a); - BIO_puts(bp, " % "); - BN_print(bp, b[j]); - BIO_puts(bp, "\n"); - } - } -# endif } } } diff --git a/crypto/cast/casttest.c b/crypto/cast/casttest.c index 9c6614bc8b..8063b9c2e1 100644 --- a/crypto/cast/casttest.c +++ b/crypto/cast/casttest.c @@ -112,34 +112,6 @@ static unsigned char c_b[16] = { 0x80, 0xAC, 0x05, 0xB8, 0xE8, 0x3D, 0x69, 0x6E }; -# if 0 -char *text = "Hello to all people out there"; - -static unsigned char cfb_key[16] = { - 0xe1, 0xf0, 0xc3, 0xd2, 0xa5, 0xb4, 0x87, 0x96, - 0x69, 0x78, 0x4b, 0x5a, 0x2d, 0x3c, 0x0f, 0x1e, -}; -static unsigned char cfb_iv[80] = - { 0x34, 0x12, 0x78, 0x56, 0xab, 0x90, 0xef, 0xcd }; -static unsigned char cfb_buf1[40], cfb_buf2[40], cfb_tmp[8]; -# define CFB_TEST_SIZE 24 -static unsigned char plain[CFB_TEST_SIZE] = { - 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, - 0x20, 0x74, 0x68, 0x65, 0x20, 0x74, - 0x69, 0x6d, 0x65, 0x20, 0x66, 0x6f, - 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 -}; - -static unsigned char cfb_cipher64[CFB_TEST_SIZE] = { - 0x59, 0xD8, 0xE2, 0x65, 0x00, 0x58, 0x6C, 0x3F, - 0x2C, 0x17, 0x25, 0xD0, 0x1A, 0x38, 0xB7, 0x2A, - 0x39, 0x61, 0x37, 0xDC, 0x79, 0xFB, 0x9F, 0x45 -/*- 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38, - 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9, - 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/ -}; -# endif - int main(int argc, char *argv[]) { # ifdef FULL_TEST diff --git a/crypto/des/destest.c b/crypto/des/destest.c index be68d36bcf..14f4dfe77c 100644 --- a/crypto/des/destest.c +++ b/crypto/des/destest.c @@ -345,12 +345,7 @@ static unsigned char ofb_cipher[24] = { 0x35, 0xf2, 0x4a, 0x24, 0x2e, 0xeb, 0x3d, 0x3f, 0x3d, 0x6d, 0x5b, 0xe3, 0x25, 0x5a, 0xf8, 0xc3 }; - -# if 0 -static DES_LONG cbc_cksum_ret = 0xB462FEF7L; -# else static DES_LONG cbc_cksum_ret = 0xF7FE62B4L; -# endif static unsigned char cbc_cksum_data[8] = { 0x1D, 0x26, 0x93, 0x97, 0xf7, 0xfe, 0x62, 0xb4 }; diff --git a/crypto/ec/ectest.c b/crypto/ec/ectest.c index a6be1a9556..fc04f3b3e1 100644 --- a/crypto/ec/ectest.c +++ b/crypto/ec/ectest.c @@ -114,93 +114,6 @@ int main(int argc, char *argv[]) # define TIMING_RAND_PT 1 # define TIMING_SIMUL 2 -# if 0 -static void timings(EC_GROUP *group, int type, BN_CTX *ctx) -{ - clock_t clck; - int i, j; - BIGNUM *s; - BIGNUM *r[10], *r0[10]; - EC_POINT *P; - - s = BN_new(); - if (s == NULL) - ABORT; - - fprintf(stdout, "Timings for %d-bit field, ", EC_GROUP_get_degree(group)); - if (!EC_GROUP_get_order(group, s, ctx)) - ABORT; - fprintf(stdout, "%d-bit scalars ", (int)BN_num_bits(s)); - fflush(stdout); - - P = EC_POINT_new(group); - if (P == NULL) - ABORT; - EC_POINT_copy(P, EC_GROUP_get0_generator(group)); - - for (i = 0; i < 10; i++) { - if ((r[i] = BN_new()) == NULL) - ABORT; - if (!BN_pseudo_rand(r[i], BN_num_bits(s), 0, 0)) - ABORT; - if (type != TIMING_BASE_PT) { - if ((r0[i] = BN_new()) == NULL) - ABORT; - if (!BN_pseudo_rand(r0[i], BN_num_bits(s), 0, 0)) - ABORT; - } - } - - clck = clock(); - for (i = 0; i < 10; i++) { - for (j = 0; j < 10; j++) { - if (!EC_POINT_mul - (group, P, (type != TIMING_RAND_PT) ? r[i] : NULL, - (type != TIMING_BASE_PT) ? P : NULL, - (type != TIMING_BASE_PT) ? r0[i] : NULL, ctx)) - ABORT; - } - } - clck = clock() - clck; - - fprintf(stdout, "\n"); - -# ifdef CLOCKS_PER_SEC - /* - * "To determine the time in seconds, the value returned by the clock - * function should be divided by the value of the macro CLOCKS_PER_SEC." - * -- ISO/IEC 9899 - */ -# define UNIT "s" -# else -# define UNIT "units" -# define CLOCKS_PER_SEC 1 -# endif - - if (type == TIMING_BASE_PT) { - fprintf(stdout, "%i %s in %.2f " UNIT "\n", i * j, - "base point multiplications", (double)clck / CLOCKS_PER_SEC); - } else if (type == TIMING_RAND_PT) { - fprintf(stdout, "%i %s in %.2f " UNIT "\n", i * j, - "random point multiplications", - (double)clck / CLOCKS_PER_SEC); - } else if (type == TIMING_SIMUL) { - fprintf(stdout, "%i %s in %.2f " UNIT "\n", i * j, - "s*P+t*Q operations", (double)clck / CLOCKS_PER_SEC); - } - fprintf(stdout, "average: %.4f " UNIT "\n", - (double)clck / (CLOCKS_PER_SEC * i * j)); - - EC_POINT_free(P); - BN_free(s); - for (i = 0; i < 10; i++) { - BN_free(r[i]); - if (type != TIMING_BASE_PT) - BN_free(r0[i]); - } -} -# endif - /* test multiplication with group order, long and negative scalars */ static void group_order_tests(EC_GROUP *group) { @@ -443,18 +356,6 @@ static void prime_field_tests(void) if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT; -# if 0 /* optional */ - { - EC_POINT *points[3]; - - points[0] = R; - points[1] = Q; - points[2] = P; - if (!EC_POINTs_make_affine(group, 2, points, ctx)) - ABORT; - } -# endif - } while (!EC_POINT_is_at_infinity(group, P)); @@ -952,27 +853,6 @@ static void prime_field_tests(void) BN_free(scalar3); } -# if 0 - timings(P_160, TIMING_BASE_PT, ctx); - timings(P_160, TIMING_RAND_PT, ctx); - timings(P_160, TIMING_SIMUL, ctx); - timings(P_192, TIMING_BASE_PT, ctx); - timings(P_192, TIMING_RAND_PT, ctx); - timings(P_192, TIMING_SIMUL, ctx); - timings(P_224, TIMING_BASE_PT, ctx); - timings(P_224, TIMING_RAND_PT, ctx); - timings(P_224, TIMING_SIMUL, ctx); - timings(P_256, TIMING_BASE_PT, ctx); - timings(P_256, TIMING_RAND_PT, ctx); - timings(P_256, TIMING_SIMUL, ctx); - timings(P_384, TIMING_BASE_PT, ctx); - timings(P_384, TIMING_RAND_PT, ctx); - timings(P_384, TIMING_SIMUL, ctx); - timings(P_521, TIMING_BASE_PT, ctx); - timings(P_521, TIMING_RAND_PT, ctx); - timings(P_521, TIMING_SIMUL, ctx); -# endif - if (ctx) BN_CTX_free(ctx); BN_free(p); @@ -1456,39 +1336,6 @@ static void char2_field_tests(void) fprintf(stdout, " ok\n\n"); } -# if 0 - timings(C2_K163, TIMING_BASE_PT, ctx); - timings(C2_K163, TIMING_RAND_PT, ctx); - timings(C2_K163, TIMING_SIMUL, ctx); - timings(C2_B163, TIMING_BASE_PT, ctx); - timings(C2_B163, TIMING_RAND_PT, ctx); - timings(C2_B163, TIMING_SIMUL, ctx); - timings(C2_K233, TIMING_BASE_PT, ctx); - timings(C2_K233, TIMING_RAND_PT, ctx); - timings(C2_K233, TIMING_SIMUL, ctx); - timings(C2_B233, TIMING_BASE_PT, ctx); - timings(C2_B233, TIMING_RAND_PT, ctx); - timings(C2_B233, TIMING_SIMUL, ctx); - timings(C2_K283, TIMING_BASE_PT, ctx); - timings(C2_K283, TIMING_RAND_PT, ctx); - timings(C2_K283, TIMING_SIMUL, ctx); - timings(C2_B283, TIMING_BASE_PT, ctx); - timings(C2_B283, TIMING_RAND_PT, ctx); - timings(C2_B283, TIMING_SIMUL, ctx); - timings(C2_K409, TIMING_BASE_PT, ctx); - timings(C2_K409, TIMING_RAND_PT, ctx); - timings(C2_K409, TIMING_SIMUL, ctx); - timings(C2_B409, TIMING_BASE_PT, ctx); - timings(C2_B409, TIMING_RAND_PT, ctx); - timings(C2_B409, TIMING_SIMUL, ctx); - timings(C2_K571, TIMING_BASE_PT, ctx); - timings(C2_K571, TIMING_RAND_PT, ctx); - timings(C2_K571, TIMING_SIMUL, ctx); - timings(C2_B571, TIMING_BASE_PT, ctx); - timings(C2_B571, TIMING_RAND_PT, ctx); - timings(C2_B571, TIMING_SIMUL, ctx); -# endif - if (ctx) BN_CTX_free(ctx); BN_free(p); @@ -1783,10 +1630,6 @@ static void nistp_single_test(const struct nistp_test_params *test) fprintf(stdout, "ok\n"); group_order_tests(NISTP); -# if 0 - timings(NISTP, TIMING_BASE_PT, ctx); - timings(NISTP, TIMING_RAND_PT, ctx); -# endif EC_GROUP_free(NISTP); EC_POINT_free(G); EC_POINT_free(P); diff --git a/crypto/ecdh/ecdhtest.c b/crypto/ecdh/ecdhtest.c index 5aed2b124b..41725f6a8d 100644 --- a/crypto/ecdh/ecdhtest.c +++ b/crypto/ecdh/ecdhtest.c @@ -92,10 +92,6 @@ int main(int argc, char *argv[]) # include # include -# if 0 -static void cb(int p, int n, void *arg); -# endif - static const char rnd_seed[] = "string to make the random number generator think it has entropy"; @@ -544,22 +540,4 @@ int main(int argc, char *argv[]) CRYPTO_mem_leaks_fp(stderr); EXIT(ret); } - -# if 0 -static void cb(int p, int n, void *arg) -{ - char c = '*'; - - if (p == 0) - c = '.'; - if (p == 1) - c = '+'; - if (p == 2) - c = '*'; - if (p == 3) - c = '\n'; - BIO_write((BIO *)arg, &c, 1); - (void)BIO_flush((BIO *)arg); -} -# endif #endif diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c index b356131d64..ea332ae34b 100644 --- a/crypto/evp/evp_test.c +++ b/crypto/evp/evp_test.c @@ -480,9 +480,6 @@ int main(int argc, char **argv) /* Load all compiled-in ENGINEs */ ENGINE_load_builtin_engines(); #endif -#if 0 - OPENSSL_config(); -#endif #ifndef OPENSSL_NO_ENGINE /* * Register all available ENGINE implementations of ciphers and digests. diff --git a/ssl/ssltest.c b/ssl/ssltest.c index 7bf7e5577d..3eb13e26dd 100644 --- a/ssl/ssltest.c +++ b/ssl/ssltest.c @@ -740,13 +740,6 @@ static int custom_ext_3_srv_add_cb(SSL *s, unsigned int ext_type, static char *cipher = NULL; static int verbose = 0; static int debug = 0; -#if 0 -/* Not used yet. */ -# ifdef FIONBIO -static int s_nbio = 0; -# endif -#endif - static const char rnd_seed[] = "string to make the random number generator think it has entropy"; @@ -754,6 +747,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long bytes, clock_t *s_time, clock_t *c_time); int doit(SSL *s_ssl, SSL *c_ssl, long bytes); static int do_test_cipherlist(void); + static void sv_usage(void) { fprintf(stderr, "usage: ssltest [args ...]\n"); @@ -2487,10 +2481,6 @@ static int verify_callback(int ok, X509_STORE_CTX *ctx) if (ok == 1) { X509 *xs = ctx->current_cert; -#if 0 - X509 *xi = ctx->current_issuer; -#endif - if (xs->ex_flags & EXFLAG_PROXY) { unsigned int *letters = X509_STORE_CTX_get_ex_data(ctx, get_proxy_auth_ex_data_idx -- 2.34.1