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

Side by Side Diff: LayoutTests/crypto/sign-verify.html

Issue 23164012: WebCrypto: Remove support for multi-part operations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Sync to tot 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script> 4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 <script src="resources/common.js"></script> 5 <script src="resources/common.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
11 <script> 11 <script>
12 description("Tests cypto.subtle.sign and crypto.subtle.verify"); 12 description("Tests cypto.subtle.sign and crypto.subtle.verify");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 importHmacSha1Key().then(function(key) { 16 importHmacSha1Key().then(function(key) {
17 hmacSha1Key = key; 17 hmacSha1Key = key;
18 hmacSha1 = {name: 'hmac', hash: {name: 'Sha-1'}}; 18 hmacSha1 = {name: 'hmac', hash: {name: 'Sha-1'}};
19 19
20 // Pass invalid signature parameters to verify() 20 data = asciiToArrayBuffer("hello");
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"); 21 var expectedSignature = asciiToArrayBuffer("signed HMAC:hello");
27 22
28 var signPromise = crypto.subtle.sign(hmacSha1, hmacSha1Key).process(data).fi nish(); 23 // Pass invalid signature parameters to verify()
29 var verifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, expectedSign ature).process(data).finish(); 24 shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, null, data)");
30 var badVerifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, asciiToAr rayBuffer("badsignature")).process(data).finish(); 25 shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, 'a', data)");
26 shouldThrow("crypto.subtle.verify(hmacSha1, hmacSha1Key, [], data)");
27
28 var signPromise = crypto.subtle.sign(hmacSha1, hmacSha1Key, data);
29 var verifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, expectedSign ature, data);
30 var badVerifyPromise = crypto.subtle.verify(hmacSha1, hmacSha1Key, asciiToAr rayBuffer("badsignature"), data);
31 31
32 Promise.every(signPromise, verifyPromise, badVerifyPromise).then(function(re sults) 32 Promise.every(signPromise, verifyPromise, badVerifyPromise).then(function(re sults)
33 { 33 {
34 signResult = results[0]; 34 signResult = results[0];
35 verifyResult1 = results[1]; 35 verifyResult1 = results[1];
36 verifyResult2 = results[2]; 36 verifyResult2 = results[2];
37 37
38 shouldBe("signResult.byteLength", "17"); 38 shouldBe("signResult.byteLength", "17");
39 shouldBe("verifyResult1", "true"); 39 shouldBe("verifyResult1", "true");
40 shouldBe("verifyResult2", "false"); 40 shouldBe("verifyResult2", "false");
41 41
42 finishJSTest(); 42 finishJSTest();
43 }); 43 });
44 }); 44 });
45 45
46 </script> 46 </script>
47 47
48 <script src="../fast/js/resources/js-test-post.js"></script> 48 <script src="../fast/js/resources/js-test-post.js"></script>
49 </body> 49 </body>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/normalize-algorithm-expected.txt ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698