code: def get_entropy(hsm, iterations, entropy_ratio):
      
      fd = os.open("/dev/random", os.O_WRONLY)
      # struct rand_pool_info {
      #    int     entropy_count;
      #    int     buf_size;
      #    __u32   buf[0];
      # };
      fmt = 'ii%is' % (pyhsm.defines.YSM_MAX_PKT_SIZE - 1)
      for _ in xrange(iterations):
          rnd = hsm.random(pyhsm.defines.YSM_MAX_PKT_SIZE - 1)
          this = struct.pack(fmt, entropy_ratio * len(rnd), len(rnd), rnd)
          fcntl.ioctl(fd, RNDADDENTROPY, this)
      os.close(fd)
docs: Read entropy from YubiHSM and feed it to Linux as entropy using ioctl() syscall.