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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 // (1) Import the key | 82 // (1) Import the key |
83 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { | 83 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { |
84 key = result; | 84 key = result; |
85 | 85 |
86 // shouldBe() can only resolve variables in global context. | 86 // shouldBe() can only resolve variables in global context. |
87 tmpKey = key; | 87 tmpKey = key; |
88 shouldBe("tmpKey.type", "'secret'") | 88 shouldBe("tmpKey.type", "'secret'") |
89 shouldBe("tmpKey.extractable", "false") | 89 shouldBe("tmpKey.extractable", "false") |
90 shouldBe("tmpKey.algorithm.name", "'AES-CBC'") | 90 shouldBe("tmpKey.algorithm.name", "'AES-CBC'") |
91 shouldBe("tmpKey.usages.join(',')", "'encrypt,decrypt'") | 91 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'") |
92 | 92 |
93 // (2) Encrypt. | 93 // (2) Encrypt. |
94 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); | 94 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); |
95 }).then(function(result) { | 95 }).then(function(result) { |
96 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); | 96 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); |
97 | 97 |
98 // (3) Decrypt | 98 // (3) Decrypt |
99 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); | 99 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); |
100 }).then(function(result) { | 100 }).then(function(result) { |
101 bytesShouldMatchHexString("Decryption", testCase.plainText, result); | 101 bytesShouldMatchHexString("Decryption", testCase.plainText, result); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 // ------------------------------------------------- | 237 // ------------------------------------------------- |
238 // Wait until all the tests have been run. | 238 // Wait until all the tests have been run. |
239 // ------------------------------------------------- | 239 // ------------------------------------------------- |
240 | 240 |
241 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); | 241 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); |
242 | 242 |
243 </script> | 243 </script> |
244 | 244 |
245 </body> | 245 </body> |
OLD | NEW |