From 6938dbb84a2d19962fe37404efe822cf84e1fd31 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Thu, 30 Jan 2014 13:53:33 +0100
Subject: [PATCH] NTLM: use a fake entropy for debug builds with CURL_ENTROPY
 set

Use the environment variable to get entropy from, if set, when built
debug enabled.
---
 lib/curl_ntlm_msgs.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/curl_ntlm_msgs.c b/lib/curl_ntlm_msgs.c
index 050ffe2..42613b0 100644
--- a/lib/curl_ntlm_msgs.c
+++ b/lib/curl_ntlm_msgs.c
@@ -764,12 +764,21 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
     unsigned char ntlmv2hash[0x18];
 
 #if defined(DEBUGBUILD)
-    /* Use static client nonce in debug (Test Suite) builds */
-    memcpy(entropy, "12345678", sizeof(entropy));
-#else
+    char *force_entropy = getenv("CURL_ENTROPY");
+    if(force_entropy) {
+      /* Use static client nonce in debug (Test Suite) builds */
+      size_t elen = strlen(force_entropy);
+      if(elen < sizeof(entropy))
+        memset(entropy, 45, sizeof(entropy));
+      else
+        elen = sizeof(entropy);
+      memcpy(entropy, force_entropy, elen);
+    }
+    else
+#endif
     /* Create an 8 byte random client nonce */
     Curl_ssl_random(data, entropy, sizeof(entropy));
-#endif
+
 
     res = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer);
     if(res)
-- 
1.9.0

