mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1106087 - Add test to ensure we can export newly generated ECDH private keys r=rbarnes
This commit is contained in:
parent
a339ca0ee1
commit
b5f9ed75b6
@ -298,6 +298,37 @@ TestArray.addTest(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
TestArray.addTest(
|
||||||
|
"JWK export of a newly generated ECDH private key",
|
||||||
|
function () {
|
||||||
|
var that = this;
|
||||||
|
var alg = { name: "ECDH", namedCurve: "P-256" };
|
||||||
|
var reBase64URL = /^[a-zA-Z0-9_-]+$/;
|
||||||
|
|
||||||
|
function doExportToJWK(x) {
|
||||||
|
return crypto.subtle.exportKey("jwk", x.privateKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
crypto.subtle.generateKey(alg, true, ["deriveKey", "deriveBits"])
|
||||||
|
.then(doExportToJWK)
|
||||||
|
.then(
|
||||||
|
complete(that, function(x) {
|
||||||
|
return x.ext &&
|
||||||
|
x.kty == 'EC' &&
|
||||||
|
x.crv == 'P-256' &&
|
||||||
|
reBase64URL.test(x.x) &&
|
||||||
|
reBase64URL.test(x.y) &&
|
||||||
|
reBase64URL.test(x.d) &&
|
||||||
|
x.x.length == 43 && // 32 octets, base64-encoded
|
||||||
|
x.y.length == 43 && // 32 octets, base64-encoded
|
||||||
|
shallowArrayEquals(x.key_ops, ['deriveKey', 'deriveBits']);
|
||||||
|
}),
|
||||||
|
error(that)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
TestArray.addTest(
|
TestArray.addTest(
|
||||||
"Derive an HMAC key from two ECDH keys and test sign/verify",
|
"Derive an HMAC key from two ECDH keys and test sign/verify",
|
||||||
|
Loading…
Reference in New Issue
Block a user