summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorRemco Rijnders <remco@webconquest.com>2020-08-31 13:10:25 -0400
committerRemco Rijnders <remco@webconquest.com>2020-09-14 08:59:00 -0400
commit8ccd96dbb699912c1f9cc2291c76f5da39e3d06e (patch)
tree42726420a4f6cd669bed546e3a9fc082c8878d04 /init.c
parent56de020a2e67d383040cf22e543b87e4bac77446 (diff)
Implement LFRS113 PRNG functions
- Instead of relying on random() implementations which can be of questionable quality or relying on the presence of /dev/urandom, we implement our own PRNG implementation that uses the LFRS113 PRNG algorithm by Pierre L'Ecuyer. We seed this PRNG with values based on time, pid and ppid. It is OK if not all seeds are of the highest quality as all four seeds would have to be known to predict the numbers generated. In addition to this, we also use /dev/urandom values (if available) that we mix into our four seeds. In case we are reseeding we will also reuse our existing state information for setting the new seed values. - Add a function to Base64 encode 96 random bits
Diffstat (limited to 'init.c')
-rw-r--r--init.c20
1 files changed, 0 insertions, 20 deletions
diff --git a/init.c b/init.c
index ff8e74f5..59f5cfcf 100644
--- a/init.c
+++ b/init.c
@@ -39,8 +39,6 @@
#include "mutt_ssl.h"
#endif
-
-
#include "mx.h"
#include "init.h"
#include "mailbox.h"
@@ -3558,23 +3556,6 @@ static int mutt_execute_commands (LIST *p)
return 0;
}
-static void mutt_srandom (void)
-{
- struct timeval tv;
- unsigned seed;
-
- gettimeofday(&tv, NULL);
- /* POSIX.1-2008 states that seed is 'unsigned' without specifying its width.
- * Use as many of the lower order bits from the current time of day as the seed.
- * If the upper bound is truncated, that is fine.
- *
- * tv_sec is integral of type integer or float. Cast to 'long long' before
- * bitshift in case it is a float.
- */
- seed = ((LONGLONG) tv.tv_sec << 20) | tv.tv_usec;
- srandom(seed);
-}
-
static char* mutt_find_cfg (const char *home, const char *xdg_cfg_home)
{
const char* names[] =
@@ -3633,7 +3614,6 @@ void mutt_init (int skip_sys_rc, LIST *commands)
MUTT_HASH_ALLOW_DUPS);
mutt_menu_init ();
- mutt_srandom ();
mutt_buffer_pool_init ();
buffer = mutt_buffer_pool_get ();