summaryrefslogtreecommitdiff
path: root/net/freerdp1/files/patch-libfreerdp_common_assistance.c
blob: 3db652d46915c5b1065df196ff486e1b301b9f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
--- libfreerdp/common/assistance.c.orig	2018-11-06 05:10:45 UTC
+++ libfreerdp/common/assistance.c
@@ -478,7 +478,11 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char*
 	int cbPassStubW;
 	int EncryptedSize;
 	BYTE PasswordHash[16];
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	EVP_CIPHER_CTX *rc4Ctx;
+#else
 	EVP_CIPHER_CTX rc4Ctx;
+#endif
 	BYTE *pbIn, *pbOut;
 	int cbOut, cbIn, cbFinal;
 	WCHAR* PasswordW = NULL;
@@ -516,9 +520,16 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char*
 	*((UINT32*) pbIn) = cbPassStubW;
 	CopyMemory(&pbIn[4], PassStubW, cbPassStubW);
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	rc4Ctx = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_init(rc4Ctx);
+
+	status = EVP_EncryptInit_ex(rc4Ctx, EVP_rc4(), NULL, NULL, NULL);
+#else
 	EVP_CIPHER_CTX_init(&rc4Ctx);
 
 	status = EVP_EncryptInit_ex(&rc4Ctx, EVP_rc4(), NULL, NULL, NULL);
+#endif
 
 	if (!status)
 	{
@@ -526,7 +537,11 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char*
 		return NULL;
 	}
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	status = EVP_EncryptInit_ex(rc4Ctx, NULL, NULL, PasswordHash, NULL);
+#else
 	status = EVP_EncryptInit_ex(&rc4Ctx, NULL, NULL, PasswordHash, NULL);
+#endif
 
 	if (!status)
 	{
@@ -537,7 +552,11 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char*
 	cbOut = cbFinal = 0;
 	cbIn = EncryptedSize;
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	status = EVP_EncryptUpdate(rc4Ctx, pbOut, &cbOut, pbIn, cbIn);
+#else
 	status = EVP_EncryptUpdate(&rc4Ctx, pbOut, &cbOut, pbIn, cbIn);
+#endif
 
 	if (!status)
 	{
@@ -545,7 +564,11 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char*
 		return NULL;
 	}
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	status = EVP_EncryptFinal_ex(rc4Ctx, pbOut + cbOut, &cbFinal);
+#else
 	status = EVP_EncryptFinal_ex(&rc4Ctx, pbOut + cbOut, &cbFinal);
+#endif
 
 	if (!status)
 	{
@@ -553,7 +576,11 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char*
 		return NULL;
 	}
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	EVP_CIPHER_CTX_free(rc4Ctx);
+#else
 	EVP_CIPHER_CTX_cleanup(&rc4Ctx);
+#endif
 
 	free(pbIn);
 	free(PasswordW);
@@ -571,7 +598,11 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* fil
 	int cbPasswordW;
 	int cchOutW = 0;
 	WCHAR* pbOutW = NULL;
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	EVP_CIPHER_CTX *aesDec;
+#else
 	EVP_CIPHER_CTX aesDec;
+#endif
 	WCHAR* PasswordW = NULL;
 	BYTE *pbIn, *pbOut;
 	int cbOut, cbIn, cbFinal;
@@ -598,17 +629,31 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* fil
 
 	ZeroMemory(InitializationVector, sizeof(InitializationVector));
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	aesDec = EVP_CIPHER_CTX_new();
+	EVP_CIPHER_CTX_init(aesDec);
+
+	status = EVP_DecryptInit_ex(aesDec, EVP_aes_128_cbc(), NULL, NULL, NULL);
+#else
 	EVP_CIPHER_CTX_init(&aesDec);
 
 	status = EVP_DecryptInit_ex(&aesDec, EVP_aes_128_cbc(), NULL, NULL, NULL);
+#endif
 
 	if (status != 1)
 		return -1;
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	EVP_CIPHER_CTX_set_key_length(aesDec, (128 / 8));
+	EVP_CIPHER_CTX_set_padding(aesDec, 0);
+
+	status = EVP_DecryptInit_ex(aesDec, EVP_aes_128_cbc(), NULL, DerivedKey, InitializationVector);
+#else
 	EVP_CIPHER_CTX_set_key_length(&aesDec, (128 / 8));
 	EVP_CIPHER_CTX_set_padding(&aesDec, 0);
 
 	status = EVP_DecryptInit_ex(&aesDec, EVP_aes_128_cbc(), NULL, DerivedKey, InitializationVector);
+#endif
 
 	if (status != 1)
 		return -1;
@@ -621,12 +666,20 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* fil
 	if (!pbOut)
 		return -1;
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	status = EVP_DecryptUpdate(aesDec, pbOut, &cbOut, pbIn, cbIn);
+#else
 	status = EVP_DecryptUpdate(&aesDec, pbOut, &cbOut, pbIn, cbIn);
+#endif
 
 	if (status != 1)
 		return -1;
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	status = EVP_DecryptFinal_ex(aesDec, pbOut + cbOut, &cbFinal);
+#else
 	status = EVP_DecryptFinal_ex(&aesDec, pbOut + cbOut, &cbFinal);
+#endif
 
 	if (status != 1)
 	{
@@ -634,7 +687,11 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* fil
 		return -1;
 	}
 
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+	EVP_CIPHER_CTX_free(aesDec);
+#else
 	EVP_CIPHER_CTX_cleanup(&aesDec);
+#endif
 
 	cbOut += cbFinal;
 	cbFinal = 0;