summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2020-10-31 08:46:25 +1100
committerCommit Bot <commit-bot@chromium.org>2020-11-03 01:05:41 +0000
commitbd699e2e1b19c7010e668b1f665f66b538076ec2 (patch)
tree10515143310c42bee8300dc1bfa35a883d0626b4
parent93e6aa0347e7683635b40feab5c5338c201d0b7f (diff)
downloadchrome-ec-stabilize-13597.70.B-cr50_stab.tar.gz
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.py6
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