| 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.algorithm.length", (keyData.byteLength * 8).toString())
; |
| 91 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'"); | 92 shouldBe("tmpKey.usages.join(',')", "'decrypt,encrypt'"); |
| 92 | 93 |
| 93 // (2) Encrypt. | 94 // (2) Encrypt. |
| 94 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); | 95 return crypto.subtle.encrypt(algorithm, key, hexStringToUint8Array(testC
ase.plainText)); |
| 95 }).then(function(result) { | 96 }).then(function(result) { |
| 96 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); | 97 bytesShouldMatchHexString("Encryption", testCase.cipherText, result); |
| 97 | 98 |
| 98 // (3) Decrypt | 99 // (3) Decrypt |
| 99 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); | 100 return crypto.subtle.decrypt(algorithm, key, hexStringToUint8Array(testC
ase.cipherText)); |
| 100 }).then(function(result) { | 101 }).then(function(result) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 shouldThrow("crypto.subtle.encrypt({name: 'bogus'}, null, data)"); | 232 shouldThrow("crypto.subtle.encrypt({name: 'bogus'}, null, data)"); |
| 232 } | 233 } |
| 233 | 234 |
| 234 addTask(importTestKeys().then(testNormalizationFailures)); | 235 addTask(importTestKeys().then(testNormalizationFailures)); |
| 235 | 236 |
| 236 completeTestWhenAllTasksDone(); | 237 completeTestWhenAllTasksDone(); |
| 237 | 238 |
| 238 </script> | 239 </script> |
| 239 | 240 |
| 240 </body> | 241 </body> |
| OLD | NEW |