Skip to content

Enhance crypto/sig.js coverage #17426

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

Closed
wants to merge 9 commits into from
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
36 changes: 36 additions & 0 deletions test/parallel/test-crypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,42 @@ const certPem = fixtures.readSync('test_cert.pem', 'ascii');
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
const modSize = 1024;

{
const Sign = crypto.Sign;
const instance = Sign('SHA256');
assert(instance instanceof Sign, 'Sign is expected to return a new ' +
'instance when called without `new`');
}

{
const Verify = crypto.Verify;
const instance = Verify('SHA256');
assert(instance instanceof Verify, 'Verify is expected to return a new ' +
'instance when called without `new`');
}

common.expectsError(
() => crypto.createVerify('SHA256').verify({
key: certPem,
padding: undefined,
}, ''),
{
code: 'ERR_INVALID_OPT_VALUE',
type: Error,
message: 'The value "undefined" is invalid for option "padding"'
});

common.expectsError(
() => crypto.createVerify('SHA256').verify({
key: certPem,
saltLength: undefined,
}, ''),
{
code: 'ERR_INVALID_OPT_VALUE',
type: Error,
message: 'The value "undefined" is invalid for option "saltLength"'
});

// Test signing and verifying
{
const s1 = crypto.createSign('SHA1')
Expand Down