Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / hkdf / deriveKey.html
blob415131d79e834843977ce77d25154318dad19f9c
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("Test that keys can be derived from an HKDF key");
14 jsTestIsAsync = true;
16 kHkdfKey = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";
18 var extractable = true;
19 var derivingKeyAlgorithm = {
20 name: "HKDF",
21 hash: "SHA-256",
22 salt: new Uint8Array(),
23 info: new Uint8Array()
26 Promise.resolve(null).then(function(result) {
27 return crypto.subtle.importKey("raw", hexStringToUint8Array(kHkdfKey), "HKDF", extractable, ['deriveKey']);
28 }).then(function(result) {
29 baseKey = result;
31 return crypto.subtle.deriveKey(derivingKeyAlgorithm, baseKey, {name: "AES-GCM", length: 256}, extractable, ['encrypt']);
32 }).then(function(result) {
33 derivedKey = result;
35 shouldEvaluateAs("derivedKey.type", "secret");
36 shouldEvaluateAs("derivedKey.extractable", extractable);
37 shouldEvaluateAs("derivedKey.algorithm.name", "AES-GCM");
38 shouldEvaluateAs("derivedKey.usages.join(',')", "encrypt");
40 debug("\nTry to derive an HKDF key...");
41 return crypto.subtle.deriveKey(derivingKeyAlgorithm, baseKey, "HKDF", extractable, ['deriveKey']);
42 }).then(failAndFinishJSTest, function(result) {
43 logError(result);
45 // Create an empty key and test deriving a key with it.
46 return crypto.subtle.importKey("raw", new Uint8Array(), "HKDF", extractable, ['deriveKey']);
47 }).then(function(result) {
48 emptyKey = result;
50 shouldEvaluateAs("emptyKey.type", "secret");
51 shouldEvaluateAs("emptyKey.extractable", extractable);
52 shouldEvaluateAs("emptyKey.algorithm.name", "HKDF");
53 shouldEvaluateAs("emptyKey.usages.join(',')", "deriveKey");
55 return crypto.subtle.deriveKey(derivingKeyAlgorithm, emptyKey, {name: "AES-GCM", length: 256}, extractable, ['encrypt']);
56 }).then(function(result) {
57 derivedKey = result;
59 shouldEvaluateAs("derivedKey.type", "secret");
60 shouldEvaluateAs("derivedKey.extractable", extractable);
61 shouldEvaluateAs("derivedKey.algorithm.name", "AES-GCM");
62 shouldEvaluateAs("derivedKey.usages.join(',')", "encrypt");
63 }).then(finishJSTest, failAndFinishJSTest);
65 </script>
67 </body>
68 </html>