Parse RSA parameters DP, DQ and QP from PKCS1 private keys #352
No reviewers
Labels
No labels
api-spec
bug
CLA requested
CLA valid
compliance
DO NOT MERGE
duplicate
enhancement
feature branch
good first issue
HEADER FORMATTING ISSUE
help wanted
Information
invalid
Jira status: AWAITING REVIEW
Jira status: CLOSED
Jira status: DONE
Jira status: IN PROGRESS
Jira status: IN REVIEW
Jira status: OPEN
Jira status: REOPENED
Jira status: RESOLVED
mirrored
mirror internally
needs: backports
needs: ci
needs: design review
needs: preceding PR
needs: review
needs: work
notabug
open for community contribution
Product Backlog
question
ready for merge
security
stale
type: bug
type: enhancement
type: question
web pages
wontfix
writing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-ARMmbed/mbed-crypto!352
Loading…
Reference in a new issue
No description provided.
Delete branch "jack/parse-rsa-crt-params"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Otherwise these values are recomputed in
mbedtls_rsa_deduce_crt, which currently suffers from side channel issues in the computation of QP (see https://eprint.iacr.org/2020/055). By loading the pre-computed values not only is the side channel avoided, but runtime overhead of loading RSA keys is reduced.Discussion in https://github.com/ARMmbed/mbed-crypto/issues/347
Thanks for the patch! Unfortunately, the CI points out that it doesn't build when
MBEDTLS_RSA_NO_CRTis defined.To reproduce:
To run all the tests we run with CRT usage disabled:
@ -777,0 +784,4 @@/* Import DP */if( ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DP ) ) != 0)goto cleanup;Could we please add a comment here as a reminder for the future to ensure that nobody "optimises" this code out?
Basically explaining that although we could compute these values, we choose not to because this way it is faster and reduces the attack surface exposed to side channel attacks.
@gilles-peskine-arm I addressed the build problem but it looks like Jenkins is still failing, can you forward the issue here?
tests/scripts/all.sh test_rsa_no_crtwas able to reproduce the error you were seeing, but after fixing it a later build fails withThis appears to be a GCM test so I don't think has anything to do with my change - and the same error appears with
developmentbranch.Unfortunately
all.shis very sensitive to the OS and tools used and can have such problems. As a workaround you could delete thegenerate_randomfunction fromtests/suites/test_suite_psa_crypto.functionand the entries starting withgenerate_randomfromtests/suites/test_suite_psa_crypto.datathentests/scripts/all.sh test_rsa_no_crtshould be able to reproduce the failure.For more detailed test output you can run the individual test functions with
-voption. For example:cd tests/ && ./test_suite_pk -v.@yanesca Thanks, your suggestion resolved the build problem in the random tests. Unfortunately? now
all.shpasses for me so I still don't know why the Jenkins builds are failing.I copied the CI output here:
https://gist.github.com/yanesca/f250b5faa8e390b76eede7520e4ec84c
In the first couple of lines it prints out the OS and tools versions. Also here is my local environment (slightly more recent than the CI), I could reproduce with these too (I encountered the same compilation problem though):
The PR should be ready after fixing this test. This won't make the CI green though, because we have an unrelated failure in the CI.
I was not able to reproduce until I edited
all.shto add-fsanitize=leak- for whatever reason it doesn't show up with just ASan. Anyway should be resolved now.Yes, it is resolved, the CI is only failing on known issues that are unrelated to this PR.
Aren't you on OS X by any chance? Leak analyser is turned off by default in OS X ASan:
https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
As noted by @yanesca, please use
mbedtls_asn1_get_mpiwhere applicable.@ -325,7 +334,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )*/Style:
Updated
Looks good to me!
The only thing left on this PR is to do the backports. @jack-fortanix Could you please raise PRs with the same content in the Mbed TLS repository targeting the
mbedtls-2.7andmbedtls-2.16branches?Thank you for submitting the backports!