[10791] in cryptography@c2.net mail archive

home help back first fref pref prev next nref lref last post

Re: Just how bad is the Microsoft Visual C++ 6 rand function,

daemon@ATHENA.MIT.EDU (Werner Koch)
Wed May 22 17:37:47 2002

To: "'cryptography@wasabisystems.com'" <cryptography@wasabisystems.com>
From: Werner Koch <wk@gnupg.org>
Mail-Followup-To: "'cryptography@wasabisystems.com'" <cryptography@wasabisystems.com>
Date: Wed, 22 May 2002 08:55:53 +0200
In-Reply-To: <F504A8CEE925D411AF4A00508B8BE90A01E90E55@exna07.securitydynamics.com> ("Trei,
 Peter"'s message of "Tue, 21 May 2002 11:52:01 -0400")
Message-ID: <87d6vopt6u.fsf@alberti.gnupg.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

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@wasabisystems.com

home help back first fref pref prev next nref lref last post