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 API to gather curve params from an OpenSSL::PKey::EC::Group #432

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rickmark
Copy link
Contributor

This is a basic read API for getting the EC params for a given explicit or named group instance.

Resolves #425

Rick Mark added 2 commits March 30, 2021 16:21
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.
Copy link
Member

@rhenium rhenium left a 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).

ext/openssl/ossl_pkey_ec.c Outdated Show resolved Hide resolved
ext/openssl/ossl_pkey_ec.c Outdated Show resolved Hide resolved
test/openssl/test_pkey_ec_point.rb Outdated Show resolved Hide resolved
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
Copy link
Member

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)
Copy link
Member

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

Suggested change
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);
Copy link
Member

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
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!group will not happen.

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

Successfully merging this pull request may close these issues.

Create API to get curve parameters on a group
3 participants