Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The private Comba helpers can overrun their workspace when called directly with oversized inputs. With the default 60-bit digits and
MP_WARRAY = 512:s_mp_sqr_combawitha->used = 257writes past the end ofW. Rejecta->used > MP_WARRAY / 2before doubling the size or growing the destination.s_mp_montgomery_reduce_combawithn->used = 256needs 513 workspace entries. Extend the existing input-size check to rejectn->used > (MP_WARRAY - 1) / 2before growing the destination or zeroing the workspace.Both cases return
MP_VALwith the input numbers and destination unchanged. Release the temporary workspace on these exits whenMP_SMALL_STACK_SIZEis enabled. Express the limits usingMP_WARRAYso they follow the digit configuration.Add regression coverage for the first rejected sizes, rejected in-place squaring, the largest supported Montgomery modulus, and the existing oversized-input rejection.
The current public dispatch paths already check these Comba size limits. This change makes the private helpers enforce their own workspace bounds. The patch is limited to bounds validation and regression tests.
Validation against
developatae40a87a920099a7d9d00979570e0c8d917a1fd7, using GCC 11.4.0:MP_VALafter the patch.MP_SMALL_STACK_SIZE.git diff --checkpass.