summaryrefslogtreecommitdiff
path: root/hwrand.py
blob: 92016a145c200bb84ff502add78e0dc9294633fd (plain)
1
2
3
4
5
6
7
#!/usr/bin/env python
import fcntl, select, struct
with open('/dev/hwrng', 'rb') as hw, open('/dev/random') as rnd:
    while True:
        d = hw.read(512)
        fcntl.ioctl(rnd, 0x40085203, struct.pack('ii', 4 * len(d), len(d)) + d)
        select.select([], [rnd], [])