Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

WebCrypto.getRandomValues vs crypto.randomBytes #46

Closed
daviddias opened this issue Dec 2, 2016 · 5 comments
Closed

WebCrypto.getRandomValues vs crypto.randomBytes #46

daviddias opened this issue Dec 2, 2016 · 5 comments
Assignees
Labels

Comments

@daviddias
Copy link
Member

daviddias commented Dec 2, 2016

crypto.randomBytes

https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback

returns a Buffer with random bytes given the size

WebCrypto.getRandomValues(arr)

https://developer.mozilla.org/en/docs/Web/API/RandomSource/getRandomValues

overwrites an array with randomBytes

Why didn't WebCrypto do the same thing that Node.js was doing, when it came after?

@daviddias daviddias added the WAT label Dec 2, 2016
@dignifiedquire
Copy link
Member

are you trying to collect all strange behavior of webcrypto here? ;)

@daviddias
Copy link
Member Author

@dignifiedquire exactly, hopefully it will be useful to enumerate issues in the future

@daviddias daviddias added the status/deferred Conscious decision to pause or backlog label Dec 5, 2016
@dignifiedquire
Copy link
Member

As a side note, the webcrypto api is much more sensible when trying to optimize for speed and allocations. You can manage your own array and fill it with random values, whereas the node api is actually much worse, as it forces allocation of a new buffer when generating random values.

@daviddias
Copy link
Member Author

Still a WAT

@ghost ghost assigned hugomrdias Dec 5, 2018
@ghost ghost added status/in-progress In progress and removed status/deferred Conscious decision to pause or backlog labels Dec 5, 2018
@ghost ghost removed the status/in-progress In progress label Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants