X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=engines%2Fccgost%2Fgost_ameth.c;h=5ca3a6e62954129f61f58be9cb9ae2fe0a341177;hp=bc4532558c69b077890391a0ec5a9e382f7e51c3;hb=75ebbd9aa411c5b8b19ded6ace2b34181566b56a;hpb=8817e2e0c998757d3bd036d7f45fe8d0a49fbe2d diff --git a/engines/ccgost/gost_ameth.c b/engines/ccgost/gost_ameth.c index bc4532558c..5ca3a6e629 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; } @@ -200,7 +200,7 @@ BIGNUM *gost_get0_priv_key(const EVP_PKEY *pkey) if (!ec) { return NULL; } - if (!(priv = EC_KEY_get0_private_key(ec))) + if ((priv = EC_KEY_get0_private_key(ec)) == NULL) return NULL; return (BIGNUM *)priv; } @@ -284,9 +284,7 @@ static void pkey_free_gost94(EVP_PKEY *key) static void pkey_free_gost01(EVP_PKEY *key) { - if (key->pkey.ec) { - EC_KEY_free(key->pkey.ec); - } + EC_KEY_free(key->pkey.ec); } /* ------------------ private key functions -----------------------------*/ @@ -527,12 +525,14 @@ static int param_copy_gost94(EVP_PKEY *to, const EVP_PKEY *from) dto = DSA_new(); EVP_PKEY_assign(to, EVP_PKEY_base_id(from), dto); } -#define COPYBIGNUM(a,b,x) if (a->x) BN_free(a->x); a->x=BN_dup(b->x); - COPYBIGNUM(dto, dfrom, p) - COPYBIGNUM(dto, dfrom, q) - COPYBIGNUM(dto, dfrom, g) + BN_free(dto->p); + dto->p = BN_dup(dfrom->p); + BN_free(dto->q); + dto->q = BN_dup(dfrom->q); + BN_free(dto->g); + dto->g = BN_dup(dfrom->g); - if (dto->priv_key) + if (dto->priv_key) gost94_compute_public(dto); return 1; } @@ -551,16 +551,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; } @@ -758,14 +758,14 @@ 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); + BN_free(X); + 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); @@ -848,9 +848,7 @@ static int pkey_bits_gost(const EVP_PKEY *pk) /* ---------------------- ASN1 METHOD for GOST MAC -------------------*/ static void mackey_free_gost(EVP_PKEY *pk) { - if (pk->pkey.ptr) { - OPENSSL_free(pk->pkey.ptr); - } + OPENSSL_free(pk->pkey.ptr); } static int mac_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)