BoringSSL: Use EC_KEY_new_by_curve_name() to simplify implementation

There is no need to go through EC_GROUP_new_by_curve_name(),
EC_KEY_new(), and EC_KEY_set_group() when a single call to
EC_KEY_new_by_curve_name() takes care of all that.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2017-12-10 23:41:29 +02:00
parent a5da39607d
commit 7641d485db
2 changed files with 4 additions and 8 deletions

View file

@ -1068,7 +1068,6 @@ static EVP_PKEY * dpp_gen_keypair(const struct dpp_curve_params *curve)
{ {
#ifdef OPENSSL_IS_BORINGSSL #ifdef OPENSSL_IS_BORINGSSL
EVP_PKEY_CTX *kctx = NULL; EVP_PKEY_CTX *kctx = NULL;
const EC_GROUP *group;
EC_KEY *ec_params; EC_KEY *ec_params;
#else #else
EVP_PKEY_CTX *pctx, *kctx = NULL; EVP_PKEY_CTX *pctx, *kctx = NULL;
@ -1084,9 +1083,8 @@ static EVP_PKEY * dpp_gen_keypair(const struct dpp_curve_params *curve)
return NULL; return NULL;
} }
#ifdef OPENSSL_IS_BORINGSSL #ifdef OPENSSL_IS_BORINGSSL
group = EC_GROUP_new_by_curve_name(nid); ec_params = EC_KEY_new_by_curve_name(nid);
ec_params = EC_KEY_new(); if (!ec_params) {
if (!ec_params || EC_KEY_set_group(ec_params, group) != 1) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"DPP: Failed to generate EC_KEY parameters"); "DPP: Failed to generate EC_KEY parameters");
goto fail; goto fail;

View file

@ -1706,7 +1706,6 @@ struct crypto_ecdh * crypto_ecdh_init(int group)
struct crypto_ecdh *ecdh; struct crypto_ecdh *ecdh;
EVP_PKEY *params = NULL; EVP_PKEY *params = NULL;
#ifdef OPENSSL_IS_BORINGSSL #ifdef OPENSSL_IS_BORINGSSL
const EC_GROUP *ec_group;
EC_KEY *ec_params; EC_KEY *ec_params;
#else /* OPENSSL_IS_BORINGSSL */ #else /* OPENSSL_IS_BORINGSSL */
EVP_PKEY_CTX *pctx = NULL; EVP_PKEY_CTX *pctx = NULL;
@ -1722,9 +1721,8 @@ struct crypto_ecdh * crypto_ecdh_init(int group)
goto fail; goto fail;
#ifdef OPENSSL_IS_BORINGSSL #ifdef OPENSSL_IS_BORINGSSL
ec_group = EC_GROUP_new_by_curve_name(ecdh->ec->nid); ec_params = EC_KEY_new_by_curve_name(ecdh->ec->nid);
ec_params = EC_KEY_new(); if (!ec_params) {
if (!ec_params || EC_KEY_set_group(ec_params, ec_group) != 1) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"BoringSSL: Failed to generate EC_KEY parameters"); "BoringSSL: Failed to generate EC_KEY parameters");
goto fail; goto fail;