diff options
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/ec2_smpl.c | 4 | ||||
-rw-r--r-- | crypto/ec/ec_ameth.c | 20 | ||||
-rw-r--r-- | crypto/ec/ec_asn1.c | 10 | ||||
-rw-r--r-- | crypto/ec/ec_key.c | 4 | ||||
-rw-r--r-- | crypto/ec/ec_lib.c | 12 | ||||
-rw-r--r-- | crypto/ec/ec_mult.c | 8 | ||||
-rw-r--r-- | crypto/ec/ec_pmeth.c | 6 | ||||
-rw-r--r-- | crypto/ec/eck_prn.c | 4 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp256.c | 2 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp521.c | 2 | ||||
-rw-r--r-- | crypto/ec/ecp_nistz256.c | 10 | ||||
-rw-r--r-- | crypto/ec/ecp_smpl.c | 4 |
12 files changed, 45 insertions, 41 deletions
diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c index d6a41a46bf..66bff0dadc 100644 --- a/crypto/ec/ec2_smpl.c +++ b/crypto/ec/ec2_smpl.c @@ -134,7 +134,7 @@ int ec_GF2m_simple_group_init(EC_GROUP *group) group->a = BN_new(); group->b = BN_new(); - if (!group->field || !group->a || !group->b) { + if (group->field == NULL || group->a == NULL || group->b == NULL) { BN_free(group->field); BN_free(group->a); BN_free(group->b); @@ -326,7 +326,7 @@ int ec_GF2m_simple_point_init(EC_POINT *point) point->Y = BN_new(); point->Z = BN_new(); - if (!point->X || !point->Y || !point->Z) { + if (point->X == NULL || point->Y == NULL || point->Z == NULL) { BN_free(point->X); BN_free(point->Y); BN_free(point->Z); diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index e2f32872c6..19932d541c 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -90,7 +90,7 @@ static int eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key) ASN1_STRING *pstr = NULL; pstr = ASN1_STRING_new(); - if (!pstr) + if (pstr == NULL) return 0; pstr->length = i2d_ECParameters(ec_key, &pstr->data); if (pstr->length <= 0) { @@ -120,7 +120,7 @@ static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) if (penclen <= 0) goto err; penc = OPENSSL_malloc(penclen); - if (!penc) + if (penc == NULL) goto err; p = penc; penclen = i2o_ECPublicKey(ec_key, &p); @@ -326,7 +326,7 @@ static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) return 0; } ep = OPENSSL_malloc(eplen); - if (!ep) { + if (ep == NULL) { EC_KEY_set_enc_flags(ec_key, old_flags); ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); return 0; @@ -359,7 +359,7 @@ static int ec_bits(const EVP_PKEY *pkey) const EC_GROUP *group; int ret; - if (!order) { + if (order == NULL) { ERR_clear_error(); return 0; } @@ -679,7 +679,7 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx, goto err; grp = EC_KEY_get0_group(pk->pkey.ec); ecpeer = EC_KEY_new(); - if (!ecpeer) + if (ecpeer == NULL) goto err; if (!EC_KEY_set_group(ecpeer, grp)) goto err; @@ -696,7 +696,7 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx, if (!o2i_ECPublicKey(&ecpeer, &p, plen)) goto err; pkpeer = EVP_PKEY_new(); - if (!pkpeer) + if (pkpeer == NULL) goto err; EVP_PKEY_set1_EC_KEY(pkpeer, ecpeer); if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0) @@ -864,7 +864,7 @@ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri) if (penclen <= 0) goto err; penc = OPENSSL_malloc(penclen); - if (!penc) + if (penc == NULL) goto err; p = penc; penclen = i2o_ECPublicKey(eckey, &p); @@ -922,11 +922,11 @@ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri) /* Package wrap algorithm in an AlgorithmIdentifier */ wrap_alg = X509_ALGOR_new(); - if (!wrap_alg) + if (wrap_alg == NULL) goto err; wrap_alg->algorithm = OBJ_nid2obj(wrap_nid); wrap_alg->parameter = ASN1_TYPE_new(); - if (!wrap_alg->parameter) + if (wrap_alg->parameter == NULL) goto err; if (EVP_CIPHER_param_to_asn1(ctx, wrap_alg->parameter) <= 0) goto err; @@ -955,7 +955,7 @@ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri) if (!penc || !penclen) goto err; wrap_str = ASN1_STRING_new(); - if (!wrap_str) + if (wrap_str == NULL) goto err; ASN1_STRING_set0(wrap_str, penc, penclen); penc = NULL; diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index bd6592b647..dacbdbf6ff 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -383,7 +383,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) goto err; char_two->p.tpBasis = ASN1_INTEGER_new(); - if (!char_two->p.tpBasis) { + if (char_two->p.tpBasis == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } @@ -398,7 +398,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) goto err; char_two->p.ppBasis = X9_62_PENTANOMIAL_new(); - if (!char_two->p.ppBasis) { + if (char_two->p.ppBasis == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } @@ -411,7 +411,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) /* for ONB the parameters are (asn1) NULL */ char_two->p.onBasis = ASN1_NULL_new(); - if (!char_two->p.onBasis) { + if (char_two->p.onBasis == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } @@ -1028,6 +1028,10 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) if (priv_key->privateKey) { if (ret->priv_key == NULL) ret->priv_key = BN_secure_new(); + if (ret->priv_key == NULL) { + ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); + goto err; + } ret->priv_key = BN_bin2bn(ASN1_STRING_data(priv_key->privateKey), ASN1_STRING_length(priv_key->privateKey), ret->priv_key); diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index ddb3257d77..d5706010ff 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -352,12 +352,12 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, return 0; } ctx = BN_CTX_new(); - if (!ctx) + if (ctx == NULL) goto err; point = EC_POINT_new(key->group); - if (!point) + if (point == NULL) goto err; tx = BN_CTX_get(ctx); diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 793645de8a..7cb4759f65 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -91,10 +91,10 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth) ret->meth = meth; ret->order = BN_new(); - if (!ret->order) + if (ret->order == NULL) goto err; ret->cofactor = BN_new(); - if (!ret->cofactor) + if (ret->cofactor == NULL) goto err; ret->asn1_flag = OPENSSL_EC_NAMED_CURVE; ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED; @@ -464,9 +464,9 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx) EC_GROUP_get_curve_name(a) != EC_GROUP_get_curve_name(b)) return 1; - if (!ctx) + if (ctx == NULL) ctx_new = ctx = BN_CTX_new(); - if (!ctx) + if (ctx == NULL) return -1; BN_CTX_start(ctx); @@ -476,7 +476,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx) b1 = BN_CTX_get(ctx); b2 = BN_CTX_get(ctx); b3 = BN_CTX_get(ctx); - if (!b3) { + if (b3 == NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx_new); return -1; @@ -1075,7 +1075,7 @@ int ec_precompute_mont_data(EC_GROUP *group) goto err; group->mont_data = BN_MONT_CTX_new(); - if (!group->mont_data) + if (group->mont_data == NULL) goto err; if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) { diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index a3d9885dcf..7e29397cba 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -101,7 +101,7 @@ static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group) return NULL; ret = OPENSSL_zalloc(sizeof(*ret)); - if (!ret) { + if (ret == NULL) { ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; } @@ -296,10 +296,10 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]); /* Ensure wNAF is initialised in case we end up going to err */ - if (wNAF) + if (wNAF != NULL) wNAF[0] = NULL; /* preliminary pivot */ - if (!wsize || !wNAF_len || !wNAF || !val_sub) { + if (wsize == NULL || wNAF_len == NULL || wNAF == NULL || val_sub == NULL) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); goto err; } @@ -657,7 +657,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) * and store */ points = OPENSSL_malloc(sizeof(*points) * (num + 1)); - if (!points) { + if (points == NULL) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index aa1fa9f53f..ecae0bfe26 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c @@ -93,7 +93,7 @@ static int pkey_ec_init(EVP_PKEY_CTX *ctx) EC_PKEY_CTX *dctx; dctx = OPENSSL_zalloc(sizeof(*dctx)); - if (!dctx) + if (dctx == NULL) return 0; dctx->cofactor_mode = -1; @@ -248,7 +248,7 @@ static int pkey_ec_kdf_derive(EVP_PKEY_CTX *ctx, if (!pkey_ec_derive(ctx, NULL, &ktmplen)) return 0; ktmp = OPENSSL_malloc(ktmplen); - if (!ktmp) + if (ktmp == NULL) return 0; if (!pkey_ec_derive(ctx, ktmp, &ktmplen)) goto err; @@ -442,7 +442,7 @@ static int pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) return 0; } ec = EC_KEY_new(); - if (!ec) + if (ec == NULL) return 0; ret = EC_KEY_set_group(ec, dctx->gen_group); if (ret) diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c index f1248b8da9..b9653ac9f9 100644 --- a/crypto/ec/eck_prn.c +++ b/crypto/ec/eck_prn.c @@ -119,7 +119,7 @@ int EC_KEY_print(BIO *bp, const EC_KEY *x, int off) EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) + if (pk == NULL || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) return 0; ret = EVP_PKEY_print_private(bp, pk, off, NULL); EVP_PKEY_free(pk); @@ -131,7 +131,7 @@ int ECParameters_print(BIO *bp, const EC_KEY *x) EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) + if (pk == NULL || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) return 0; ret = EVP_PKEY_print_params(bp, pk, 4, NULL); EVP_PKEY_free(pk); diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index 110984b125..48ed2c452e 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -1817,7 +1817,7 @@ static NISTP256_PRE_COMP *nistp256_pre_comp_new() { NISTP256_PRE_COMP *ret = NULL; ret = OPENSSL_malloc(sizeof(*ret)); - if (!ret) { + if (ret == NULL) { ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; } diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index febf5e94b7..dd5b19b581 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -1646,7 +1646,7 @@ static NISTP521_PRE_COMP *nistp521_pre_comp_new() { NISTP521_PRE_COMP *ret = OPENSSL_zalloc(sizeof(*ret)); - if (!ret) { + if (ret == NULL) { ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; } diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c index 503606085f..3d83303349 100644 --- a/crypto/ec/ecp_nistz256.c +++ b/crypto/ec/ecp_nistz256.c @@ -1102,10 +1102,10 @@ __owur static int ecp_nistz256_set_from_affine(EC_POINT *out, const EC_GROUP *gr int ret = 0; x = BN_new(); - if (!x) + if (x == NULL) return 0; y = BN_new(); - if (!y) { + if (y == NULL) { BN_free(x); return 0; } @@ -1305,13 +1305,13 @@ __owur static int ecp_nistz256_points_mul(const EC_GROUP *group, * handled like a normal point. */ new_scalars = OPENSSL_malloc((num + 1) * sizeof(BIGNUM *)); - if (!new_scalars) { + if (new_scalars == NULL) { ECerr(EC_F_ECP_NISTZ256_POINTS_MUL, ERR_R_MALLOC_FAILURE); goto err; } new_points = OPENSSL_malloc((num + 1) * sizeof(EC_POINT *)); - if (!new_points) { + if (new_points == NULL) { ECerr(EC_F_ECP_NISTZ256_POINTS_MUL, ERR_R_MALLOC_FAILURE); goto err; } @@ -1410,7 +1410,7 @@ static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group) ret = OPENSSL_malloc(sizeof(*ret)); - if (!ret) { + if (ret == NULL) { ECerr(EC_F_ECP_NISTZ256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; } diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index df7314a73a..a4830cb006 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -132,7 +132,7 @@ int ec_GFp_simple_group_init(EC_GROUP *group) group->field = BN_new(); group->a = BN_new(); group->b = BN_new(); - if (!group->field || !group->a || !group->b) { + if (group->field == NULL || group->a == NULL || group->b == NULL) { BN_free(group->field); BN_free(group->a); BN_free(group->b); @@ -359,7 +359,7 @@ int ec_GFp_simple_point_init(EC_POINT *point) point->Z = BN_new(); point->Z_is_one = 0; - if (!point->X || !point->Y || !point->Z) { + if (point->X == NULL || point->Y == NULL || point->Z == NULL) { BN_free(point->X); BN_free(point->Y); BN_free(point->Z); |