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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // (1) Import the key | 87 // (1) Import the key |
88 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable,
usages).then(function(result) { | 88 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable,
usages).then(function(result) { |
89 key = result; | 89 key = result; |
90 | 90 |
91 // shouldBe() can only resolve variables in global context. | 91 // shouldBe() can only resolve variables in global context. |
92 tmpKey = key; | 92 tmpKey = key; |
93 shouldBe("tmpKey.type", "'secret'") | 93 shouldBe("tmpKey.type", "'secret'") |
94 shouldBe("tmpKey.extractable", "false") | 94 shouldBe("tmpKey.extractable", "false") |
95 shouldBe("tmpKey.algorithm.name", "'HMAC'") | 95 shouldBe("tmpKey.algorithm.name", "'HMAC'") |
96 shouldBe("tmpKey.algorithm.hash.name", "'" + testCase.algorithm + "'") | 96 shouldBe("tmpKey.algorithm.hash.name", "'" + testCase.algorithm + "'") |
| 97 shouldEvaluateTo("tmpKey.algorithm.length", keyData.length * 8); |
97 shouldBe("tmpKey.usages.join(',')", "'sign,verify'") | 98 shouldBe("tmpKey.usages.join(',')", "'sign,verify'") |
98 | 99 |
99 // (2) Sign. | 100 // (2) Sign. |
100 return crypto.subtle.sign(algorithm, key, hexStringToUint8Array(testCase
.message)); | 101 return crypto.subtle.sign(algorithm, key, hexStringToUint8Array(testCase
.message)); |
101 }).then(function(result) { | 102 }).then(function(result) { |
102 bytesShouldMatchHexString("Mac", testCase.mac, result); | 103 bytesShouldMatchHexString("Mac", testCase.mac, result); |
103 | 104 |
104 // (3) Verify | 105 // (3) Verify |
105 return crypto.subtle.verify(algorithm, key, hexStringToUint8Array(testCa
se.mac), hexStringToUint8Array(testCase.message)); | 106 return crypto.subtle.verify(algorithm, key, hexStringToUint8Array(testCa
se.mac), hexStringToUint8Array(testCase.message)); |
106 }).then(function(result) { | 107 }).then(function(result) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 143 |
143 // ------------------------------------------------- | 144 // ------------------------------------------------- |
144 // Wait until all the tests have been run. | 145 // Wait until all the tests have been run. |
145 // ------------------------------------------------- | 146 // ------------------------------------------------- |
146 | 147 |
147 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); | 148 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); |
148 | 149 |
149 </script> | 150 </script> |
150 | 151 |
151 </body> | 152 </body> |
OLD | NEW |