Remove temporary allocation in mbedtls_mpi_sub_abs #366
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!366
Loading…
Reference in a new issue
No description provided.
Delete branch "development"
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?
In cases where X == B the code now no longer requires an extra call to
mbedtls_calloc if X->n >= A->n. This reduces calls to mbedtls_calloc in
test_suite_ecdsa by 52% and in test_suite_ecdh by 36%.
This does not update mpi_sub_hlp - in mpi_montmul this translates to a
performance decrease for rsa and dhm since in all cases X == A.
Thank you for your contribution!
Unfortunately there are build failures on some of the platforms we test, specifically with Visual Studio and IAR. Here are the logs:
iar8-mingw.txt
Windows-2013.txt
Hi, did my last push should resolve the build failures? Either way, it looks like some of the automated tests are still failing. Is there some way for me to get access to the logs for the failed tests? All the tests in pre-push.sh, as well as run-test-suites.pl, pass on my machine so it would be helpful to see the logs.
@marchmarch Thanks for the update! The CI now passes apart from some Mbed OS jobs which fail for a pre-existing reason and which wouldn't block this PR.
I'm ok with the new subtraction code. The performance gain is substantial on my PC (+10-20% on P curves). However it does increase the code size a little.
Is there really a performance hit if we use the subtraction new code only? I just did a very quick test on my PC: replace the calls to
mpi_sub_hlpinmpi_montmulwith calls tombedtls_mpi_sub_abs(with the redundantcmpcall) and ranprograms/test/benchmark rsa dhm. The change didn't make a perceptible difference.We don't directly test most bignum functions with aliased arguments (i.e. when a result is also an argument). We do usually test them indirectly through rsa/ecp/… but that's indirect. Since this PR modifies
mbedtls_mpi_sub_abs, I'd like to set the ball rolling with this function. Can you please cherry-pickgithub.com/gilles-peskine-arm/mbed-crypto@4273d9de92into this PR?We credit all contributions in the Mbed TLS changelog. Would you like to be credited as “Eric Adamson”, “marchmarch” or something else?
I am instructed not to accept contributions without a contributor license agreement until further notice. Have you signed one already? If you haven't, you'll need to sign one, or wait a little as we're working to get rid of this legal requirement.
Yes, the performance hit was pretty minor. On my PC the rsa/dhm benchmarks are on the order of 1% worse if I pull the new subtraction code out into mpi_sub_hlp. When I compile the current code mpi_sub_hlp is 226 bytes, so maybe it's worth taking the performance hit. I'm happy to either move the code into mpi_sub_hlp or leave it as-is.
Done.
Please credit me as "Eric Adamson".
I don't mind signing it but I won't have access to a scanner until later in the week. I'll reply again once I've submitted the form.
Personally I find a 1% hit on operations that are slow anyway acceptable. You can often save or lose that much by doing things like changing the alignment of the code with respect to cache lines anyway.
For the code size, with a particular set of build options, I get 15885B → 15965B for
bignum.oon Cortex-M0. That's not a lot, but it's within the order of magnitude where we do care.Can you please make a separate PR with a single implementation of subtraction for comparison?
On the license agreement issue, we should have a resolution that allows you to sign electronically very soon. Please stay tuned.
On the legal side, it's now official: we don't need a CLA anymore. Instead, please indicate that you accept to contribute your code under a dual license Apache-2.0 + GPL-2.0-or-later by including a “Signed-off-by” line in each commit message.
Ok, I created a second pull request here: https://github.com/ARMmbed/mbed-crypto/pull/373
That's great news!
Hi, is there anything I need to do to move either pull request forward?
The ball is now in our court. We need to review and I'm afraid we have very limited bandwidth until April.
Superseded by https://github.com/ARMmbed/mbed-crypto/pull/373
Pull request closed