Package: openipmi / 2.0.22-1.1

0001-Add-openssl-1.1.0-support.patch Patch series | download
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
From eeacbf0c675b61881fc00539cb365de084950ceb Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Sun, 25 Sep 2016 23:45:12 +0200
Subject: [PATCH] Add openssl 1.1.0 support

while keeping work under openssl 1.0.2.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 lanserv/lanserv_ipmi.c | 34 +++++++++++++++++++++-------------
 lib/aes_cbc.c          | 34 +++++++++++++++++++++-------------
 2 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/lanserv/lanserv_ipmi.c b/lanserv/lanserv_ipmi.c
index b0a2431f1322..67bf74a5e697 100644
--- a/lanserv/lanserv_ipmi.c
+++ b/lanserv/lanserv_ipmi.c
@@ -2217,7 +2217,7 @@ aes_cbc_encrypt(lanserv_data_t *lan, session_t *session,
     unsigned char  *d;
     unsigned char  *iv;
     unsigned int   i;
-    EVP_CIPHER_CTX ctx;
+    EVP_CIPHER_CTX *ctx;
     int            rv;
     int            outlen;
     int            tmplen;
@@ -2264,14 +2264,18 @@ aes_cbc_encrypt(lanserv_data_t *lan, session_t *session,
     *data_size += 16;
 
     /* Ok, we're set to do the crypt operation. */
-    EVP_CIPHER_CTX_init(&ctx);
-    EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, a->ckey, iv);
-    EVP_CIPHER_CTX_set_padding(&ctx, 0);
-    if (!EVP_EncryptUpdate(&ctx, *pos, &outlen, d, l)) {
+    ctx = EVP_CIPHER_CTX_new();
+    if (!ctx) {
+	    rv = ENOMEM;
+	    goto out_cleanup;
+    }
+    EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, a->ckey, iv);
+    EVP_CIPHER_CTX_set_padding(ctx, 0);
+    if (!EVP_EncryptUpdate(ctx, *pos, &outlen, d, l)) {
 	rv = ENOMEM;
 	goto out_cleanup;
     }
-    if (!EVP_EncryptFinal_ex(&ctx, (*pos) + outlen, &tmplen)) {
+    if (!EVP_EncryptFinal_ex(ctx, (*pos) + outlen, &tmplen)) {
 	rv = ENOMEM; /* right? */
 	goto out_cleanup;
     }
@@ -2281,7 +2285,7 @@ aes_cbc_encrypt(lanserv_data_t *lan, session_t *session,
     *data_len = outlen + 16;
 
  out_cleanup:
-    EVP_CIPHER_CTX_cleanup(&ctx);
+    EVP_CIPHER_CTX_free(ctx);
     free(d);
     return rv;
 }
@@ -2292,7 +2296,7 @@ aes_cbc_decrypt(lanserv_data_t *lan, session_t *session, msg_t *msg)
     auth_data_t    *a = &session->auth_data;
     unsigned int   l = msg->len;
     unsigned char  *d;
-    EVP_CIPHER_CTX ctx;
+    EVP_CIPHER_CTX *ctx;
     int            outlen;
     unsigned char  *pad;
     int            padlen;
@@ -2312,10 +2316,14 @@ aes_cbc_decrypt(lanserv_data_t *lan, session_t *session, msg_t *msg)
     memcpy(d, msg->data+16, l);
 
     /* Ok, we're set to do the decrypt operation. */
-    EVP_CIPHER_CTX_init(&ctx);
-    EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, a->k2, msg->data);
-    EVP_CIPHER_CTX_set_padding(&ctx, 0);
-    if (!EVP_DecryptUpdate(&ctx, msg->data+16, &outlen, d, l)) {
+    ctx = EVP_CIPHER_CTX_new();
+    if (!ctx) {
+	    rv = ENOMEM;
+	    goto out_cleanup;
+    }
+    EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, a->k2, msg->data);
+    EVP_CIPHER_CTX_set_padding(ctx, 0);
+    if (!EVP_DecryptUpdate(ctx, msg->data+16, &outlen, d, l)) {
 	rv = EINVAL;
 	goto out_cleanup;
     }
@@ -2348,7 +2356,7 @@ aes_cbc_decrypt(lanserv_data_t *lan, session_t *session, msg_t *msg)
     msg->len = outlen;
 
  out_cleanup:
-    EVP_CIPHER_CTX_cleanup(&ctx);
+    EVP_CIPHER_CTX_free(ctx);
     free(d);
     return rv;
 }
