| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <p id="description"></p> | 8 <p id="description"></p> |
| 9 <div id="console"></div> | 9 <div id="console"></div> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 function testWithAESCBC(expectedUsages, jwkUsages, importUsages) | 32 function testWithAESCBC(expectedUsages, jwkUsages, importUsages) |
| 33 { | 33 { |
| 34 if (jwkUsages.key_ops) { | 34 if (jwkUsages.key_ops) { |
| 35 aesKeyAsJSON.key_ops = jwkUsages.key_ops; | 35 aesKeyAsJSON.key_ops = jwkUsages.key_ops; |
| 36 delete aesKeyAsJSON.use; | 36 delete aesKeyAsJSON.use; |
| 37 } else { | 37 } else { |
| 38 delete aesKeyAsJSON.key_ops; | 38 delete aesKeyAsJSON.key_ops; |
| 39 aesKeyAsJSON.use = jwkUsages.use; | 39 aesKeyAsJSON.use = jwkUsages.use; |
| 40 } | 40 } |
| 41 | 41 |
| 42 return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(aesKe
yAsJSON)), {name: "AES-CBC"}, extractable, importUsages).then(function(result) { | 42 return crypto.subtle.importKey("jwk", aesKeyAsJSON, {name: "AES-CBC"}, extra
ctable, importUsages).then(function(result) { |
| 43 key = result; | 43 key = result; |
| 44 debug(JSON.stringify(jwkUsages) + ":"); | 44 debug(JSON.stringify(jwkUsages) + ":"); |
| 45 shouldBe("key.usages", JSON.stringify(expectedUsages)); | 45 shouldBe("key.usages", JSON.stringify(expectedUsages)); |
| 46 debug(""); | 46 debug(""); |
| 47 }, function(result) { | 47 }, function(result) { |
| 48 debug(JSON.stringify(jwkUsages) + ":"); | 48 debug(JSON.stringify(jwkUsages) + ":"); |
| 49 debug("Failed importing with " + importUsages + ": " + result); | 49 debug("Failed importing with " + importUsages + ": " + result); |
| 50 }); | 50 }); |
| 51 } | 51 } |
| 52 | 52 |
| 53 function testWithHMAC(expectedUsages, jwkUsages, importUsages) | 53 function testWithHMAC(expectedUsages, jwkUsages, importUsages) |
| 54 { | 54 { |
| 55 if (jwkUsages.key_ops) { | 55 if (jwkUsages.key_ops) { |
| 56 hmacKeyAsJSON.key_ops = jwkUsages.key_ops; | 56 hmacKeyAsJSON.key_ops = jwkUsages.key_ops; |
| 57 delete hmacKeyAsJSON.use; | 57 delete hmacKeyAsJSON.use; |
| 58 } else { | 58 } else { |
| 59 delete hmacKeyAsJSON.key_ops; | 59 delete hmacKeyAsJSON.key_ops; |
| 60 hmacKeyAsJSON.use = jwkUsages.use; | 60 hmacKeyAsJSON.use = jwkUsages.use; |
| 61 } | 61 } |
| 62 | 62 |
| 63 return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(hmacK
eyAsJSON)), {name: 'hmac', hash: {name: 'sha-256'}}, extractable, importUsages).
then(function(result) { | 63 return crypto.subtle.importKey("jwk", hmacKeyAsJSON, {name: 'hmac', hash: {n
ame: 'sha-256'}}, extractable, importUsages).then(function(result) { |
| 64 key = result; | 64 key = result; |
| 65 debug(JSON.stringify(jwkUsages) + ":"); | 65 debug(JSON.stringify(jwkUsages) + ":"); |
| 66 shouldBe("key.usages", JSON.stringify(expectedUsages)); | 66 shouldBe("key.usages", JSON.stringify(expectedUsages)); |
| 67 debug(""); | 67 debug(""); |
| 68 }, function(result) { | 68 }, function(result) { |
| 69 debug(JSON.stringify(jwkUsages) + ":"); | 69 debug(JSON.stringify(jwkUsages) + ":"); |
| 70 debug("Failed importing with " + importUsages + ": " + result); | 70 debug("Failed importing with " + importUsages + ": " + result); |
| 71 }); | 71 }); |
| 72 } | 72 } |
| 73 | 73 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 testWithAESCBC(["decrypt"], {key_ops: ["Encrypt", "decrypt"]}, ["decrypt"]), | 114 testWithAESCBC(["decrypt"], {key_ops: ["Encrypt", "decrypt"]}, ["decrypt"]), |
| 115 testWithAESCBC(null, {key_ops: ["'encrypt'", "decrypt"]}, ["encrypt"]), | 115 testWithAESCBC(null, {key_ops: ["'encrypt'", "decrypt"]}, ["encrypt"]), |
| 116 testWithAESCBC(null, {key_ops: ["encrypt "]}, ["encrypt"]), | 116 testWithAESCBC(null, {key_ops: ["encrypt "]}, ["encrypt"]), |
| 117 testWithAESCBC(null, {key_ops: ["Encrypt"]}, ["encrypt"]), | 117 testWithAESCBC(null, {key_ops: ["Encrypt"]}, ["encrypt"]), |
| 118 | 118 |
| 119 ]).then(finishJSTest, failAndFinishJSTest); | 119 ]).then(finishJSTest, failAndFinishJSTest); |
| 120 </script> | 120 </script> |
| 121 | 121 |
| 122 </body> | 122 </body> |
| 123 </html> | 123 </html> |
| OLD | NEW |