Changeset 219119 in webkit


Ignore:
Timestamp:
Jul 4, 2017, 10:43:18 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[WTF] Initialize srandom and srand with cryptographically random number
https://bugs.webkit.org/show_bug.cgi?id=174123

Reviewed by Mark Lam.

Use cryptographically random number instead of current time as a seed.

  • wtf/RandomNumberSeed.h:

(WTF::initializeRandomNumberGenerator):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r219117 r219119  
     12017-07-04  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [WTF] Initialize srandom and srand with cryptographically random number
     4        https://bugs.webkit.org/show_bug.cgi?id=174123
     5
     6        Reviewed by Mark Lam.
     7
     8        Use cryptographically random number instead of current time as a seed.
     9
     10        * wtf/RandomNumberSeed.h:
     11        (WTF::initializeRandomNumberGenerator):
     12
    1132017-07-04  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/WTF/wtf/RandomNumberSeed.h

    r218594 r219119  
    2929#include <stdlib.h>
    3030#include <time.h>
     31#include <wtf/CryptographicallyRandomNumber.h>
    3132
    3233#if HAVE(SYS_TIME_H)
     
    4849    // On Windows we use rand_s which initialises itself
    4950#elif OS(UNIX)
    50     // srandomdev is not guaranteed to exist on linux so we use this poor seed, this should be improved
    51     timeval time;
    52     gettimeofday(&time, 0);
    53     srandom(static_cast<unsigned>(time.tv_usec * getpid()));
     51    srandom(cryptographicallyRandomNumber());
    5452#else
    55     srand(static_cast<unsigned>(time(0)));
     53    srand(cryptographicallyRandomNumber());
    5654#endif
    5755
Note: See TracChangeset for help on using the changeset viewer.