[GCrypt] HKDF bit derivation support
[WebKit-https.git] / LayoutTests / crypto / crypto-random-values.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description("Tests crypto.randomValues.");
11
12 if (!window.ArrayBuffer)
13     debug("This test requres ArrayBuffers to run!");
14
15 shouldBe("'crypto' in window", "true");
16 shouldBe("'getRandomValues' in window.crypto", "true");
17
18 try {
19     // FIXME: This test is flaky.  If we ran this test every second since the
20     //        beginning of the universe, on average, it would have failed
21     //        2^{-748} times.
22
23     var reference = new Uint8Array(100);
24     var sample = new Uint8Array(100);
25
26     crypto.getRandomValues(reference);
27     crypto.getRandomValues(sample);
28
29     var matchingBytes = 0;
30
31     for (var i = 0; i < reference.length; i++) {
32         if (reference[i] == sample[i])
33             matchingBytes++;
34     }
35
36     shouldBe("matchingBytes < 100", "true");
37 } catch(ex) {
38     debug(ex);
39 }
40
41 </script>
42 <script src="../resources/js-test-post.js"></script>
43 </body>
44 </html>
45
46