Skip to content

Commit

Permalink
Merge branch 'maint-2.2' into maint-3.0
Browse files Browse the repository at this point in the history
* maint-2.2:
  Ruby/OpenSSL 2.2.3
  ts: use TS_VERIFY_CTX_set_certs instead of TS_VERIFY_CTS_set_certs
  ocsp: disable OCSP_basic_verify() workaround on LibreSSL 3.5
  Actions - update workflow to use OpenSSL 1.1.1, actions/checkout@v3
  pkey/ec: fix ossl_raise() calls using cEC_POINT instead of eEC_POINT
  raise when EC_POINT_cmp or EC_GROUP_cmp error instead of returning true
  • Loading branch information
rhenium committed Dec 23, 2022
2 parents 1f4c9d8 + 04acccd commit 10f8d69
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
# ubuntu-latest is 22.04, uses OpenSSL 3
os: [ ubuntu-20.04, macos-latest ]
ruby: [ head, "3.0", "2.7", "2.6" ]
steps:
- name: repo checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: load ruby
uses: ruby/setup-ruby@v1
Expand All @@ -38,10 +39,11 @@ jobs:
fail-fast: false
matrix:
os: [ windows-latest ]
ruby: [ mswin, mingw, "3.0", "2.7", "2.6" ]
# current mswin build uses OpenSSL 3
ruby: [ mingw, "3.0", "2.7", "2.6" ]
steps:
- name: repo checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: load ruby, install/update gcc, install openssl
uses: MSP-Greg/setup-ruby-pkgs@v1
Expand Down Expand Up @@ -80,7 +82,7 @@ jobs:
- libressl-3.3.4
steps:
- name: repo checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: prepare openssl
run: |
Expand Down
15 changes: 15 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ Notable changes
[[GitHub #342]](https://github.com/ruby/openssl/issues/342)


Version 2.2.3
=============

Bug fixes
---------

* Fix serveral methods in OpenSSL::PKey::EC::Point attempting to raise an error
with an incorrect class, which would end up with a TypeError.
[[GitHub #570]](https://github.com/ruby/openssl/pull/570)
* Fix OpenSSL::PKey::EC::Point#eql? and OpenSSL::PKey::EC::Group#eql?
incorrectly treated OpenSSL's internal errors as "not equal".
[[GitHub #564]](https://github.com/ruby/openssl/pull/564)
* Fix build with LibreSSL 3.5 or later.


Version 2.2.2
=============

Expand Down
28 changes: 16 additions & 12 deletions ext/openssl/ossl_pkey_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,11 @@ static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
GetECGroup(a, group1);
GetECGroup(b, group2);

if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1)
return Qfalse;

return Qtrue;
switch (EC_GROUP_cmp(group1, group2, ossl_bn_ctx)) {
case 0: return Qtrue;
case 1: return Qfalse;
default: ossl_raise(eEC_GROUP, "EC_GROUP_cmp");
}
}

/*
Expand Down Expand Up @@ -1244,10 +1245,13 @@ static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
GetECPoint(b, point2);
GetECGroup(group_v1, group);

if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1)
return Qfalse;
switch (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx)) {
case 0: return Qtrue;
case 1: return Qfalse;
default: ossl_raise(eEC_POINT, "EC_POINT_cmp");
}

return Qtrue;
UNREACHABLE;
}

/*
Expand All @@ -1265,7 +1269,7 @@ static VALUE ossl_ec_point_is_at_infinity(VALUE self)
switch (EC_POINT_is_at_infinity(group, point)) {
case 1: return Qtrue;
case 0: return Qfalse;
default: ossl_raise(cEC_POINT, "EC_POINT_is_at_infinity");
default: ossl_raise(eEC_POINT, "EC_POINT_is_at_infinity");
}

UNREACHABLE;
Expand All @@ -1286,7 +1290,7 @@ static VALUE ossl_ec_point_is_on_curve(VALUE self)
switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) {
case 1: return Qtrue;
case 0: return Qfalse;
default: ossl_raise(cEC_POINT, "EC_POINT_is_on_curve");
default: ossl_raise(eEC_POINT, "EC_POINT_is_on_curve");
}

UNREACHABLE;
Expand All @@ -1309,7 +1313,7 @@ static VALUE ossl_ec_point_make_affine(VALUE self)
rb_warn("OpenSSL::PKey::EC::Point#make_affine! is deprecated");
#if !OSSL_OPENSSL_PREREQ(3, 0, 0)
if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
ossl_raise(cEC_POINT, "EC_POINT_make_affine");
ossl_raise(eEC_POINT, "EC_POINT_make_affine");
#endif

return self;
Expand All @@ -1328,7 +1332,7 @@ static VALUE ossl_ec_point_invert(VALUE self)
GetECPointGroup(self, group);

if (EC_POINT_invert(group, point, ossl_bn_ctx) != 1)
ossl_raise(cEC_POINT, "EC_POINT_invert");
ossl_raise(eEC_POINT, "EC_POINT_invert");

return self;
}
Expand All @@ -1346,7 +1350,7 @@ static VALUE ossl_ec_point_set_to_infinity(VALUE self)
GetECPointGroup(self, group);

if (EC_POINT_set_to_infinity(group, point) != 1)
ossl_raise(cEC_POINT, "EC_POINT_set_to_infinity");
ossl_raise(eEC_POINT, "EC_POINT_set_to_infinity");

return self;
}
Expand Down

0 comments on commit 10f8d69

Please sign in to comment.