I'm facing an issue with the PointyCastle plugin in a Flutter application where RSA PKCS#1 v1.5 signatures, generated with SHA-256, fail to verify despite being valid. The same signatures are successfully verified using OpenSSL and other online RSA signature verification tools. This inconsistency suggests a potential problem with how PointyCastle handles RSA signature verification.
Context
We have implemented a Flutter plugin that utilizes RSA PKCS#1 v1.5 for signing and verifying data. The signing and verification processes are expected to use the SHA-256 hash algorithm.
Key Generation: RSA keys are generated and stored securely.
Signature Creation: A payload is signed using the private RSA key and the resulting signature is base64 encoded.
Verification: The signature is verified against the payload using the corresponding RSA public key.
Steps to Reproduce
Generate RSA Key Pair: Use the RSA algorithm to generate a 2048-bit key pair.
Sign Payload: Use the RSA private key to sign a payload ("Biometric payload") with PKCS#1 v1.5 padding and SHA-256 hashing.
Verify Signature in PointyCastle:
Decode the base64 encoded signature.
Hash the payload using SHA-256.
Use PointyCastle's Signer initialized with SHA-256/RSA to verify the signature.
Description
I'm facing an issue with the PointyCastle plugin in a Flutter application where RSA PKCS#1 v1.5 signatures, generated with SHA-256, fail to verify despite being valid. The same signatures are successfully verified using OpenSSL and other online RSA signature verification tools. This inconsistency suggests a potential problem with how PointyCastle handles RSA signature verification.
Context
We have implemented a Flutter plugin that utilizes RSA PKCS#1 v1.5 for signing and verifying data. The signing and verification processes are expected to use the SHA-256 hash algorithm.
Steps to Reproduce
"Biometric payload"
) with PKCS#1 v1.5 padding and SHA-256 hashing.Signer
initialized withSHA-256/RSA
to verify the signature.Observed Behavior
false
, indicating that the signature is invalid.Verified OK
, confirming that the signature is valid.Example Code
Output