def get_entropy(hsm, iterations, entropy_ratio):
fd = os.open("<STR_LIT>", os.O_WRONLY)<EOL>fmt = '<STR_LIT>' % (pyhsm.defines.YSM_MAX_PKT_SIZE - <NUM_LIT:1>)<EOL>for _ in xrange(iterations):<EOL><INDENT>rnd = hsm.random(pyhsm.defines.YSM_MAX_PKT_SIZE - <NUM_LIT:1>)<EOL>this = struct.pack(fmt, entropy_ratio * len(rnd), len(rnd), rnd)<EOL>fcntl.ioctl(fd, RNDADDENTROPY, this)<EOL><DEDENT>os.close(fd)<EOL>
Read entropy from YubiHSM and feed it to Linux as entropy using ioctl() syscall.