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

Enhance crypto/sig.js coverage #17426

Closed
wants to merge 9 commits into from
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