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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/crypto/resources/common.js ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Tests cypto.subtle.sign and crypto.subtle.verify");
13
14 jsTestIsAsync = true;
15
16 importHmacSha1Key().then(function(key) {
17 hmacSha1Key = key;
18 hmacSha1 = {name: 'hmac', hash: {name: 'Sha-1'}};
19
20 // Pass invalid signature parameters to verify()
21 shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, null)");
22 shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, 'a')");
23 shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, [])");
24
25 var data = asciiToArrayBuffer("hello");
26 var expectedSignature = asciiToArrayBuffer("signed HMAC:hello");
27
28 var signPromise = crypto.subtle.sign(hmacSha1, hmacSha1Key).process(data).fi nish();
29 var verifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, expectedSign ature).process(data).finish();
30 var badVerifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, asciiToAr rayBuffer("badsignature")).process(data).finish();
31
32 Promise.every(signPromise, verifyPromise, badVerifyPromise).then(function(re sults)
33 {
34 signResult = results[0];
35 verifyResult1 = results[1];
36 verifyResult2 = results[2];
37
38 shouldBe("signResult.byteLength", "17");
39 shouldBe("verifyResult1", "true");
40 shouldBe("verifyResult2", "false");
41
42 finishJSTest();
43 });
44 });
45
46 </script>
47
48 <script src="../fast/js/resources/js-test-post.js"></script>
49 </body>
OLDNEW
« 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