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 23 matching lines...) Expand all Loading... |
34 var extractable = false; | 34 var extractable = false; |
35 var usages = ['sign', 'verify']; | 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: "RSASSA-PKCS1-v1_5", modulusLength: 256, publicExpone
nt: hexStringToUint8Array("010001"), hash: {name: "SHA-256"}}; | 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 shouldBeTrue("publicKey instanceof CryptoKey", true); |
| 45 |
44 shouldEvaluateAsSilent("publicKey.type", "public"); | 46 shouldEvaluateAsSilent("publicKey.type", "public"); |
45 shouldEvaluateAsSilent("publicKey.extractable", true); | 47 shouldEvaluateAsSilent("publicKey.extractable", true); |
46 shouldEvaluateAsSilent("publicKey.algorithm.name", algorithm.name); | 48 shouldEvaluateAsSilent("publicKey.algorithm.name", algorithm.name); |
47 shouldEvaluateAsSilent("publicKey.algorithm.modulusLength", algorithm.mo
dulusLength); | 49 shouldEvaluateAsSilent("publicKey.algorithm.modulusLength", algorithm.mo
dulusLength); |
48 shouldEvaluateAsSilent("bytesToHexString(publicKey.algorithm.publicExpon
ent)", "010001"); | 50 shouldEvaluateAsSilent("bytesToHexString(publicKey.algorithm.publicExpon
ent)", "010001"); |
49 | 51 |
50 shouldEvaluateAsSilent("privateKey.type", "private"); | 52 shouldEvaluateAsSilent("privateKey.type", "private"); |
51 shouldEvaluateAsSilent("privateKey.extractable", false); | 53 shouldEvaluateAsSilent("privateKey.extractable", false); |
52 shouldEvaluateAsSilent("privateKey.algorithm.name", algorithm.name); | 54 shouldEvaluateAsSilent("privateKey.algorithm.name", algorithm.name); |
53 shouldEvaluateAsSilent("privateKey.algorithm.modulusLength", algorithm.m
odulusLength); | 55 shouldEvaluateAsSilent("privateKey.algorithm.modulusLength", algorithm.m
odulusLength); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 }); | 180 }); |
179 } | 181 } |
180 | 182 |
181 Promise.all([ | 183 Promise.all([ |
182 testHmac(), | 184 testHmac(), |
183 testGenerateRsaKey(), | 185 testGenerateRsaKey(), |
184 testAesGcm(), | 186 testAesGcm(), |
185 testHmac(), | 187 testHmac(), |
186 testAesGcm(), | 188 testAesGcm(), |
187 ]).then(notifySuccess, notifyFailure); | 189 ]).then(notifySuccess, notifyFailure); |
OLD | NEW |