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

Side by Side Diff: LayoutTests/crypto/aes-key-usages.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("Make sure that the usages of an AES key are respected");
13
14 jsTestIsAsync = true;
15
16 var data = asciiToUint8Array("hello");
17 var iv = new Uint8Array(16);
18
19 function importKeyExcludingUsage(usage)
20 {
21 var algorithm = {name: 'aes-cbc'};
22 var extractable = false;
23 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
24
25 var usages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"];
26 for (var i in usages) {
27 if (usages[i] == usage) {
28 usages.splice(i, 1);
29 break;
30 }
31 }
32
33 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage s);
34 }
35
36 function testEncrypt()
37 {
38 return importKeyExcludingUsage("encrypt").then(function(key) {
39 return crypto.subtle.encrypt({name: 'AES-CBC', iv: iv}, key, data);
40 }).then(failAndFinishJSTest, function(result) {
41 logError(result);
42 });
43 }
44
45 function testDecrypt()
46 {
47 return importKeyExcludingUsage("decrypt").then(function(key) {
48 return crypto.subtle.decrypt({name: 'AES-CBC', iv: iv}, key, data);
49 }).then(failAndFinishJSTest, function(result) {
50 logError(result);
51 });
52 }
53
54 // FIXME: Add wrapKey() and unwrapKey()
55
56 testEncrypt().then(testDecrypt).then(finishJSTest, failAndFinishJSTest);
57
58 </script>
59
60 </body>
61 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/aes-key-algorithm-mismatch-expected.txt ('k') | LayoutTests/crypto/aes-key-usages-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698