| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.algorithm.length", (keyData.byteLength * 8).toString())
; |
| 155 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'"); | 155 shouldBe("tmpKey.usages.join(',')", "'encrypt,decrypt'"); |
| 156 | 156 |
| 157 // (2) Encrypt. | 157 // (2) Encrypt. |
| 158 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); | 158 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); |
| 159 }).then(function(result) { | 159 }).then(function(result) { |
| 160 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); | 160 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); |
| 161 | 161 |
| 162 // (3) Decrypt | 162 // (3) Decrypt |
| 163 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); | 163 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); |
| 164 }).then(function(result) { | 164 }).then(function(result) { |
| 165 bytesShouldMatchHexString("Decryption", testCase.plainText, result); | 165 bytesShouldMatchHexString("Decryption", testCase.plainText, result); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 182 | 182 |
| 183 // (1) Import the key | 183 // (1) Import the key |
| 184 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { | 184 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s).then(function(result) { |
| 185 key = result; | 185 key = result; |
| 186 | 186 |
| 187 // shouldBe() can only resolve variables in global context. | 187 // shouldBe() can only resolve variables in global context. |
| 188 tmpKey = key; | 188 tmpKey = key; |
| 189 shouldBe("tmpKey.type", "'secret'"); | 189 shouldBe("tmpKey.type", "'secret'"); |
| 190 shouldBe("tmpKey.extractable", "false"); | 190 shouldBe("tmpKey.extractable", "false"); |
| 191 shouldBe("tmpKey.algorithm.name", "'AES-GCM'"); | 191 shouldBe("tmpKey.algorithm.name", "'AES-GCM'"); |
| 192 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'"); | 192 shouldBe("tmpKey.usages.join(',')", "'encrypt,decrypt'"); |
| 193 | 193 |
| 194 // (2) Encrypt. | 194 // (2) Encrypt. |
| 195 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); | 195 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); |
| 196 }).then(function(result) { | 196 }).then(function(result) { |
| 197 bytesShouldMatchHexString("Encryption", testCase.cipherText + testCase.a
uthenticationTag, result); | 197 bytesShouldMatchHexString("Encryption", testCase.cipherText + testCase.a
uthenticationTag, result); |
| 198 | 198 |
| 199 // (3) Decrypt | 199 // (3) Decrypt |
| 200 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText + testCase.authenticationTag)); | 200 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText + testCase.authenticationTag)); |
| 201 }).then(function(result) { | 201 }).then(function(result) { |
| 202 bytesShouldMatchHexString("Decryption", testCase.plainText, result); | 202 bytesShouldMatchHexString("Decryption", testCase.plainText, result); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 shouldThrow("crypto.subtle.encrypt({name: 'bogus'}, null, data)"); | 349 shouldThrow("crypto.subtle.encrypt({name: 'bogus'}, null, data)"); |
| 350 } | 350 } |
| 351 | 351 |
| 352 addTask(importTestKeys().then(testNormalizationFailures)); | 352 addTask(importTestKeys().then(testNormalizationFailures)); |
| 353 | 353 |
| 354 completeTestWhenAllTasksDone(); | 354 completeTestWhenAllTasksDone(); |
| 355 | 355 |
| 356 </script> | 356 </script> |
| 357 | 357 |
| 358 </body> | 358 </body> |
| OLD | NEW |