pub fn verifier_from_der(
        &self,
        input: impl AsRef<[u8]>,
    ) -> Result<RsassaPssJwsVerifier, JoseError> {
        (|| -> anyhow::Result<RsassaPssJwsVerifier> {
            let input = input.as_ref();
            let spki_der_vec;
            let spki_der = match RsaPssKeyPair::detect_pkcs8(input, true) {
                Some((hash, mgf1_hash, salt_len)) => {
                    if hash != self.hash_algorithm() {
                        bail!("The message digest parameter is mismatched: {}", hash);
                    } else if mgf1_hash != self.hash_algorithm() {
                        bail!(
                            "The mgf1 message digest parameter is mismatched: {}",
                            mgf1_hash
                        );
                    } else if salt_len != self.salt_len() {
                        bail!("The salt size is mismatched: {}", salt_len);
                    }

                    input.as_ref()
                }
                None => {
                    let rsa_der_vec;
                    let rsa_der = match RsaKeyPair::detect_pkcs8(input, true) {
                        Some(_) => {
                            let rsa = Rsa::public_key_from_der(input)?;
                            rsa_der_vec = rsa.public_key_to_der_pkcs1()?;
                            &rsa_der_vec
                        }
                        None => input,
                    };

                    spki_der_vec = RsaPssKeyPair::to_pkcs8(
                        rsa_der,
                        true,
                        self.hash_algorithm(),
                        self.hash_algorithm(),
                        self.salt_len(),
                    );
                    spki_der_vec.as_slice()
                }
            };

            let public_key = PKey::public_key_from_der(spki_der)?;

            let rsa = public_key.rsa()?;
            if rsa.size() * 8 < 2048 {
                bail!("key length must be 2048 or more.");
            }

            Ok(RsassaPssJwsVerifier {
                algorithm: self.clone(),
                public_key,
                key_id: None,
            })
        })()
        .map_err(|err| JoseError::InvalidKeyFormat(err))
    }
/// Return a verifier from a public key that is a DER encoded SubjectPublicKeyInfo or PKCS#1 RSAPublicKey.
///
/// # Arguments
/// * `input` - A public key that is a DER encoded SubjectPublicKeyInfo or PKCS#1 RSAPublicKey.
Return a verifier from a public key that is a DER encoded SubjectPublicKeyInfo or PKCS#1 RSAPublicKey.
Return a verifier from a public key that is a DER encoded SubjectPublicKeyInfo or PKCS#1 RSAPublicKey .
pub fn verifier_from_der(
        &self,
        input: impl AsRef<[u8]>,
    ) -> Result<RsassaPssJwsVerifier, JoseError> {
        (|| -> anyhow::Result<RsassaPssJwsVerifier> {
            let input = input.as_ref();
            let spki_der_vec;
            let spki_der = match RsaPssKeyPair::detect_pkcs8(input, true) {
                Some((hash, mgf1_hash, salt_len)) => {
                    if hash != self.hash_algorithm() {
                        bail!("The message digest parameter is mismatched: {}", hash);
                    } else if mgf1_hash != self.hash_algorithm() {
                        bail!(
                            "The mgf1 message digest parameter is mismatched: {}",
                            mgf1_hash
                        );
                    } else if salt_len != self.salt_len() {
                        bail!("The salt size is mismatched: {}", salt_len);
                    }
                    input.as_ref()
                }
                None => {
                    let rsa_der_vec;
                    let rsa_der = match RsaKeyPair::detect_pkcs8(input, true) {
                        Some(_) => {
                            let rsa = Rsa::public_key_from_der(input)?;
                            rsa_der_vec = rsa.public_key_to_der_pkcs1()?;
                            &rsa_der_vec
                        }
                        None => input,
                    };
                    spki_der_vec = RsaPssKeyPair::to_pkcs8(
                        rsa_der,
                        true,
                        self.hash_algorithm(),
                        self.hash_algorithm(),
                        self.salt_len(),
                    );
                    spki_der_vec.as_slice()
                }
            };
            let public_key = PKey::public_key_from_der(spki_der)?;
            let rsa = public_key.rsa()?;
            if rsa.size() * 8 < 2048 {
                bail!("key length must be 2048 or more.");
            }
            Ok(RsassaPssJwsVerifier {
                algorithm: self.clone(),
                public_key,
                key_id: None,
            })
        })()
        .map_err(|err| JoseError::InvalidKeyFormat(err))
    }
pub fn verifier_from_der ( & self , input : impl AsRef < [ u8 ] > , ) -> Result < RsassaPssJwsVerifier , JoseError > { ( | | -> anyhow :: Result < RsassaPssJwsVerifier > { let input = input . as_ref ( ) ; let spki_der_vec ; let spki_der = match RsaPssKeyPair :: detect_pkcs8 ( input , true ) { Some ( ( hash , mgf1_hash , salt_len ) ) => { if hash != self . hash_algorithm ( ) { bail ! ( " " hash ) ; } else if mgf1_hash != self . hash_algorithm ( ) { bail ! ( " " mgf1_hash ) ; } else if salt_len != self . salt_len ( ) { bail ! ( " " salt_len ) ; } input . as_ref ( ) } None => { let rsa_der_vec ; let rsa_der = match RsaKeyPair :: detect_pkcs8 ( input , true ) { Some ( _ ) => { let rsa = Rsa :: public_key_from_der ( input ) ? ; rsa_der_vec = rsa . public_key_to_der_pkcs1 ( ) ? ; & rsa_der_vec } None => input , } ; spki_der_vec = RsaPssKeyPair :: to_pkcs8 ( rsa_der , true , self . hash_algorithm ( ) , self . hash_algorithm ( ) , self . salt_len ( ) , ) ; spki_der_vec . as_slice ( ) } } ; let public_key = PKey :: public_key_from_der ( spki_der ) ? ; let rsa = public_key . rsa ( ) ? ; if rsa . size ( ) * 8 < 2048 { bail ! ( " " ) ; } Ok ( RsassaPssJwsVerifier { algorithm : self . clone ( ) , public_key , key_id : None , } ) } ) ( ) . map_err ( | err | JoseError :: InvalidKeyFormat ( err ) ) }
Return a verifier from a public key that is a DER encoded SubjectPublicKeyInfo or PKCS#1 RSAPublicKey.
Return a verifier from a public key that is a DER encoded SubjectPublicKeyInfo or PKCS#1 RSAPublicKey .
&self
input
impl AsRef<[u8]>
&self
input
impl AsRef<[u8]>