From 4a9a1f3d4fa0ef9cd02df3ddfabc0ec6eede120d Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 6 Mar 2024 17:14:15 -0700 Subject: [PATCH] ssh-key: correct erroneous signature constants The elliptic curve was misspecified for `p384::ecdsa::Signature` and `p521::ecdsa::Signature`. Additionally P-521 had an incorrect field size. Closes #197 --- ssh-key/src/signature.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ssh-key/src/signature.rs b/ssh-key/src/signature.rs index 2a1e498..c791978 100644 --- a/ssh-key/src/signature.rs +++ b/ssh-key/src/signature.rs @@ -560,7 +560,7 @@ impl TryFrom<&Signature> for p384::ecdsa::Signature { match signature.algorithm { Algorithm::Ecdsa { - curve: EcdsaCurve::NistP256, + curve: EcdsaCurve::NistP384, } => { let reader = &mut signature.as_bytes(); let r = Mpint::decode(reader)?; @@ -586,11 +586,11 @@ impl TryFrom<&Signature> for p521::ecdsa::Signature { type Error = Error; fn try_from(signature: &Signature) -> Result { - const FIELD_SIZE: usize = 48; + const FIELD_SIZE: usize = 66; match signature.algorithm { Algorithm::Ecdsa { - curve: EcdsaCurve::NistP256, + curve: EcdsaCurve::NistP521, } => { let reader = &mut signature.as_bytes(); let r = Mpint::decode(reader)?;