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

Unified Diff: third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization.html

Issue 2316633003: Copy data bytes in Web Crypto's importKey() and verify() operations (Closed)
Patch Set: add layout tests Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization.html
diff --git a/third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization.html b/third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization.html
new file mode 100644
index 0000000000000000000000000000000000000000..3f7b49473cbf0b2c1eb1693ee054adaffe8f7195
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization.html
@@ -0,0 +1,59 @@
+<!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.importKey() using a BufferSource that is modified during algorithm normalization");
+
+jsTestIsAsync = true;
+
+var kKeyDataHex = "30112233445566778899aabbccddeeff";
+
+keyData = hexStringToUint8Array(kKeyDataHex);
+
+function corruptKeyData()
+{
+ debug("Corrupting keyData...");
+ keyData[0] = 0;
+ keyData[1] = 0;
+}
+
+// This algorithm has a custom getter that modifies the key data.
+var importAlgorithm = {
+ get name() {
+ debug("Accessed name property");
+ corruptKeyData();
+ return 'aes-cbc';
+ }
+};
+
+var extractable = true;
+var usages = ['encrypt', 'decrypt'];
+
+debug("Importing key...");
+crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable, usages).then(function(result) {
+ debug("Exporting key...");
+ return crypto.subtle.exportKey('raw', result);
+}).then(function(result) {
+ bytesShouldMatchHexString("Exported data", kKeyDataHex, result);
+
+ debug("Importing key (again)...");
+ return crypto.subtle.importKey('raw', keyData, "AES-CBC", extractable, usages);
+}).then(function(result) {
+ debug("Importing second key...");
+ return crypto.subtle.exportKey('raw', result);
+}).then(function(result) {
+ // This time the imported key should reflect the modified version.
+ bytesShouldMatchHexString("Exported data", "00002233445566778899aabbccddeeff", result);
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/crypto/subtle/modify-importKey-data-during-normalization-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698