-
Notifications
You must be signed in to change notification settings - Fork 167
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 API to gather curve params from an OpenSSL::PKey::EC::Group
#432
base: master
Are you sure you want to change the base?
Conversation
To allow more detailed testing seperating these tests to align with the class hierarchy
This allows for gathering the field (needed for modulus match for the curve) and other curve parameters that could be set on a new group but not read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also added a comment about the design at #425 (comment).
Document the fallback of `field_type` Proper newlines Split declare initialize for C conformance Remove unneeded returns for `rb_raise`
* See the OpenSSL documentation for EC_METHOD_get_field_type(). | ||
* If the field type is GFp (NID_X9_62_prime_field) it will return :GFp | ||
* If the field type is GF2m (NID_X9_62_characteristic_two_field) it will return :GF2m | ||
* If OpenSSL returns any other value it will return the raw NID_X9_62 value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I commented in #425, I'd like to avoid the usage of :GFp
or :GF2m
symbols and simply use OBJ_nid2sn()
.
# frozen_string_literal: true | ||
require_relative 'utils' | ||
|
||
if defined?(OpenSSL) && defined?(OpenSSL::PKey::EC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this came from test_pkey_ec.rb
, but this is redundant. While you are at it, can you update it (and other occurrences in test_pkey_ec*.rb
) to simply
if defined?(OpenSSL) && defined?(OpenSSL::PKey::EC) | |
if defined?(OpenSSL::PKey::EC) |
} | ||
|
||
const EC_METHOD *method = EC_GROUP_method_of(group); | ||
int field_type_id = EC_METHOD_get_field_type(method); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable declarations need to be at the beginning of the block while we support Ruby <= 2.6.
|
||
/* | ||
* call-seq: | ||
* group.curve_params => Array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per #425, this returns Hash?
BIGNUM *pBN, *aBN, *bBN; | ||
|
||
GetECGroup(self, group); | ||
if (!group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!group
will not happen.
This is a basic read API for getting the EC params for a given explicit or named group instance.
Resolves #425