arc4random vs RAND_pseudo_bytes

Robert Connolly robert at linuxfromscratch.org
Mon Sep 3 20:44:25 PDT 2007


It looks like HLFS is the only one using arc4random() under Linux. While 
looking at how to use arc4random() with Coreutils, I started to think maybe 
using OpenSSL's RAND_pseudo_bytes() is a more portable idea.

Pretty much every Linux distribution includes OpenSSL, so patching Glibc's 
mktemp(), etc, for OpenSSL would probably be more widely used and tested. The 
quality is pretty much the same. For HLFS, RAND_pseudo_bytes() can be patched 
to use /dev/erandom to conserve entropy, but RAND_pseudo_bytes() would be 
much more likely to be used by other distros, so there's better real-world 
testing of it, and feedback.

arc4random() is a safe and secure prng, but I get no feedback about it. Using 
RAND_pseudo_bytes() would have the affect of removing cryptography from 
Glibc, and using OpenSSL whenever possible, which is the direction I've been 
going.

Using RAND_pseudo_bytes() with mktemp() is a circular dependency between libc 
and OpenSSL, but this can be overcome with dynamic libraries. It means 
installing OpenSSL in chapter 5.

Opinions/comments?

robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hlfs-dev/attachments/20070903/f20f920a/attachment.sig>


More information about the hlfs-dev mailing list