From f9283b7125226e020af908825ee7ea347e976ad2 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 13 Sep 2015 13:51:13 +0000 Subject: style(9) grenade. --- src/regress/lib/libcrypto/ecdh/ecdhtest.c | 331 ++++++++++++++++-------------- 1 file changed, 178 insertions(+), 153 deletions(-) diff --git a/src/regress/lib/libcrypto/ecdh/ecdhtest.c b/src/regress/lib/libcrypto/ecdh/ecdhtest.c index 427957f709..eac7dab426 100644 --- a/src/regress/lib/libcrypto/ecdh/ecdhtest.c +++ b/src/regress/lib/libcrypto/ecdh/ecdhtest.c @@ -21,7 +21,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -82,8 +82,9 @@ #include static const int KDF1_SHA1_len = 20; -static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen) - { +static void * +KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen) +{ #ifndef OPENSSL_NO_SHA if (*outlen < SHA_DIGEST_LENGTH) return NULL; @@ -93,18 +94,19 @@ static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen) #else return NULL; #endif - } +} -static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) - { - EC_KEY *a=NULL; - EC_KEY *b=NULL; - BIGNUM *x_a=NULL, *y_a=NULL, - *x_b=NULL, *y_b=NULL; +static int +test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) +{ + EC_KEY *a = NULL; + EC_KEY *b = NULL; + BIGNUM *x_a = NULL, *y_a = NULL, + *x_b = NULL, *y_b = NULL; char buf[12]; - unsigned char *abuf=NULL,*bbuf=NULL; - int i,alen,blen,aout,bout,ret=0; + unsigned char *abuf = NULL, *bbuf = NULL; + int i, alen, blen, aout, bout, ret = 0; const EC_GROUP *group; a = EC_KEY_new_by_curve_name(nid); @@ -114,66 +116,67 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) group = EC_KEY_get0_group(a); - if ((x_a=BN_new()) == NULL) goto err; - if ((y_a=BN_new()) == NULL) goto err; - if ((x_b=BN_new()) == NULL) goto err; - if ((y_b=BN_new()) == NULL) goto err; + if ((x_a = BN_new()) == NULL) + goto err; + if ((y_a = BN_new()) == NULL) + goto err; + if ((x_b = BN_new()) == NULL) + goto err; + if ((y_b = BN_new()) == NULL) + goto err; - BIO_puts(out,"Testing key generation with "); - BIO_puts(out,text); + BIO_puts(out, "Testing key generation with "); + BIO_puts(out, text); (void)BIO_flush(out); - if (!EC_KEY_generate_key(a)) goto err; - - if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) - { + if (!EC_KEY_generate_key(a)) + goto err; + + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { if (!EC_POINT_get_affine_coordinates_GFp(group, - EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; - } + EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; + } #ifndef OPENSSL_NO_EC2M - else - { + else { if (!EC_POINT_get_affine_coordinates_GF2m(group, - EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; - } + EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; + } #endif - BIO_printf(out," ."); + BIO_printf(out, " ."); (void)BIO_flush(out); - if (!EC_KEY_generate_key(b)) goto err; + if (!EC_KEY_generate_key(b)) + goto err; - if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) - { - if (!EC_POINT_get_affine_coordinates_GFp(group, - EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; - } + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { + if (!EC_POINT_get_affine_coordinates_GFp(group, + EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; + } #ifndef OPENSSL_NO_EC2M - else - { - if (!EC_POINT_get_affine_coordinates_GF2m(group, - EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; - } + else { + if (!EC_POINT_get_affine_coordinates_GF2m(group, + EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; + } #endif - BIO_printf(out,"."); + BIO_printf(out, "."); (void)BIO_flush(out); - alen=KDF1_SHA1_len; - abuf=malloc(alen); - aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1); + alen = KDF1_SHA1_len; + abuf = malloc(alen); + aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), a, KDF1_SHA1); - BIO_printf(out,"."); + BIO_printf(out, "."); (void)BIO_flush(out); - blen=KDF1_SHA1_len; - bbuf=malloc(blen); - bout=ECDH_compute_key(bbuf,blen,EC_KEY_get0_public_key(a),b,KDF1_SHA1); + blen = KDF1_SHA1_len; + bbuf = malloc(blen); + bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), b, KDF1_SHA1); - BIO_printf(out,"."); + BIO_printf(out, "."); (void)BIO_flush(out); - if ((aout < 4) || (bout != aout) || (memcmp(abuf,bbuf,aout) != 0)) - { + if ((aout < 4) || (bout != aout) || (memcmp(abuf, bbuf, aout) != 0)) { BIO_printf(out, " failed\n\n"); BIO_printf(out, "key a:\n"); BIO_printf(out, "private key: "); @@ -193,114 +196,117 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) BN_print(out, y_b); BIO_printf(out, "\n"); BIO_printf(out, "generated key a: "); - for (i=0; i