diff --git a/src/jwk.rs b/src/jwk.rs index 828f7b7..994205b 100644 --- a/src/jwk.rs +++ b/src/jwk.rs @@ -838,5 +838,5 @@ pub trait IntoJsonWebKey: Sealed { /// # Errors /// /// Returns an [`Err`] if the conversion fails. - fn into_jwk(self, alg: impl Into>) -> Result; + fn into_jwk(self, alg: Option>) -> Result; } diff --git a/src/jwk/okp/curve25519/ed25519.rs b/src/jwk/okp/curve25519/ed25519.rs index a43d4dd..9b647cb 100644 --- a/src/jwk/okp/curve25519/ed25519.rs +++ b/src/jwk/okp/curve25519/ed25519.rs @@ -135,14 +135,12 @@ impl IntoJsonWebKey for Ed25519PrivateKey { type Algorithm = (); type Error = Infallible; - fn into_jwk(self, alg: impl Into>) -> Result { + fn into_jwk(self, alg: Option>) -> Result { let key = JsonWebKeyType::Asymmetric(Box::new(AsymmetricJsonWebKey::Private( Private::Okp(OkpPrivate::Curve25519(Curve25519Private::Ed(self))), ))); let mut jwk = JsonWebKey::new(key); - jwk.algorithm = alg - .into() - .map(|_| JsonWebAlgorithm::Signing(JsonWebSigningAlgorithm::EdDSA)); + jwk.algorithm = alg.map(|_| JsonWebAlgorithm::Signing(JsonWebSigningAlgorithm::EdDSA)); Ok(jwk) } } @@ -152,14 +150,12 @@ impl IntoJsonWebKey for Ed25519PublicKey { type Algorithm = (); type Error = Infallible; - fn into_jwk(self, alg: impl Into>) -> Result { + fn into_jwk(self, alg: Option>) -> Result { let key = JsonWebKeyType::Asymmetric(Box::new(AsymmetricJsonWebKey::Public(Public::Okp( OkpPublic::Curve25519(Curve25519Public::Ed(self)), )))); let mut jwk = JsonWebKey::new(key); - jwk.algorithm = alg - .into() - .map(|_| JsonWebAlgorithm::Signing(JsonWebSigningAlgorithm::EdDSA)); + jwk.algorithm = alg.map(|_| JsonWebAlgorithm::Signing(JsonWebSigningAlgorithm::EdDSA)); Ok(jwk) } } diff --git a/src/jwk/rsa.rs b/src/jwk/rsa.rs index 722c0e7..c0c3958 100644 --- a/src/jwk/rsa.rs +++ b/src/jwk/rsa.rs @@ -39,11 +39,11 @@ impl IntoJsonWebKey for RsaPublicKey { fn into_jwk( self, - alg: impl Into>, + alg: Option>, ) -> Result { - let alg = alg - .into() - .map(|rsa| jwa::JsonWebAlgorithm::Signing(jwa::JsonWebSigningAlgorithm::Rsa(rsa))); + let alg = alg.map(|rsa| { + jwa::JsonWebAlgorithm::Signing(jwa::JsonWebSigningAlgorithm::Rsa(rsa.into())) + }); let key = super::JsonWebKeyType::Asymmetric(Box::new(super::AsymmetricJsonWebKey::Public( super::Public::Rsa(self), @@ -150,11 +150,11 @@ impl IntoJsonWebKey for RsaPrivateKey { fn into_jwk( self, - alg: impl Into>, + alg: Option>, ) -> Result { - let alg = alg - .into() - .map(|rsa| jwa::JsonWebAlgorithm::Signing(jwa::JsonWebSigningAlgorithm::Rsa(rsa))); + let alg = alg.map(|rsa| { + jwa::JsonWebAlgorithm::Signing(jwa::JsonWebSigningAlgorithm::Rsa(rsa.into())) + }); let key = super::JsonWebKeyType::Asymmetric(Box::new( super::AsymmetricJsonWebKey::Private(super::Private::Rsa(Box::new(self))), diff --git a/src/jwk/symmetric/hmac.rs b/src/jwk/symmetric/hmac.rs index 66513fb..eaa4b3d 100644 --- a/src/jwk/symmetric/hmac.rs +++ b/src/jwk/symmetric/hmac.rs @@ -125,14 +125,14 @@ impl IntoJsonWebKey for HmacKey { fn into_jwk( self, - alg: impl Into>, + alg: Option>, ) -> Result { let key = jwk::JsonWebKeyType::Symmetric(jwk::SymmetricJsonWebKey::OctetSequence( OctetSequence::new(self.key), )); let mut jwk = crate::JsonWebKey::new(key); - jwk.algorithm = alg.into().map(|_| JsonWebAlgorithm::Signing(H::ALGORITHM)); + jwk.algorithm = alg.map(|_| JsonWebAlgorithm::Signing(H::ALGORITHM)); Ok(jwk) } } diff --git a/src/macros.rs b/src/macros.rs index 8ff016a..39017b9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -44,7 +44,7 @@ macro_rules! impl_ec { fn into_jwk( self, - alg: impl Into>, + alg: Option>, ) -> Result { let key = crate::jwk::JsonWebKeyType::Asymmetric(alloc::boxed::Box::new( crate::jwk::AsymmetricJsonWebKey::Public(crate::jwk::Public::Ec( @@ -53,7 +53,7 @@ macro_rules! impl_ec { )); let mut jwk = crate::JsonWebKey::new(key); - jwk.algorithm = alg.into().map(|_| crate::jwa::JsonWebAlgorithm::Signing($alg)); + jwk.algorithm = alg.map(|_| crate::jwa::JsonWebAlgorithm::Signing($alg.into())); Ok(jwk) } } @@ -74,7 +74,7 @@ macro_rules! impl_ec { fn into_jwk( self, - alg: impl Into>, + alg: Option>, ) -> Result { let key = crate::jwk::JsonWebKeyType::Asymmetric(alloc::boxed::Box::new( crate::jwk::AsymmetricJsonWebKey::Private(crate::jwk::Private::Ec( @@ -83,7 +83,7 @@ macro_rules! impl_ec { )); let mut jwk = crate::JsonWebKey::new(key); - jwk.algorithm = alg.into().map(|_| crate::jwa::JsonWebAlgorithm::Signing($alg)); + jwk.algorithm = alg.map(|_| crate::jwa::JsonWebAlgorithm::Signing($alg.into())); Ok(jwk) } }