From bbd171c7d5734172ae3b14bc794d0f8d43d2ff15 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 23 Sep 2021 12:39:59 +0200 Subject: [PATCH] test: add regression test --- spec/node-spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/node-spec.js b/spec/node-spec.js index 56cf8c127d91f..4d06e39d445d4 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -317,6 +317,21 @@ describe('node feature', () => { // eslint-disable-next-line no-octal crypto.createDiffieHellman('abc', '123'); }); + + it('does not crash when calling crypto.createPrivateKey() with an unsupported algorithm', () => { + const crypto = require('crypto'); + + const ed448 = { + crv: 'Ed448', + x: 'KYWcaDwgH77xdAwcbzOgvCVcGMy9I6prRQBhQTTdKXUcr-VquTz7Fd5adJO0wT2VHysF3bk3kBoA', + d: 'UhC3-vN5vp_g9PnTknXZgfXUez7Xvw-OfuJ0pYkuwzpYkcTvacqoFkV_O05WMHpyXkzH9q2wzx5n', + kty: 'OKP' + }; + + expect(() => { + crypto.createPrivateKey({ key: ed448, format: 'jwk' }); + }).to.throw(/Failed to create key - unsupported algorithm/); + }); }); describe('process.stdout', () => {