Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkey, ssl: use EVP_PKEY_eq() instead of EVP_PKEY_cmp()
Browse files Browse the repository at this point in the history
EVP_PKEY_cmp() has been renamed to EVP_PKEY_eq() in OpenSSL 3.0.0.
rhenium committed May 25, 2021
1 parent e90a2a5 commit a811750
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
@@ -176,6 +176,7 @@ def find_openssl_library
have_func("EVP_MD_CTX_get0_md")
have_func("EVP_PKEY_todata")
have_func("EVP_PKEY_dup")
have_func("EVP_PKEY_eq")

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

4 changes: 4 additions & 0 deletions ext/openssl/openssl_missing.h
Original file line number Diff line number Diff line change
@@ -223,4 +223,8 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
# define EVP_MD_CTX_get0_md(ctx) EVP_MD_CTX_md(ctx)
#endif

#ifndef HAVE_EVP_PKEY_EQ
# define EVP_PKEY_eq(a, b) EVP_PKEY_cmp(a, b)
#endif

#endif /* _OSSL_OPENSSL_MISSING_H_ */
4 changes: 2 additions & 2 deletions ext/openssl/ossl_pkey.c
Original file line number Diff line number Diff line change
@@ -936,14 +936,14 @@ ossl_pkey_compare(VALUE self, VALUE other)
if (EVP_PKEY_id(selfPKey) != EVP_PKEY_id(otherPKey))
ossl_raise(rb_eTypeError, "cannot match different PKey types");

ret = EVP_PKEY_cmp(selfPKey, otherPKey);
ret = EVP_PKEY_eq(selfPKey, otherPKey);

if (ret == 0)
return Qfalse;
else if (ret == 1)
return Qtrue;
else
ossl_raise(ePKeyError, "EVP_PKEY_cmp");
ossl_raise(ePKeyError, "EVP_PKEY_eq");
}

/*
2 changes: 1 addition & 1 deletion ext/openssl/ossl_ssl.c
Original file line number Diff line number Diff line change
@@ -1175,7 +1175,7 @@ ossl_sslctx_add_certificate(int argc, VALUE *argv, VALUE self)
EVP_PKEY_free(pub_pkey);
if (!pub_pkey)
rb_raise(rb_eArgError, "certificate does not contain public key");
if (EVP_PKEY_cmp(pub_pkey, pkey) != 1)
if (EVP_PKEY_eq(pub_pkey, pkey) != 1)
rb_raise(rb_eArgError, "public key mismatch");

if (argc >= 3)

0 comments on commit a811750

Please sign in to comment.