diff --git a/src/token/cose/encrypted/encrypt/mod.rs b/src/token/cose/encrypted/encrypt/mod.rs index 2957182..d68734b 100644 --- a/src/token/cose/encrypted/encrypt/mod.rs +++ b/src/token/cose/encrypted/encrypt/mod.rs @@ -72,7 +72,7 @@ pub trait CoseEncryptBuilderExt: Sized { /// # Examples /// /// Refer to [the documentation for the CoseEncrypt extensions](CoseEncryptExt) for examples. - fn try_encrypt( + fn try_encrypt( self, backend: &mut B, key_provider: &CKP, @@ -84,7 +84,7 @@ pub trait CoseEncryptBuilderExt: Sized { } impl CoseEncryptBuilderExt for CoseEncryptBuilder { - fn try_encrypt( + fn try_encrypt( self, backend: &mut B, key_provider: &CKP, @@ -342,7 +342,7 @@ pub trait CoseEncryptExt { /// ) /// ); /// ``` - fn try_decrypt( + fn try_decrypt( &self, backend: &mut B, key_provider: &CKP, @@ -427,7 +427,7 @@ pub trait CoseEncryptExt { fn try_decrypt_with_recipients< B: KeyDistributionCryptoBackend + EncryptCryptoBackend, CKP: KeyProvider, - CAP: AadProvider + ?Sized, + CAP: AadProvider, >( &self, backend: &mut B, @@ -437,7 +437,7 @@ pub trait CoseEncryptExt { } impl CoseEncryptExt for CoseEncrypt { - fn try_decrypt( + fn try_decrypt( &self, backend: &mut B, key_provider: &CKP, @@ -468,7 +468,7 @@ impl CoseEncryptExt for CoseEncrypt { fn try_decrypt_with_recipients< B: KeyDistributionCryptoBackend + EncryptCryptoBackend, CKP: KeyProvider, - CAP: AadProvider + ?Sized, + CAP: AadProvider, >( &self, backend: &mut B, diff --git a/src/token/cose/encrypted/encrypt/tests.rs b/src/token/cose/encrypted/encrypt/tests.rs index df9cd30..f0f3266 100644 --- a/src/token/cose/encrypted/encrypt/tests.rs +++ b/src/token/cose/encrypted/encrypt/tests.rs @@ -108,7 +108,7 @@ impl Cos if let Some(partial_iv) = determine_header_param( encrypt_cfg.protected.as_ref(), encrypt_cfg.unprotected.as_ref(), - |v| (!v.partial_iv.is_empty()).then(|| &v.partial_iv), + |v| (!v.partial_iv.is_empty()).then_some(&v.partial_iv), ) { enc_key.base_iv = calculate_base_iv( encrypt_cfg @@ -169,7 +169,7 @@ impl Cos if let Some(partial_iv) = determine_header_param( test_case.protected.as_ref(), test_case.unprotected.as_ref(), - |v| (!v.partial_iv.is_empty()).then(|| &v.partial_iv), + |v| (!v.partial_iv.is_empty()).then_some(&v.partial_iv), ) { key_with_alg.base_iv = calculate_base_iv( test_case diff --git a/src/token/cose/encrypted/encrypt0/mod.rs b/src/token/cose/encrypted/encrypt0/mod.rs index 63dc761..4d5c737 100644 --- a/src/token/cose/encrypted/encrypt0/mod.rs +++ b/src/token/cose/encrypted/encrypt0/mod.rs @@ -61,7 +61,7 @@ pub trait CoseEncrypt0BuilderExt: Sized { /// # Examples /// /// Refer to [the documentation for the CoseEncrypt0 extensions](CoseEncrypt0Ext) for examples. - fn try_encrypt( + fn try_encrypt( self, backend: &mut B, key_provider: &CKP, @@ -74,7 +74,7 @@ pub trait CoseEncrypt0BuilderExt: Sized { } impl CoseEncrypt0BuilderExt for CoseEncrypt0Builder { - fn try_encrypt( + fn try_encrypt( self, backend: &mut B, key_provider: &CKP, @@ -256,7 +256,7 @@ pub trait CoseEncrypt0Ext { /// ) /// ); /// ``` - fn try_decrypt( + fn try_decrypt( &self, backend: &mut B, key_provider: &CKP, @@ -266,7 +266,7 @@ pub trait CoseEncrypt0Ext { } impl CoseEncrypt0Ext for CoseEncrypt0 { - fn try_decrypt( + fn try_decrypt( &self, backend: &mut B, key_provider: &CKP, diff --git a/src/token/cose/encrypted/mod.rs b/src/token/cose/encrypted/mod.rs index 6e3a93f..db7faa1 100644 --- a/src/token/cose/encrypted/mod.rs +++ b/src/token/cose/encrypted/mod.rs @@ -342,7 +342,7 @@ pub fn aes_ccm_algorithm_tag_len( } } -fn determine_and_check_aes_params<'a, 'b, BE: Display>( +fn determine_and_check_aes_params<'a, BE: Display>( alg: iana::Algorithm, parsed_key: CoseParsedKey<'a, BE>, protected: Option<&Header>, @@ -351,11 +351,11 @@ fn determine_and_check_aes_params<'a, 'b, BE: Display>( let symm_key = key::ensure_valid_aes_key::(alg, parsed_key)?; let iv = header_util::determine_header_param(protected, unprotected, |v| { - (!v.iv.is_empty()).then(|| &v.iv) + (!v.iv.is_empty()).then_some(&v.iv) }); let partial_iv = header_util::determine_header_param(protected, unprotected, |v| { - (!v.partial_iv.is_empty()).then(|| &v.partial_iv) + (!v.partial_iv.is_empty()).then_some(&v.partial_iv) }); let expected_iv_len = aes_algorithm_iv_len(alg)?; @@ -392,7 +392,7 @@ fn determine_and_check_aes_params<'a, 'b, BE: Display>( let mut message_iv = vec![0u8; expected_iv_len]; // Left-pad the Partial IV with zeros to the length of IV - message_iv[(expected_iv_len - partial_iv.len())..].copy_from_slice(&partial_iv); + message_iv[(expected_iv_len - partial_iv.len())..].copy_from_slice(partial_iv); // XOR the padded Partial IV with the Context IV. message_iv .iter_mut() diff --git a/src/token/cose/maced/mac/mod.rs b/src/token/cose/maced/mac/mod.rs index e159c14..bc320c5 100644 --- a/src/token/cose/maced/mac/mod.rs +++ b/src/token/cose/maced/mac/mod.rs @@ -62,7 +62,7 @@ pub trait CoseMacBuilderExt: Sized { /// # Examples /// /// Refer to [the documentation for the CoseMac extensions](CoseMacExt) for examples. - fn try_compute( + fn try_compute( self, backend: &mut B, key_provider: &CKP, @@ -73,7 +73,7 @@ pub trait CoseMacBuilderExt: Sized { } impl CoseMacBuilderExt for CoseMacBuilder { - fn try_compute( + fn try_compute( self, backend: &mut B, key_provider: &CKP, @@ -303,7 +303,7 @@ pub trait CoseMacExt { /// ) /// ); /// ``` - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -384,7 +384,7 @@ pub trait CoseMacExt { fn try_verify_with_recipients< B: KeyDistributionCryptoBackend + MacCryptoBackend, CKP: KeyProvider, - CAP: AadProvider + ?Sized, + CAP: AadProvider, >( &self, backend: &mut B, @@ -395,7 +395,7 @@ pub trait CoseMacExt { } impl CoseMacExt for CoseMac { - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -423,7 +423,7 @@ impl CoseMacExt for CoseMac { fn try_verify_with_recipients< B: KeyDistributionCryptoBackend + MacCryptoBackend, CKP: KeyProvider, - CAP: AadProvider + ?Sized, + CAP: AadProvider, >( &self, backend: &mut B, diff --git a/src/token/cose/maced/mac0/mod.rs b/src/token/cose/maced/mac0/mod.rs index 22cf27d..bed8597 100644 --- a/src/token/cose/maced/mac0/mod.rs +++ b/src/token/cose/maced/mac0/mod.rs @@ -58,7 +58,7 @@ pub trait CoseMac0BuilderExt: Sized { /// # Examples /// /// Refer to [the documentation for the CoseMac0 extensions](CoseMac0Ext) for examples. - fn try_compute( + fn try_compute( self, backend: &mut B, key_provider: &CKP, @@ -69,7 +69,7 @@ pub trait CoseMac0BuilderExt: Sized { } impl CoseMac0BuilderExt for CoseMac0Builder { - fn try_compute( + fn try_compute( self, backend: &mut B, key_provider: &CKP, @@ -228,7 +228,7 @@ pub trait CoseMac0Ext { /// ) /// ); /// ``` - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -237,7 +237,7 @@ pub trait CoseMac0Ext { } impl CoseMac0Ext for CoseMac0 { - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, diff --git a/src/token/cose/recipient/mod.rs b/src/token/cose/recipient/mod.rs index 2e54b18..14554d0 100644 --- a/src/token/cose/recipient/mod.rs +++ b/src/token/cose/recipient/mod.rs @@ -538,7 +538,7 @@ pub trait CoseRecipientBuilderExt: Sized { // Integration into coset will allow reducing the number of algorithms, but for now this will // have to make do. #[allow(clippy::too_many_arguments)] - fn try_encrypt( + fn try_encrypt( self, backend: &mut B, key_provider: &CKP, @@ -551,7 +551,7 @@ pub trait CoseRecipientBuilderExt: Sized { } impl CoseRecipientBuilderExt for CoseRecipientBuilder { - fn try_encrypt( + fn try_encrypt( self, backend: &mut B, key_provider: &CKP, @@ -757,7 +757,7 @@ pub trait CoseRecipientExt { /// # Examples /// /// Refer to the trait-level documentation for an example. - fn try_decrypt( + fn try_decrypt( &self, backend: &mut B, key_provider: &CKP, @@ -768,7 +768,7 @@ pub trait CoseRecipientExt { } impl CoseRecipientExt for CoseRecipient { - fn try_decrypt( + fn try_decrypt( &self, backend: &mut B, key_provider: &CKP, diff --git a/src/token/cose/signed/sign/mod.rs b/src/token/cose/signed/sign/mod.rs index 02deee0..7132163 100644 --- a/src/token/cose/signed/sign/mod.rs +++ b/src/token/cose/signed/sign/mod.rs @@ -53,7 +53,7 @@ pub trait CoseSignBuilderExt: Sized { /// # Examples /// /// Refer to [the documentation for the CoseSign extensions](CoseSignExt) for examples. - fn try_add_sign( + fn try_add_sign( self, backend: &mut B, key_provider: &CKP, @@ -91,7 +91,7 @@ pub trait CoseSignBuilderExt: Sized { /// # Examples /// /// Refer to [the documentation for the CoseSign extensions](CoseSignExt) for examples. - fn try_add_sign_detached( + fn try_add_sign_detached( self, backend: &mut B, key_provider: &CKP, @@ -102,7 +102,7 @@ pub trait CoseSignBuilderExt: Sized { } impl CoseSignBuilderExt for CoseSignBuilder { - fn try_add_sign( + fn try_add_sign( self, backend: &mut B, key_provider: &CKP, @@ -125,7 +125,7 @@ impl CoseSignBuilderExt for CoseSignBuilder { }, ) } - fn try_add_sign_detached( + fn try_add_sign_detached( self, backend: &mut B, key_provider: &CKP, @@ -301,7 +301,7 @@ pub trait CoseSignExt { /// ) /// ); /// ``` - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -346,7 +346,7 @@ pub trait CoseSignExt { /// # Examples /// /// Refer to the trait-level documentation for examples. - fn try_verify_detached( + fn try_verify_detached( &self, backend: &mut B, key_provider: &CKP, @@ -357,7 +357,7 @@ pub trait CoseSignExt { } impl CoseSignExt for CoseSign { - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -399,7 +399,7 @@ impl CoseSignExt for CoseSign { .collect(), )) } - fn try_verify_detached( + fn try_verify_detached( &self, backend: &mut B, key_provider: &CKP, diff --git a/src/token/cose/signed/sign1/mod.rs b/src/token/cose/signed/sign1/mod.rs index a1da838..756e4ed 100644 --- a/src/token/cose/signed/sign1/mod.rs +++ b/src/token/cose/signed/sign1/mod.rs @@ -57,7 +57,7 @@ pub trait CoseSign1BuilderExt: Sized { // the builder pattern, but it is necessary here, as we lack access to the `protected` // and `unprotected` headers that were previously set (the field is private). // This should be fixed when porting all of this to coset. - fn try_sign( + fn try_sign( self, backend: &mut B, key_provider: &CKP, @@ -102,7 +102,7 @@ pub trait CoseSign1BuilderExt: Sized { // and `unprotected` headers that were previously set (the field is private). // This should be fixed when porting all of this to coset. // This applies to all COSE structures. - fn try_sign_detached( + fn try_sign_detached( self, backend: &mut B, key_provider: &CKP, @@ -114,7 +114,7 @@ pub trait CoseSign1BuilderExt: Sized { } impl CoseSign1BuilderExt for CoseSign1Builder { - fn try_sign( + fn try_sign( self, backend: &mut B, key_provider: &CKP, @@ -143,7 +143,7 @@ impl CoseSign1BuilderExt for CoseSign1Builder { }, ) } - fn try_sign_detached( + fn try_sign_detached( self, backend: &mut B, key_provider: &CKP, @@ -357,7 +357,7 @@ pub trait CoseSign1Ext { /// ) /// ); /// ``` - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -400,7 +400,7 @@ pub trait CoseSign1Ext { /// # Examples /// /// Refer to the trait-level documentation for examples. - fn try_verify_detached( + fn try_verify_detached( &self, backend: &mut B, key_provider: &CKP, @@ -411,7 +411,7 @@ pub trait CoseSign1Ext { } impl CoseSign1Ext for CoseSign1 { - fn try_verify( + fn try_verify( &self, backend: &mut B, key_provider: &CKP, @@ -435,13 +435,7 @@ impl CoseSign1Ext for CoseSign1 { ) } - fn try_verify_detached< - 'a, - 'b, - B: SignCryptoBackend, - CKP: KeyProvider, - CAP: AadProvider + ?Sized, - >( + fn try_verify_detached<'a, 'b, B: SignCryptoBackend, CKP: KeyProvider, CAP: AadProvider>( &self, backend: &mut B, key_provider: &CKP, diff --git a/src/token/mod.rs b/src/token/mod.rs index 956fbeb..d0acd63 100644 --- a/src/token/mod.rs +++ b/src/token/mod.rs @@ -138,7 +138,7 @@ mod tests; /// # Example /// /// see the [module-level documentation](self) for an example -pub fn encrypt_access_token( +pub fn encrypt_access_token( backend: &mut T, key: &CoseKey, claims: ClaimsSet, @@ -213,7 +213,7 @@ where /// # Ok::<(), AccessTokenError<::Error>>(()) /// ``` #[allow(clippy::missing_panics_doc)] -pub fn encrypt_access_token_multiple<'a, T, I, AAD: AadProvider + ?Sized>( +pub fn encrypt_access_token_multiple<'a, T, I, AAD: AadProvider>( backend: &mut T, keys: I, claims: ClaimsSet, @@ -333,7 +333,7 @@ where /// assert!(verify_access_token(&mut backend, &key, &token, &None).is_ok()); /// # Ok::<(), AccessTokenError<::Error>>(()) /// ``` -pub fn sign_access_token( +pub fn sign_access_token( backend: &mut T, key: &CoseKey, claims: ClaimsSet, @@ -425,7 +425,7 @@ where /// assert!(verify_access_token_multiple(&mut backend, &key2, &token, &None).is_ok()); /// # Ok::<(), AccessTokenError<::Error>>(()) /// ``` -pub fn sign_access_token_multiple<'a, T, I, AAD: AadProvider + ?Sized>( +pub fn sign_access_token_multiple<'a, T, I, AAD: AadProvider>( backend: &mut T, keys: I, claims: ClaimsSet, @@ -518,7 +518,7 @@ pub fn get_token_headers(token: &ByteString) -> Option<(Header, ProtectedHeader) /// # Example /// /// For an example, see the documentation of [`sign_access_token`]. -pub fn verify_access_token( +pub fn verify_access_token( backend: &mut T, key_provider: &CKP, token: &ByteString, @@ -544,7 +544,7 @@ where /// Returns an error if the [`CoseSign`] structure could not be parsed, an error during verification /// occurs (see [`CoseSignExt::try_verify`] for possible errors) or the contained payload is not a /// valid [`ClaimsSet`]. -pub fn verify_access_token_multiple( +pub fn verify_access_token_multiple( backend: &mut T, key_provider: &CKP, token: &ByteString, @@ -574,7 +574,7 @@ where /// # Example /// /// For an example, see the documentation of [`encrypt_access_token`]. -pub fn decrypt_access_token( +pub fn decrypt_access_token( backend: &mut T, key_provider: &CKP, token: &ByteString, @@ -603,7 +603,7 @@ where /// Returns an error if the [`CoseEncrypt`] structure could not be parsed, an error during decryption /// occurs (see [`CoseEncryptExt::try_decrypt_with_recipients`] for possible errors) or the decrypted /// payload is not a valid [`ClaimsSet`]. -pub fn decrypt_access_token_multiple( +pub fn decrypt_access_token_multiple( backend: &mut T, key_provider: &CKP, token: &ByteString,