browserify / randombytes

random bytes from browserify stand alone
MIT License
99 stars 47 forks source link

Allow requesting more than 65536 bytes in the browser #15

Closed achingbrain closed 6 years ago

achingbrain commented 6 years ago

Calls crypto.getRandomValues(buffer) repeatedly until the request number of bytes have been generated.

Will throw an error if fewer than zero or more than the max value of a uint32 bytes are requested in the same way as node.js.

Fixes #14

achingbrain commented 6 years ago

@calvinmetcalf thanks for your input - were there any further comments or do you think this can be merged?

calvinmetcalf commented 6 years ago

I think this can be done with zero copies, let me do some tests

calvinmetcalf commented 6 years ago

hey take a look at #16, it turns out we can simplify a lot of stuff

achingbrain commented 6 years ago

Looks fine. I guess the only problem would be if someone's bundler setup doesn't use a TypedArray to back it's Buffer implementation as that's what crypto.getRandomValues() requires as an argument.

The original code has the comment in case browserify isn't using the Uint8Array version above where it creates a Uint8Array to pass to crypto.getRandomValues() - I took that to mean someone once thought there was a chance that Buffer might not be a TypedArray behind the scenes.

calvinmetcalf commented 6 years ago

Yeah but we're not using the built in buffer, we're using safe buffer which seems to work on phantom

On Tue, Jul 17, 2018, 7:11 PM Alex Potsides notifications@github.com wrote:

Looks fine. I guess the only problem would be if someone's bundler setup doesn't use a TypedArray https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray to back it's Buffer implementation as that's what crypto.getRandomValues() requires as an argument.

The original code has the comment in case browserify isn't using the Uint8Array version above where it creates a Uint8Array to pass to crypto.getRandomValues() - I took that to mean someone once thought there was a chance that Buffer might not be a TypedArray behind the scenes.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/crypto-browserify/randombytes/pull/15#issuecomment-405757071, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4nwHefy8jZ3mbb72USySMC42QeJMlks5uHm8hgaJpZM4VElEs .

achingbrain commented 6 years ago

Should probably remove that comment then?

calvinmetcalf commented 6 years ago

good call

calvinmetcalf commented 6 years ago

yeah that comment is gone in the other pull, which I'm going to close this in favor of