summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/node_compat/config.jsonc1
-rw-r--r--cli/tests/node_compat/test/parallel/test-crypto-dh-shared.js22
-rw-r--r--cli/tests/node_compat/test/parallel/test-crypto-dh.js26
3 files changed, 36 insertions, 13 deletions
diff --git a/cli/tests/node_compat/config.jsonc b/cli/tests/node_compat/config.jsonc
index 8631efcad..36b22a672 100644
--- a/cli/tests/node_compat/config.jsonc
+++ b/cli/tests/node_compat/config.jsonc
@@ -240,6 +240,7 @@
"test-console-sync-write-error.js",
"test-console-table.js",
"test-console-tty-colors.js",
+ "test-crypto-dh-shared.js",
"test-crypto-dh.js",
"test-crypto-hkdf.js",
"test-crypto-hmac.js",
diff --git a/cli/tests/node_compat/test/parallel/test-crypto-dh-shared.js b/cli/tests/node_compat/test/parallel/test-crypto-dh-shared.js
new file mode 100644
index 000000000..5ab6fe465
--- /dev/null
+++ b/cli/tests/node_compat/test/parallel/test-crypto-dh-shared.js
@@ -0,0 +1,22 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 18.12.1
+// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
+
+'use strict';
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+
+const assert = require('assert');
+const crypto = require('crypto');
+
+const alice = crypto.createDiffieHellmanGroup('modp5');
+const bob = crypto.createDiffieHellmanGroup('modp5');
+alice.generateKeys();
+bob.generateKeys();
+const aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex');
+const bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex');
+assert.strictEqual(aSecret, bSecret);
diff --git a/cli/tests/node_compat/test/parallel/test-crypto-dh.js b/cli/tests/node_compat/test/parallel/test-crypto-dh.js
index b436207ac..bcf0c6764 100644
--- a/cli/tests/node_compat/test/parallel/test-crypto-dh.js
+++ b/cli/tests/node_compat/test/parallel/test-crypto-dh.js
@@ -187,22 +187,22 @@ if (false) {
message: 'The "curve" argument must be of type string. ' +
'Received undefined'
});
-
- assert.throws(
- function() {
- crypto.getDiffieHellman('unknown-group');
- },
- {
- name: 'Error',
- code: 'ERR_CRYPTO_UNKNOWN_DH_GROUP',
- message: 'Unknown DH group'
- },
- 'crypto.getDiffieHellman(\'unknown-group\') ' +
- 'failed to throw the expected error.'
- );
}
assert.throws(
+ function() {
+ crypto.getDiffieHellman('unknown-group');
+ },
+ {
+ name: 'Error',
+ code: 'ERR_CRYPTO_UNKNOWN_DH_GROUP',
+ message: 'Unknown DH group'
+ },
+ 'crypto.getDiffieHellman(\'unknown-group\') ' +
+ 'failed to throw the expected error.'
+);
+
+assert.throws(
() => crypto.createDiffieHellman('', true),
{
code: 'ERR_INVALID_ARG_TYPE'