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

Side by Side Diff: third_party/WebKit/LayoutTests/crypto/subtle/neuter-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 = "";
26
27 function corruptPlainText()
28 {
29 debug("Corrupted plainText");
30
31 debug("Neutering plainText...");
32 try { postMessage(plainText, "xxx", [plainText.buffer]); } catch (e) { }
33 shouldBe("plainText.byteLength", "0");
34 }
35
36 var extractable = true;
37 var usages = ['encrypt', 'decrypt'];
38
39 debug("Importing key...");
40 crypto.subtle.importKey('raw', keyData, "aes-cbc", extractable, usages).then(fun ction(result) {
41 key = result;
42
43 debug("\nEncrypting (as a control group)...");
44 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plainText);
45 }).then(function(result) {
46 bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
47
48 // This algorithm has custom getters that modifies plainText.
49 var algorithm = {
50 get name() {
51 debug("Accessed name property");
52 corruptPlainText();
53 return 'aes-cbc';
54 },
55
56 iv: iv,
57 };
58
59 debug("\nEncrypting again, using an algorithm that mutates the array buffer. ..");
60 return crypto.subtle.encrypt(algorithm, key, plainText);
61 }).then(function(result) {
62 bytesShouldMatchHexString("plainText", kModifiedPlainText, plainText);
63 bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
64 }).then(finishJSTest, failAndFinishJSTest);
65 </script>
66
67 </body>
68 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698