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

Unified Diff: LayoutTests/crypto/aes-kw-key-manipulation.html

Issue 298023002: [webcrypto] Import WebKit's webcrypto tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove FIXME for unrecognized jwk usages (supported now) Created 6 years, 6 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: LayoutTests/crypto/aes-kw-key-manipulation.html
diff --git a/LayoutTests/crypto/aes-kw-key-manipulation.html b/LayoutTests/crypto/aes-kw-key-manipulation.html
new file mode 100644
index 0000000000000000000000000000000000000000..69dcdf8e77dfafaef9025413ebf8e08fd9b33964
--- /dev/null
+++ b/LayoutTests/crypto/aes-kw-key-manipulation.html
@@ -0,0 +1,52 @@
+<!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("Test generating, importing and exporting keys for AES-KW. Test that they can't be used with another algorithm.");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+debug("Generating a key...");
+crypto.subtle.generateKey({name: "aes-kw", length: 256}, extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+ key = result;
+ shouldBe("key.toString()", "'[object Key]'");
+ shouldBe("key.type", "'secret'");
+ shouldBe("key.algorithm.name", "'AES-KW'");
+ shouldBe("key.algorithm.length", "256");
+
+ debug("\nTesting that the key can't be used with AES-CBC...");
+ iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f");
+
+ return crypto.subtle.wrapKey("raw", key, key, {name: "AES-CBC", iv: iv});
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+
+ debug("\nExporting the key to raw...");
+ return crypto.subtle.exportKey('raw', key);
+}).then(function(result) {
+ exportedKey = result;
+ shouldBe("exportedKey.toString()", "'[object ArrayBuffer]'");
+ debug("Importing it back...");
+ return crypto.subtle.importKey('raw', exportedKey, {name: "aes-kw"}, extractable, ["wrapKey", "unwrapKey"]);
+}).then(function(result) {
+ importedKey = result;
+
+ shouldBe("importedKey.toString()", "'[object Key]'");
+ shouldBe("importedKey.type", "'secret'");
+ shouldBe("importedKey.algorithm.name", "'AES-KW'");
+ shouldBe("importedKey.algorithm.length", "256");
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/aes-export-key-expected.txt ('k') | LayoutTests/crypto/aes-kw-key-manipulation-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698