-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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 Cipher, Decipher coverage #17449
Conversation
const Decipher = crypto.Decipher; | ||
const instance = crypto.Decipher('aes-256-cbc', 'secret'); | ||
assert(instance instanceof Decipher, 'Decipher is expected to return a new ' + | ||
'instance when called without `new`'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent once more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a silly mistake.
I'll fix it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Same deal as #17458 (comment), are we able to use the |
There was a problem hiding this 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
@@ -70,6 +70,81 @@ testCipher1(Buffer.from('MySecretKey123')); | |||
testCipher2('0123456789abcdef'); | |||
testCipher2(Buffer.from('0123456789abcdef')); | |||
|
|||
{ | |||
const Cipher = crypto.Cipher; | |||
const instance = crypto.Cipher('aes-256-cbc', 'secret'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createCipher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same adobe #17458 (comment)
|
||
{ | ||
const Decipher = crypto.Decipher; | ||
const instance = crypto.Decipher('aes-256-cbc', 'secret'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createDecipher
Landed in 84b7a86 |
Cipher - Call constructor withour new keyword - Call constructor with cipher is not string - Call constructor with cipher is string and password is not string - Call Cipher#update with data is not string - Call Cipher#setAuthTag with tagbuf is not string - Call Cipher#setAAD with aadbuf is not string Decipher - Call constructor withour new keyword - Call constructor with cipher is not string - Call constructor with cipher is string and password is not string PR-URL: #17449 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
These tests rely on the semver major changes in #16527 |
I added those test:
Cipher
Cipher#update
with data is not stringCipher#setAuthTag
with tagbuf is not stringCipher#setAAD
with aadbuf is not stringDecipher
Current coverage is here: https://coverage.nodejs.org/coverage-06e1b0386196f8f8/root/internal/crypto/cipher.js.html
Cipheriv
andDecipheriv
is not covered in this PR to avoid PR too large.I'm going to write these test in another PR.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test