diff options
author | Mary Ruthven <mruthven@chromium.org> | 2020-10-31 08:46:25 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-03 01:05:41 +0000 |
commit | bd699e2e1b19c7010e668b1f665f66b538076ec2 (patch) | |
tree | 10515143310c42bee8300dc1bfa35a883d0626b4 | |
parent | 93e6aa0347e7683635b40feab5c5338c201d0b7f (diff) | |
download | chrome-ec-stabilize-13597.68.B-cr50_stab.tar.gz |
rsa_test: use whatever primality test existsstabilize-quickfix-13597.30.B-cr50_stabstabilize-ambassador-13597.79.B-cr50_stabstabilize-13605.B-cr50_stabstabilize-13597.97.B-cr50_stabstabilize-13597.95.B-cr50_stabstabilize-13597.94.B-cr50_stabstabilize-13597.90.B-cr50_stabstabilize-13597.85.B-cr50_stabstabilize-13597.84.B-cr50_stabstabilize-13597.71.B-cr50_stabstabilize-13597.70.B-cr50_stabstabilize-13597.69.B-cr50_stabstabilize-13597.68.B-cr50_stabstabilize-13597.67.B-cr50_stabstabilize-13597.66.B-cr50_stabstabilize-13597.105.B-cr50_stabstabilize-13597.103.B-cr50_stabstabilize-13591.B-cr50_stabrelease-R88-13597.B-cr50_stab
Python may use different rsa versions inside and outside of the chroot.
miller_rabin_primality_testing may or may not exist. For tpmtest
randomized_primality_testing and miller_rabin_primality_testing are
interchangeable. Use whatever primality test rma.prime has.
BUG=b:172081851
TEST=make tpmtest ; run inside and outside of the chroot
Change-Id: Iabd9755f0a264070ff321bde045a87f7397f7062
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511432
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | test/tpm_test/rsa_test.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/tpm_test/rsa_test.py b/test/tpm_test/rsa_test.py index 52754b38d8..ceaa15786f 100644 --- a/test/tpm_test/rsa_test.py +++ b/test/tpm_test/rsa_test.py @@ -519,6 +519,10 @@ _PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 38791, 38803, 38821, 38833, 38839, 38851, 38861, 38867, 38873] +if hasattr(rsa.prime, 'miller_rabin_primality_testing'): + PRIMALITY_TEST = rsa.prime.miller_rabin_primality_testing +else: + PRIMALITY_TEST = rsa.prime.randomized_primality_testing def _prime_from_seed(seed): rounds = 7 @@ -539,7 +543,7 @@ def _prime_from_seed(seed): window = _window(candidate, _PRIMES[:4096]) for i, bit in enumerate(window): if not bit: - if rsa.prime.miller_rabin_primality_testing(candidate + i, rounds): + if PRIMALITY_TEST(candidate + i, rounds): return candidate + i return None |