Changeset 26415


Ignore:
Timestamp:
2011-04-02T21:44:51+02:00 (7 years ago)
Author:
nbd
Message:

hostapd: write a stampfile when the random pool has been initialized - fixes rejected assoc attempts after hostapd restart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/hostapd/patches/700-random_pool_add_kernel.patch

    r26414 r26415  
    11--- a/src/crypto/random.c 
    22+++ b/src/crypto/random.c 
    3 @@ -48,6 +48,8 @@ 
     3@@ -38,6 +38,8 @@ 
     4 #include "sha1.h" 
     5 #include "random.h" 
     6  
     7+#define RANDOM_STAMPFILE "/var/run/.random_available" 
     8+ 
     9 #define POOL_WORDS 32 
     10 #define POOL_WORDS_MASK (POOL_WORDS - 1) 
     11 #define POOL_TAP1 26 
     12@@ -48,6 +50,8 @@ 
    413 #define EXTRACT_LEN 16 
    514 #define MIN_READY_MARK 2 
     
    1019 static unsigned int input_rotate = 0; 
    1120 static unsigned int pool_pos = 0; 
    12 @@ -122,7 +124,7 @@ static void random_extract(u8 *out) 
     21@@ -122,7 +126,7 @@ static void random_extract(u8 *out) 
    1322 } 
    1423  
     
    1928        struct os_time t; 
    2029        static unsigned int count = 0; 
    21 @@ -335,3 +337,22 @@ void random_deinit(void) 
     30@@ -191,9 +195,13 @@ int random_get_bytes(void *buf, size_t l 
     31 int random_pool_ready(void) 
     32 { 
     33 #ifdef __linux__ 
     34+       struct stat st; 
     35        int fd; 
     36        ssize_t res; 
     37  
     38+       if (stat(RANDOM_STAMPFILE, &st) == 0) 
     39+               return 1; 
     40+ 
     41        /* 
     42         * Make sure that there is reasonable entropy available before allowing 
     43         * some key derivation operations to proceed. 
     44@@ -258,9 +266,15 @@ int random_pool_ready(void) 
     45  
     46 void random_mark_pool_ready(void) 
     47 { 
     48+       int fd; 
     49+ 
     50        own_pool_ready++; 
     51        wpa_printf(MSG_DEBUG, "random: Mark internal entropy pool to be " 
     52                   "ready (count=%u/%u)", own_pool_ready, MIN_READY_MARK); 
     53+ 
     54+       fd = open(RANDOM_STAMPFILE, O_CREAT | O_WRONLY | O_EXCL | O_NOFOLLOW, 0600); 
     55+       if (fd >= 0) 
     56+               close(fd); 
     57 } 
     58  
     59  
     60@@ -335,3 +349,22 @@ void random_deinit(void) 
    2261        random_close_fd(); 
    2362 #endif /* __linux__ */ 
Note: See TracChangeset for help on using the changeset viewer.