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

Unified Diff: LayoutTests/crypto/aes-kw-wrap-unwrap-aes.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-wrap-unwrap-aes.html
diff --git a/LayoutTests/crypto/aes-kw-wrap-unwrap-aes.html b/LayoutTests/crypto/aes-kw-wrap-unwrap-aes.html
new file mode 100644
index 0000000000000000000000000000000000000000..9e12086d0cc38c63755a9cba29712e7141476bb2
--- /dev/null
+++ b/LayoutTests/crypto/aes-kw-wrap-unwrap-aes.html
@@ -0,0 +1,57 @@
+<!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 wrapping and unwrapping keys with AES-KW.");
+
+jsTestIsAsync = true;
+
+var kekData = hexStringToUint8Array("000102030405060708090A0B0C0D0E0F");
+var keyData = hexStringToUint8Array("00112233445566778899AABBCCDDEEFF");
+var extractable = true;
+
+debug("Importing key encryption key...");
+crypto.subtle.importKey("raw", kekData, {name: "aes-kw"}, extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+ kek = result;
+
+ debug("Importing a key to be wrapped...");
+ return crypto.subtle.importKey("raw", keyData, {name: "aes-cbc"}, extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]);
+}).then(function(result) {
+ key = result;
+
+ debug("Wrapping it...");
+ return crypto.subtle.wrapKey("raw", key, kek, {name: "aes-kw"});
+}).then(function(result) {
+ wrappedKey = result;
+ shouldBe("bytesToHexString(wrappedKey)", "'1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5'"); // Result from RFC 3394.
+
+ debug("Unwrapping it...");
+ return crypto.subtle.unwrapKey("raw", wrappedKey, kek, {name: "aes-kw"}, {name: "aes-cbc"}, extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]);
+}).then(function(result) {
+ unwrappedKey = result;
+ shouldBe("unwrappedKey.toString()", "'[object Key]'");
+ shouldBe("unwrappedKey.type", "'secret'");
+ shouldBe("unwrappedKey.extractable", "true");
+ shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
+ shouldBe("unwrappedKey.algorithm.length", "128");
+ shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']");
+
+ debug("Exporting it...");
+ return crypto.subtle.exportKey("raw", unwrappedKey);
+}).then(function(result) {
+ unwrappedKeyData = result;
+ shouldBe("bytesToHexString(unwrappedKeyData)", "bytesToHexString(keyData)");
+
+ finishJSTest();
+});
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/aes-kw-key-manipulation-expected.txt ('k') | LayoutTests/crypto/aes-kw-wrap-unwrap-aes-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698