Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Side by Side Diff: third_party/WebKit/LayoutTests/crypto/subtle/modify-encrypt-data-during-normalization.html

Issue 2141843002: Copy array buffer data used by WebCrypto in the order expected by draft specification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change FIXME --> TODO(eroman) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Tests crypto.subtle.encrypt() using a BufferSource that is modified during algorithm normalization");
13
14 jsTestIsAsync = true;
15
16 data = null;
17 key = null;
18
19 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
20 var iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f");
21 var kPlainText = "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e 5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710";
22 var kExpectedCipherTextHex = "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95 db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78c b82807230e1321d3fae00d18cc2012";
23 var plainText = hexStringToUint8Array(kPlainText);
24 // This is the plaintext resulting from corruptPlainText.
25 var kModifiedPlainText = "0000bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76f ac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710";
26
27 function corruptPlainText()
28 {
29 debug("Corrupted plainText");
30 plainText[0] = 0;
31 plainText[1] = 0;
32 }
33
34 var extractable = true;
35 var usages = ['encrypt', 'decrypt'];
36
37 debug("Importing key...");
38 crypto.subtle.importKey('raw', keyData, "aes-cbc", extractable, usages).then(fun ction(result) {
39 key = result;
40
41 debug("\nEncrypting (as a control group)...");
42 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plainText);
43 }).then(function(result) {
44 bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
45
46 // This algorithm has custom getters that modifies plainText.
47 var algorithm = {
48 get name() {
49 debug("Accessed name property");
50 corruptPlainText();
51 return 'aes-cbc';
52 },
53
54 get iv() {
55 debug("Accessed iv property");
56 corruptPlainText();
57 return iv;
58 }
59 };
60
61 debug("\nEncrypting again, using an algorithm that mutates the array buffer. ..");
62 return crypto.subtle.encrypt(algorithm, key, plainText);
63 }).then(function(result) {
64 bytesShouldMatchHexString("plainText", kModifiedPlainText, plainText);
65 bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
66 }).then(finishJSTest, failAndFinishJSTest);
67 </script>
68
69 </body>
70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698