Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / import-aes-key-bad-length.html
blobe7de29d79266b8160b51523e3eadb0b5ef080ce4
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 importing an AES key from raw with wrong length");
14 jsTestIsAsync = true;
16 // -------------------------------------------------
17 // Failed key import.
18 // -------------------------------------------------
20 // Supported key lengths are 16 (128-bit), 32 (256-bit), 24 (192-bit),
21 // Try key lengths that are off by 1 from the supported ones.
22 var kUnsupportedKeyLengths = [
23 0, 1, 15, 17, 31, 33, 23, 25, 64
26 // Not exhaustive
27 var kAesAlgorithms = [
28 "AES-CBC", "AES-GCM", "AES-KW"
31 function testInvalidKeyImport(algorithmName, keyLengthBytes)
33 var algorithm = {name: algorithmName};
34 var keyData = new Uint8Array(keyLengthBytes);
36 var usages = ['encrypt', 'decrypt'];
37 var extractable = false;
39 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages).then(function(result) {
40 debug("FAIL: Successfully imported " + algorithmName + " key of length " + keyData.byteLength + " bytes");
41 }, function(result) {
42 debug("PASS: Failed to import " + algorithmName + " key of length " + keyData.byteLength + " bytes");
43 });
46 var lastPromise = Promise.resolve(null);
48 kAesAlgorithms.forEach(function(algorithmName) {
49 kUnsupportedKeyLengths.forEach(function(keyLengthBytes) {
50 lastPromise = lastPromise.then(testInvalidKeyImport.bind(null, algorithmName, keyLengthBytes));
51 });
52 });
54 lastPromise.then(finishJSTest, failAndFinishJSTest);
56 </script>
58 </body>
59 </html>