From 0e1ce2055e4b05204fd79d1f3866a113842c3cbf Mon Sep 17 00:00:00 2001 From: Evgenii Shchepotev Date: Sun, 26 May 2019 13:17:54 +0300 Subject: [PATCH] test: rsa-pss generateKeyPairSync invalid option hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/27883 Reviewed-By: Ujjwal Sharma Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Tobias Nießen --- test/parallel/test-crypto-keygen.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 19afd715e47cb1..8c3432e06cb647 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -999,6 +999,20 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); }); } + // Invalid hash value. + for (const hashValue of [123, true, {}, []]) { + common.expectsError(() => { + generateKeyPairSync('rsa-pss', { + modulusLength: 4096, + hash: hashValue + }); + }, { + type: TypeError, + code: 'ERR_INVALID_OPT_VALUE', + message: `The value "${hashValue}" is invalid for option "hash"` + }); + } + // Invalid private key type. for (const type of ['foo', 'spki']) { common.expectsError(() => {