summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2019-10-10 02:41:30 +0200
committerRich Trott <rtrott@gmail.com>2019-10-11 22:02:55 -0700
commitc64ed10d8067fc3b21578d3eafe322d0e9496980 (patch)
treed391c01fbb94d9c30fcf16468236344e3f157581 /lib
parent88e815649bbc9529e23bef22dda17570bd972683 (diff)
downloadandroid-node-v8-c64ed10d8067fc3b21578d3eafe322d0e9496980.tar.gz
android-node-v8-c64ed10d8067fc3b21578d3eafe322d0e9496980.tar.bz2
android-node-v8-c64ed10d8067fc3b21578d3eafe322d0e9496980.zip
crypto: reject public keys properly
Fixes: https://github.com/nodejs/node/issues/29904 PR-URL: https://github.com/nodejs/node/pull/29913 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/crypto/keys.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js
index fb17ba36ce..250147d752 100644
--- a/lib/internal/crypto/keys.js
+++ b/lib/internal/crypto/keys.js
@@ -270,7 +270,10 @@ function prepareAsymmetricKey(key, ctx) {
...(ctx !== kCreatePrivate ? ['KeyObject'] : [])],
key);
}
- return { data, ...parseKeyEncoding(key, undefined) };
+
+ const isPublic =
+ (ctx === kConsumePrivate || ctx === kCreatePrivate) ? false : undefined;
+ return { data, ...parseKeyEncoding(key, undefined, isPublic) };
} else {
throw new ERR_INVALID_ARG_TYPE(
'key',