param_source: use random.SystemRandom as random nr source

Python's random module uses a PRNG (Mersenne Twister) which is
utterly insecure for key generation - it was so far only used for
testing.  Replace it with random.SystemRandom(), which draws from
/dev/urandom and is suitable for generating cryptographic key material.

Change-Id: I6de38c14ac6dd55bc84d53974192509c18d02bfa
Jenkins: skip-card-test
This commit is contained in:
Neels Hofmeyr authored and Vadim Yanitskiy committed 2026-06-21 03:42:06 +07:00
1 parent b5ba274583
commit 512aba8b1d
1 file changed
+1 -1
+1 -1
View File
@@ -124,7 +124,7 @@ class DecimalRangeSource(InputExpandingParamSource):
return "%0*d" % (self.num_digits, val) # pylint: disable=consider-using-f-string
class RandomSourceMixin:
random_impl = random # TODO secure random source?
random_impl = random.SystemRandom()
class RandomDigitSource(DecimalRangeSource, RandomSourceMixin):
"""return a different sequence of random decimal digits each"""