MD5 Folding in kernel RNG

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Kjell Wooding
Date: Monday, December 27, 2010 - 6:07 pm

The OpenBSD random number subsystem uses an in-kernel entropy pool. This
data isn't used directly. When entropy is requested, the contents of the
pool are hashed with MD5, and the massaged output used to seed an RC4 PRNG.

In looking at the code, however, I notice we actually fold the MD5 output in
half. From extract_entropy():

              MD5Final(buffer, &tmp);

                /*
                 * In case the hash function has some recognizable
                 * output pattern, we fold it in half.
                 */
                buffer[0] ^= buffer[15];
                buffer[1] ^= buffer[14];
                buffer[2] ^= buffer[13];
                buffer[3] ^= buffer[12];
                buffer[4] ^= buffer[11];
                buffer[5] ^= buffer[10];
                buffer[6] ^= buffer[ 9];
                buffer[7] ^= buffer[ 8];

               /* Copy data to destination buffer */
                bcopy(buffer, buf, i);
                nbytes -= i;
                buf += i;

My question: Why? What exactly are we protecting against, and is this really
protection? (the comment indicates "some recognizable output pattern, but
that means little to me as is) Can we really be sure it doesn't make things
worse?

Is this done elsewhere, or is it our particular brand of voodoo?

Happy ho ho,

-kj
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
MD5 Folding in kernel RNG, Kjell Wooding, (Mon Dec 27, 6:07 pm)
Re: MD5 Folding in kernel RNG, Ted Unangst, (Mon Dec 27, 9:02 pm)
Re: MD5 Folding in kernel RNG, Damien Miller, (Tue Dec 28, 1:48 am)
Re: MD5 Folding in kernel RNG, Kjell Wooding, (Tue Dec 28, 1:08 pm)
Re: MD5 Folding in kernel RNG, Damien Miller, (Tue Dec 28, 1:45 pm)
Re: MD5 Folding in kernel RNG, Kjell Wooding, (Tue Dec 28, 2:42 pm)