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

crypto.math module utils: add some tests, fix quick_is_not_prime() for small primes #733

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Adds basic unit tests for crypto.math module utils.

Fixes bug in quick_is_not_prime() that makes it claim that primes < 200 are not prime. This is due this function being designed to test large numbers, it was never meant to be used for such small numbers.

ISSUE TYPE
  • Bugfix Pull Request
  • Test Pull Request
COMPONENT NAME

crypto.math module utils

@felixfontein felixfontein merged commit 0c62837 into ansible-collections:main Apr 29, 2024
142 checks passed
Copy link

patchback bot commented Apr 29, 2024

Backport to stable-1: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 0c62837 on top of patchback/backports/stable-1/0c6283729632334a4fda10fba1d1a8422fa33052/pr-733

Backporting merged PR #733 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.crypto.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-1/0c6283729632334a4fda10fba1d1a8422fa33052/pr-733 upstream/stable-1
  4. Now, cherry-pick PR crypto.math module utils: add some tests, fix quick_is_not_prime() for small primes #733 contents into that branch:
    $ git cherry-pick -x 0c6283729632334a4fda10fba1d1a8422fa33052
    If it'll yell at you with something like fatal: Commit 0c6283729632334a4fda10fba1d1a8422fa33052 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 0c6283729632334a4fda10fba1d1a8422fa33052
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR crypto.math module utils: add some tests, fix quick_is_not_prime() for small primes #733 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-1/0c6283729632334a4fda10fba1d1a8422fa33052/pr-733
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein deleted the math branch April 29, 2024 06:50
felixfontein added a commit to felixfontein/community.crypto that referenced this pull request Apr 29, 2024
…r small primes (ansible-collections#733)

* Fix quick_is_not_prime() for small primes. Add some tests.

* Fix return value of convert_int_to_bytes(0, 0) on Python 2.

* Add some more test cases.

* Simplify the changelog and point out that these errors only happen for cases not happening in regular use.

(cherry picked from commit 0c62837)
felixfontein added a commit that referenced this pull request Apr 29, 2024
…r small primes (#733) (#734)

* Fix quick_is_not_prime() for small primes. Add some tests.

* Fix return value of convert_int_to_bytes(0, 0) on Python 2.

* Add some more test cases.

* Simplify the changelog and point out that these errors only happen for cases not happening in regular use.

(cherry picked from commit 0c62837)
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.

1 participant