OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 importUnwrappingKey().then(function(result) { | 25 importUnwrappingKey().then(function(result) { |
26 wrappedKey = new Uint8Array(100); | 26 wrappedKey = new Uint8Array(100); |
27 unwrappingKey = result; | 27 unwrappingKey = result; |
28 unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)}; | 28 unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)}; |
29 unwrappedKeyAlgorithm = unwrapAlgorithm; | 29 unwrappedKeyAlgorithm = unwrapAlgorithm; |
30 extractable = true; | 30 extractable = true; |
31 keyUsages = ['encrypt']; | 31 keyUsages = ['encrypt']; |
32 | 32 |
33 // Invalid wrappedKey | 33 // Invalid wrappedKey |
34 shouldThrow("crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgor
ithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 34 return crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgorithm,
unwrappedKeyAlgorithm, extractable, keyUsages); |
| 35 }).then(failAndFinishJSTest, function(result) { |
| 36 error = result; |
| 37 shouldBeNull("error"); |
35 | 38 |
36 // Invalid unwrappingKey | 39 // Invalid unwrappingKey |
37 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 40 return crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorithm, unw
rappedKeyAlgorithm, extractable, keyUsages); |
| 41 }).then(failAndFinishJSTest, function(result) { |
| 42 error = result; |
| 43 shouldBeNull("error"); |
38 | 44 |
39 // Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null). | 45 // Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null). |
40 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, null, extractable, 9)"); | 46 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, null, extractable, 9)"); |
41 | 47 |
42 // Invalid unwrapAlgorithm | 48 // Invalid unwrapAlgorithm |
43 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, null,
unwrappedKeyAlgorithm, extractable, keyUsages)"); | 49 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, null, unwra
ppedKeyAlgorithm, extractable, keyUsages); |
| 50 }).then(failAndFinishJSTest, function(result) { |
| 51 error = result; |
| 52 shouldBeNull("error"); |
44 | 53 |
45 // Invalid unwrappedKeyAlgorithm (specified but bad). | 54 // Invalid unwrappedKeyAlgorithm (specified but bad). |
46 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwra
pAlgorithm, 3, extractable, keyUsages)"); | 55 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwra
pAlgorithm, 3, extractable, keyUsages)"); |
47 | 56 |
48 // Invalid format | 57 // Invalid format |
49 return crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey, unwr
apAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages); | 58 return crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey, unwr
apAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages); |
50 }).then(failAndFinishJSTest, function(result) { | 59 }).then(failAndFinishJSTest, function(result) { |
51 error = result; | 60 error = result; |
52 shouldBeNull("error"); | 61 shouldBeNull("error"); |
53 | 62 |
54 // SHA-1 isn't a valid unwrapKey algorithm. | 63 // SHA-1 isn't a valid unwrapKey algorithm. |
55 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name: 'SHA
-1'}, unwrappedKeyAlgorithm, extractable, keyUsages); | 64 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name: 'SHA
-1'}, unwrappedKeyAlgorithm, extractable, keyUsages); |
56 }).then(failAndFinishJSTest, function(result) { | 65 }).then(failAndFinishJSTest, function(result) { |
57 error = result; | 66 error = result; |
58 shouldBeNull("error"); | 67 shouldBeNull("error"); |
59 | 68 |
60 // Mismatch between the unwrappingKey's algorithm and unwrapAlgorithm. | 69 // Mismatch between the unwrappingKey's algorithm and unwrapAlgorithm. |
61 aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0}; | 70 aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0}; |
62 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, aesCtrAlgor
ithm, unwrappedKeyAlgorithm, extractable, keyUsages); | 71 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, aesCtrAlgor
ithm, unwrappedKeyAlgorithm, extractable, keyUsages); |
63 }).then(failAndFinishJSTest, function(result) { | 72 }).then(failAndFinishJSTest, function(result) { |
64 error = result; | 73 error = result; |
65 shouldBeNull("error"); | 74 shouldBeNull("error"); |
66 }).then(finishJSTest, failAndFinishJSTest); | 75 }).then(finishJSTest, failAndFinishJSTest); |
67 | 76 |
68 </script> | 77 </script> |
69 | 78 |
70 </body> | 79 </body> |
71 </html> | 80 </html> |
OLD | NEW |