Chromium Code Reviews| Index: LayoutTests/crypto/subtle/derive-hkdf-keys.html |
| diff --git a/LayoutTests/crypto/subtle/derive-hkdf-keys.html b/LayoutTests/crypto/subtle/derive-hkdf-keys.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc7a35f12bea285cef1cead23a6f265bd57d4a7d |
| --- /dev/null |
| +++ b/LayoutTests/crypto/subtle/derive-hkdf-keys.html |
| @@ -0,0 +1,57 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<script src="../../resources/js-test.js"></script> |
| +<script src="resources/common.js"></script> |
| +</head> |
| +<body> |
| +<p id="description"></p> |
| +<div id="console"></div> |
| + |
| +<script> |
| +description("Test deriving HKDF keys with deriveKey()"); |
| + |
| +jsTestIsAsync = true; |
| + |
| +var extractable = true; |
| +var derivingKeyAlgorithm = { |
| + name: "HKDF", |
| + hash: "SHA-256", |
| + salt: new Uint8Array(), |
| + info: new Uint8Array() |
| +}; |
| + |
| +Promise.resolve(null).then(function(result) { |
| + return crypto.subtle.generateKey({name: "ECDH", namedCurve: "P-256"}, true, ['deriveKey']); |
| +}).then(function(result) { |
| + ecdhKey = result; |
| + |
| + return crypto.subtle.generateKey({name: "ECDH", namedCurve: "P-256"}, false, ['deriveKey']); |
| +}).then(function(result) { |
| + publicKey = result.publicKey; |
| + |
| + debug("Derive an HKDF key from ECDH keys"); |
| + return crypto.subtle.deriveKey({name: "ECDH", namedCurve: "P-256", public: publicKey}, ecdhKey.privateKey, "HKDF", true, ['deriveBits']); |
| +}).then(function(result) { |
| + hkdfKey = result; |
| + |
| + shouldEvaluateAs("hkdfKey.algorithm.name", "HKDF"); |
| + shouldEvaluateAs("hkdfKey.extractable", true); |
| + shouldEvaluateAs("hkdfKey.usages.join(',')", "deriveBits"); |
| + |
| + debug("\nTry to derive an HKDF key from an HKDF key"); |
| + var hkdfAlgorithm = { |
| + name: "HKDF", |
| + hash: "SHA-256", |
| + salt: new Uint8Array(), |
| + info: new Uint8Array() |
| + }; |
| + return crypto.subtle.deriveKey(hkdfAlgorithm, hkdfKey, "HKDF", true, ['deriveBits']); |
|
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
|
| +}).then(failAndFinishJSTest, function(result) { |
| + logError(result); |
| +}).then(finishJSTest, failAndFinishJSTest); |
| + |
| +</script> |
| + |
| +</body> |
| +</html> |