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

Side by Side Diff: third_party/WebKit/LayoutTests/crypto/subtle/neuter-algorithm-data-during-encrypt.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 bad algorithm inputs for AES-CTR");
13
14 jsTestIsAsync = true;
15
16 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
17 var data = asciiToUint8Array("hello");
18 var key = null;
19 var counter = new Uint8Array(16);
20 var kExpectedCipherTextHex = "1592076075";
21 var kLength = 8;
22
23 function corruptCounter()
24 {
25 debug("Neutering counter...");
26 try { postMessage(counter, "xxx", [counter.buffer]); } catch (e) { }
27 shouldBe("counter.byteLength", "0");
28 }
29
30 Promise.resolve(null).then(function(result) {
31 var usages = ['encrypt', 'decrypt'];
32 var extractable = false;
33
34 debug("\nImporting AES-CTR key...");
35 return crypto.subtle.importKey('raw', keyData, "aes-ctr", extractable, usage s);
36 }).then(function(result) {
37 key = result;
38
39 debug("\nencrypt() with normal data (control group)...");
40 return crypto.subtle.encrypt({name: 'AES-CTR', counter: counter, length: kLe ngth}, key, data);
41 }).then(function(result) {
42 bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
43
44 var algorithm = {
45 name: 'AES-CTR',
46
47 get counter() {
48 debug("Accessed counter");
49 return counter;
50 },
51
52 get length() {
53 debug("Accessed length");
54 corruptCounter();
55 return kLength;
56 }
57 };
58
59 return crypto.subtle.encrypt(algorithm, key, data);
60 }).then(function(result) {
61 bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
62
63 }).then(finishJSTest, failAndFinishJSTest);
64
65 </script>
66
67 </body>
68 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698