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

crypto: add KeyObject.prototype.equals method #42093

Merged
merged 15 commits into from
Feb 26, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! crypto: add KeyObject.prototype.equals method
panva committed Feb 24, 2022
commit 8b4be299e2009bf195762bcc8349f84fa42638a5
11 changes: 6 additions & 5 deletions src/crypto/crypto_keys.cc
Original file line number Diff line number Diff line change
@@ -1165,15 +1165,16 @@ void KeyObjectHandle::Equals(const FunctionCallbackInfo<Value>& args) {
case kKeyTypePrivate: {
EVP_PKEY* pkey = key->GetAsymmetricKey().get();
EVP_PKEY* pkey2 = key2->GetAsymmetricKey().get();
if (EVP_PKEY_id(pkey) == EVP_PKEY_id(pkey2)) {
#if OPENSSL_VERSION_MAJOR >= 3
ret = EVP_PKEY_eq(pkey, pkey2) == 1;
int ok = EVP_PKEY_eq(pkey, pkey2);
#else
ret = EVP_PKEY_cmp(pkey, pkey2) == 1;
int ok = EVP_PKEY_cmp(pkey, pkey2);
#endif
} else {
ret = false;
if (ok == -2) {
Environment* env = Environment::GetCurrent(args);
return THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env);
}
ret = ok == 1;
break;
}
default: