browserify / randombytes

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

secure random number generation not supported by this browser use chrome, FireFox or Internet Explorer 11 #6

Closed omryr closed 7 years ago

omryr commented 7 years ago

im using a library that is using this one and im getting this error when running in IE 11, did anyone encounter it? and if yes what was the solution? i am looking for a few hours now and kinda lost, would appreciate any help. thanks!

calvinmetcalf commented 7 years ago

that's really strange because IE11 supports it, what library are you using that is relying on it and what is the exact version of that library and IE are you using

omryr commented 7 years ago

im using etereumjs-wallet library

calvinmetcalf commented 7 years ago

using it where?

omryr commented 7 years ago

in a client side application

calvinmetcalf commented 7 years ago

in a browser? if so which one?

omryr commented 7 years ago

it happens to me in explorer 11 and also safari on ipads

calvinmetcalf commented 7 years ago

other discussion ethereumjs/ethereumjs-wallet#15

what are you using to bundle the app, does it work in chrome ?

therightstuff commented 7 years ago

if you're looking for crypto library compatible keys, take a look at https://gist.github.com/therightstuff/84ae710c3c301fe7979d7f0aa9c7c147 - i initially used aes-js and md5 on the client, but i now use the browserified crypto library; there was no need to modify the generateSessionKeys function.

calvinmetcalf commented 7 years ago

@therightstuff the interesting thing is just that that error shouldn't be coming up at all here so there is likely something weird going on in like a bundler or something

omryr commented 7 years ago

im using "webpack": "^2.3.3"

omryr commented 7 years ago

and yes it works in chrome and mosly works in safari, IE it doesnt work at all

calvinmetcalf commented 7 years ago

what version of IE, exactly ?

On Mon, May 8, 2017 at 11:24 AM omryr notifications@github.com wrote:

and yes it works in chrome and mosly works in safari, IE it doesnt work at all

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/crypto-browserify/randombytes/issues/6#issuecomment-299899081, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n3PHoGlZuRzmmosUM9ICkw1fj49eks5r3zOjgaJpZM4NJeiw .

omryr commented 7 years ago

im trying IE 11 atm

calvinmetcalf commented 7 years ago

ok and if it doesn't work then the full version number would be helpful

On Mon, May 8, 2017 at 11:29 AM omryr notifications@github.com wrote:

im trying IE 11 atm

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/crypto-browserify/randombytes/issues/6#issuecomment-299900915, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n7vbmh4wg5BLBdrfwdbBS2SNt1Etks5r3zTrgaJpZM4NJeiw .

omryr commented 7 years ago

IE 11.0.15063.0 is the version im running

dcousens commented 7 years ago

Verdict?

calvinmetcalf commented 7 years ago

I have no clue, I'm not able to reproduce

On Wed, May 24, 2017 at 4:17 AM Daniel Cousens notifications@github.com wrote:

Verdict?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/crypto-browserify/randombytes/issues/6#issuecomment-303644095, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n8EhJccsd-P_7v2mRE-TnILFDsx9ks5r898KgaJpZM4NJeiw .

bokub commented 6 years ago

Same problem with both IE 11.786.15063.0

I'm using browserify version 14.5.0 + babel 6.26.0.

Here is the generated code:

    var Buffer = require('safe-buffer').Buffer;
    var crypto = global.crypto || global.msCrypto;
    if (crypto && crypto.getRandomValues) {
        module.exports = randomBytes;
    } else {
        module.exports = oldBrowser;
    }

Both global.crypto and global.msCrypto are undefined.

calvinmetcalf commented 6 years ago

is have you configured babel or webpack not to include global ?

bokub commented 6 years ago

EDIT: it was not webpack version 14.5.0 but browserify version 14.5.0.

And no, I don't know how to do this, but I'll look

By the way, I forgot to mention that my code is in a web worker, and console.log(global) logs [object WorkerGlobalScope]

calvinmetcalf commented 6 years ago

are window.crypto and window.msCrypto also undefined and does global === window ?

bokub commented 6 years ago

window is undefined because my code is in a web worker. However, global is equal to the WorkerGlobalScope

calvinmetcalf commented 6 years ago

oh yeah getRandomValues isn't available in a web worker

bokub commented 6 years ago

Works with chrome and recent Firefox versions though..

Thanks for your help :+1:

MaxMillington commented 6 years ago

I'm getting this error in IE10. Does randombytes not support IE10?

calvinmetcalf commented 6 years ago

that is correct

AilsonEsi commented 6 years ago

hi guys, some one can help me, so im trying to create a project i had same error, im using linux mint, what can i do to solve this?

calvinmetcalf commented 6 years ago

@AilsonEsi what browser and version are you using, and are you trying to use it in a web worker?

xellDart commented 6 years ago

some here

calvinmetcalf commented 6 years ago

folks, are you in a web worker? if so browsers don't support it, maybe we need a more explicit error when you try to use this in a web worker?