This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pyurandom() fails if user does not have an entropy device
Type: behavior Stage:
Components: FreeBSD Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, koobs, pehdrah
Priority: normal Keywords:

Created on 2018-10-31 19:06 by pehdrah, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg329005 - (view) Author: Gyff Mjord (pehdrah) Date: 2018-10-31 19:06
Because of [reasons], I installed a FreeBSD and recompiled it to provide a minimalist kernel. Thus, it does not have the entropy devices /dev/urandom and /dev/random

It is a FreeBSD-10-0 running in a Hyper-V virutalization platform.

I kinda recompiled python-3.7.1 from the source code to get my own version of python running, but I got stuck in this part. So looking at the Modules/bootstrap_hash.c file I do not see the code of pyurandom() falling back to a something silly.

Plus, there is a problem that happens only in Unix at least in this version of python. Looking at the code of the same file. we can see:

static int pyurandom(...)
{
...
int res
...
if (res < 0){
  return -1
}
if (res == 1){
  return 0
}
...
}

I am sorry for the laziness but I believe my point is clear.

The thing is. If the random function returns 0 it will return 0 but if it returns 1 it will also return 0.

In other words, the number 1 is out of the scope of the random numbers. It is a small prejudice for the random function, but it is not mathematically right. This issue with the number 1, does not happen if the user does not have /dev/random (But it still needs /dev/urandom)
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79308
2018-10-31 19:51:22pablogsalsetnosy: + christian.heimes
2018-10-31 19:06:46pehdrahcreate