2020-12-03 14:38:50 -06:00
|
|
|
#!/usr/bin/python
|
|
|
|
import fcntl, struct
|
|
|
|
import time
|
2020-12-15 10:43:12 -06:00
|
|
|
from os import path
|
2020-12-03 14:38:50 -06:00
|
|
|
|
|
|
|
RNDADDENTROPY=0x40085203
|
|
|
|
|
|
|
|
def avail():
|
|
|
|
with open("/proc/sys/kernel/random/entropy_avail", mode='r') as avail:
|
|
|
|
return int(avail.read())
|
|
|
|
|
2020-12-15 10:43:12 -06:00
|
|
|
if path.exists("/proc/sys/kernel/random/entropy_avail"):
|
|
|
|
while 1:
|
|
|
|
while avail() < 2048:
|
|
|
|
with open('/dev/urandom', 'rb') as urnd, open("/dev/random", mode='wb') as rnd:
|
|
|
|
d = urnd.read(512)
|
|
|
|
t = struct.pack('ii', 4 * len(d), len(d)) + d
|
|
|
|
fcntl.ioctl(rnd, RNDADDENTROPY, t)
|
|
|
|
time.sleep(30)
|