#include "squid.h"
#include <cstring>
+#include <random>
#if HAVE_STRINGS_H
#include <strings.h>
#endif
/* ************************************************************************* */
/*
- * Generates a challenge request nonce. The randomness of the 8 byte
- * challenge strings can be guarenteed to be poor at best.
+ * Generates a challenge request nonce.
*/
void
ntlm_make_nonce(char *nonce)
{
- static unsigned hash;
- uint32_t r = static_cast<uint32_t>(rand());
- r = (hash ^ r) + r;
+ static std::mt19937 mt(time(0));
+ static std::uniform_int_distribution<uint8_t> dist;
- for (int i = 0; i < NTLM_NONCE_LEN; ++i) {
- nonce[i] = static_cast<char>(r & 0xFF);
- r = (r >> 2) ^ r;
- }
- hash = r;
+ for (int i = 0; i < NTLM_NONCE_LEN; ++i)
+ nonce[i] = static_cast<char>(dist(mt) & 0xFF);
}
/**