From 95fb9fb58dd94e29659cff80867c197eb0a1fece Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 4 Oct 2023 13:21:18 +1100 Subject: [PATCH] Rename `from_raw` to `guess_kind_from_der` This more accurately describes what the function does. --- src/key_pair.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/key_pair.rs b/src/key_pair.rs index 020793ce..bf4bfa16 100644 --- a/src/key_pair.rs +++ b/src/key_pair.rs @@ -55,7 +55,7 @@ impl KeyPair { /// /// Equivalent to using the [`TryFrom`] implementation. pub fn from_der(der: &[u8]) -> Result { - Ok(KeyPair::from_raw(der)?) + Ok(KeyPair::guess_kind_from_der(der)?) } /// Returns the key pair's signature algorithm pub fn algorithm(&self) -> &'static SignatureAlgorithm { @@ -66,7 +66,7 @@ impl KeyPair { pub fn from_pem(pem_str: &str) -> Result { let private_key = pem::parse(pem_str)?; let private_key_der: &[_] = private_key.contents(); - Ok(KeyPair::from_raw(private_key_der)?) + Ok(KeyPair::guess_kind_from_der(private_key_der)?) } /// Obtains the key pair from a raw public key and a remote private key @@ -142,7 +142,7 @@ impl KeyPair { }) } - pub(crate) fn from_raw(pkcs8: &[u8]) -> Result { + pub(crate) fn guess_kind_from_der(pkcs8: &[u8]) -> Result { let (kind, alg) = if let Ok(edkp) = Ed25519KeyPair::from_pkcs8_maybe_unchecked(pkcs8) { (KeyPairKind::Ed(edkp), &PKCS_ED25519) } else if let Ok(eckp) =