OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../resources/js-test.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 calling cypto.subtle.sign and crypto.subtle.verify with incor
rect inputs"); | |
13 | |
14 jsTestIsAsync = true; | |
15 | |
16 function importHmacKey() | |
17 { | |
18 var importAlgorithm = {name: 'HMAC', hash: {name: 'sha-1'}}; | |
19 var keyData = new Uint8Array(16); | |
20 var extractable = true; | |
21 var usages = ['sign', 'verify']; | |
22 | |
23 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable,
usages); | |
24 } | |
25 | |
26 data = asciiToUint8Array("hello"); | |
27 hmac = {name: 'HMAC', hash: {name: 'sha-1'}}; | |
28 | |
29 importHmacKey().then(function(result) { | |
30 key = result; | |
31 | |
32 // Pass invalid signature parameters to verify() | |
33 return crypto.subtle.verify(hmac, key, null, data); | |
34 }).then(failAndFinishJSTest, function(result) { | |
35 logError(result); | |
36 | |
37 // Pass invalid signature parameters to verify() | |
38 return crypto.subtle.verify(hmac, key, 'a', data); | |
39 }).then(failAndFinishJSTest, function(result) { | |
40 logError(result); | |
41 | |
42 // Pass invalid signature parameters to verify() | |
43 return crypto.subtle.verify(hmac, key, [], data); | |
44 }).then(failAndFinishJSTest, function(result) { | |
45 logError(result); | |
46 | |
47 // Operation does not support signing. | |
48 return crypto.subtle.sign({name: 'sha-1'}, key, data); | |
49 }).then(failAndFinishJSTest, function(result) { | |
50 logError(result); | |
51 | |
52 // Operation doesn't support signing (also given an invalid key, but the | |
53 // first failure takes priority) | |
54 return crypto.subtle.sign({name: 'AES-CBC'}, key, data); | |
55 }).then(failAndFinishJSTest, function(result) { | |
56 logError(result); | |
57 }).then(finishJSTest, failAndFinishJSTest); | |
58 | |
59 </script> | |
60 | |
61 </body> | |
62 </html> | |
OLD | NEW |