|| (group = EC_KEY_get0_group(eckey)) == NULL
|| (nid = EC_GROUP_get_curve_name(group)) == 0)
goto end;
- if (nid == NID_sm2)
- EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2);
+ if (nid == NID_sm2
+ && !EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2))
+ goto end;
}
#endif
*pkeysize = EVP_PKEY_size(pkey);
return 80;
if (L == 2048 && (N == 224 || N == 256))
return 112;
- if (L == 2048 && N == 256)
- return 112;
if (L == 3072 && N == 256)
return 128;
}
EVP_MD_CTX *mctx = NULL;
int mdsize;
+ mdsize = EVP_MD_size(evpmd);
+ if (mdsize <= 0)
+ return 0;
+
mctx = EVP_MD_CTX_new();
if (mctx == NULL)
- goto err;
+ return 0;
- mdsize = EVP_MD_size(evpmd);
- if (mdsize <= 0)
- goto err;
/*
* A.2.3 Step (4) & (5)
* A.2.4 Step (6) & (7)
|| !EVP_DigestFinal_ex(mctx, md, NULL)
|| (BN_bin2bn(md, mdsize, tmp) == NULL)
|| !BN_mod_exp_mont(g, tmp, e, p, ctx, mont))
- return 0;
+ break; /* exit on failure */
/*
* A.2.3 Step (10)
* A.2.4 Step (12)
break; /* found g */
}
}
-err:
EVP_MD_CTX_free(mctx);
return ret;
}
if (seed != params->seed)
OPENSSL_free(seed);
OPENSSL_free(seed_tmp);
- if (ctx)
+ if (ctx != NULL)
BN_CTX_end(ctx);
BN_CTX_free(ctx);
BN_MONT_CTX_free(mont);
/* initialize cipher/digest methods table */
if (!ssl_load_ciphers(ret))
- return 0;
+ goto err2;
if (!SSL_CTX_set_ciphersuites(ret, OSSL_default_ciphersuites()))
goto err;