Bug #1977 ยป http_auth_mod_usertracks_entropy.patch
src/base.h (working copy) | ||
---|---|---|
649 | 649 |
time_t last_generated_debug_ts; |
650 | 650 |
time_t startup_ts; |
651 | 651 | |
652 |
/* Real entropy. Set in server.c if DEV_RANDOM is defined */ |
|
653 |
#ifdef DEV_RANDOM |
|
654 |
char entropy[8]; |
|
655 |
#endif |
|
656 | ||
652 | 657 |
buffer *ts_debug_str; |
653 | 658 |
buffer *ts_date_str; |
654 | 659 |
src/http_auth.c (working copy) | ||
---|---|---|
1226 | 1226 |
/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */ |
1227 | 1227 |
LI_ltostr(hh, srv->cur_ts); |
1228 | 1228 |
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh)); |
1229 | ||
1230 |
#ifdef DEV_RANDOM |
|
1231 |
/* Add entropy */ |
|
1232 |
MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy)); |
|
1233 |
#else |
|
1229 | 1234 |
LI_ltostr(hh, rand()); |
1230 | 1235 |
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh)); |
1236 |
#endif |
|
1231 | 1237 | |
1232 | 1238 |
MD5_Final(h, &Md5Ctx); |
1233 | 1239 |
src/mod_usertrack.c (working copy) | ||
---|---|---|
228 | 228 |
/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */ |
229 | 229 |
LI_ltostr(hh, srv->cur_ts); |
230 | 230 |
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh)); |
231 |
#ifdef DEV_RANDOM |
|
232 |
/* Add entropy */ |
|
233 |
MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy)); |
|
234 |
#else |
|
231 | 235 |
LI_ltostr(hh, rand()); |
232 | 236 |
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh)); |
237 |
#endif |
|
233 | 238 | |
234 | 239 |
MD5_Final(h, &Md5Ctx); |
235 | 240 |
src/server.c (working copy) | ||
---|---|---|
223 | 223 |
srv->mtime_cache[i].mtime = (time_t)-1; |
224 | 224 |
srv->mtime_cache[i].str = buffer_init(); |
225 | 225 |
} |
226 |
#ifdef DEV_RANDOM |
|
227 |
/* Initialize entropy field in srv */ |
|
228 |
{ |
|
229 |
FILE *f; |
|
230 |
if(f = fopen(DEV_RANDOM, "rb")) { |
|
231 |
fread(&srv->entropy, sizeof(srv->entropy), 1, f); |
|
232 |
fclose(f); |
|
233 |
} |
|
234 |
} |
|
235 |
#endif |
|
226 | 236 | |
227 | 237 |
srv->cur_ts = time(NULL); |
228 | 238 |
srv->startup_ts = srv->cur_ts; |
configure.ac (working copy) | ||
---|---|---|
79 | 79 |
AC_FUNC_STRFTIME |
80 | 80 |
AC_CHECK_FUNCS([issetugid]) |
81 | 81 | |
82 |
dnl Checks for entropy source |
|
83 |
AC_MSG_CHECKING(for entropy source) |
|
84 | ||
85 |
case $host_os in |
|
86 |
*darwin*|*cygwin*|*aix*|*mingw* ) |
|
87 |
AC_MSG_ERROR(Entropy source cannot be determined on this platform) |
|
88 |
;; |
|
89 |
* ) |
|
90 |
if test -r "/dev/random"; then |
|
91 |
AC_DEFINE(DEV_RANDOM, ["/dev/random"], [Random source]) |
|
92 |
AC_MSG_RESULT(/dev/random) |
|
93 |
elif test -r "/dev/urandom"; then |
|
94 |
AC_DEFINE(DEV_RANDOM, ["/dev/urandom"], [Random source]) |
|
95 |
AC_MSG_RESULT(/dev/urandom) |
|
96 |
else |
|
97 |
AC_MSG_ERROR(Entropy source not found. Need /dev/random or /dev/urandom) |
|
98 |
fi |
|
99 |
;; |
|
100 |
esac |
|
101 | ||
82 | 102 |
dnl Checks for database. |
83 | 103 |
MYSQL_INCLUDE="" |
84 | 104 |
MYSQL_LIBS="" |