From 2b354223d44daa5068cfc90266312e3c2fbb991b Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 26 Feb 2022 14:51:09 +0100 Subject: [PATCH] crypto: add KeyObject.prototype.equals method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/42093 Reviewed-By: Ben Noordhuis Reviewed-By: Tobias Nießen --- doc/api/crypto.md | 14 +++++++ lib/internal/crypto/keys.js | 10 +++++ src/crypto/crypto_keys.cc | 50 ++++++++++++++++++++++++ src/crypto/crypto_keys.h | 1 + test/parallel/test-crypto-key-objects.js | 49 +++++++++++++++++++++++ 5 files changed, 124 insertions(+) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index c361dd02ea13ce..50fbd1dd29ba43 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -2082,6 +2082,20 @@ encryption mechanism, PEM-level encryption is not supported when encrypting a PKCS#8 key. See [RFC 5208][] for PKCS#8 encryption and [RFC 1421][] for PKCS#1 and SEC1 encryption. +### `keyObject.equals(otherKeyObject)` + + + +* `otherKeyObject`: {KeyObject} A `KeyObject` with which to + compare `keyObject`. +* Returns: {boolean} + +Returns `true` or `false` depending on whether the keys have exactly the same +type, value, and parameters. This method is not +[constant time](https://en.wikipedia.org/wiki/Timing_attack). + ### `keyObject.symmetricKeySize`