yarrow random generator

Paul Graphov graphov at gmail.com
Thu Dec 24 13:14:39 UTC 2009

Hello guys,

I've looked at FreeBSD 8.0 cryptographically secure pseudorandom
numbers generator and have a question. It looks like a bug but I'am
not sure.

In file sys/dev/randomdev.c, function random_read:

        if (!random_systat.seeded)
                error = (*random_systat.block)(flag);

It blocks until PRNG is seeded. For software random generator implementation
block method looks as follows, sys/dev/randomdev_soft.c:

random_yarrow_block(int flag)
        int error = 0;


        /* Blocking logic */
        while (random_systat.seeded && !error) {
                if (flag & O_NONBLOCK)
                        error = EWOULDBLOCK;
                else {
                        printf("Entropy device is blocking.\n");
                        error = msleep(&random_systat,
                            PUSER | PCATCH, "block", 0);

        return error;

It seems that random_systat.seeded in "while" condition should be negated.
Or it will never block actually, or block erroneously until next reseed
(under very rare

Am I right?


More information about the freebsd-hackers mailing list