[New-bugs-announce] [issue35127] pyurandom() fails if user does not have an entropy device

Gyff Mjord report at bugs.python.org
Wed Oct 31 15:06:46 EDT 2018


New submission from Gyff Mjord <vookshinchanrj at hotmail.com>:

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)

----------
components: FreeBSD
messages: 329005
nosy: koobs, pehdrah
priority: normal
severity: normal
status: open
title: pyurandom() fails if user does not have an entropy device
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35127>
_______________________________________


More information about the New-bugs-announce mailing list