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

Unified Diff: LayoutTests/crypto/jwk-export-use-values.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
« no previous file with comments | « LayoutTests/crypto/import-jwk-expected.txt ('k') | LayoutTests/crypto/jwk-export-use-values-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/jwk-export-use-values.html
diff --git a/LayoutTests/crypto/jwk-export-use-values.html b/LayoutTests/crypto/jwk-export-use-values.html
new file mode 100644
index 0000000000000000000000000000000000000000..efed16a81d61b20c5b79fddcff5c88f9da1235ca
--- /dev/null
+++ b/LayoutTests/crypto/jwk-export-use-values.html
@@ -0,0 +1,63 @@
+<!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 exporting keys with various usages to JWK.");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+var aesKeyAsArrayBuffer = Base64URL.parse("jnOw99oOZFLIEPMrgJB55WL46tJSLGt7");
+var hmacKeyAsArrayBuffer = Base64URL.parse("ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs");
+
+function testWithAESCBC(usages, expectedKeyOps)
+{
+ return crypto.subtle.importKey("raw", aesKeyAsArrayBuffer, {name: "AES-CBC"}, extractable, usages).then(function(result) {
+ return crypto.subtle.exportKey("jwk", result);
+ }).then(function(result) {
+ jwk = JSON.parse(bytesToASCIIString(result));
+ debug(usages + ":");
+ shouldBe("jwk.use", "undefined");
+ shouldBe("jwk.key_ops", JSON.stringify(expectedKeyOps));
+ debug("");
+ });
+}
+
+function testWithHMAC(usages, expectedKeyOps)
+{
+ return crypto.subtle.importKey("raw", hmacKeyAsArrayBuffer, {name: 'hmac', hash: {name: 'sha-256'}}, extractable, usages).then(function(result) {
+ return crypto.subtle.exportKey("jwk", result);
+ }).then(function(result) {
+ jwk = JSON.parse(bytesToASCIIString(result));
+ debug(usages + ":");
+ shouldBe("jwk.use", "undefined");
+ shouldBe("jwk.key_ops", JSON.stringify(expectedKeyOps));
+ debug("");
+ });
+}
+
+Promise.all([
+ testWithAESCBC(["encrypt"], ["encrypt"]),
+ testWithAESCBC(["decrypt"], ["decrypt"]),
+ testWithAESCBC(["encrypt", "decrypt"], ["encrypt", "decrypt"]),
+ testWithAESCBC(["wrapKey"], ["wrapKey"]),
+ testWithAESCBC(["unwrapKey"], ["unwrapKey"]),
+ testWithAESCBC(["wrapKey", "unwrapKey"], ["wrapKey", "unwrapKey"]),
+ testWithAESCBC(["encrypt", "decrypt", "wrapKey"], ["encrypt", "decrypt", "wrapKey"]),
+ testWithAESCBC(["encrypt", "decrypt", "wrapKey", "unwrapKey"], ["encrypt", "decrypt", "wrapKey", "unwrapKey"]),
+ testWithHMAC(["sign"], ["sign"]),
+ testWithHMAC(["verify"], ["verify"]),
+ testWithHMAC(["sign", "verify"], ["sign", "verify"]),
+]).then(finishJSTest, failAndFinishJSTest);
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/import-jwk-expected.txt ('k') | LayoutTests/crypto/jwk-export-use-values-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698