Skip to content

Commit

Permalink
ssh-key: correct erroneous signature constants
Browse files Browse the repository at this point in the history
The elliptic curve was misspecified for `p384::ecdsa::Signature` and
`p521::ecdsa::Signature`.

Additionally P-521 had an incorrect field size.

Closes #197
  • Loading branch information
tarcieri committed Mar 7, 2024
1 parent 8abfc94 commit 4a9a1f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ssh-key/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -586,11 +586,11 @@ impl TryFrom<&Signature> for p521::ecdsa::Signature {
type Error = Error;

fn try_from(signature: &Signature) -> Result<p521::ecdsa::Signature> {
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)?;
Expand Down

0 comments on commit 4a9a1f3

Please sign in to comment.