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

Bugfixes to fp_prime_random_ex #4

Closed
wants to merge 7 commits into from
Closed

Conversation

rasky
Copy link
Contributor

@rasky rasky commented Sep 21, 2011

This branch contains some fixes to fp_prime_random_ex. See the specific commits. Specifically:

  1. Remove unused "t" parameter.
  2. Avoid generating primes with MSB=0x80 when size is a multiple of 8
  3. Avoid usage of malloc()

When we ask to generate a prime whose size is a multiple of 8,
the code wrongly computes the mask as 0x00 instead of 0xFF, so the
generated prime always has the MSB set to 0x80 (the highest bit is OR'ed
later in the code).
This is the only instance of dynamic memory in TFM. It can be avoided
by writing directly into the dp[] array, and it does not violate C
aliasing rules which specifically allow access on objects through char*.
It does not matter the platform-specific representation of digits since
we are filling them with random data anyway.
There are potential issues with weird platforms were not
all bits of a fp_digit are used (padding bits), plus it
makes it harder to do reproducible testing of algorithms.
@rasky
Copy link
Contributor Author

rasky commented Sep 27, 2011

Updated after mailing-list reviews: remove possibly unportable code, and fixed more bugs discovered by accurate testing.

@levitte
Copy link
Collaborator

levitte commented Sep 18, 2024

This needs rebasing and some love. Seeing that this is a really old PR, I'm making a reboot PR and doing the work

@levitte
Copy link
Collaborator

levitte commented Sep 18, 2024

Reboot in #39, closing this

@levitte levitte closed this Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants