}
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;
}
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;
}
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 -----------------------------*/
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;
}
}
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;
}
}
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);
/* ---------------------- 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)