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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 var keyData = hexStringToUint8Array(testCase.key); | 82 var keyData = hexStringToUint8Array(testCase.key); |
83 var usages = ['sign', 'verify']; | 83 var usages = ['sign', 'verify']; |
84 var extractable = false; | 84 var extractable = false; |
85 | 85 |
86 // (1) Import the key | 86 // (1) Import the key |
87 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { | 87 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { |
88 key = result; | 88 key = result; |
89 | 89 |
90 // shouldBe() can only resolve variables in global context. | 90 // shouldBe() can only resolve variables in global context. |
91 tmpKey = key; | 91 tmpKey = key; |
92 tmpHashName = testCase.algorithm; | |
93 shouldBe("tmpKey.type", "'secret'") | 92 shouldBe("tmpKey.type", "'secret'") |
94 shouldBe("tmpKey.extractable", "false") | 93 shouldBe("tmpKey.extractable", "false") |
95 shouldBe("tmpKey.algorithm.name", "'HMAC'") | 94 shouldBe("tmpKey.algorithm.name", "'HMAC'") |
96 shouldBe("tmpKey.algorithm.hash.name", "tmpHashName") | |
97 shouldBe("tmpKey.usages.join(',')", "'sign,verify'") | 95 shouldBe("tmpKey.usages.join(',')", "'sign,verify'") |
98 | 96 |
99 // (2) Sign. | 97 // (2) Sign. |
100 return crypto.subtle.sign(algorithm, key, hexStringToUint8Array(testCase
.message)); | 98 return crypto.subtle.sign(algorithm, key, hexStringToUint8Array(testCase
.message)); |
101 }).then(function(result) { | 99 }).then(function(result) { |
102 bytesShouldMatchHexString("Mac", testCase.mac, result); | 100 bytesShouldMatchHexString("Mac", testCase.mac, result); |
103 | 101 |
104 // (3) Verify | 102 // (3) Verify |
105 return crypto.subtle.verify(algorithm, key, hexStringToUint8Array(testCa
se.mac), hexStringToUint8Array(testCase.message)); | 103 return crypto.subtle.verify(algorithm, key, hexStringToUint8Array(testCa
se.mac), hexStringToUint8Array(testCase.message)); |
106 }).then(function(result) { | 104 }).then(function(result) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 153 |
156 // ------------------------------------------------- | 154 // ------------------------------------------------- |
157 // Wait until all the tests have been run. | 155 // Wait until all the tests have been run. |
158 // ------------------------------------------------- | 156 // ------------------------------------------------- |
159 | 157 |
160 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); | 158 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); |
161 | 159 |
162 </script> | 160 </script> |
163 | 161 |
164 </body> | 162 </body> |
OLD | NEW |