pub fn verify(
    signature: &str,
    signing_input: &str,
    key: Key,
    algorithm: Algorithm,
) -> Result<bool> {
    match algorithm {
        Algorithm::HS256 | Algorithm::HS384 | Algorithm::HS512 => {
            // we just re-sign the data with the key and compare if they are equal
            let signed = sign(signing_input, key, algorithm)?;
            Ok(verify_slices_are_equal(signature.as_ref(), signed.as_ref()).is_ok())
        }
        Algorithm::ES256 => {
            verify_ring_es(&signature::ECDSA_P256_SHA256_FIXED, signature, signing_input, key)
        }
        Algorithm::ES384 => {
            verify_ring_es(&signature::ECDSA_P384_SHA384_FIXED, signature, signing_input, key)
        }
        Algorithm::RS256 => {
            verify_ring_rsa(&signature::RSA_PKCS1_2048_8192_SHA256, signature, signing_input, key)
        }
        Algorithm::RS384 => {
            verify_ring_rsa(&signature::RSA_PKCS1_2048_8192_SHA384, signature, signing_input, key)
        }
        Algorithm::RS512 => {
            verify_ring_rsa(&signature::RSA_PKCS1_2048_8192_SHA512, signature, signing_input, key)
        }
        Algorithm::PS256 => {
            verify_ring_rsa(&signature::RSA_PSS_2048_8192_SHA256, signature, signing_input, key)
        }
        Algorithm::PS384 => {
            verify_ring_rsa(&signature::RSA_PSS_2048_8192_SHA384, signature, signing_input, key)
        }
        Algorithm::PS512 => {
            verify_ring_rsa(&signature::RSA_PSS_2048_8192_SHA512, signature, signing_input, key)
        }
    }
}
/// Compares the signature given with a re-computed signature for HMAC or using the public key
/// for RSA.
///
/// Only use this function if you want to do something other than JWT.
///
/// `signature` is the signature part of a jwt (text after the second '.')
///
/// `signing_input` is base64(header) + "." + base64(claims)
Compares the signature given with a re-computed signature for HMAC or using the public key
for RSA.

Only use this function if you want to do something other than JWT.

`signature` is the signature part of a jwt (text after the second '.')


Compares the signature given with a re - computed signature for HMAC or using the public key for RSA . Only use this function if you want to do something other than JWT . ` signature ` is the signature part of a jwt ( text after the second ' . ' )
pub fn verify(
    signature: &str,
    signing_input: &str,
    key: Key,
    algorithm: Algorithm,
) -> Result<bool> {
    match algorithm {
        Algorithm::HS256 | Algorithm::HS384 | Algorithm::HS512 => {
            // we just re-sign the data with the key and compare if they are equal
            let signed = sign(signing_input, key, algorithm)?;
            Ok(verify_slices_are_equal(signature.as_ref(), signed.as_ref()).is_ok())
        }
        Algorithm::ES256 => {
            verify_ring_es(&signature::ECDSA_P256_SHA256_FIXED, signature, signing_input, key)
        }
        Algorithm::ES384 => {
            verify_ring_es(&signature::ECDSA_P384_SHA384_FIXED, signature, signing_input, key)
        }
        Algorithm::RS256 => {
            verify_ring_rsa(&signature::RSA_PKCS1_2048_8192_SHA256, signature, signing_input, key)
        }
        Algorithm::RS384 => {
            verify_ring_rsa(&signature::RSA_PKCS1_2048_8192_SHA384, signature, signing_input, key)
        }
        Algorithm::RS512 => {
            verify_ring_rsa(&signature::RSA_PKCS1_2048_8192_SHA512, signature, signing_input, key)
        }
        Algorithm::PS256 => {
            verify_ring_rsa(&signature::RSA_PSS_2048_8192_SHA256, signature, signing_input, key)
        }
        Algorithm::PS384 => {
            verify_ring_rsa(&signature::RSA_PSS_2048_8192_SHA384, signature, signing_input, key)
        }
        Algorithm::PS512 => {
            verify_ring_rsa(&signature::RSA_PSS_2048_8192_SHA512, signature, signing_input, key)
        }
    }
}
pub fn verify ( signature : & str , signing_input : & str , key : Key , algorithm : Algorithm , ) -> Result < bool > { match algorithm { Algorithm :: HS256 | Algorithm :: HS384 | Algorithm :: HS512 => { // we just re-sign the data with the key and compare if they are equal let signed = sign ( signing_input , key , algorithm ) ? ; Ok ( verify_slices_are_equal ( signature . as_ref ( ) , signed . as_ref ( ) ) . is_ok ( ) ) } Algorithm :: ES256 => { verify_ring_es ( & signature :: ECDSA_P256_SHA256_FIXED , signature , signing_input , key ) } Algorithm :: ES384 => { verify_ring_es ( & signature :: ECDSA_P384_SHA384_FIXED , signature , signing_input , key ) } Algorithm :: RS256 => { verify_ring_rsa ( & signature :: RSA_PKCS1_2048_8192_SHA256 , signature , signing_input , key ) } Algorithm :: RS384 => { verify_ring_rsa ( & signature :: RSA_PKCS1_2048_8192_SHA384 , signature , signing_input , key ) } Algorithm :: RS512 => { verify_ring_rsa ( & signature :: RSA_PKCS1_2048_8192_SHA512 , signature , signing_input , key ) } Algorithm :: PS256 => { verify_ring_rsa ( & signature :: RSA_PSS_2048_8192_SHA256 , signature , signing_input , key ) } Algorithm :: PS384 => { verify_ring_rsa ( & signature :: RSA_PSS_2048_8192_SHA384 , signature , signing_input , key ) } Algorithm :: PS512 => { verify_ring_rsa ( & signature :: RSA_PSS_2048_8192_SHA512 , signature , signing_input , key ) } } }
Compares the signature given with a re-computed signature for HMAC or using the public key
for RSA.
Compares the signature given with a re - computed signature for HMAC or using the public key for RSA .
signature
&str
signing_input
&str
key
Key
algorithm
Algorithm