From 2e26547328a32c2291faa6e177092fbb66b7f9bd Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 23 Jun 2023 21:31:59 -0400 Subject: [PATCH 1/2] Rename `Signing::Null` to `Signing::None` There is no need to avoid conflict with `Option::None` if glob imports are avoided; "none" is a more accurate term here than "null". --- jose-jwa/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jose-jwa/src/lib.rs b/jose-jwa/src/lib.rs index fd1509b..db1e7ae 100644 --- a/jose-jwa/src/lib.rs +++ b/jose-jwa/src/lib.rs @@ -93,10 +93,8 @@ pub enum Signing { Rs512, /// No digital signature or MAC performed (Optional) - /// - /// This variant is renamed as `Null` to avoid colliding with `Option::None`. #[serde(rename = "none")] - Null, + None, } impl fmt::Display for Signing { From 419d9ae770c705704feb3ff20261d31157a95beb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 23 Jun 2023 21:36:34 -0400 Subject: [PATCH 2/2] Apply change from `Signing::Null` to `Signing::None` --- jose-jwk/src/crypto/p256.rs | 6 +++--- jose-jwk/src/crypto/p384.rs | 6 +++--- jose-jwk/src/crypto/rsa.rs | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/jose-jwk/src/crypto/p256.rs b/jose-jwk/src/crypto/p256.rs index 04d0ea1..042da07 100644 --- a/jose-jwk/src/crypto/p256.rs +++ b/jose-jwk/src/crypto/p256.rs @@ -6,7 +6,7 @@ use p256::elliptic_curve::sec1::{FromEncodedPoint, ToEncodedPoint}; use p256::{EncodedPoint, FieldBytes, PublicKey, SecretKey}; -use jose_jwa::{Algorithm, Algorithm::Signing, Signing::*}; +use jose_jwa::{Algorithm, Algorithm::Signing, Signing as S}; use super::Error; use super::KeyInfo; @@ -18,7 +18,7 @@ impl KeyInfo for PublicKey { } fn is_supported(&self, algo: &Algorithm) -> bool { - matches!(algo, Signing(Es256)) + matches!(algo, Signing(S::Es256)) } } @@ -28,7 +28,7 @@ impl KeyInfo for SecretKey { } fn is_supported(&self, algo: &Algorithm) -> bool { - matches!(algo, Signing(Es256)) + matches!(algo, Signing(S::Es256)) } } diff --git a/jose-jwk/src/crypto/p384.rs b/jose-jwk/src/crypto/p384.rs index 89b1577..b6a3cb6 100644 --- a/jose-jwk/src/crypto/p384.rs +++ b/jose-jwk/src/crypto/p384.rs @@ -6,7 +6,7 @@ use p384::elliptic_curve::sec1::{FromEncodedPoint, ToEncodedPoint}; use p384::{EncodedPoint, FieldBytes, PublicKey, SecretKey}; -use jose_jwa::{Algorithm, Algorithm::Signing, Signing::*}; +use jose_jwa::{Algorithm, Algorithm::Signing, Signing as S}; use super::Error; use super::KeyInfo; @@ -18,7 +18,7 @@ impl KeyInfo for PublicKey { } fn is_supported(&self, algo: &Algorithm) -> bool { - matches!(algo, Signing(Es384)) + matches!(algo, Signing(S::Es384)) } } @@ -28,7 +28,7 @@ impl KeyInfo for SecretKey { } fn is_supported(&self, algo: &Algorithm) -> bool { - matches!(algo, Signing(Es384)) + matches!(algo, Signing(S::Es384)) } } diff --git a/jose-jwk/src/crypto/rsa.rs b/jose-jwk/src/crypto/rsa.rs index a515344..ec60653 100644 --- a/jose-jwk/src/crypto/rsa.rs +++ b/jose-jwk/src/crypto/rsa.rs @@ -8,7 +8,7 @@ use rsa::{ BigUint, RsaPrivateKey, RsaPublicKey, }; -use jose_jwa::{Algorithm, Algorithm::Signing, Signing::*}; +use jose_jwa::{Algorithm, Algorithm::Signing, Signing as S}; use super::Error; use super::KeyInfo; @@ -31,12 +31,12 @@ impl KeyInfo for RsaPublicKey { #[allow(clippy::match_like_matches_macro)] match algo { - Signing(Rs256) => true, - Signing(Rs384) => true, - Signing(Rs512) => true, - Signing(Ps256) => true, - Signing(Ps384) => true, - Signing(Ps512) => true, + Signing(S::Rs256) => true, + Signing(S::Rs384) => true, + Signing(S::Rs512) => true, + Signing(S::Ps256) => true, + Signing(S::Ps384) => true, + Signing(S::Ps512) => true, _ => false, } } @@ -50,12 +50,12 @@ impl KeyInfo for RsaPrivateKey { fn is_supported(&self, algo: &Algorithm) -> bool { #[allow(clippy::match_like_matches_macro)] match (algo, self.strength()) { - (Signing(Rs256), 16..) => true, - (Signing(Rs384), 24..) => true, - (Signing(Rs512), 32..) => true, - (Signing(Ps256), 16..) => true, - (Signing(Ps384), 24..) => true, - (Signing(Ps512), 32..) => true, + (Signing(S::Rs256), 16..) => true, + (Signing(S::Rs384), 24..) => true, + (Signing(S::Rs512), 32..) => true, + (Signing(S::Ps256), 16..) => true, + (Signing(S::Ps384), 24..) => true, + (Signing(S::Ps512), 32..) => true, _ => false, } }