keybase / kbpgp

OpenPGP (RFC4880) Implementation in IcedCoffeeScript
https://keybase.io/kbpgp
BSD 3-Clause "New" or "Revised" License
535 stars 74 forks source link

Using Crypto in FireFox WebWorker #90

Open clevertree opened 9 years ago

clevertree commented 9 years ago

Can't figure out how to get kbpgp to recognize Crypto in FF's webworker. Basically self.crypto isn't set, and kbpgp appears to look for window.crypto only.

Here's an ugly fix I use to get past this.

/** Fix **/
if(!_browser_rng_primitive && typeof self.crypto !== "undefined") {
    _browser_rng_primitive = function(arg) {
        return self.crypto.getRandomValues(arg);
    };
}

The fix would only require searching for self.crypto along with window.crypto in the _browser_rng_primitive. I can push a fix if you want.

acasajus commented 8 years ago

Where do you place the fix? I'd like to try it out.