-
Notifications
You must be signed in to change notification settings - Fork 1
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
Math.random() is not cryptographically secure #12
Comments
@hacklschorsch what do you think about 74b5e1a |
Hi! Sorry for the delay, I overlooked your activity here. Even though I think invoking this API once per byte is a bit much overhead - it can yield up to 64 KB of randomness in one go - I think we shouldn't be worrying about performance yet. More of a worry to me is this documentation on getRandomValues() on MDN:
Maybe you can use a key derivation function like PBKDF2 to get some more bits out of this generateKey() method and not do the whole key generation shebang for every byte? Since I am treading on rather thin ice here - my own crypto kung foo isn't very strong - I would like refer to the warning from the beginning of the docs to the SubtleCrypto interface:
And of course there's to note that you cannot generate a one time pad with a pseudo random number generator. So maybe this is good as a demonstration - but it's not a real one time pad, but rather a not very efficient stream cipher? Maybe there is some silver bullet? Quick Googling yielded this paper: Implementation of One-Time Pad Cryptography but quick skimming looks like it's all bull? |
Math.random()
is used for cryptography, but it is not a suitable source of randomness:msgsplit/static/msgsplit.js
Line 5 in e15c42f
These two articles illustrate the problem quite well:
TIFU by using Math.random() by Mike Malone, Betable CTO, 2015-11-19
and
There’s Math.random(), and then there’s Math.random() by Yang Guo, v8 Engineer at Google, 2015-12-17
I thus propose to use the Web Cryptography API instead.
The text was updated successfully, but these errors were encountered: