OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('../../resources/js-test.js'); | 2 importScripts('../../resources/js-test.js'); |
3 importScripts('common.js'); | 3 importScripts('common.js'); |
4 } | 4 } |
5 | 5 |
6 function shouldEvaluateAsSilent(expressionToEval, expectedResult) | 6 function shouldEvaluateAsSilent(expressionToEval, expectedResult) |
7 { | 7 { |
8 var result = eval(expressionToEval); | 8 var result = eval(expressionToEval); |
9 if (result !== expectedResult) { | 9 if (result !== expectedResult) { |
10 testFailed(expressionToEval + " evaluated to " + result + " instead of "
+ expectedResult); | 10 testFailed(expressionToEval + " evaluated to " + result + " instead of "
+ expectedResult); |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 function notifyFailure(details) | 27 function notifyFailure(details) |
28 { | 28 { |
29 doPostMessage("FAIL:" + details); | 29 doPostMessage("FAIL:" + details); |
30 } | 30 } |
31 | 31 |
32 function testGenerateRsaKey() | 32 function testGenerateRsaKey() |
33 { | 33 { |
34 var extractable = false; | 34 var extractable = false; |
35 var usages = ['encrypt', 'decrypt']; | 35 var usages = ['encrypt', 'decrypt']; |
36 // Note that the modulus length is unsually small, in order to speed up the
test. | 36 // Note that the modulus length is unusually small in order to speed up |
| 37 // the test (1024 or 2048 would be more typical). |
37 var algorithm = {name: "RSAES-PKCS1-v1_5", modulusLength: 256, publicExponen
t: hexStringToUint8Array("010001")}; | 38 var algorithm = {name: "RSAES-PKCS1-v1_5", modulusLength: 256, publicExponen
t: hexStringToUint8Array("010001")}; |
38 | 39 |
39 return crypto.subtle.generateKey(algorithm, extractable, usages).then(functi
on(result) { | 40 return crypto.subtle.generateKey(algorithm, extractable, usages).then(functi
on(result) { |
40 publicKey = result.publicKey; | 41 publicKey = result.publicKey; |
41 privateKey = result.privateKey; | 42 privateKey = result.privateKey; |
42 | 43 |
43 shouldEvaluateAsSilent("publicKey.type", "public"); | 44 shouldEvaluateAsSilent("publicKey.type", "public"); |
44 shouldEvaluateAsSilent("publicKey.extractable", true); | 45 shouldEvaluateAsSilent("publicKey.extractable", true); |
45 shouldEvaluateAsSilent("publicKey.algorithm.name", algorithm.name); | 46 shouldEvaluateAsSilent("publicKey.algorithm.name", algorithm.name); |
46 shouldEvaluateAsSilent("publicKey.algorithm.modulusLength", algorithm.mo
dulusLength); | 47 shouldEvaluateAsSilent("publicKey.algorithm.modulusLength", algorithm.mo
dulusLength); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 }); | 178 }); |
178 } | 179 } |
179 | 180 |
180 Promise.all([ | 181 Promise.all([ |
181 testHmac(), | 182 testHmac(), |
182 testGenerateRsaKey(), | 183 testGenerateRsaKey(), |
183 testAesGcm(), | 184 testAesGcm(), |
184 testHmac(), | 185 testHmac(), |
185 testAesGcm(), | 186 testAesGcm(), |
186 ]).then(notifySuccess, notifyFailure); | 187 ]).then(notifySuccess, notifyFailure); |
OLD | NEW |