From: Bodo Möller Date: Wed, 6 Nov 2002 11:48:09 +0000 (+0000) Subject: print less output (no details unless a test failed) X-Git-Tag: OpenSSL_0_9_7-beta4~18^2~80 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=e2916b254038aabe577c3a7812a83f7a9bc3a371 print less output (no details unless a test failed) Submitted by: Nils Larsch --- diff --git a/crypto/ecdh/ecdhtest.c b/crypto/ecdh/ecdhtest.c index c51731917d..1b9648f065 100644 --- a/crypto/ecdh/ecdhtest.c +++ b/crypto/ecdh/ecdhtest.c @@ -113,7 +113,8 @@ int test_ecdh_curve(int nid, char *text, BN_CTX *ctx, BIO *out) { EC_KEY *a=NULL; EC_KEY *b=NULL; - BIGNUM *x=NULL, *y=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; @@ -124,51 +125,71 @@ int test_ecdh_curve(int nid, char *text, BN_CTX *ctx, BIO *out) if ((b=EC_KEY_new()) == NULL) goto err; b->group = a->group; - if ((x=BN_new()) == NULL) goto err; - if ((y=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); +#ifdef NOISY BIO_puts(out,"\n"); +#else + BIO_flush(out); +#endif if (!EC_KEY_generate_key(a)) goto err; - BIO_puts(out," pri 1="); - BN_print(out,a->priv_key); - BIO_puts(out,"\n pub 1="); + if (EC_METHOD_get_field_type(EC_GROUP_method_of(a->group)) == NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(a->group, a->pub_key, x, y, ctx)) goto err; + if (!EC_POINT_get_affine_coordinates_GFp(a->group, a->pub_key, x_a, y_a, ctx)) goto err; } else { - if (!EC_POINT_get_affine_coordinates_GF2m(a->group, a->pub_key, x, y, ctx)) goto err; + if (!EC_POINT_get_affine_coordinates_GF2m(a->group, a->pub_key, x_a, y_a, ctx)) goto err; } - BN_print(out,x); +#ifdef NOISY + BIO_puts(out," pri 1="); + BN_print(out,a->priv_key); + BIO_puts(out,"\n pub 1="); + BN_print(out,x_a); BIO_puts(out,","); - BN_print(out,y); + BN_print(out,y_a); BIO_puts(out,"\n"); +#else + BIO_printf(out," ."); + BIO_flush(out); +#endif if (!EC_KEY_generate_key(b)) goto err; - BIO_puts(out," pri 2="); - BN_print(out,b->priv_key); - BIO_puts(out,"\n pub 2="); + if (EC_METHOD_get_field_type(EC_GROUP_method_of(b->group)) == NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(b->group, b->pub_key, x, y, ctx)) goto err; + if (!EC_POINT_get_affine_coordinates_GFp(b->group, b->pub_key, x_b, y_b, ctx)) goto err; } else { - if (!EC_POINT_get_affine_coordinates_GF2m(a->group, b->pub_key, x, y, ctx)) goto err; + if (!EC_POINT_get_affine_coordinates_GF2m(a->group, b->pub_key, x_b, y_b, ctx)) goto err; } - BN_print(out,x); + +#ifdef NOISY + BIO_puts(out," pri 2="); + BN_print(out,b->priv_key); + BIO_puts(out,"\n pub 2="); + BN_print(out,x_b); BIO_puts(out,","); - BN_print(out,y); + BN_print(out,y_b); BIO_puts(out,"\n"); +#else + BIO_printf(out,"."); + BIO_flush(out); +#endif alen=ECDH_size(a); abuf=(unsigned char *)OPENSSL_malloc(alen); aout=ECDH_compute_key(abuf,b->pub_key,a); +#ifdef NOISY BIO_puts(out," key1 ="); for (i=0; ipub_key,b); +#ifdef NOISY BIO_puts(out," key2 ="); for (i=0; ipriv_key); + BIO_printf(out, "\n"); + BIO_printf(out, "public key (x,y): "); + BN_print(out, x_a); + BIO_printf(out, ","); + BN_print(out, y_a); + BIO_printf(out, "\nkey b:\n"); + BIO_printf(out, "private key: "); + BN_print(out, b->priv_key); + BIO_printf(out, "\n"); + BIO_printf(out, "public key (x,y): "); + BN_print(out, x_b); + BIO_printf(out, ","); + BN_print(out, y_b); + BIO_printf(out, "\n"); + BIO_printf(out, "generated key a: "); + for (i=0; igroup) EC_GROUP_free(a->group); a->group = b->group = NULL; if (b) EC_KEY_free(b);