Package: xca Version: 1.3.2-1 Hi folks,
I always wondered why xca can generate keys so fast. Reading the code I stumbled over this in entropy.cpp: : random_from_file("/dev/random", 64); random_from_file("/dev/hwrng", 64); : int Entropy::random_from_file(QString fname, unsigned amount, int weakness) { char buf[256]; const char *file; int fd, sum; QByteArray ba; ba = filename2bytearray(fname); file = ba.constData(); fd = open(file, O_RDONLY | O_NONBLOCK); if (fd == -1) return 0; for (sum=0; amount > 0;) { int len = read(fd, buf, amount > sizeof buf ? sizeof buf : amount); if (len > 0) { RAND_seed(buf, len); seed_strength += len / weakness; amount -= len; sum += len; } if (len == -1) { if (errno != EWOULDBLOCK) qWarning("Error '%s' while reading '%s'\n", strerror(errno), file); len = 0; } if (len == 0) break; } close(fd); #ifdef DEBUG_ENTROPY fprintf(stderr, "Entropy from file '%s' = %d bytes\n", file, sum); #endif return sum; } Esp. the "if (len == 0) break;" together with the O_NONBLOCK looks weird (IMHO). Doesn't this mean that if there is no entropy in /dev/random at all, then it returns immediately instead of collecting at least a few bits of random data? Regards Harri