feat: add support for public exponent 3 #8
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The PKCS#1 v1.5 signature verification in the library was done assuming the exponent used for the public key is 65537. While this is the most widely used exponent, the exponent 3 is also in use, notably in some electronic passports. So this PR aims to add the support for this exponent in addition to 65537.
Problem*
Unability to verify signature using 3 as public exponent.
Summary*
The function
verify_sha256_pkcs1v15
now takes in a new argument to specify the exponent. The exponent can be either 65537 or 3 if any other number the verification will fail straight away.A test case was also added for a 2048-bit RSA signature using 3 as a public exponent.
The signature gen Rust script also takes in an exponent argument (defaulting to 65537) to generate a sample signature with a custom exponent.
Additional Context
The public exponent 3 is required to verify the signatures of some passports.
PR Checklist*
cargo fmt
on default settings.