summaryrefslogtreecommitdiff
path: root/lib/internal/crypto
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2019-06-21 16:37:06 +0200
committerTobias Nießen <tniessen@tnie.de>2019-08-07 13:45:42 +0200
commit0c9ad34427cdc8a68c8b3e7c2d4748f462567680 (patch)
tree4daa9f7d90a2c5583c1d0052817c26f5a68bdb9a /lib/internal/crypto
parent0b5b81c82af70072eac09d39ec43b5707d8d8a0c (diff)
downloadandroid-node-v8-0c9ad34427cdc8a68c8b3e7c2d4748f462567680.tar.gz
android-node-v8-0c9ad34427cdc8a68c8b3e7c2d4748f462567680.tar.bz2
android-node-v8-0c9ad34427cdc8a68c8b3e7c2d4748f462567680.zip
crypto: extend RSA-OAEP support with oaepHash
This adds an oaepHash option to asymmetric encryption which allows users to specify a hash function when using OAEP padding. This feature is required for interoperability with WebCrypto applications. PR-URL: https://github.com/nodejs/node/pull/28335 Fixes: https://github.com/nodejs/node/issues/25756 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'lib/internal/crypto')
-rw-r--r--lib/internal/crypto/cipher.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js
index e2fe291526..34507dd157 100644
--- a/lib/internal/crypto/cipher.js
+++ b/lib/internal/crypto/cipher.js
@@ -50,7 +50,10 @@ function rsaFunctionFor(method, defaultPadding, keyType) {
preparePrivateKey(options) :
preparePublicOrPrivateKey(options);
const padding = options.padding || defaultPadding;
- return method(data, format, type, passphrase, buffer, padding);
+ const { oaepHash } = options;
+ if (oaepHash !== undefined && typeof oaepHash !== 'string')
+ throw new ERR_INVALID_ARG_TYPE('options.oaepHash', 'string', oaepHash);
+ return method(data, format, type, passphrase, buffer, padding, oaepHash);
};
}