sonic-buildimage/platform/marvell-armhf/sonic-platform-nokia/entropy.py
Rajkumar-Marvell 82bf3b6fb6 [Marevell] Fix armhf build failure (#9875)
Signed-off-by: Rajkumar Pennadam Ramamoorthy <rpennadamram@marvell.com>
2022-03-01 22:49:26 +00:00

23 lines
687 B
Python

#!/usr/bin/python
import fcntl, struct
import time
from os import path
RNDADDENTROPY=0x40085203
def avail():
if path.exists("/proc/sys/kernel/random/entropy_avail"):
with open("/proc/sys/kernel/random/entropy_avail", mode='r') as avail:
return int(avail.read())
else:
return int(2048)
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)