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

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

Issue 24467004: [webcrypto] Remove MockWebCrypto. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 2 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
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
(...skipping 26 matching lines...) Expand all
37 // --------------------------------------------------- 37 // ---------------------------------------------------
38 // HMAC normalization failures (HmacParams) 38 // HMAC normalization failures (HmacParams)
39 // --------------------------------------------------- 39 // ---------------------------------------------------
40 shouldThrow("crypto.subtle.sign({name: 'hmac'}, keys.hmacSha1, data)"); 40 shouldThrow("crypto.subtle.sign({name: 'hmac'}, keys.hmacSha1, data)");
41 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: 3}, keys.hmacSha1, data )"); 41 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: 3}, keys.hmacSha1, data )");
42 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: null}, keys.hmacSha1, d ata)"); 42 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: null}, keys.hmacSha1, d ata)");
43 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {}}, keys.hmacSha1, dat a)"); 43 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {}}, keys.hmacSha1, dat a)");
44 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'foo'}}, keys.hm acSha1, data)"); 44 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'foo'}}, keys.hm acSha1, data)");
45 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'AES-CBC'}}, key s.hmacSha1, data)"); 45 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'AES-CBC'}}, key s.hmacSha1, data)");
46 46
47 // ---------------------------------------------------
48 // RSASSA-PKCS1-v1_5 normalization failures (RsaSsaParams)
49 // ---------------------------------------------------
50 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5'}, keys.rsaSsaSha1 , data)");
51 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: 3}, keys.r saSsaSha1, data)");
52 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: null}, key s.rsaSsaSha1, data)");
53 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {}}, keys. rsaSsaSha1, data)");
54 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {name: 'fo o'}}, keys.rsaSsaSha1, data)");
55 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {name: 'AE S-CBC'}}, keys.rsaSsaSha1, data)");
56
57 return crypto.subtle.sign(hmacSha1, keys.hmacSha1, data); 47 return crypto.subtle.sign(hmacSha1, keys.hmacSha1, data);
58 }).then(function(result) { 48 }).then(function(result) {
59 signResult = result; 49 signResult = arrayBufferToHexString(result);
60 shouldBe("signResult.byteLength", "17"); 50 shouldBe("signResult", "'[89 0d 9b 89 4b 23 97 69 ac 77 25 04 66 dc e4 2a f9 26 ed 76]'");
61
62 expectedSignature = asciiToArrayBuffer("signed HMAC:hello");
63 return crypto.subtle.verify(hmacSha1, keys.hmacSha1, expectedSignature, data );
64 }).then(function(result) {
65 verifyResult = result;
66 shouldBe("verifyResult", "true");
67 51
68 return crypto.subtle.verify(hmacSha1, keys.hmacSha1, asciiToArrayBuffer("bad signature"), data); 52 return crypto.subtle.verify(hmacSha1, keys.hmacSha1, asciiToArrayBuffer("bad signature"), data);
69 }).then(function(result) { 53 }).then(function(result) {
70 verifyResult = result; 54 verifyResult = result;
71 shouldBe("verifyResult", "false"); 55 shouldBe("verifyResult", "false");
72
73 return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-1' }, leng th: 48}, false, ['sign']);
74 }).then(function(result) {
75 generatedHmacSha1Key = result;
76
77 // Cannot use an HMAC SHA-1 key for signing HMAC SHA-256
78 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'sha-256'}}, gen eratedHmacSha1Key, data)");
79
80 // However it can be used to sign for HMAC SHA-1
81 shouldNotThrow("crypto.subtle.sign(hmacSha1, generatedHmacSha1Key, data)");
82 }).then(finishJSTest, failAndFinishJSTest); 56 }).then(finishJSTest, failAndFinishJSTest);
83 57
84 </script> 58 </script>
85 59
86 <script src="../fast/js/resources/js-test-post.js"></script> 60 <script src="../fast/js/resources/js-test-post.js"></script>
87 </body> 61 </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