43 lines
1.1 KiB
HTML
43 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<script src="../resources/common.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
|
|
<script>
|
|
description("Test ECDH deriveBits operation with generated base key and null length");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var extractable = true;
|
|
var jwkPublicKey = {
|
|
kty: "EC",
|
|
crv: "P-256",
|
|
x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
|
|
y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
|
|
};
|
|
|
|
crypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveBits"]).then(function(result) {
|
|
privateKey = result.privateKey;
|
|
return crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]);
|
|
}).then(function(result) {
|
|
publicKey = result;
|
|
return crypto.subtle.deriveBits({ name:"ECDH", public:publicKey }, privateKey, null);
|
|
}).then(function(result) {
|
|
derivedKey = result;
|
|
|
|
shouldBe("derivedKey.byteLength", "32");
|
|
|
|
finishJSTest();
|
|
}, failAndFinishJSTest);
|
|
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|