-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
[v10.x Backport] Backport crypto fix to v10 #37009
[v10.x Backport] Backport crypto fix to v10 #37009
Conversation
@nodejs/lts |
This comment has been minimized.
This comment has been minimized.
@@ -30,11 +30,17 @@ const crypto = require('crypto'); | |||
|
|||
const stream = require('stream'); | |||
const s = new stream.PassThrough(); | |||
const h = crypto.createHash('sha1'); | |||
const expect = '15987e60950cf22655b9323bc1e281f9c4aff47e'; | |||
const h = crypto.createHash('sha3-512'); |
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.
This fails when linked against openssl 1.1.0: https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu1804_sharedlibs_openssl110_x64/24809/
15:30:02 not ok 393 parallel/test-crypto-hash-stream-pipe
15:30:02 ---
15:30:02 duration_ms: 0.138
15:30:02 severity: fail
15:30:02 exitcode: 1
15:30:02 stack: |-
15:30:02 internal/crypto/hash.js:33
15:30:02 this._handle = new _Hash(algorithm);
15:30:02 ^
15:30:02
15:30:02 Error: Digest method not supported
15:30:02 at new Hash (internal/crypto/hash.js:33:18)
15:30:02 at Object.createHash (crypto.js:101:10)
15:30:02 at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux-containered/test/parallel/test-crypto-hash-stream-pipe.js:33:18)
15:30:02 at Module._compile (internal/modules/cjs/loader.js:778:30)
15:30:02 at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
15:30:02 at Module.load (internal/modules/cjs/loader.js:653:32)
15:30:02 at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
15:30:02 at Function.Module._load (internal/modules/cjs/loader.js:585:3)
15:30:02 at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
15:30:02 at startup (internal/bootstrap/node.js:283:19)
15:30:02 ...
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.
oops, I'll amend that shortly. Thanks!
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.
sorry that shortly turned into 13 days :[. Should be working now. Thanks!
When piping data into an SHA3 hash, EVP_DigestFinal_ex is called in hash._flush, bypassing safeguards in the JavaScript layer. Calling hash.digest causes EVP_DigestFinal_ex to be called again, resulting in a segmentation fault in the SHA3 implementation of OpenSSL. A relatively easy solution is to cache the result of calling EVP_DigestFinal_ex until the Hash object is garbage collected. PR-URL: nodejs#28251 Fixes: nodejs#28245 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This test fails prior to 990feaf being cherry-picked due to stream.pipeline with a crypto.Hash not working properly. That bug also seems to have affected md5.
e175973
to
6858287
Compare
When piping data into an SHA3 hash, EVP_DigestFinal_ex is called in hash._flush, bypassing safeguards in the JavaScript layer. Calling hash.digest causes EVP_DigestFinal_ex to be called again, resulting in a segmentation fault in the SHA3 implementation of OpenSSL. A relatively easy solution is to cache the result of calling EVP_DigestFinal_ex until the Hash object is garbage collected. PR-URL: #28251 Fixes: #28245 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: #37009 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
When piping data into an SHA3 hash, EVP_DigestFinal_ex is called in hash._flush, bypassing safeguards in the JavaScript layer. Calling hash.digest causes EVP_DigestFinal_ex to be called again, resulting in a segmentation fault in the SHA3 implementation of OpenSSL. A relatively easy solution is to cache the result of calling EVP_DigestFinal_ex until the Hash object is garbage collected. PR-URL: #28251 Fixes: #28245 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Backport-PR-URL: #37009 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Landed in d6f3694...f55ce7c. |
When piping data into an SHA3 hash, EVP_DigestFinal_ex is called in hash._flush, bypassing safeguards in the JavaScript layer. Calling hash.digest causes EVP_DigestFinal_ex to be called again, resulting in a segmentation fault in the SHA3 implementation of OpenSSL. A relatively easy solution is to cache the result of calling EVP_DigestFinal_ex until the Hash object is garbage collected. PR-URL: #28251 Fixes: #28245 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Backport-PR-URL: #37009 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
|
This backports 990feafcb to v10.x. This fixes an issue when using
stream.pipeline()
with an instance ofcrypto.Hash
.It was fixed in 12.6.0, so this backports to v10.x and adds a test for it.