Unified random functions and remaining MD5.
authorArmin Novak <armin.novak@gmail.com>
Wed, 24 Feb 2016 19:39:49 +0000 (20:39 +0100)
committerArmin Novak <armin.novak@gmail.com>
Wed, 24 Feb 2016 19:41:01 +0000 (20:41 +0100)
libfreerdp/common/assistance.c
libfreerdp/core/autodetect.c
libfreerdp/core/gateway/ncacn_http.c
libfreerdp/core/gateway/ntlm.c
libfreerdp/core/gateway/rpc.c
libfreerdp/core/gateway/rts.c
libfreerdp/crypto/crypto.c

index 9e4702e..c69d729 100644 (file)
 #endif
 
 #include <winpr/crt.h>
+#include <winpr/crypto.h>
 #include <winpr/print.h>
 #include <winpr/windows.h>
 
 #include <openssl/ssl.h>
-#include <openssl/md5.h>
-#include <openssl/rc4.h>
-#include <openssl/sha.h>
 #include <openssl/evp.h>
 #include <openssl/aes.h>
-#include <openssl/rand.h>
 #include <openssl/engine.h>
 
 #include <freerdp/log.h>
@@ -523,7 +520,7 @@ char* freerdp_assistance_generate_pass_stub(DWORD flags)
         * Example: WB^6HsrIaFmEpi
         */
 
-       RAND_bytes((BYTE*) nums, sizeof(nums));
+       winpr_RAND((BYTE*) nums, sizeof(nums));
 
        passStub[0] = set1[nums[0] % sizeof(set1)]; /* character 0 */
        passStub[1] = set2[nums[1] % sizeof(set2)]; /* character 1 */
@@ -547,7 +544,7 @@ char* freerdp_assistance_generate_pass_stub(DWORD flags)
 BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* passStub, int* pEncryptedSize)
 {
        int status;
-       MD5_CTX md5Ctx;
+       WINPR_MD5_CTX md5Ctx;
        int cbPasswordW;
        int cbPassStubW;
        int EncryptedSize;
@@ -565,14 +562,29 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
 
        cbPasswordW = (status - 1) * 2;
 
-       MD5_Init(&md5Ctx);
-       MD5_Update(&md5Ctx, PasswordW, cbPasswordW);
-       MD5_Final((void*) PasswordHash, &md5Ctx);
+       if (!winpr_MD5_Init(&md5Ctx))
+    {
+        free (PasswordW);
+        return NULL;
+    }
+       if (!winpr_MD5_Update(&md5Ctx, (BYTE*)PasswordW, cbPasswordW))
+    {
+        free (PasswordW);
+        return NULL;
+    }
+       if (!winpr_MD5_Final(&md5Ctx, (BYTE*) PasswordHash))
+    {
+        free (PasswordW);
+        return NULL;
+    }
 
        status = ConvertToUnicode(CP_UTF8, 0, passStub, -1, &PassStubW, 0);
 
        if (status <= 0)
+    {
+        free (PasswordW);
                return NULL;
+    }
 
        cbPassStubW = (status - 1) * 2;
 
index 1a89737..178e989 100644 (file)
@@ -21,6 +21,8 @@
 #include "config.h"
 #endif
 
+#include <winpr/crypto.h>
+
 #include "autodetect.h"
 
 #define RDP_RTT_REQUEST_TYPE_CONTINUOUS  0x0001
@@ -173,7 +175,7 @@ BOOL autodetect_send_bandwidth_measure_payload(rdpContext* context, UINT16 paylo
                return FALSE;
        }
 
-       RAND_bytes(buffer, payloadLength);
+       winpr_RAND(buffer, payloadLength);
        Stream_Write(s, buffer, payloadLength);
 
        bResult = rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ);
@@ -225,7 +227,7 @@ static BOOL autodetect_send_bandwidth_measure_stop(rdpContext* context, UINT16 p
                                return FALSE;
                        }
 
-                       RAND_bytes(buffer, payloadLength);
+                       winpr_RAND(buffer, payloadLength);
                        Stream_Write(s, buffer, payloadLength);
                }
        }
index 175aab3..f6f6801 100644 (file)
@@ -29,8 +29,6 @@
 #include <winpr/dsparse.h>
 #include <winpr/winhttp.h>
 
-#include <openssl/rand.h>
-
 #define TAG FREERDP_TAG("core.gateway.ntlm")
 
 wStream* rpc_ntlm_http_request(rdpRpc* rpc, HttpContext* http, const char* method, int contentLength, SecBuffer* ntlmToken)
index c9795b6..ce6925b 100644 (file)
@@ -28,7 +28,6 @@
 #include <winpr/dsparse.h>
 
 #include <freerdp/log.h>
-#include <openssl/rand.h>
 
 #include "http.h"
 
index 16f4af1..d7309b9 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <freerdp/log.h>
 
-#include <openssl/rand.h>
 #include <openssl/bio.h>
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
index 31edc86..df939b9 100644 (file)
@@ -22,6 +22,7 @@
 #endif
 
 #include <winpr/crt.h>
+#include <winpr/crypto.h>
 #include <winpr/winhttp.h>
 
 #include <freerdp/log.h>
@@ -422,7 +423,7 @@ int rts_ping_traffic_sent_notify_command_write(BYTE* buffer, UINT32 PingTrafficS
 
 void rts_generate_cookie(BYTE* cookie)
 {
-       RAND_pseudo_bytes(cookie, 16);
+       winpr_RAND(cookie, 16);
 }
 
 /* CONN/A Sequence */
index de885bd..654efeb 100644 (file)
@@ -22,6 +22,7 @@
 #endif
 
 #include <winpr/crt.h>
+#include <winpr/crypto.h>
 
 #include <freerdp/log.h>
 #include <freerdp/crypto/crypto.h>
@@ -290,7 +291,7 @@ void crypto_reverse(BYTE* data, int length)
 
 void crypto_nonce(BYTE* nonce, int size)
 {
-       RAND_bytes((void*) nonce, size);
+       winpr_RAND((void*) nonce, size);
 }
 
 char* crypto_cert_fingerprint(X509* xcert)