Pull the EC_GROUP_new_by_curve_name up into EVP_PKEY_CTX_set_ec_paramgen_curve_nid

ec_pkey_meth, and thus every all of EC EVP_PKEY logic, currently depends
on all supported curves by way of EC_GROUP_new_by_curve_name. In
reality, the only call pattern which depends on every curve is
"paramgem", when callers do:

    EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, nullptr);
    EVP_PKEY_paramgen_init(ctx);
    EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, NID_X9_62_prime256v1);
    EVP_PKEY_paramgen(ctx, &key);

This is a really roundabout way to get at a basically static object. EVP
is kinda cumbersome. The other pattern is keygen when you don't already
have an object that represents the curve, since OpenSSL does not provide
such a thing.

    EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, nullptr);
    EVP_PKEY_keygen_init(ctx);
    EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, NID_X9_62_prime256v1);
    EVP_PKEY_keygen(ctx, &key);

That one is harder to avoid because EVP does not provide a better way to
do this. Ideally our API would look more like
EVP_generate_ec_key(EC_group_p256()), or perhaps
EVP_PKEY_generate(EVP_pkey_ec_p256()) or something.

Either way, we can lift the dependency to
EVP_PKEY_CTX_set_ec_paramgen_curve_nid which is the function that
actually pulls in all curves, and then folks who don't use that pattern
aren't impacted. The other thing I considered was to make
EVP_PKEY_CTX_new_id(EVP_PKEY_EC) use a different method table from
EVP_PKEY_CTX_new(pkey), but this was really easy.

(We can do this because our EVP_PKEY_CTRL_* constants are completely
internal. We don't have to implement the same hooks that upstream does.)

Bug: 42290364
Change-Id: Ib223b966d1a48527088e1bb13435ac6dc2c11749
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81509
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Lily Chen <chlily@google.com>
Commit-Queue: Lily Chen <chlily@google.com>
2 files changed
tree: d468733d956019964f8ee35a8bb641d79b6faf0b
  1. .bcr/
  2. .github/
  3. cmake/
  4. crypto/
  5. decrepit/
  6. docs/
  7. fuzz/
  8. gen/
  9. include/
  10. infra/
  11. pki/
  12. rust/
  13. ssl/
  14. third_party/
  15. tool/
  16. util/
  17. .bazelignore
  18. .bazelrc
  19. .bazelversion
  20. .clang-format
  21. .gitignore
  22. API-CONVENTIONS.md
  23. AUTHORS
  24. BREAKING-CHANGES.md
  25. BUILD.bazel
  26. build.json
  27. BUILDING.md
  28. CMakeLists.txt
  29. codereview.settings
  30. CONTRIBUTING.md
  31. FUZZING.md
  32. go.mod
  33. go.sum
  34. INCORPORATING.md
  35. LICENSE
  36. MODULE.bazel
  37. MODULE.bazel.lock
  38. PORTING.md
  39. PrivacyInfo.xcprivacy
  40. README.md
  41. SANDBOXING.md
  42. STYLE.md
README.md

BoringSSL

BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.

Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.

Programs ship their own copies of BoringSSL when they use it and we update everything as needed when deciding to make API changes. This allows us to mostly avoid compromises in the name of compatibility. It works for us, but it may not work for you.

BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built up a large number of patches that were maintained while tracking upstream OpenSSL. As Google's product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved in maintaining all these patches in multiple places was growing steadily.

Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's not part of the NDK) and a number of other apps/programs.

Project links:

To file a security issue, use the Chromium process and mention in the report this is for BoringSSL. You can ignore the parts of the process that are specific to Chromium/Chrome.

There are other files in this directory which might be helpful: