Bug #1977 ยป http_auth_mod_usertracks_entropy.patch
src/base.h (working copy) | ||
---|---|---|
time_t last_generated_debug_ts;
|
||
time_t startup_ts;
|
||
/* Real entropy. Set in server.c if DEV_RANDOM is defined */
|
||
#ifdef DEV_RANDOM
|
||
char entropy[8];
|
||
#endif
|
||
buffer *ts_debug_str;
|
||
buffer *ts_date_str;
|
||
src/http_auth.c (working copy) | ||
---|---|---|
/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */
|
||
LI_ltostr(hh, srv->cur_ts);
|
||
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||
#ifdef DEV_RANDOM
|
||
/* Add entropy */
|
||
MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
|
||
#else
|
||
LI_ltostr(hh, rand());
|
||
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||
#endif
|
||
MD5_Final(h, &Md5Ctx);
|
||
src/mod_usertrack.c (working copy) | ||
---|---|---|
/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */
|
||
LI_ltostr(hh, srv->cur_ts);
|
||
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||
#ifdef DEV_RANDOM
|
||
/* Add entropy */
|
||
MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
|
||
#else
|
||
LI_ltostr(hh, rand());
|
||
MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||
#endif
|
||
MD5_Final(h, &Md5Ctx);
|
||
src/server.c (working copy) | ||
---|---|---|
srv->mtime_cache[i].mtime = (time_t)-1;
|
||
srv->mtime_cache[i].str = buffer_init();
|
||
}
|
||
#ifdef DEV_RANDOM
|
||
/* Initialize entropy field in srv */
|
||
{
|
||
FILE *f;
|
||
if(f = fopen(DEV_RANDOM, "rb")) {
|
||
fread(&srv->entropy, sizeof(srv->entropy), 1, f);
|
||
fclose(f);
|
||
}
|
||
}
|
||
#endif
|
||
srv->cur_ts = time(NULL);
|
||
srv->startup_ts = srv->cur_ts;
|
configure.ac (working copy) | ||
---|---|---|
AC_FUNC_STRFTIME
|
||
AC_CHECK_FUNCS([issetugid])
|
||
dnl Checks for entropy source
|
||
AC_MSG_CHECKING(for entropy source)
|
||
case $host_os in
|
||
*darwin*|*cygwin*|*aix*|*mingw* )
|
||
AC_MSG_ERROR(Entropy source cannot be determined on this platform)
|
||
;;
|
||
* )
|
||
if test -r "/dev/random"; then
|
||
AC_DEFINE(DEV_RANDOM, ["/dev/random"], [Random source])
|
||
AC_MSG_RESULT(/dev/random)
|
||
elif test -r "/dev/urandom"; then
|
||
AC_DEFINE(DEV_RANDOM, ["/dev/urandom"], [Random source])
|
||
AC_MSG_RESULT(/dev/urandom)
|
||
else
|
||
AC_MSG_ERROR(Entropy source not found. Need /dev/random or /dev/urandom)
|
||
fi
|
||
;;
|
||
esac
|
||
dnl Checks for database.
|
||
MYSQL_INCLUDE=""
|
||
MYSQL_LIBS=""
|