mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(ext/node): fix error type in DiffieHellman constructor (#29721)
This commit is contained in:
parent
e5b96243ac
commit
b979c886e6
3 changed files with 9 additions and 6 deletions
|
@ -117,7 +117,10 @@ export class DiffieHellmanImpl {
|
|||
// The supplied parameter is our primeLength, generate a suitable prime.
|
||||
this.#primeLength = sizeOrKey as number;
|
||||
if (this.#primeLength < 2) {
|
||||
throw new NodeError("ERR_OSSL_BN_BITS_TOO_SMALL", "bits too small");
|
||||
throw new NodeError(
|
||||
"ERR_OSSL_DH_MODULUS_TOO_SMALL",
|
||||
"modulus too small",
|
||||
);
|
||||
}
|
||||
|
||||
this.#prime = Buffer.from(
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
"test-console-formatTime.js",
|
||||
"test-console-instance.js",
|
||||
"test-console-tty-colors.js",
|
||||
"test-crypto-dh-errors.js",
|
||||
"test-crypto-hash.js",
|
||||
"test-crypto-hkdf.js",
|
||||
"test-crypto-hmac.js",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 20.11.1
|
||||
// Taken from Node 23.9.0
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
'use strict';
|
||||
|
@ -12,6 +12,7 @@ if (!common.hasCrypto)
|
|||
|
||||
const assert = require('assert');
|
||||
const crypto = require('crypto');
|
||||
const { hasOpenSSL3 } = require('../common/crypto');
|
||||
|
||||
// https://github.com/nodejs/node/issues/32738
|
||||
// XXX(bnoordhuis) validateInt32() throwing ERR_OUT_OF_RANGE and RangeError
|
||||
|
@ -31,7 +32,7 @@ assert.throws(() => crypto.createDiffieHellman('abcdef', 13.37), {
|
|||
});
|
||||
|
||||
for (const bits of [-1, 0, 1]) {
|
||||
if (common.hasOpenSSL3) {
|
||||
if (hasOpenSSL3) {
|
||||
assert.throws(() => crypto.createDiffieHellman(bits), {
|
||||
code: 'ERR_OSSL_DH_MODULUS_TOO_SMALL',
|
||||
name: 'Error',
|
||||
|
@ -50,7 +51,7 @@ for (const g of [-1, 1]) {
|
|||
const ex = {
|
||||
code: 'ERR_OSSL_DH_BAD_GENERATOR',
|
||||
name: 'Error',
|
||||
message: /bad generator/,
|
||||
message: /(?:bad[_ ]generator)/i,
|
||||
};
|
||||
assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
|
||||
assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
|
||||
|
@ -62,7 +63,7 @@ for (const g of [Buffer.from([]),
|
|||
const ex = {
|
||||
code: 'ERR_OSSL_DH_BAD_GENERATOR',
|
||||
name: 'Error',
|
||||
message: /bad generator/,
|
||||
message: /(?:bad[_ ]generator)/i,
|
||||
};
|
||||
assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
|
||||
assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue