diff options
author | Viktor Dukhovni <openssl-users@dukhovni.org> | 2015-04-16 07:50:03 +0200 |
---|---|---|
committer | Viktor Dukhovni <openssl-users@dukhovni.org> | 2015-04-16 19:44:59 +0200 |
commit | 61986d32f37cbaeaed08bd955ff27d35b72ea29a (patch) | |
tree | a93f68aa58dd5dea6550887b9f44796d92a5b183 /engines | |
parent | Remove code for deleted function from ssl.h (diff) | |
download | openssl-61986d32f37cbaeaed08bd955ff27d35b72ea29a.tar.xz openssl-61986d32f37cbaeaed08bd955ff27d35b72ea29a.zip |
Code style: space after 'if'
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'engines')
-rw-r--r-- | engines/ccgost/gost2001.c | 56 | ||||
-rw-r--r-- | engines/ccgost/gost_ameth.c | 18 | ||||
-rw-r--r-- | engines/ccgost/gost_sign.c | 27 | ||||
-rw-r--r-- | engines/e_sureware.c | 6 |
4 files changed, 55 insertions, 52 deletions
diff --git a/engines/ccgost/gost2001.c b/engines/ccgost/gost2001.c index 5c4efd6e57..83cc693f75 100644 --- a/engines/ccgost/gost2001.c +++ b/engines/ccgost/gost2001.c @@ -41,7 +41,7 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) BN_CTX *ctx = BN_CTX_new(); int ok = 0; - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } @@ -53,7 +53,7 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); q = BN_CTX_get(ctx); - if(!p || !a || !b || !x || !y || !q) { + if (!p || !a || !b || !x || !y || !q) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } @@ -64,7 +64,7 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) GOST_R_UNSUPPORTED_PARAMETER_SET); goto err; } - if(!BN_hex2bn(&p, params->p) + if (!BN_hex2bn(&p, params->p) || !BN_hex2bn(&a, params->a) || !BN_hex2bn(&b, params->b)) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, @@ -73,18 +73,18 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) } grp = EC_GROUP_new_curve_GFp(p, a, b, ctx); - if(!grp) { + if (!grp) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } P = EC_POINT_new(grp); - if(!P) { + if (!P) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } - if(!BN_hex2bn(&x, params->x) + if (!BN_hex2bn(&x, params->x) || !BN_hex2bn(&y, params->y) || !EC_POINT_set_affine_coordinates_GFp(grp, P, x, y, ctx) || !BN_hex2bn(&q, params->q)) { @@ -98,12 +98,12 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) fprintf(stderr, "\n"); #endif - if(!EC_GROUP_set_generator(grp, P, q, NULL)) { + if (!EC_GROUP_set_generator(grp, P, q, NULL)) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR); goto err; } EC_GROUP_set_curve_name(grp, params->nid); - if(!EC_KEY_set_group(eckey, grp)) { + if (!EC_KEY_set_group(eckey, grp)) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR); goto err; } @@ -134,7 +134,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) NULL, *e = NULL; EC_POINT *C = NULL; BN_CTX *ctx = BN_CTX_new(); - if(!ctx || !md) { + if (!ctx || !md) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -146,22 +146,22 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) goto err; } group = EC_KEY_get0_group(eckey); - if(!group) { + if (!group) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } order = BN_CTX_get(ctx); - if(!order || !EC_GROUP_get_order(group, order, ctx)) { + if (!order || !EC_GROUP_get_order(group, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } priv_key = EC_KEY_get0_private_key(eckey); - if(!priv_key) { + if (!priv_key) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } e = BN_CTX_get(ctx); - if(!e || !BN_mod(e, md, order, ctx)) { + if (!e || !BN_mod(e, md, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } @@ -177,7 +177,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) } k = BN_CTX_get(ctx); C = EC_POINT_new(group); - if(!k || !C) { + if (!k || !C) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -205,7 +205,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) goto err; } - if(!BN_nnmod(r, X, order, ctx)) { + if (!BN_nnmod(r, X, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } @@ -223,7 +223,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) goto err; } - if(!BN_mod_mul(tmp, priv_key, r, order, ctx) + if (!BN_mod_mul(tmp, priv_key, r, order, ctx) || !BN_mod_mul(tmp2, k, e, order, ctx) || !BN_mod_add(s, tmp, tmp2, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); @@ -234,14 +234,14 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) newsig->s = BN_dup(s); newsig->r = BN_dup(r); - if(!newsig->s || !newsig->r) { + if (!newsig->s || !newsig->r) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } ret = newsig; err: - if(ctx) { + if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } @@ -270,7 +270,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, const EC_POINT *pub_key = NULL; int ok = 0; - if(!ctx || !group) { + if (!ctx || !group) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -284,13 +284,13 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, X = BN_CTX_get(ctx); R = BN_CTX_get(ctx); v = BN_CTX_get(ctx); - if(!order || !e || !z1 || !z2 || !tmp || !X || !R || !v) { + if (!order || !e || !z1 || !z2 || !tmp || !X || !R || !v) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } pub_key = EC_KEY_get0_public_key(ec); - if(!pub_key || !EC_GROUP_get_order(group, order, ctx)) { + if (!pub_key || !EC_GROUP_get_order(group, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -304,7 +304,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, } md = hashsum2bn(dgst); - if(!md || !BN_mod(e, md, order, ctx)) { + if (!md || !BN_mod(e, md, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -319,7 +319,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, goto err; } v = BN_mod_inverse(v, e, order, ctx); - if(!v + if (!v || !BN_mod_mul(z1, sig->s, v, order, ctx) || !BN_sub(tmp, order, sig->r) || !BN_mod_mul(z2, tmp, v, order, ctx)) { @@ -347,7 +347,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_EC_LIB); goto err; } - if(!BN_mod(R, X, order, ctx)) { + if (!BN_mod(R, X, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -392,7 +392,7 @@ int gost2001_compute_public(EC_KEY *ec) return 0; } ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); goto err; } @@ -403,7 +403,7 @@ int gost2001_compute_public(EC_KEY *ec) } pub_key = EC_POINT_new(group); - if(!pub_key) { + if (!pub_key) { GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); goto err; } @@ -436,7 +436,7 @@ int gost2001_keygen(EC_KEY *ec) BIGNUM *order = BN_new(), *d = BN_new(); const EC_GROUP *group = EC_KEY_get0_group(ec); - if(!group || !EC_GROUP_get_order(group, order, NULL)) { + if (!group || !EC_GROUP_get_order(group, order, NULL)) { GOSTerr(GOST_F_GOST2001_KEYGEN, ERR_R_INTERNAL_ERROR); BN_free(d); BN_free(order); @@ -454,7 +454,7 @@ int gost2001_keygen(EC_KEY *ec) } while (BN_is_zero(d)); - if(!EC_KEY_set_private_key(ec, d)) { + if (!EC_KEY_set_private_key(ec, d)) { GOSTerr(GOST_F_GOST2001_KEYGEN, ERR_R_INTERNAL_ERROR); BN_free(d); BN_free(order); diff --git a/engines/ccgost/gost_ameth.c b/engines/ccgost/gost_ameth.c index c5ca44f3f7..b1615bfa6c 100644 --- a/engines/ccgost/gost_ameth.c +++ b/engines/ccgost/gost_ameth.c @@ -115,7 +115,7 @@ static int decode_gost_algor_params(EVP_PKEY *pkey, X509_ALGOR *palg) } param_nid = OBJ_obj2nid(gkp->key_params); GOST_KEY_PARAMS_free(gkp); - if(!EVP_PKEY_set_type(pkey, pkey_nid)) { + if (!EVP_PKEY_set_type(pkey, pkey_nid)) { GOSTerr(GOST_F_DECODE_GOST_ALGOR_PARAMS, ERR_R_INTERNAL_ERROR); return 0; } @@ -549,16 +549,16 @@ static int param_copy_gost01(EVP_PKEY *to, const EVP_PKEY *from) } if (!eto) { eto = EC_KEY_new(); - if(!eto) { + if (!eto) { GOSTerr(GOST_F_PARAM_COPY_GOST01, ERR_R_MALLOC_FAILURE); return 0; } - if(!EVP_PKEY_assign(to, EVP_PKEY_base_id(from), eto)) { + if (!EVP_PKEY_assign(to, EVP_PKEY_base_id(from), eto)) { GOSTerr(GOST_F_PARAM_COPY_GOST01, ERR_R_INTERNAL_ERROR); return 0; } } - if(!EC_KEY_set_group(eto, EC_KEY_get0_group(efrom))) { + if (!EC_KEY_set_group(eto, EC_KEY_get0_group(efrom))) { GOSTerr(GOST_F_PARAM_COPY_GOST01, ERR_R_INTERNAL_ERROR); return 0; } @@ -756,14 +756,16 @@ static int pub_encode_gost01(X509_PUBKEY *pub, const EVP_PKEY *pk) } X = BN_new(); Y = BN_new(); - if(!X || !Y) { + if (!X || !Y) { GOSTerr(GOST_F_PUB_ENCODE_GOST01, ERR_R_MALLOC_FAILURE); - if(X) BN_free(X); - if(Y) BN_free(Y); + if (X) + BN_free(X); + if (Y) + BN_free(Y); BN_free(order); return 0; } - if(!EC_POINT_get_affine_coordinates_GFp(EC_KEY_get0_group(ec), + if (!EC_POINT_get_affine_coordinates_GFp(EC_KEY_get0_group(ec), pub_key, X, Y, NULL)) { GOSTerr(GOST_F_PUB_ENCODE_GOST01, ERR_R_INTERNAL_ERROR); BN_free(X); diff --git a/engines/ccgost/gost_sign.c b/engines/ccgost/gost_sign.c index 1d7ed86da2..c2516ead0e 100644 --- a/engines/ccgost/gost_sign.c +++ b/engines/ccgost/gost_sign.c @@ -58,7 +58,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BIGNUM *md = hashsum2bn(dgst); /* check if H(M) mod q is zero */ BN_CTX *ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -71,7 +71,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) tmp = BN_CTX_get(ctx); k = BN_CTX_get(ctx); tmp2 = BN_CTX_get(ctx); - if(!tmp || !k || !tmp2) { + if (!tmp || !k || !tmp2) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -89,7 +89,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BN_mod_exp(tmp, dsa->g, k, dsa->p, ctx); if (!(newsig->r)) { newsig->r = BN_new(); - if(!newsig->r) { + if (!newsig->r) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -102,7 +102,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BN_mod_mul(tmp2, k, md, dsa->q, ctx); if (!newsig->s) { newsig->s = BN_new(); - if(!newsig->s) { + if (!newsig->s) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -114,11 +114,11 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) ret = newsig; err: BN_free(md); - if(ctx) { + if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } - if(!ret && newsig) { + if (!ret && newsig) { DSA_SIG_free(newsig); } return ret; @@ -169,7 +169,7 @@ int gost_do_verify(const unsigned char *dgst, int dgst_len, BIGNUM *tmp2 = NULL, *tmp3 = NULL; int ok = 0; BN_CTX *ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } @@ -189,7 +189,7 @@ int gost_do_verify(const unsigned char *dgst, int dgst_len, tmp2 = BN_CTX_get(ctx); tmp3 = BN_CTX_get(ctx); u = BN_CTX_get(ctx); - if(!tmp || !v || !q2 || !z1 || !z2 || !tmp2 || !tmp3 || !u) { + if (!tmp || !v || !q2 || !z1 || !z2 || !tmp2 || !tmp3 || !u) { GOSTerr(GOST_F_GOST_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } @@ -214,8 +214,9 @@ int gost_do_verify(const unsigned char *dgst, int dgst_len, GOSTerr(GOST_F_GOST_DO_VERIFY, GOST_R_SIGNATURE_MISMATCH); } err: - if(md) BN_free(md); - if(ctx) { + if (md) + BN_free(md); + if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } @@ -235,13 +236,13 @@ int gost94_compute_public(DSA *dsa) return 0; } ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST94_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); return 0; } dsa->pub_key = BN_new(); - if(!dsa->pub_key) { + if (!dsa->pub_key) { GOSTerr(GOST_F_GOST94_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); BN_CTX_free(ctx); return 0; @@ -293,7 +294,7 @@ int fill_GOST94_params(DSA *dsa, int nid) int gost_sign_keygen(DSA *dsa) { dsa->priv_key = BN_new(); - if(!dsa->priv_key) { + if (!dsa->priv_key) { GOSTerr(GOST_F_GOST_SIGN_KEYGEN, ERR_R_MALLOC_FAILURE); return 0; } diff --git a/engines/e_sureware.c b/engines/e_sureware.c index 5e1786ca0f..4580250d98 100644 --- a/engines/e_sureware.c +++ b/engines/e_sureware.c @@ -710,7 +710,7 @@ static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id, /* set public big nums */ rsatmp->e = BN_new(); rsatmp->n = BN_new(); - if(!rsatmp->e || !rsatmp->n) + if (!rsatmp->e || !rsatmp->n) goto err; bn_expand2(rsatmp->e, el / sizeof(BN_ULONG)); bn_expand2(rsatmp->n, el / sizeof(BN_ULONG)); @@ -752,7 +752,7 @@ static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id, dsatmp->p = BN_new(); dsatmp->q = BN_new(); dsatmp->g = BN_new(); - if(!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g) + if (!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g) goto err; bn_expand2(dsatmp->pub_key, el / sizeof(BN_ULONG)); bn_expand2(dsatmp->p, el / sizeof(BN_ULONG)); @@ -1018,7 +1018,7 @@ static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *from, int flen, } psign->r = BN_new(); psign->s = BN_new(); - if(!psign->r || !psign->s) + if (!psign->r || !psign->s) goto err; bn_expand2(psign->r, 20 / sizeof(BN_ULONG)); bn_expand2(psign->s, 20 / sizeof(BN_ULONG)); |