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

Side by Side Diff: LayoutTests/crypto/unwrapKey-badParameters.html

Issue 806913006: [WebCrypto] Move LayoutTests from crypto to crypto/subtle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update path for deserialize legacy tests Created 6 years 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
OLDNEW
(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 calls to unwrapKey() with bad inputs.");
13
14 jsTestIsAsync = true;
15
16 function importUnwrappingKey()
17 {
18 var data = new Uint8Array(16);
19 var extractable = true;
20 var keyUsages = ['unwrapKey'];
21
22 return crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, extractable, keyUsages);
23 }
24
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'];
32
33 // Invalid wrappedKey
34 return crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
35 }).then(failAndFinishJSTest, function(result) {
36 logError(result);
37
38 // Invalid unwrappingKey
39 return crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorithm, unw rappedKeyAlgorithm, extractable, keyUsages);
40 }).then(failAndFinishJSTest, function(result) {
41 logError(result);
42
43 // Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null).
44 return crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorithm, nul l, extractable, 9);
45 }).then(failAndFinishJSTest, function(result) {
46 logError(result);
47
48 // Invalid unwrapAlgorithm
49 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, null, unwra ppedKeyAlgorithm, extractable, keyUsages);
50 }).then(failAndFinishJSTest, function(result) {
51 logError(result);
52
53 // Invalid unwrappedKeyAlgorithm (specified but bad).
54 return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwrapAlgor ithm, 3, extractable, keyUsages);
55 }).then(failAndFinishJSTest, function(result) {
56 logError(result);
57
58 // Invalid format
59 return crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey, unwr apAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
60 }).then(failAndFinishJSTest, function(result) {
61 logError(result);
62
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);
67
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, aesCtrAlgor ithm, unwrappedKeyAlgorithm, extractable, keyUsages);
71 }).then(failAndFinishJSTest, function(result) {
72 logError(result);
73 }).then(finishJSTest, failAndFinishJSTest);
74
75 </script>
76
77 </body>
78 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/subtle/wrapKey-unextractable-expected.txt ('k') | LayoutTests/crypto/unwrapKey-badParameters-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698