Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / aes-key-usages.html
blob50755f3d523da81230daf6718bebb34b53a66f3b
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("Make sure that the usages of an AES key are respected");
14 jsTestIsAsync = true;
16 var data = asciiToUint8Array("hello");
17 var iv = new Uint8Array(16);
19 function importKeyExcludingUsage(usage)
21 var algorithm = {name: 'aes-cbc'};
22 var extractable = false;
23 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
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;
33 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages);
36 function testEncrypt()
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 });
45 function testDecrypt()
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 });
54 // FIXME: Add wrapKey() and unwrapKey()
56 testEncrypt().then(testDecrypt).then(finishJSTest, failAndFinishJSTest);
58 </script>
60 </body>
61 </html>