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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/crypto/subtle/neuter-algorithm-data-during-encrypt.html
diff --git a/third_party/WebKit/LayoutTests/crypto/subtle/neuter-algorithm-data-during-encrypt.html b/third_party/WebKit/LayoutTests/crypto/subtle/neuter-algorithm-data-during-encrypt.html
new file mode 100644
index 0000000000000000000000000000000000000000..c9e687ace23339ae3b2484b65c22736a8c46c9f1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/crypto/subtle/neuter-algorithm-data-during-encrypt.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script src="resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Tests bad algorithm inputs for AES-CTR");
+
+jsTestIsAsync = true;
+
+var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
+var data = asciiToUint8Array("hello");
+var key = null;
+var counter = new Uint8Array(16);
+var kExpectedCipherTextHex = "1592076075";
+var kLength = 8;
+
+function corruptCounter()
+{
+ debug("Neutering counter...");
+ try { postMessage(counter, "xxx", [counter.buffer]); } catch (e) { }
+ shouldBe("counter.byteLength", "0");
+}
+
+Promise.resolve(null).then(function(result) {
+ var usages = ['encrypt', 'decrypt'];
+ var extractable = false;
+
+ debug("\nImporting AES-CTR key...");
+ return crypto.subtle.importKey('raw', keyData, "aes-ctr", extractable, usages);
+}).then(function(result) {
+ key = result;
+
+ debug("\nencrypt() with normal data (control group)...");
+ return crypto.subtle.encrypt({name: 'AES-CTR', counter: counter, length: kLength}, key, data);
+}).then(function(result) {
+ bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
+
+ var algorithm = {
+ name: 'AES-CTR',
+
+ get counter() {
+ debug("Accessed counter");
+ return counter;
+ },
+
+ get length() {
+ debug("Accessed length");
+ corruptCounter();
+ return kLength;
+ }
+ };
+
+ return crypto.subtle.encrypt(algorithm, key, data);
+}).then(function(result) {
+ bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
+
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698