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 14 matching lines...) Expand all Loading... |
25 } | 25 } |
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 = ['sign', 'verify']; |
36 // Note that the modulus length is unusually small in order to speed up | 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 // the test (1024 or 2048 would be more typical). |
38 var algorithm = {name: "RSAES-PKCS1-v1_5", modulusLength: 256, publicExponen
t: hexStringToUint8Array("010001")}; | 38 var algorithm = {name: "RSASSA-PKCS1-v1_5", modulusLength: 256, publicExpone
nt: hexStringToUint8Array("010001"), hash: {name: "SHA-256"}}; |
39 | 39 |
40 return crypto.subtle.generateKey(algorithm, extractable, usages).then(functi
on(result) { | 40 return crypto.subtle.generateKey(algorithm, extractable, usages).then(functi
on(result) { |
41 publicKey = result.publicKey; | 41 publicKey = result.publicKey; |
42 privateKey = result.privateKey; | 42 privateKey = result.privateKey; |
43 | 43 |
44 shouldEvaluateAsSilent("publicKey.type", "public"); | 44 shouldEvaluateAsSilent("publicKey.type", "public"); |
45 shouldEvaluateAsSilent("publicKey.extractable", true); | 45 shouldEvaluateAsSilent("publicKey.extractable", true); |
46 shouldEvaluateAsSilent("publicKey.algorithm.name", algorithm.name); | 46 shouldEvaluateAsSilent("publicKey.algorithm.name", algorithm.name); |
47 shouldEvaluateAsSilent("publicKey.algorithm.modulusLength", algorithm.mo
dulusLength); | 47 shouldEvaluateAsSilent("publicKey.algorithm.modulusLength", algorithm.mo
dulusLength); |
48 shouldEvaluateAsSilent("bytesToHexString(publicKey.algorithm.publicExpon
ent)", "010001"); | 48 shouldEvaluateAsSilent("bytesToHexString(publicKey.algorithm.publicExpon
ent)", "010001"); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 }); | 178 }); |
179 } | 179 } |
180 | 180 |
181 Promise.all([ | 181 Promise.all([ |
182 testHmac(), | 182 testHmac(), |
183 testGenerateRsaKey(), | 183 testGenerateRsaKey(), |
184 testAesGcm(), | 184 testAesGcm(), |
185 testHmac(), | 185 testHmac(), |
186 testAesGcm(), | 186 testAesGcm(), |
187 ]).then(notifySuccess, notifyFailure); | 187 ]).then(notifySuccess, notifyFailure); |
OLD | NEW |