mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
fix(ext/node): support Diffie-Hellman key type in crypto.createPrivateKey()
(#22984)
Towards #22489 Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
d366cf77e1
commit
b0c687c1d2
2 changed files with 19 additions and 0 deletions
|
@ -1607,6 +1607,7 @@ pub fn op_node_create_public_key(
|
|||
named_curve: named_curve.to_string(),
|
||||
})
|
||||
}
|
||||
DH_KEY_AGREEMENT_OID => Ok(AsymmetricKeyDetails::Dh),
|
||||
_ => Err(type_error("Unsupported algorithm")),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,6 +248,24 @@ Deno.test("createPrivateKey dh", function () {
|
|||
assertEquals(key.asymmetricKeyType, "dh");
|
||||
});
|
||||
|
||||
Deno.test("createPublicKey dh", function () {
|
||||
// 1.2.840.113549.1.3.1
|
||||
const pem = "-----BEGIN PUBLIC KEY-----\n" +
|
||||
"MIIBnzCB1QYJKoZIhvcNAQMBMIHHAoHBAP//////////yQ/aoiFowjTExmKLgNwc\n" +
|
||||
"0SkCTgiKZ8x0Agu+pjsTmyJRSgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHC\n" +
|
||||
"ReSFtXZiXn7G9ExC6aY37WsL/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7ORb\n" +
|
||||
"PcIAfLihY78FmNpINhxV05ppFj+o/STPX4NlXSPco62WHGLzViCFUrue1SkHcJaW\n" +
|
||||
"bWcMNU5KvJgE8XRsCMojcyf//////////wIBAgOBxAACgcBR7+iL5qx7aOb9K+aZ\n" +
|
||||
"y2oLt7ST33sDKT+nxpag6cWDDWzPBKFDCJ8fr0v7yW453px8N4qi4R7SYYxFBaYN\n" +
|
||||
"Y3JvgDg1ct2JC9sxSuUOLqSFn3hpmAjW7cS0kExIVGfdLlYtIqbhhuo45cTEbVIM\n" +
|
||||
"rDEz8mjIlnvbWpKB9+uYmbjfVoc3leFvUBqfG2In2m23Md1swsPxr3n7g68H66JX\n" +
|
||||
"iBJKZLQMqNdbY14G9rdKmhhTJrQjC+i7Q/wI8JPhOFzHIGA=\n" +
|
||||
"-----END PUBLIC KEY-----";
|
||||
const key = createPublicKey(pem);
|
||||
assertEquals(key.type, "public");
|
||||
assertEquals(key.asymmetricKeyType, "dh");
|
||||
});
|
||||
|
||||
// openssl ecparam -name secp256r1 -genkey -noout -out a.pem
|
||||
// openssl pkcs8 -topk8 -nocrypt -in a.pem -out b.pem
|
||||
const ecPrivateKey = Deno.readTextFileSync(
|
||||
|
|
Loading…
Reference in a new issue