diff options
author | Joe Truba <joe@bannable.net> | 2022-11-19 21:46:49 +0000 |
---|---|---|
committer | Joe Truba <joe@bannable.net> | 2022-11-23 06:37:57 +0000 |
commit | e1e8f3cebe37c7ba032388fef7ce127a17903d30 (patch) | |
tree | 04518f37acd8b3e80515d7c12cbc0dbc84cfd3bb /ext | |
parent | de8a644bc45b5441a14bd62f7ecc8b2bea2aba88 (diff) | |
download | ruby-openssl-e1e8f3cebe37c7ba032388fef7ce127a17903d30.tar.gz |
raise when EC_POINT_cmp or EC_GROUP_cmp error instead of returning true
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl_pkey_ec.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c index 1d105abd..3ea35f8a 100644 --- a/ext/openssl/ossl_pkey_ec.c +++ b/ext/openssl/ossl_pkey_ec.c @@ -860,10 +860,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"); + } } /* @@ -1424,10 +1425,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; } /* |