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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/crypto/subtle/modify-encrypt-data-during-normalization.html
diff --git a/third_party/WebKit/LayoutTests/crypto/subtle/modify-encrypt-data-during-normalization.html b/third_party/WebKit/LayoutTests/crypto/subtle/modify-encrypt-data-during-normalization.html
new file mode 100644
index 0000000000000000000000000000000000000000..b5ecdf4704c0cf2c9f789eb716c14d62e381918f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/crypto/subtle/modify-encrypt-data-during-normalization.html
@@ -0,0 +1,70 @@
+<!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 crypto.subtle.encrypt() using a BufferSource that is modified during algorithm normalization");
+
+jsTestIsAsync = true;
+
+data = null;
+key = null;
+
+var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
+var iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f");
+var kPlainText = "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710";
+var kExpectedCipherTextHex = "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78cb82807230e1321d3fae00d18cc2012";
+var plainText = hexStringToUint8Array(kPlainText);
+// This is the plaintext resulting from corruptPlainText.
+var kModifiedPlainText = "0000bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710";
+
+function corruptPlainText()
+{
+ debug("Corrupted plainText");
+ plainText[0] = 0;
+ plainText[1] = 0;
+}
+
+var extractable = true;
+var usages = ['encrypt', 'decrypt'];
+
+debug("Importing key...");
+crypto.subtle.importKey('raw', keyData, "aes-cbc", extractable, usages).then(function(result) {
+ key = result;
+
+ debug("\nEncrypting (as a control group)...");
+ return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plainText);
+}).then(function(result) {
+ bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
+
+ // This algorithm has custom getters that modifies plainText.
+ var algorithm = {
+ get name() {
+ debug("Accessed name property");
+ corruptPlainText();
+ return 'aes-cbc';
+ },
+
+ get iv() {
+ debug("Accessed iv property");
+ corruptPlainText();
+ return iv;
+ }
+ };
+
+ debug("\nEncrypting again, using an algorithm that mutates the array buffer...");
+ return crypto.subtle.encrypt(algorithm, key, plainText);
+}).then(function(result) {
+ bytesShouldMatchHexString("plainText", kModifiedPlainText, plainText);
+ bytesShouldMatchHexString("Encryption", kExpectedCipherTextHex, result);
+}).then(finishJSTest, failAndFinishJSTest);
+</script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698