| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Should this be labeled in progress? |
Sorry, something went wrong.
|
haven't decided yet lol.... the rest of what I want to do here should likely go into a separate PR. It's rather extensive |
Sorry, something went wrong.
|
ping @nodejs/crypto |
Sorry, something went wrong.
|
While moving things around it also updates to use internal/errors |
Sorry, something went wrong.
|
Is it something that you would like to land before Node 9? |
Sorry, something went wrong.
|
I'd like to yes. |
Sorry, something went wrong.
There was a problem hiding this comment.
nit: use printf-like syntax?
Sorry, something went wrong.
There was a problem hiding this comment.
We should probably document these and recommend their usage since it's useless to create an instance of the class. That can be done in another PR.
Sorry, something went wrong.
There was a problem hiding this comment.
Might as well do it in this PR
Sorry, something went wrong.
There was a problem hiding this comment.
Done!
Sorry, something went wrong.
There was a problem hiding this comment.
If I'm reading the C++ code correctly, with the previous undefined check, if a digest that is neither undefined nor a string is passed, a default value would be used. That includes null. Is this something that we want to break?
Lines 5392 to 5403 in bf1ca8f
Sorry, something went wrong.
There was a problem hiding this comment.
you're right. this should allow digest to be null so it will default. Will fix.
Sorry, something went wrong.
There was a problem hiding this comment.
nit: use printf-like syntax?
Sorry, something went wrong.
There was a problem hiding this comment.
I can, yeah, I tend to prefer this way but it's no biggie for me :-)
Sorry, something went wrong.
There was a problem hiding this comment.
I don't mind keeping it this way if that's what you prefer 👍
Sorry, something went wrong.
There was a problem hiding this comment.
nah... I'll change it. It's no biggie and I don't feel strongly about it
Sorry, something went wrong.
|
Thanks. LGTM. A CITGM run wouldn't hurt IMO. |
Sorry, something went wrong.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/10067/ |
Sorry, something went wrong.
|
Not seeing anything of significant concern in CITGM. regular CI is still running. |
Sorry, something went wrong.
|
Btw, all... A big reason I'm going through all this is to work towards support for async crypto API variants. I will likely only pursue it, however, once async iterators have landed. The following is an example of what I'm looking to achieve: const crypto = require('crypto');
async function hash(alg, data, enc) {
const hash = crypto.createHash(alg);
for await (const chunk of data) {
hash.update(chunk);
}
return hash.digest(enc);
}
var n = 0;
async function* dataIterator() {
while (n++ < 10)
yield `testing${n}`;
}
const p = hash('sha256', dataIterator(), 'hex');
p.then(console.log).catch(console.error);The async hash function above returns a Promise that uses an async iterator to feed data into the hash. async variants of hash, hmac, sign, verify, cipher and decipher are all trivially possible with this approach. This, of course, does not really do much to help with performance on the TLS side, but it does provide a nice Promise-oriented API. |
Sorry, something went wrong.
There was a problem hiding this comment.
One question, otherwise LGTM.
Sorry, something went wrong.
There was a problem hiding this comment.
Huh? Why?
Sorry, something went wrong.
There was a problem hiding this comment.
Because it segfaults with a double free without it!
Sorry, something went wrong.
There was a problem hiding this comment.
so this particular line of code was not being exercised previously because the input was always a Uint8Array. The if check above would always be true. If any of thing is passed, however, the Buffer would segfault when it tried to GC due to a double free.
Sorry, something went wrong.
There was a problem hiding this comment.
I will say that I'm not entirely sure this is the right approach to take on this! :-) (Copy might be better but I'm not entirely sure about that either)
Sorry, something went wrong.
There was a problem hiding this comment.
(The challenge here, btw, is that we have two TypedArray instances being created that cover the same data space... thinking about it now, copying the data would be best.)
Sorry, something went wrong.
There was a problem hiding this comment.
@jasnell What happens if the original Uint8Array is freed before this one?
Sorry, something went wrong.
There was a problem hiding this comment.
Yep, that's the exact weirdness I'm looking at. Looking at it again, I've just changed the if block above to s/isUint8Array/isArrayBufferView and everything works as it should :-)
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
|
small linting error fixed. Landing shortly. |
Sorry, something went wrong.
* Split single monolithic file into multiple * Make Certificate methods static * Allow randomFill(Sync) to use any ArrayBufferView * Use internal/errors throughout * Improve arg validation in Hash/Hmac * Doc updates
* Split single monolithic file into multiple * Make Certificate methods static * Allow randomFill(Sync) to use any ArrayBufferView * Use internal/errors throughout * Improve arg validation in Hash/Hmac * Doc updates PR-URL: #15231 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
|
The "notable change" here is that randomFill and randomFillSync can now fill any TypedArray with random data, it's not just limited to Buffer and Uint8Array any more. |
Sorry, something went wrong.
* Split single monolithic file into multiple * Make Certificate methods static * Allow randomFill(Sync) to use any ArrayBufferView * Use internal/errors throughout * Improve arg validation in Hash/Hmac * Doc updates PR-URL: nodejs/node#15231 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
* Split single monolithic file into multiple * Make Certificate methods static * Allow randomFill(Sync) to use any ArrayBufferView * Use internal/errors throughout * Improve arg validation in Hash/Hmac * Doc updates PR-URL: nodejs/node#15231 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
| Back | FazBrowse Home | New Git URL |
Beginning of a larger bit of work on the crypto API and implementation.
Checklist
Affected core subsystem(s)
crypto