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

crypto: migrate crypto sign to internal/errors #15757

Closed
wants to merge 2 commits into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Oct 3, 2017

Improve argument type checking and move into js, use internal/errors

Improve tests.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

crypto

@jasnell jasnell added errors Issues and PRs related to JavaScript errors originated in Node.js core. semver-major PRs that contain breaking changes and should be released in the next major version. labels Oct 3, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Oct 3, 2017
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'key',
['string', 'Buffer', 'TypedArray', 'DataView']);
}

var ret = this._handle.sign(toBuf(key), passphrase, rsaPadding,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: toBuf() seems redundant here.

const { Writable } = require('stream');
const { inherits } = require('util');

function Sign(algorithm, options) {
if (typeof algorithm !== 'string')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe it's better to move this after the instanceof check to only run it once when Sign is called without new.

@@ -80,6 +94,8 @@ Sign.prototype.sign = function sign(options, encoding) {


function Verify(algorithm, options) {
if (typeof algorithm !== 'string')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@jasnell
Copy link
Member Author

jasnell commented Oct 13, 2017

@nodejs/tsc ... ping? Please review?

@jasnell jasnell requested a review from a team October 13, 2017 21:22
Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Next step would be to migrate SignBase::CheckThrow...

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the wrong box before

@joyeecheung
Copy link
Member

joyeecheung commented Oct 14, 2017

Also after this patch, sign.sign() and verify.verify() take array buffer views as key, the documentation need to be updated (not necessarily in this PR)

@jasnell
Copy link
Member Author

jasnell commented Oct 16, 2017

re: SignBase::CheckThrow and the doc updates... yes, I intend to do both in separate PRs.

@jasnell jasnell force-pushed the crypto-sign-internal-errors branch from f143a84 to 2579276 Compare October 16, 2017 16:59
@jasnell
Copy link
Member Author

jasnell commented Oct 16, 2017

@nodejs/tsc ... need at least one more TSC signoff on this please

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jasnell
Copy link
Member Author

jasnell commented Oct 16, 2017

Improve argument type checking and move into js, use internal/errors
@jasnell jasnell force-pushed the crypto-sign-internal-errors branch from 2579276 to cee5974 Compare October 20, 2017 21:34
@jasnell
Copy link
Member Author

jasnell commented Oct 20, 2017

@jasnell
Copy link
Member Author

jasnell commented Oct 23, 2017

CI was a bit too red, trying again: https://ci.nodejs.org/job/node-test-commit/13401/

jasnell added a commit that referenced this pull request Oct 24, 2017
Improve argument type checking and move into js, use internal/errors

PR-URL: #15757
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@jasnell
Copy link
Member Author

jasnell commented Oct 24, 2017

Landed in b8bc652

@jasnell jasnell closed this Oct 24, 2017
addaleax pushed a commit to ayojs/ayo that referenced this pull request Oct 26, 2017
Improve argument type checking and move into js, use internal/errors

PR-URL: nodejs/node#15757
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
Improve argument type checking and move into js, use internal/errors

PR-URL: nodejs/node#15757
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants