/// Verify a PKCS#1 v1.5 SHA-256 RSA signature
///
/// As specified in RFC 8017
/// (https://datatracker.ietf.org/doc/html/rfc8017#section-8.2) and used by
/// the IC for webauthn (https://docs.dfinity.systems/spec/public/#webauthn)
Verify a PKCS#1 v1.5 SHA-256 RSA signature
As specified in RFC 8017
and used by
the IC for webauthn
Verify a PKCS#1 v1 . 5 SHA - 256 RSA signature As specified in RFC 8017 and used by the IC for webauthn
pub fn verify_pkcs1_sha256(&self, message: &[u8], signature: &[u8]) -> CryptoResult<()> {
        let digest = Sha256::hash(message);
        let padding = rsa::PaddingScheme::PKCS1v15Sign {
            hash: Some(rsa::Hash::SHA2_256),
        };
        match self.key.verify(padding, &digest, signature) {
            Ok(_) => Ok(()),
            Err(e) => Err(CryptoError::SignatureVerification {
                algorithm: AlgorithmId::RsaSha256,
                public_key_bytes: self.as_der().to_vec(),
                sig_bytes: signature.to_vec(),
                internal_error: format!("{:?}", e),
            }),
        }
    }
pub fn verify_pkcs1_sha256 ( & self , message : & [ u8 ] , signature : & [ u8 ] ) -> CryptoResult < ( ) > { let digest = Sha256 :: hash ( message ) ; let padding = rsa :: PaddingScheme :: PKCS1v15Sign { hash : Some ( rsa :: Hash :: SHA2_256 ) , } ; match self . key . verify ( padding , & digest , signature ) { Ok ( _ ) => Ok ( ( ) ) , Err ( e ) => Err ( CryptoError :: SignatureVerification { algorithm : AlgorithmId :: RsaSha256 , public_key_bytes : self . as_der ( ) . to_vec ( ) , sig_bytes : signature . to_vec ( ) , internal_error : format ! ( " " e ) , } ) , } }
Verify a PKCS#1 v1.5 SHA-256 RSA signature
As specified in RFC 8017
(https://datatracker.ietf.org/doc/html/rfc8017#section-8.2) and used by
the IC for webauthn (https://docs.dfinity.systems/spec/public/#webauthn)
Verify a PKCS#1 v1 . 5 SHA - 256 RSA signature As specified in RFC 8017 ( https : // datatracker . ietf . org / doc / html / rfc8017#section - 8 . 2 ) and used by the IC for webauthn ( https : // docs . dfinity . systems / spec / public / #webauthn )
&self
message
&[u8]
signature
&[u8]