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

Unified Diff: LayoutTests/crypto/sign-verify.html

Issue 21561004: WebCrypto: Add crypto.subtle.verify() to the platform interfaces. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing file common.js Created 7 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
« no previous file with comments | « LayoutTests/crypto/resources/common.js ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/sign-verify.html
diff --git a/LayoutTests/crypto/sign-verify.html b/LayoutTests/crypto/sign-verify.html
new file mode 100644
index 0000000000000000000000000000000000000000..f9a73fd651b1815a07c5dd424a535e978c5f8d13
--- /dev/null
+++ b/LayoutTests/crypto/sign-verify.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Tests cypto.subtle.sign and crypto.subtle.verify");
+
+jsTestIsAsync = true;
+
+importHmacSha1Key().then(function(key) {
+ hmacSha1Key = key;
+ hmacSha1 = {name: 'hmac', hash: {name: 'Sha-1'}};
+
+ // Pass invalid signature parameters to verify()
+ shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, null)");
+ shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, 'a')");
+ shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, [])");
+
+ var data = asciiToArrayBuffer("hello");
+ var expectedSignature = asciiToArrayBuffer("signed HMAC:hello");
+
+ var signPromise = crypto.subtle.sign(hmacSha1, hmacSha1Key).process(data).finish();
+ var verifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, expectedSignature).process(data).finish();
+ var badVerifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, asciiToArrayBuffer("badsignature")).process(data).finish();
+
+ Promise.every(signPromise, verifyPromise, badVerifyPromise).then(function(results)
+ {
+ signResult = results[0];
+ verifyResult1 = results[1];
+ verifyResult2 = results[2];
+
+ shouldBe("signResult.byteLength", "17");
+ shouldBe("verifyResult1", "true");
+ shouldBe("verifyResult2", "false");
+
+ finishJSTest();
+ });
+});
+
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
« no previous file with comments | « LayoutTests/crypto/resources/common.js ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698