diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js index c0073abcfd4ee9..a6bb0266ff45d0 100644 --- a/test/parallel/test-crypto-cipheriv-decipheriv.js +++ b/test/parallel/test-crypto-cipheriv-decipheriv.js @@ -205,3 +205,15 @@ for (let n = 1; n < 256; n += 1) { if (common.hasFipsCrypto && n < 12) continue; crypto.createCipheriv('aes-128-gcm', Buffer.alloc(16), Buffer.alloc(n)); } + +{ + // Passing an invalid cipher name should throw. + assert.throws( + () => crypto.createCipheriv('aes-127', Buffer.alloc(16), null), + /Unknown cipher/); + + // Passing a key with an invalid length should throw. + assert.throws( + () => crypto.createCipheriv('aes-128-ecb', Buffer.alloc(17), null), + /Invalid key length/); +} diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js index f21db29d36107f..8e04396bc1e7e4 100644 --- a/test/parallel/test-crypto-hmac.js +++ b/test/parallel/test-crypto-hmac.js @@ -463,3 +463,9 @@ common.expectsError( assert.deepStrictEqual(h.digest('latin1'), ''); } } + +{ + assert.throws( + () => crypto.createHmac('sha7', 'key'), + /Unknown message digest/); +} diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index eaf555ff57f9d8..f87e21d223ba27 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -363,3 +363,9 @@ common.expectsError( assert.throws(() => verify.verify('test', input), errObj); }); } + +{ + assert.throws( + () => crypto.createSign('sha8'), + /Unknown message digest/); +}