OLD | NEW |
---|---|
(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("Test deriving HKDF keys with deriveKey()"); | |
13 | |
14 jsTestIsAsync = true; | |
15 | |
16 var extractable = true; | |
17 var derivingKeyAlgorithm = { | |
18 name: "HKDF", | |
19 hash: "SHA-256", | |
20 salt: new Uint8Array(), | |
21 info: new Uint8Array() | |
22 }; | |
23 | |
24 Promise.resolve(null).then(function(result) { | |
25 return crypto.subtle.generateKey({name: "ECDH", namedCurve: "P-256"}, true, ['deriveKey']); | |
26 }).then(function(result) { | |
27 ecdhKey = result; | |
28 | |
29 return crypto.subtle.generateKey({name: "ECDH", namedCurve: "P-256"}, false, ['deriveKey']); | |
30 }).then(function(result) { | |
31 publicKey = result.publicKey; | |
32 | |
33 debug("Derive an HKDF key from ECDH keys"); | |
34 return crypto.subtle.deriveKey({name: "ECDH", namedCurve: "P-256", public: p ublicKey}, ecdhKey.privateKey, "HKDF", true, ['deriveBits']); | |
35 }).then(function(result) { | |
36 hkdfKey = result; | |
37 | |
38 shouldEvaluateAs("hkdfKey.algorithm.name", "HKDF"); | |
39 shouldEvaluateAs("hkdfKey.extractable", true); | |
40 shouldEvaluateAs("hkdfKey.usages.join(',')", "deriveBits"); | |
41 | |
42 debug("\nTry to derive an HKDF key from an HKDF key"); | |
43 var hkdfAlgorithm = { | |
44 name: "HKDF", | |
45 hash: "SHA-256", | |
46 salt: new Uint8Array(), | |
47 info: new Uint8Array() | |
48 }; | |
49 return crypto.subtle.deriveKey(hkdfAlgorithm, hkdfKey, "HKDF", true, ['deriv eBits']); | |
eroman
2015/01/12 22:35:23
This test is a weak test IMO:
(1) using an impor
nharper
2015/01/13 00:11:15
1) I'm now importing 2 ECDH keys and deriving an H
eroman
2015/01/13 00:45:34
Either location is fine as long as there is one so
| |
50 }).then(failAndFinishJSTest, function(result) { | |
51 logError(result); | |
52 }).then(finishJSTest, failAndFinishJSTest); | |
53 | |
54 </script> | |
55 | |
56 </body> | |
57 </html> | |
OLD | NEW |