Skip to content

Commit d42bd7f

Browse files
committed
pkey, ssl: use EVP_PKEY_eq() instead of EVP_PKEY_cmp()
OpenSSL 3.0 renamed EVP_PKEY_cmp() to EVP_PKEY_eq() because that was a confusing name.
1 parent e93a5fd commit d42bd7f

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

ext/openssl/extconf.rb

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def find_openssl_library
178178
have_func("BN_check_prime")
179179
have_func("EVP_MD_CTX_get0_md")
180180
have_func("EVP_MD_CTX_get_pkey_ctx")
181+
have_func("EVP_PKEY_eq")
181182

182183
Logging::message "=== Checking done. ===\n"
183184

ext/openssl/openssl_missing.h

+4
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,8 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
231231
# endif
232232
#endif
233233

234+
#ifndef HAVE_EVP_PKEY_EQ
235+
# define EVP_PKEY_eq(a, b) EVP_PKEY_cmp(a, b)
236+
#endif
237+
234238
#endif /* _OSSL_OPENSSL_MISSING_H_ */

ext/openssl/ossl_pkey.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,14 @@ ossl_pkey_compare(VALUE self, VALUE other)
769769
if (EVP_PKEY_id(selfPKey) != EVP_PKEY_id(otherPKey))
770770
ossl_raise(rb_eTypeError, "cannot match different PKey types");
771771

772-
ret = EVP_PKEY_cmp(selfPKey, otherPKey);
772+
ret = EVP_PKEY_eq(selfPKey, otherPKey);
773773

774774
if (ret == 0)
775775
return Qfalse;
776776
else if (ret == 1)
777777
return Qtrue;
778778
else
779-
ossl_raise(ePKeyError, "EVP_PKEY_cmp");
779+
ossl_raise(ePKeyError, "EVP_PKEY_eq");
780780
}
781781

782782
/*

ext/openssl/ossl_ssl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ ossl_sslctx_add_certificate(int argc, VALUE *argv, VALUE self)
12291229
EVP_PKEY_free(pub_pkey);
12301230
if (!pub_pkey)
12311231
rb_raise(rb_eArgError, "certificate does not contain public key");
1232-
if (EVP_PKEY_cmp(pub_pkey, pkey) != 1)
1232+
if (EVP_PKEY_eq(pub_pkey, pkey) != 1)
12331233
rb_raise(rb_eArgError, "public key mismatch");
12341234

12351235
if (argc >= 3)

0 commit comments

Comments
 (0)