Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack usage in sliding-window exponentiation #3591

Closed
d-otte opened this issue Aug 21, 2020 · 0 comments · Fixed by #3592
Closed

Stack usage in sliding-window exponentiation #3591

d-otte opened this issue Aug 21, 2020 · 0 comments · Fixed by #3592
Labels
component-crypto Crypto primitives and low-level interfaces enhancement

Comments

@d-otte
Copy link
Contributor

d-otte commented Aug 21, 2020

The sliding window for the sliding-window exponentiation is allocated (on the stack) with:

W[ 2 << MBEDTLS_MPI_WINDOW_SIZE ]

this should (most likely) be:

W[ 1 << MBEDTLS_MPI_WINDOW_SIZE ]

I ran the tests with this modification and they passed. To ensure the tests would catch actually fail if the array would be to small, I also ran them with a W[ (1 << MBEDTLS_MPI_WINDOW_SIZE) - 1], and they failed as expected.

This change will also reduce stack usage (during this function), by nearly a factor of 2! 🤩

The PR #3592 contains the modification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-crypto Crypto primitives and low-level interfaces enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants