From 0b6e4cdecef6867fecae78b74662eec56e113d36 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Mon, 29 Aug 2022 12:22:29 +0200 Subject: [PATCH] Fix EC key conversion & constraints --- crates/jose/src/constraints.rs | 2 +- crates/jose/src/jwk/public_parameters.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/jose/src/constraints.rs b/crates/jose/src/constraints.rs index 9af4c431..8e95ebbe 100644 --- a/crates/jose/src/constraints.rs +++ b/crates/jose/src/constraints.rs @@ -221,7 +221,7 @@ impl<'a> ConstraintSet<'a> { ConstraintDecision::Positive => score += 1, ConstraintDecision::Neutral => {} // If any constraint was negative, don't add it to the candidates - ConstraintDecision::Negative => break 'outer, + ConstraintDecision::Negative => continue 'outer, } } diff --git a/crates/jose/src/jwk/public_parameters.rs b/crates/jose/src/jwk/public_parameters.rs index 563bb13a..2fe00dc4 100644 --- a/crates/jose/src/jwk/public_parameters.rs +++ b/crates/jose/src/jwk/public_parameters.rs @@ -152,7 +152,7 @@ mod ec_impls { .get(..FieldSize::::USIZE) .ok_or_else(Self::Error::default)?; let y = value - .x + .y .get(..FieldSize::::USIZE) .ok_or_else(Self::Error::default)?; @@ -220,7 +220,7 @@ mod legacy { y.try_into() .map_err(|_| anyhow::anyhow!("invalid curve parameter y"))?, ), - _ => bail!("Wrong key type"), + _ => bail!("Wrong curve"), }; let point = sec1::EncodedPoint::from_affine_coordinates(&x.into(), &y.into(), false);