PennMUSH Community

Changeset 1001

Show
Ignore:
Timestamp:
07/07/07 13:15:46 (1 year ago)
Author:
shawnw
Message:

Fix OpenSSL random number issue for systems without /dev/urandom or EGD

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/devel/CHANGES.182

    r981 r1001  
    1414========================================================================== 
    1515 
    16 Version 1.8.2 patchlevel 6                       ???  ??, 2007 
     16Version 1.8.2 patchlevel 6                       July 9, 2007 
    1717 
    1818Development team changes: 
    19   * After many years, Talek has retired from development.  
     19  * After many years of valuable work, Talek has retired from 
     20    development.   
    2021 
    2122Minor changes: 
     
    2728  * Fixed assorted small memory leaks. [SW] 
    2829  * Fixed handling of telnet NOPs sent by clients. [SW] 
     30  * The OpenSSL random number pool wasn't getting adequately 
     31    initialized on systems without /dev/urandom 
    2932 
    3033Version 1.8.2 patchlevel 5                      June 13, 2007 
  • 1.8.3/branches/devel/src/myssl.c

    r931 r1001  
    7575#include <openssl/dh.h> 
    7676#include <openssl/evp.h> 
     77#include <openssl/rand.h> 
    7778 
    7879#include "conf.h" 
     
    107108static SSL_CTX *ctx = NULL; 
    108109 
     110uint32_t genrand_int32(void); 
     111 
    109112/** Initialize the SSL context. 
    110113 * \return pointer to SSL context object. 
     
    116119  unsigned char context[128]; 
    117120  DH *dh; 
     121  unsigned int reps = 1; 
    118122 
    119123  if (!bio_err) { 
     
    124128    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); 
    125129  } 
    126 #ifndef HAS_DEV_URANDOM 
    127   /* We need to seed the RNG with RAND_seed() or RAND_egd() here. 
    128    * Where are we going to get an unpredictable seed? 
    129    */ 
    130 #endif 
     130 
     131  do_rawlog(LT_ERR, "Seeding OpenSSL random number pool."); 
     132  while (!RAND_status()) { 
     133    /* At this point, a system with /dev/urandom or a EGD file in the usual 
     134       places will have enough entropy. Otherwise, be lazy and use random numbers 
     135       until it's satisfied. */ 
     136    uint32_t gibberish[4]; 
     137    int n; 
     138     
     139    for (n = 0; n < 4; n++) 
     140      gibberish[n] = genrand_int32(); 
     141 
     142    RAND_seed(gibberish, sizeof gibberish); 
     143     
     144    reps += 1; 
     145  } 
     146     
     147  do_rawlog(LT_ERR, "Seeded after %u %s.", reps, reps > 1 ? "cycles" : "cycle"); 
     148 
    131149 
    132150  /* Set up SIGPIPE handler here? */ 
  • 1.8.3/branches/devel/src/utils.c

    r979 r1001  
    5353dbref find_entrance(dbref door); 
    5454void initialize_mt(void); 
    55 static unsigned long genrand_int32(void); 
     55uint32_t genrand_int32(void); 
    5656static void init_genrand(unsigned long); 
    5757static void init_by_array(unsigned long *, int); 
     
    682682 
    683683/* generates a random number on [0,0xffffffff]-interval */ 
    684 static unsigned long 
     684uint32_t 
    685685genrand_int32(void) 
    686686{