Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use webcrypto for random number generation if available

Patch submitted 5/10/2013 by Gavin Andresen -- Thanks Gavin!
  • Loading branch information...
commit b4c2cf68e79f9f469cd180238d9377086058aaa9 1 parent 0cd980c
@cantonbecker authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 generate-wallet.html
View
11 generate-wallet.html
@@ -1622,7 +1622,14 @@
sr.pool = new Array();
sr.pptr = 0;
var t;
- if (navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
+ // Use webcrypto if available;
+ // see http://www.w3.org/2012/webcrypto/WebCryptoAPI/#Crypto-method-getRandomValues
+ if (window.crypto && window.crypto.getRandomValues) {
+ sr.pool = new Uint8Array(sr.poolSize);
+ window.crypto.getRandomValues(sr.pool);
+ sr.pptr = sr.poolSize;
+ }
+ else if (navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
// Extract entropy (256 bits) from NS4 RNG if available
var z = window.crypto.random(32);
for (t = 0; t < z.length; ++t)
@@ -7539,4 +7546,4 @@
</script>
</body>
-</html>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.