diff options
author | Tobias Nießen <tniessen@tnie.de> | 2019-03-05 18:35:50 +0100 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2019-03-09 12:00:23 +0100 |
commit | 3afa5d7ba8d7b25ff3acda303c20e41230342e18 (patch) | |
tree | c4d69aa25ff4f1cf608f5cb88dd0da055017a2f2 /test | |
parent | 1acf3b155f6345c6d3ad24f90cd49ec9d83424f5 (diff) | |
download | android-node-v8-3afa5d7ba8d7b25ff3acda303c20e41230342e18.tar.gz android-node-v8-3afa5d7ba8d7b25ff3acda303c20e41230342e18.tar.bz2 android-node-v8-3afa5d7ba8d7b25ff3acda303c20e41230342e18.zip |
crypto: improve error handling in parseKeyEncoding
This change only affects KeyObject.export().
PR-URL: https://github.com/nodejs/node/pull/26455
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-crypto-key-objects.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index 9819bb7914..8515743992 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -107,6 +107,16 @@ const privatePem = fixtures.readSync('test_rsa_privkey.pem', 'ascii'); assert.strictEqual(derivedPublicKey.asymmetricKeyType, 'rsa'); assert.strictEqual(derivedPublicKey.symmetricKeySize, undefined); + // Test exporting with an invalid options object, this should throw. + for (const opt of [undefined, null, 'foo', 0, NaN]) { + common.expectsError(() => publicKey.export(opt), { + type: TypeError, + code: 'ERR_INVALID_ARG_TYPE', + message: 'The "options" argument must be of type object. Received type ' + + typeof opt + }); + } + const publicDER = publicKey.export({ format: 'der', type: 'pkcs1' |