Skip to content

Commit

Permalink
test: add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Sep 27, 2021
1 parent 5d86dcf commit 859872e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 0 additions & 2 deletions patches/node/.patches
Expand Up @@ -27,6 +27,4 @@ fix_account_for_debugger_agent_race_condition.patch
fix_use_new_v8_error_message_property_access_format.patch
add_should_read_node_options_from_env_option_to_disable_node_options.patch
repl_fix_crash_when_sharedarraybuffer_disabled.patch
fix_readbarrier_undefined_symbol_error_on_woa_arm64.patch
fix_-wunreachable-code-return.patch
fix_crash_creating_private_key_with_unsupported_algorithm.patch
15 changes: 15 additions & 0 deletions spec/node-spec.js
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 859872e

Please sign in to comment.