diff --git a/lib/aes_cbc.c b/lib/aes_cbc.c
index 483cdfbc521b..f20d69b8b1b3 100644
--- a/lib/aes_cbc.c
+++ b/lib/aes_cbc.c
@@ -86,7 +86,7 @@ aes_cbc_encrypt(ipmi_con_t    *ipmi,
     unsigned int   l = *payload_len;
     unsigned int   i;
     unsigned char  *d;
-    EVP_CIPHER_CTX ctx;
+    EVP_CIPHER_CTX *ctx;
     int            rv;
     int            outlen;
     int            tmplen;
@@ -133,15 +133,19 @@ aes_cbc_encrypt(ipmi_con_t    *ipmi,
     *header_len -= 16;
     *max_payload_len += 16;
 
+    ctx = EVP_CIPHER_CTX_new();
+    if (!ctx) {
+	    rv = ENOMEM;
+	    goto out_cleanup;
+    }
     /* Ok, we're set to do the crypt operation. */
-    EVP_CIPHER_CTX_init(&ctx);
-    EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, info->k2, iv);
-    EVP_CIPHER_CTX_set_padding(&ctx, 0);
-    if (!EVP_EncryptUpdate(&ctx, *payload, &outlen, d, l)) {
+    EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, info->k2, iv);
+    EVP_CIPHER_CTX_set_padding(ctx, 0);
+    if (!EVP_EncryptUpdate(ctx, *payload, &outlen, d, l)) {
 	rv = ENOMEM; /* right? */
 	goto out_cleanup;
     }
-    if (!EVP_EncryptFinal_ex(&ctx, (*payload) + outlen, &tmplen)) {
+    if (!EVP_EncryptFinal_ex(ctx, (*payload) + outlen, &tmplen)) {
 	rv = ENOMEM; /* right? */
 	goto out_cleanup;
     }
@@ -154,7 +158,7 @@ aes_cbc_encrypt(ipmi_con_t    *ipmi,
     *payload_len = outlen + 16;
 
  out_cleanup:
-    EVP_CIPHER_CTX_cleanup(&ctx);
+    EVP_CIPHER_CTX_free(ctx);
     ipmi_mem_free(d);
 
     return rv;
@@ -170,7 +174,7 @@ aes_cbc_decrypt(ipmi_con_t    *ipmi,
     unsigned int   l = *payload_len;
     unsigned char  *d;
     unsigned char  *p;
-    EVP_CIPHER_CTX ctx;
+    EVP_CIPHER_CTX *ctx;
     int            outlen;
     int            rv = 0;
     unsigned char  *pad;
@@ -195,10 +199,14 @@ aes_cbc_decrypt(ipmi_con_t    *ipmi,
     memcpy(d, p, l);
 
     /* Ok, we're set to do the decrypt operation. */
-    EVP_CIPHER_CTX_init(&ctx);
-    EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, info->k2, *payload);
-    EVP_CIPHER_CTX_set_padding(&ctx, 0);
-    if (!EVP_DecryptUpdate(&ctx, p, &outlen, d, l)) {
+    ctx = EVP_CIPHER_CTX_new();
+    if (!ctx) {
+	    rv = ENOMEM;
+	    goto out_cleanup;
+    }
+    EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, info->k2, *payload);
+    EVP_CIPHER_CTX_set_padding(ctx, 0);
+    if (!EVP_DecryptUpdate(ctx, p, &outlen, d, l)) {
 	rv = EINVAL;
 	goto out_cleanup;
     }
@@ -231,7 +239,7 @@ aes_cbc_decrypt(ipmi_con_t    *ipmi,
     *payload_len = outlen;
 
  out_cleanup:
-    EVP_CIPHER_CTX_cleanup(&ctx);
+    EVP_CIPHER_CTX_free(ctx);
     ipmi_mem_free(d);
     return rv;
 }
-- 
2.11.0