Just how bad is the Microsoft Visual C++ 6 rand function, anyway?
Werner Koch
wk at gnupg.org
Wed May 22 02:55:53 EDT 2002
On Tue, 21 May 2002 11:52:01 -0400, Trei, Peter said:
> int __cdecl rand (void)
> {
> return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
> }
Which looks pretty standard and ISO-C compatible as long as RAND_MAX
yields 0x7fff. Recall that rand() was never intended as a
cryptographic strong RNG - IIRC the specs say that it must produce the
same sequence of number for a given seed (set with srand()).
Ah yes, latest Posix draft:
The rand () function shall compute a sequence of pseudo-random
integers in the range 0 to {RAND_MAX} with a period of at least
232. The rand( ) function need not be reentrant. A function that
is not required to be reentrant is not required to be thread-safe.
The rand_r( ) function shall compute a sequence of pseudo-random
integers in the range 0 to {RAND_MAX}. (The value of the {RAND_MAX}
macro shall be at least 32 767.)
Werner
---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majordomo at wasabisystems.com
More information about the cryptography
mailing list