void ECDSA_SIG_get0(BIGNUM **pr, BIGNUM **ps, ECDSA_SIG *sig)
{
- if (pr)
+ if (pr != NULL)
*pr = sig->r;
- if (ps)
+ if (ps != NULL)
*ps = sig->s;
}
EC_KEY_free(ret);
return NULL;
}
- if (ret->meth->set_group && ret->meth->set_group(ret, ret->group) == 0) {
+ if (ret->meth->set_group != NULL
+ && ret->meth->set_group(ret, ret->group) == 0) {
EC_KEY_free(ret);
return NULL;
}
}
#endif
- if (r->meth->finish)
+ if (r->meth->finish != NULL)
r->meth->finish(r);
#ifndef OPENSSL_NO_ENGINE
- if (r->engine)
+ if (r->engine != NULL)
ENGINE_finish(r->engine);
#endif
return NULL;
}
if (src->meth != dest->meth) {
- if (dest->meth->finish)
+ if (dest->meth->finish != NULL)
dest->meth->finish(dest);
#ifndef OPENSSL_NO_ENGINE
- if (dest->engine && ENGINE_finish(dest->engine) == 0)
+ if (dest->engine != NULL && ENGINE_finish(dest->engine) == 0)
return 0;
dest->engine = NULL;
#endif
}
/* copy the parameters */
- if (src->group) {
+ if (src->group != NULL) {
const EC_METHOD *meth = EC_GROUP_method_of(src->group);
/* clear the old group */
EC_GROUP_free(dest->group);
return NULL;
}
/* copy the public key */
- if (src->pub_key && src->group) {
+ if (src->pub_key != NULL && src->group != NULL) {
EC_POINT_free(dest->pub_key);
dest->pub_key = EC_POINT_new(src->group);
if (dest->pub_key == NULL)
return NULL;
}
/* copy the private key */
- if (src->priv_key) {
+ if (src->priv_key != NULL) {
if (dest->priv_key == NULL) {
dest->priv_key = BN_new();
if (dest->priv_key == NULL)
if (!EC_EX_DATA_set_data
(&dest->method_data, t, d->dup_func, d->free_func,
d->clear_free_func))
- return 0;
+ return NULL;
}
/* copy the rest */
if (src->meth != dest->meth) {
#ifndef OPENSSL_NO_ENGINE
- if (src->engine && ENGINE_init(src->engine) == 0)
- return 0;
+ if (src->engine != NULL && ENGINE_init(src->engine) == 0)
+ return NULL;
dest->engine = src->engine;
#endif
dest->meth = src->meth;
}
- if (src->meth->copy && src->meth->copy(dest, src) == 0)
- return 0;
+ if (src->meth->copy != NULL && src->meth->copy(dest, src) == 0)
+ return NULL;
return dest;
}
int EC_KEY_generate_key(EC_KEY *eckey)
{
- if (!eckey || !eckey->group) {
+ if (eckey == NULL || eckey->group == NULL) {
ECerr(EC_F_EC_KEY_GENERATE_KEY, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
- if (eckey->meth->keygen)
+ if (eckey->meth->keygen != NULL)
return eckey->meth->keygen(eckey);
ECerr(EC_F_EC_KEY_GENERATE_KEY, EC_R_OPERATION_NOT_SUPPORTED);
return 0;
const BIGNUM *order = NULL;
EC_POINT *point = NULL;
- if (!eckey || !eckey->group || !eckey->pub_key) {
+ if (eckey == NULL || eckey->group == NULL || eckey->pub_key == NULL) {
ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
* in case the priv_key is present : check if generator * priv_key ==
* pub_key
*/
- if (eckey->priv_key) {
+ if (eckey->priv_key != NULL) {
if (BN_cmp(eckey->priv_key, order) >= 0) {
ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_WRONG_ORDER);
goto err;
int tmp_nid, is_char_two = 0;
#endif
- if (!key || !key->group || !x || !y) {
+ if (key == NULL || key->group == NULL || x == NULL || y == NULL) {
ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,
ERR_R_PASSED_NULL_PARAMETER);
return 0;
int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)
{
- if (key->meth->set_group && key->meth->set_group(key, group) == 0)
+ if (key->meth->set_group != NULL && key->meth->set_group(key, group) == 0)
return 0;
EC_GROUP_free(key->group);
key->group = EC_GROUP_dup(group);
int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key)
{
- if (key->meth->set_private && key->meth->set_private(key, priv_key) == 0)
+ if (key->meth->set_private != NULL
+ && key->meth->set_private(key, priv_key) == 0)
return 0;
BN_clear_free(key->priv_key);
key->priv_key = BN_dup(priv_key);
int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key)
{
- if (key->meth->set_public && key->meth->set_public(key, pub_key) == 0)
+ if (key->meth->set_public != NULL
+ && key->meth->set_public(key, pub_key) == 0)
return 0;
EC_POINT_free(key->pub_key);
key->pub_key = EC_POINT_dup(pub_key, key->group);
}
ret->meth = EC_KEY_get_default_method();
#ifndef OPENSSL_NO_ENGINE
- if (engine) {
+ if (engine != NULL) {
if (!ENGINE_init(engine)) {
ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);
OPENSSL_free(ret);
ret->engine = engine;
} else
ret->engine = ENGINE_get_default_EC();
- if (ret->engine) {
+ if (ret->engine != NULL) {
ret->meth = ENGINE_get_EC(ret->engine);
- if (!ret->meth) {
+ if (ret->meth == NULL) {
ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);
ENGINE_finish(ret->engine);
OPENSSL_free(ret);
ret->version = 1;
ret->conv_form = POINT_CONVERSION_UNCOMPRESSED;
ret->references = 1;
- if (ret->meth->init && ret->meth->init(ret) == 0) {
+ if (ret->meth->init != NULL && ret->meth->init(ret) == 0) {
EC_KEY_free(ret);
return NULL;
}
void *(*KDF) (const void *in, size_t inlen, void *out,
size_t *outlen))
{
- if (eckey->meth->compute_key)
+ if (eckey->meth->compute_key != NULL)
return eckey->meth->compute_key(out, outlen, pub_key, eckey, KDF);
ECerr(EC_F_ECDH_COMPUTE_KEY, EC_R_OPERATION_NOT_SUPPORTED);
return 0;
ret = OPENSSL_zalloc(sizeof(*meth));
if (ret == NULL)
return NULL;
- if (meth)
+ if (meth != NULL)
*ret = *meth;
ret->flags |= EC_KEY_METHOD_DYNAMIC;
return ret;
goto err;
/* Ensure signature uses DER and doesn't have trailing garbage */
derlen = i2d_ECDSA_SIG(s, &der);
- if (derlen != sig_len || memcmp(sigbuf, der, derlen))
+ if (derlen != sig_len || memcmp(sigbuf, der, derlen) != 0)
goto err;
ret = ECDSA_do_verify(dgst, dgst_len, s, eckey);
err:
u2 = BN_CTX_get(ctx);
m = BN_CTX_get(ctx);
X = BN_CTX_get(ctx);
- if (!X) {
+ if (X == NULL) {
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);
goto err;
}
const BIGNUM *kinv, const BIGNUM *rp,
EC_KEY *eckey)
{
- if (eckey->meth->sign_sig)
+ if (eckey->meth->sign_sig != NULL)
return eckey->meth->sign_sig(dgst, dlen, kinv, rp, eckey);
ECerr(EC_F_ECDSA_DO_SIGN_EX, EC_R_OPERATION_NOT_SUPPORTED);
return NULL;
unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
const BIGNUM *r, EC_KEY *eckey)
{
- if (eckey->meth->sign)
+ if (eckey->meth->sign != NULL)
return eckey->meth->sign(type, dgst, dlen, sig, siglen, kinv, r, eckey);
ECerr(EC_F_ECDSA_SIGN_EX, EC_R_OPERATION_NOT_SUPPORTED);
return 0;
int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
BIGNUM **rp)
{
- if (eckey->meth->sign_setup)
+ if (eckey->meth->sign_setup != NULL)
return eckey->meth->sign_setup(eckey, ctx_in, kinvp, rp);
ECerr(EC_F_ECDSA_SIGN_SETUP, EC_R_OPERATION_NOT_SUPPORTED);
return 0;
int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
const ECDSA_SIG *sig, EC_KEY *eckey)
{
- if (eckey->meth->verify_sig)
+ if (eckey->meth->verify_sig != NULL)
return eckey->meth->verify_sig(dgst, dgst_len, sig, eckey);
ECerr(EC_F_ECDSA_DO_VERIFY, EC_R_OPERATION_NOT_SUPPORTED);
return 0;
int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
{
- if (eckey->meth->verify)
+ if (eckey->meth->verify != NULL)
return eckey->meth->verify(type, dgst, dgst_len, sigbuf, sig_len,
eckey);
ECerr(EC_F_ECDSA_VERIFY, EC_R_OPERATION_NOT_SUPPORTED);
return 0;
- return 0;
}
int ENGINE_register_EC(ENGINE *e)
{
- if (e->ec_meth)
+ if (e->ec_meth != NULL)
return engine_table_register(&dh_table,
engine_unregister_all_EC, e, &dummy_nid,
1, 0);
int ENGINE_set_default_EC(ENGINE *e)
{
- if (e->ec_meth)
+ if (e->ec_meth != NULL)
return engine_table_register(&dh_table,
engine_unregister_all_EC, e, &dummy_nid,
1, 1);