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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 // (1) Import the key | 145 // (1) Import the key |
146 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { | 146 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { |
147 key = result; | 147 key = result; |
148 | 148 |
149 // shouldBe() can only resolve variables in global context. | 149 // shouldBe() can only resolve variables in global context. |
150 tmpKey = key; | 150 tmpKey = key; |
151 shouldBe("tmpKey.type", "'secret'"); | 151 shouldBe("tmpKey.type", "'secret'"); |
152 shouldBe("tmpKey.extractable", "false"); | 152 shouldBe("tmpKey.extractable", "false"); |
153 shouldBe("tmpKey.algorithm.name", "'AES-CBC'"); | 153 shouldBe("tmpKey.algorithm.name", "'AES-CBC'"); |
| 154 shouldBe("tmpKey.algorithm.length", (keyData.byteLength * 8).toString())
; |
154 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'"); | 155 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'"); |
155 | 156 |
156 // (2) Encrypt. | 157 // (2) Encrypt. |
157 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); | 158 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); |
158 }).then(function(result) { | 159 }).then(function(result) { |
159 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); | 160 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); |
160 | 161 |
161 // (3) Decrypt | 162 // (3) Decrypt |
162 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); | 163 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); |
163 }).then(function(result) { | 164 }).then(function(result) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 shouldThrow("crypto.subtle.encrypt({name: 'bogus'}, null, data)"); | 349 shouldThrow("crypto.subtle.encrypt({name: 'bogus'}, null, data)"); |
349 } | 350 } |
350 | 351 |
351 addTask(importTestKeys().then(testNormalizationFailures)); | 352 addTask(importTestKeys().then(testNormalizationFailures)); |
352 | 353 |
353 completeTestWhenAllTasksDone(); | 354 completeTestWhenAllTasksDone(); |
354 | 355 |
355 </script> | 356 </script> |
356 | 357 |
357 </body> | 358 </body> |
OLD | NEW |