Skip to content
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

Fix IE10 crypto #453

Merged
merged 4 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion browser/fragments/platform-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ var Platform = {
addEventListener: window.addEventListener,
inspect: JSON.stringify,
getRandomValues: (function(crypto) {
if (crypto === undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimonWoolf did you mean something like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that should work. can you confirm it works as expected in IE10 etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimonWoolf Yup.
Tests keep on passing on Firefox and Chrome.
And with this also on IE10.
Attaching some screenshots for reference.

ie

chrome.pdf

ff.pdf

return undefined;
}
return function(arr, callback) {
crypto.getRandomValues(arr);
callback(null);
};
})(window.crypto || window.msCrypto) // mscrypto for IE11
};

2 changes: 1 addition & 1 deletion browser/lib/util/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var Crypto = (function() {
* @param callback
*/
var generateRandom;
if(typeof Uint32Array !== 'undefined' && Platform.getRandomValues && window.crypto) {
if(typeof Uint32Array !== 'undefined' && Platform.getRandomValues) {
var blockRandomArray = new Uint32Array(DEFAULT_BLOCKLENGTH_WORDS);
generateRandom = function(bytes, callback) {
var words = bytes / 4, nativeArray = (words == DEFAULT_BLOCKLENGTH_WORDS) ? blockRandomArray : new Uint32Array(words);
Expand Down