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

Linux's /dev/urandom and Python's os.urandom does not pass #10

Open
phmngcthanh opened this issue Nov 26, 2022 · 2 comments
Open

Linux's /dev/urandom and Python's os.urandom does not pass #10

phmngcthanh opened this issue Nov 26, 2022 · 2 comments

Comments

@phmngcthanh
Copy link

import os print( bin(int.from_bytes(os.urandom(1024),'big')))
does not pass Maurer test (09) and approx. Entropy test (12)
image

print( bin(int.from_bytes(open('/dev/urandom','rb').read(1024),'big'))) does not pass Maurer test (09) and randomly, does not pass approx. Entropy test (12) too

image
image

@phmngcthanh
Copy link
Author

I tried on Python 3.6.9 (default, Jun 29 2022, 11:45:57) [GCC 8.4.0] on linux, using Jetson Nano's Linux
I wonder, does it imply that both incompliance to NIST, or something else

@ThexXTURBOXx
Copy link
Contributor

ThexXTURBOXx commented Jun 28, 2023

Maurer's Test is only applicable for bit strings of length >= 387840.
As for the approximate entropy test, I think that with enough data (at least 10^6 or something), it might actually pass.
If your bit string is not long enough, the tests might "randomly" fail.

For even more reference, see section 4.3: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-22r1a.pdf

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

No branches or pull requests

2 participants