| 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 |
| 11 <script> | 11 <script> |
| 12 description("Tests sign() and verify() for HMAC"); | 12 description("Tests sign() and verify() for HMAC"); |
| 13 | 13 |
| 14 jsTestIsAsync = true; | 14 jsTestIsAsync = true; |
| 15 | 15 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 var algorithm = {name: 'HMAC'}; | 85 var algorithm = {name: 'HMAC'}; |
| 86 | 86 |
| 87 var key = null; | 87 var key = null; |
| 88 var keyData = hexStringToUint8Array(testCase.key); | 88 var keyData = hexStringToUint8Array(testCase.key); |
| 89 var usages = ['sign', 'verify']; | 89 var usages = ['sign', 'verify']; |
| 90 var extractable = false; | 90 var extractable = false; |
| 91 | 91 |
| 92 // (1) Import the key | 92 // (1) Import the key |
| 93 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable,
usages).then(function(result) { | 93 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable,
usages).then(function(result) { |
| 94 key = result; | 94 key = result; |
| 95 | 95 |
| 96 // shouldBe() can only resolve variables in global context. | 96 // shouldBe() can only resolve variables in global context. |
| 97 tmpKey = key; | 97 tmpKey = key; |
| 98 shouldEvaluateAs("tmpKey.type", "secret"); | 98 shouldEvaluateAs("tmpKey.type", "secret"); |
| 99 shouldEvaluateAs("tmpKey.extractable", false); | 99 shouldEvaluateAs("tmpKey.extractable", false); |
| 100 shouldEvaluateAs("tmpKey.algorithm.name", "HMAC"); | 100 shouldEvaluateAs("tmpKey.algorithm.name", "HMAC"); |
| 101 shouldEvaluateAs("tmpKey.algorithm.hash.name", testCase.hash); | 101 shouldEvaluateAs("tmpKey.algorithm.hash.name", testCase.hash); |
| 102 shouldEvaluateAs("tmpKey.algorithm.length", keyData.length * 8); | 102 shouldEvaluateAs("tmpKey.algorithm.length", keyData.length * 8); |
| 103 shouldEvaluateAs("tmpKey.usages.join(',')", "sign,verify"); | 103 shouldEvaluateAs("tmpKey.usages.join(',')", "sign,verify"); |
| 104 | 104 |
| 105 // (2) Sign. | 105 // (2) Sign. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 131 }) | 131 }) |
| 132 }) | 132 }) |
| 133 }); | 133 }); |
| 134 | 134 |
| 135 lastPromise.then(finishJSTest, failAndFinishJSTest); | 135 lastPromise.then(finishJSTest, failAndFinishJSTest); |
| 136 | 136 |
| 137 </script> | 137 </script> |
| 138 | 138 |
| 139 </body> | 139 </body> |
| 140 </html> | 140 </html> |
| OLD | NEW |