Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve crypto coverage #11279

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/parallel/test-crypto-dh.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0];
assert(firstByte === 2 || firstByte === 3);
firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0];
assert(firstByte === 6 || firstByte === 7);
// format value should be string
assert.throws(() => {
ecdh1.getPublicKey('buffer', 10);
}, /^TypeError: Bad format: 10$/);

// ECDH should check that point is on curve
const ecdh3 = crypto.createECDH('secp256k1');
Expand Down Expand Up @@ -277,3 +281,8 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex');
// Verify object state did not change.
assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
});

// invalid test: curve argument is undefined
assert.throws(() => {
crypto.createECDH();
}, /^TypeError: "curve" argument should be a string$/);