Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mutable EC_GROUP API for OpenSSL compatibility #1860

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

samuel40791765
Copy link
Contributor

Issues:

Addresses CryptoAlg-2547

Description of changes:

Further investigation led us to discover that Ruby depends on mutable EC_GROUPs from OpenSSL. These were made immutable with the introduction of our default static EC_GROUP curves, which have been beneficial for us and our existing consumers. This was done by making the mutable portions of EC_GROUPs no-ops (EC_GROUP_set_asn1_flag and EC_GROUP_set_point_conversion_form), which OpenSSL couldn't do due to their more complex use case.

Ruby (and possibly other dynamic languages) mutates the data being stored in EC_GROUP and depends on it for subsequent operations. Since our default groups are static and immutable, this causes issues when integrating with Ruby. We don't want to sacrifice the benefits of static groups and reversing the optional call to EC_GROUP_free is a dangerously silent memory leak.
We've decided to introduce a special API for mutable EC_GROUPs for our default curves. This gives us a path forward for Ruby and keeps the benefits of static curves for existing consumers. Custom curves are already dynamically allocated so they don't need another special API, but the additional complexities for maintaining the underlying generator warrant another commit separate from this.

Call-outs:

  1. Custom curves aren't mutable just yet, but will be in another PR.
  2. It would be nice to get additional verification that the bookkeeping in EC_GROUP_dup and EC_GROUP_cmp were done right.

Testing:

Extended against tests using existing EC_GROUPs and conversion formats. These were focused on retrieving the conv_form from the EC_GROUP to use.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 93.70079% with 8 lines in your changes missing coverage. Please review.

Project coverage is 78.42%. Comparing base (9d21f38) to head (7776e4e).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
crypto/fipsmodule/ec/ec.c 91.46% 7 Missing ⚠️
crypto/fipsmodule/ec/ec_key.c 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1860      +/-   ##
==========================================
- Coverage   78.51%   78.42%   -0.09%     
==========================================
  Files         583      585       +2     
  Lines       98809    99505     +696     
  Branches    14159    14244      +85     
==========================================
+ Hits        77583    78041     +458     
- Misses      20598    20829     +231     
- Partials      628      635       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants