Skip to content

Conversation

@Leko
Copy link
Contributor

@LekoLeko commented Dec 4, 2017

Added these case

crypto.Hash
  • Call constructor without new keyword
crypto.Hmac
  • Call constructor without new keyword
  • Call constructor with typeof hmac != string
  • Call constructor with typeof hmac = string, typeof key != string

Current coverage is here: https://coverage.nodejs.org/coverage-06e1b0386196f8f8/root/internal/crypto/hash.js.html

I cannot write test case: this._handle.update returns false in Hash#verify.
Because I don't know how to make mdctx_ to nullptr in Hash::HashUpdate.
See also:

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)

test

@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Dec 4, 2017
@LekoLeko changed the title Add missing test in crypto hash hmacEnhance crypto/hash.js coverageDec 4, 2017
@mscdexmscdex added the crypto Issues and PRs related to the crypto subsystem. label Dec 4, 2017
@lpinca
Copy link
Member

Copy link
Contributor

@apapirovskiapapirovski left a comment

Choose a reason for hiding this comment

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

LGTM but two small changes needed before this lands

{
constHash=crypto.Hash;
constinstance=crypto.Hash('sha256');
assert(instanceinstanceofHash,'Hash is expected to return a new instance'+
Copy link
Contributor

Choose a reason for hiding this comment

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

needs a space either at the end of this line (after instance) or on the next line. Right now it says "instancewhen".

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ah, Sorry. I'll update it soon.

{
constHmac=crypto.Hmac;
constinstance=crypto.Hmac('sha256','Node');
assert(instanceinstanceofHmac,'Hmac is expected to return a new instance'+
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Right now it says "instance when".
Copy link
Member

@mhdawsonmhdawson left a comment

Choose a reason for hiding this comment

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

LGTM once changes from @apapirovski are incorporated

@maclover7
Copy link
Contributor

Same deal as #17458 (comment), are we able to use the create functions here?

Copy link
Contributor

@maclover7maclover7 left a comment

Choose a reason for hiding this comment

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

Two quick nits, then LGTM


{
constHmac=crypto.Hmac;
constinstance=crypto.Hmac('sha256','Node');
Copy link
Contributor

Choose a reason for hiding this comment

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

createHmac


{
constHash=crypto.Hash;
constinstance=crypto.Hash('sha256');
Copy link
Contributor

Choose a reason for hiding this comment

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

createHash

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Same adobe #17458 (comment)

Copy link
Member

@BridgeARBridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM with @apapirovski comments addressed

@apapirovski
Copy link
Contributor

@maclover7
Copy link
Contributor

@apapirovski Can you confirm your comments were addressed?

@apapirovski
Copy link
Contributor

Yes and I'm currently landing this

@apapirovski
Copy link
Contributor

Landed in 3d64533

Thanks @Leko! 👍

apapirovski pushed a commit that referenced this pull request Dec 7, 2017
crypto.Hash - Call constructor without new keyword crypto.Hmac - Call constructor without new keyword - Call constructor with typeof hmac != string - Call constructor with typeof hmac = string, typeof key != string PR-URL: #17447 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
crypto.Hash - Call constructor without new keyword crypto.Hmac - Call constructor without new keyword - Call constructor with typeof hmac != string - Call constructor with typeof hmac = string, typeof key != string PR-URL: #17447 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
crypto.Hash - Call constructor without new keyword crypto.Hmac - Call constructor without new keyword - Call constructor with typeof hmac != string - Call constructor with typeof hmac = string, typeof key != string PR-URL: #17447 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Dec 12, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cryptoIssues and PRs related to the crypto subsystem.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Leko@lpinca@maclover7@apapirovski@BridgeAR@mhdawson@mscdex@gibfahn@nodejs-github-bot