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

apps/speed.c: skip binary curves when compiling with NO_EC2M #8422

Closed
wants to merge 3 commits into from
Closed

apps/speed.c: skip binary curves when compiling with NO_EC2M #8422

wants to merge 3 commits into from

Conversation

ciz
Copy link
Contributor

@ciz ciz commented Mar 6, 2019

openssl speed doesn't take into account that the library could be compiled without the support for the binary curves and will happily uses them, which will results in EC_GROUP_new_by_curve_name() errors.

$ openssl speed -seconds 1 ecdh
[...]
Doing 521 bits ecdh's for 1s: 2355 521-bits ECDH ops in 1.00s
ECDH EC params init failure.
140292076904960:error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group:crypto/ec/ec_curve.c:3132:
140292076904960:error:100C508D:elliptic curve routines:pkey_ec_ctrl:invalid curve:crypto/ec/ec_pmeth.c:231:

The switch to enum from macros for defining constants is needed because of the following reason:

Just adding ifdefs isn't enough. Systems without SIGALRM need special care.
The ecdh_c array is allocated of the same size as ecdh_choices, whose size depends on whether the support for binary curves is enabled or not. (The same goes for ecdsa_c).
On systems without SIGALRM, ecdh_c is indexed by predefined constants (eg. R_EC_BRP256R1) intended for representing the index of the ciphers in the ecdh_choices array.
However, in case of NO_EC2M some of the #defined constants would become invalid because the size of the array shrunk. They would point after the ecdh_c array causing an out-of-bounds access.

Using enum instead of the macros to define the curve indexes will prevent the invalid access.

ciz added 3 commits March 6, 2019 17:55
openssl speed doesn't take into account that the library could be
compiled without the support for the binary curves and happily uses
them, which results in EC_GROUP_new_by_curve_name() errors.
The ecdh_c array is allocated of the same size as ecdh_choices,
whose size depends on whether the support for binary curves is enabled
or not.  (The same goes for ecdsa_c).
On systems without SIGALRM, ecdh_c is indexed by predefined constants
intended for representing the index of the ciphers in the ecdh_choices
array.
However, in case of NO_EC2M some of the #defined constants won't match
and would actually access the ecdh_c out-of-bounds.

Use enum instead of a macro to define the curve indexes so they're
within the bounds of the ecdh_c array.
@mattcaswell mattcaswell added branch: master Merge to master branch branch: 1.1.1 Merge to OpenSSL_1_1_1-stable branch labels Mar 7, 2019
@mattcaswell mattcaswell added the approval: review pending This pull request needs review by a committer label Mar 7, 2019
@paulidale paulidale added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Mar 12, 2019
levitte pushed a commit that referenced this pull request Mar 19, 2019
openssl speed doesn't take into account that the library could be
compiled without the support for the binary curves and happily uses
them, which results in EC_GROUP_new_by_curve_name() errors.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #8422)

(cherry picked from commit d61f489)
levitte pushed a commit that referenced this pull request Mar 19, 2019
The ecdh_c array is allocated of the same size as ecdh_choices,
whose size depends on whether the support for binary curves is enabled
or not.  (The same goes for ecdsa_c).
On systems without SIGALRM, ecdh_c is indexed by predefined constants
intended for representing the index of the ciphers in the ecdh_choices
array.
However, in case of NO_EC2M some of the #defined constants won't match
and would actually access the ecdh_c out-of-bounds.

Use enum instead of a macro to define the curve indexes so they're
within the bounds of the ecdh_c array.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #8422)

(cherry picked from commit f5c9916)
@mattcaswell
Copy link
Member

Pushed. Thanks.

levitte pushed a commit that referenced this pull request Mar 19, 2019
openssl speed doesn't take into account that the library could be
compiled without the support for the binary curves and happily uses
them, which results in EC_GROUP_new_by_curve_name() errors.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #8422)
levitte pushed a commit that referenced this pull request Mar 19, 2019
The ecdh_c array is allocated of the same size as ecdh_choices,
whose size depends on whether the support for binary curves is enabled
or not.  (The same goes for ecdsa_c).
On systems without SIGALRM, ecdh_c is indexed by predefined constants
intended for representing the index of the ciphers in the ecdh_choices
array.
However, in case of NO_EC2M some of the #defined constants won't match
and would actually access the ecdh_c out-of-bounds.

Use enum instead of a macro to define the curve indexes so they're
within the bounds of the ecdh_c array.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #8422)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: master Merge to master branch branch: 1.1.1 Merge to OpenSSL_1_1_1-stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants