Brad Tilley wrote:
That's OK, my skin is thick. Thanks for the feedback.
Ok, back to the real topic. The essence is that for key (or
password generation) you'll want a cryptographically strong
generator.
See
http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator
-Otto
This was a simple attempt to produce random
strings to be used as passwords on multiple platforms in a portable
manner (the same source code should compile and execute on multiple
OSes with similar output). I assumed (wrongly) that standard C++ and
srand/rand on OpenBSD would behave as standard C++ and srand/rand
does elsewhere. I understand now why it does not.
The weird part of this (I think) for us outside viewers is that rand()
has been known to be really poor at random for a long time. Not "a few
years", but like 20+ years and more.
It's portable, but it is like the ipsec lowest-common-denominator of
using single-DES with 56-bit keys. Sure, most implementations will
support it, and will produce "similar output on multiple OSes" but NOONE
would want to protect their VPNs with it, since it sucks security-wise.
So hoping for rand() to behave in an 'expected' manner means (to me):
-I want it to be the lowest common denominator on all OSes, which would
mean "the worst possible that produces a string of numbers on each call"
I'm sure other people might hope for cryptographically secure numbers
from the call, but the general expectation one gets from manpages on
various OSes is that rand() sucks, and has been know to suck for a long
time and don't use it unless you're following some kind of "learning
C"-book written 20+ years ago to implement yahtzee.