[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled

This commit is contained in:
2026-09-13 18:24:01 +08:00
commit 3c72efcb7f
3255 changed files with 907009 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const crypto = require("node:crypto");
const {
installBoringSslDhCompat,
MODP_GROUP_PRIMES,
} = require("./boringSslDhCompat.cjs");
test("falls back to an explicit-prime DH when the runtime lacks a named group", () => {
// Simulate BoringSSL: the named lookup throws "Unknown DH group".
const target = {
createDiffieHellmanGroup(name) {
throw new Error(`Unknown DH group: ${name}`);
},
};
assert.equal(installBoringSslDhCompat(target), true);
const dh = target.createDiffieHellmanGroup("modp2");
// The fallback group uses the exact RFC 2409 group1 prime.
assert.equal(dh.getPrime("hex").toUpperCase(), MODP_GROUP_PRIMES.modp2);
// And it performs a real, correct DH exchange.
const peer = crypto.createDiffieHellman(
Buffer.from(MODP_GROUP_PRIMES.modp2, "hex"),
Buffer.from([2]),
);
const ourPublic = dh.generateKeys();
const peerPublic = peer.generateKeys();
assert.ok(dh.computeSecret(peerPublic).equals(peer.computeSecret(ourPublic)));
});
test("uses the runtime's group when the name resolves (no fallback)", () => {
let calls = 0;
const sentinel = Symbol("native-group");
const target = {
createDiffieHellmanGroup() {
calls += 1;
return sentinel;
},
};
installBoringSslDhCompat(target);
assert.equal(target.createDiffieHellmanGroup("modp2"), sentinel);
assert.equal(calls, 1);
});
test("rethrows the original error for groups it cannot back", () => {
const target = {
createDiffieHellmanGroup() {
throw new Error("Unknown DH group");
},
};
installBoringSslDhCompat(target);
assert.throws(() => target.createDiffieHellmanGroup("modp-nonexistent"), /Unknown DH group/);
});
test("install is idempotent", () => {
const target = {
createDiffieHellmanGroup() {
return null;
},
};
assert.equal(installBoringSslDhCompat(target), true);
assert.equal(installBoringSslDhCompat(target), false);
});
test("on this (OpenSSL) runtime the real modp2 still works through the shim", () => {
// Sanity check against the actual crypto module: installing must not break the
// normal path where the runtime resolves the group by name.
const localCrypto = require("node:crypto");
installBoringSslDhCompat(localCrypto);
const dh = localCrypto.createDiffieHellmanGroup("modp2");
assert.equal(dh.getPrime("hex").toUpperCase(), MODP_GROUP_PRIMES.modp2);
});