-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: support Uint8Array prime in createDH #11983
Conversation
b18f95d
to
dbee04c
Compare
test/parallel/test-crypto-dh.js
Outdated
const modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()) | ||
.toString('hex'); | ||
const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey()) | ||
.toString('hex'); |
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.
Is there a reason for indenting some of these differently?
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.
Happens around lines 120, 148, 168 and 172 too.
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 modulo style nits.
lib/crypto.js
Outdated
typeof sizeOrKey !== 'string' && | ||
!isUint8Array(sizeOrKey)) | ||
throw new TypeError('First argument should be number, string, ' + | ||
'Uint8Array or Buffer'); |
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.
Maybe add braces while you're here.
test/parallel/test-crypto-dh.js
Outdated
const modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()) | ||
.toString('hex'); | ||
const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey()) | ||
.toString('hex'); |
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.
Happens around lines 120, 148, 168 and 172 too.
test/parallel/test-crypto-dh.js
Outdated
{ | ||
// Ensure specific generator (string with encoding) works as expected, | ||
// with a Uint8Array as the first argument to createDiffieHellman(). | ||
const exmodp2 = crypto.createDiffieHellman(new Uint8Array([...modp2buf]), |
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: avoid using the spread operator? Feel free to ignore
Landed in 0db49fe |
PR-URL: #11983 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)