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 <script src="resources/keys.js"></script> | 6 <script src="resources/keys.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <p id="description"></p> | 9 <p id="description"></p> |
10 <div id="console"></div> | 10 <div id="console"></div> |
(...skipping 15 matching lines...) Expand all Loading... |
26 var algorithm = {name: 'aes-cbc', iv: iv}; | 26 var algorithm = {name: 'aes-cbc', iv: iv}; |
27 | 27 |
28 function verifyDecryptionFails(newCipherTextLength) | 28 function verifyDecryptionFails(newCipherTextLength) |
29 { | 29 { |
30 var newCipherText = cipherText.subarray(0, newCipherTextLength); | 30 var newCipherText = cipherText.subarray(0, newCipherTextLength); |
31 | 31 |
32 var description = "ciphertext length: " + newCipherText.byteLength; | 32 var description = "ciphertext length: " + newCipherText.byteLength; |
33 return crypto.subtle.decrypt(algorithm, key, newCipherText).then(function(re
sult) { | 33 return crypto.subtle.decrypt(algorithm, key, newCipherText).then(function(re
sult) { |
34 debug("FAIL: decrypting succeeded. " + description); | 34 debug("FAIL: decrypting succeeded. " + description); |
35 }, function(result) { | 35 }, function(result) { |
| 36 logError(result); |
36 debug("PASS: decrypting failed. " + description); | 37 debug("PASS: decrypting failed. " + description); |
37 }); | 38 }); |
38 } | 39 } |
39 | 40 |
40 crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages).then(fun
ction(result) { | 41 crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages).then(fun
ction(result) { |
41 key = result; | 42 key = result; |
42 | 43 |
43 // Verify that decryption works with the original ciphertext. | 44 // Verify that decryption works with the original ciphertext. |
44 return crypto.subtle.decrypt(algorithm, key, cipherText); | 45 return crypto.subtle.decrypt(algorithm, key, cipherText); |
45 }).then(function(result) { | 46 }).then(function(result) { |
(...skipping 17 matching lines...) Expand all Loading... |
63 badLengths.forEach(function(badLength) { | 64 badLengths.forEach(function(badLength) { |
64 lastPromise = lastPromise.then(verifyDecryptionFails.bind(null, badLengt
h)); | 65 lastPromise = lastPromise.then(verifyDecryptionFails.bind(null, badLengt
h)); |
65 }); | 66 }); |
66 return lastPromise; | 67 return lastPromise; |
67 }).then(finishJSTest, failAndFinishJSTest); | 68 }).then(finishJSTest, failAndFinishJSTest); |
68 | 69 |
69 </script> | 70 </script> |
70 | 71 |
71 </body> | 72 </body> |
72 </html> | 73 </html> |
OLD | NEW |