mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/node): use pem private keys in createPublicKey (#24969)
This commit is contained in:
parent
854c7ba198
commit
4dc8fe2020
1 changed files with 17 additions and 18 deletions
|
@ -522,7 +522,7 @@ impl KeyObjectHandle {
|
||||||
key: &[u8],
|
key: &[u8],
|
||||||
format: &str,
|
format: &str,
|
||||||
typ: &str,
|
typ: &str,
|
||||||
_passphrase: Option<&[u8]>,
|
passphrase: Option<&[u8]>,
|
||||||
) -> Result<KeyObjectHandle, AnyError> {
|
) -> Result<KeyObjectHandle, AnyError> {
|
||||||
let document = match format {
|
let document = match format {
|
||||||
"pem" => {
|
"pem" => {
|
||||||
|
@ -542,23 +542,22 @@ impl KeyObjectHandle {
|
||||||
Document::from_pkcs1_der(document.as_bytes())
|
Document::from_pkcs1_der(document.as_bytes())
|
||||||
.map_err(|_| type_error("invalid PKCS#1 public key"))?
|
.map_err(|_| type_error("invalid PKCS#1 public key"))?
|
||||||
}
|
}
|
||||||
EncryptedPrivateKeyInfo::PEM_LABEL => {
|
EncryptedPrivateKeyInfo::PEM_LABEL
|
||||||
// FIXME
|
| PrivateKeyInfo::PEM_LABEL
|
||||||
return Err(type_error(
|
| sec1::EcPrivateKey::PEM_LABEL
|
||||||
"deriving public key from encrypted private key",
|
| rsa::pkcs1::RsaPrivateKey::PEM_LABEL => {
|
||||||
));
|
let handle = KeyObjectHandle::new_asymmetric_private_key_from_js(
|
||||||
}
|
key, format, typ, passphrase,
|
||||||
PrivateKeyInfo::PEM_LABEL => {
|
)?;
|
||||||
// FIXME
|
match handle {
|
||||||
return Err(type_error("public key cannot be a private key"));
|
KeyObjectHandle::AsymmetricPrivate(private) => {
|
||||||
}
|
return Ok(KeyObjectHandle::AsymmetricPublic(
|
||||||
sec1::EcPrivateKey::PEM_LABEL => {
|
private.to_public_key(),
|
||||||
// FIXME
|
))
|
||||||
return Err(type_error("deriving public key from ec private key"));
|
}
|
||||||
}
|
KeyObjectHandle::AsymmetricPublic(_)
|
||||||
rsa::pkcs1::RsaPrivateKey::PEM_LABEL => {
|
| KeyObjectHandle::Secret(_) => unreachable!(),
|
||||||
// FIXME
|
}
|
||||||
return Err(type_error("deriving public key from rsa private key"));
|
|
||||||
}
|
}
|
||||||
// TODO: handle x509 certificates as public keys
|
// TODO: handle x509 certificates as public keys
|
||||||
_ => {
|
_ => {
|
||||||
|
|
Loading…
Reference in a new issue