Implement pkey_ec_keygen with EC_KEY APIs.

This removes the last caller of EVP_PKEY_copy_parameters within the
library.

Change-Id: I6af138d364973b18f52baf55c36c50a24a56bd44
Reviewed-on: https://boringssl-review.googlesource.com/6848
Reviewed-by: Adam Langley <alangley@gmail.com>
This commit is contained in:
David Benjamin 2015-12-24 21:07:32 -05:00 committed by Adam Langley
parent 692878a5f4
commit 4e98e5c903

View File

@ -211,13 +211,14 @@ static int pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) {
return 0;
}
EC_KEY *ec = EC_KEY_new();
if (!ec) {
if (ec == NULL ||
!EC_KEY_set_group(ec, EC_KEY_get0_group(ctx->pkey->pkey.ec)) ||
!EC_KEY_generate_key(ec)) {
EC_KEY_free(ec);
return 0;
}
EVP_PKEY_assign_EC_KEY(pkey, ec);
/* Note: if error return, pkey is freed by parent routine */
return EVP_PKEY_copy_parameters(pkey, ctx->pkey) &&
EC_KEY_generate_key(pkey->pkey.ec);
return 1;
}
const EVP_PKEY_METHOD ec_pkey_meth = {