Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / unwrapKey-badParameters.html
blobfaa112905c7b63dd03c915431cc7d272307f00b3
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>
11 <script>
12 description("Tests calls to unwrapKey() with bad inputs.");
14 jsTestIsAsync = true;
16 function importUnwrappingKey()
18 var data = new Uint8Array(16);
19 var extractable = true;
20 var keyUsages = ['unwrapKey'];
22 return crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, extractable, keyUsages);
25 importUnwrappingKey().then(function(result) {
26 wrappedKey = new Uint8Array(100);
27 unwrappingKey = result;
28 unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)};
29 unwrappedKeyAlgorithm = unwrapAlgorithm;
30 extractable = true;
31 keyUsages = ['encrypt'];
33 // Invalid wrappedKey
34 return crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
35 }).then(failAndFinishJSTest, function(result) {
36 logError(result);
38 // Invalid unwrappingKey
39 return crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
40 }).then(failAndFinishJSTest, function(result) {
41 logError(result);
43 // Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null).
44 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwrapAlgorithm, null, extractable, 9);
45 }).then(failAndFinishJSTest, function(result) {
46 logError(result);
48 // Invalid unwrapAlgorithm
49 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, null, unwrappedKeyAlgorithm, extractable, keyUsages);
50 }).then(failAndFinishJSTest, function(result) {
51 logError(result);
53 // Invalid unwrappedKeyAlgorithm (specified but bad).
54 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwrapAlgorithm, 3, extractable, keyUsages);
55 }).then(failAndFinishJSTest, function(result) {
56 logError(result);
58 // Invalid format
59 return crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
60 }).then(failAndFinishJSTest, function(result) {
61 logError(result);
63 // SHA-1 isn't a valid unwrapKey algorithm.
64 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name: 'SHA-1'}, unwrappedKeyAlgorithm, extractable, keyUsages);
65 }).then(failAndFinishJSTest, function(result) {
66 logError(result);
68 // Mismatch between the unwrappingKey's algorithm and unwrapAlgorithm.
69 aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0};
70 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, aesCtrAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
71 }).then(failAndFinishJSTest, function(result) {
72 logError(result);
73 }).then(finishJSTest, failAndFinishJSTest);
75 </script>
77 </body>
78 </html>