8b02f8a8c6ef026520fc57e2234040fc92273ec8
[feed/packages.git] / lang / erlang / patches / 010-openssl-md5.patch
1 From eace72dfda7e6452dc82b884f0385a78a9d65d10 Mon Sep 17 00:00:00 2001
2 From: Paul Swartz <paul@paulswartz.net>
3 Date: Sun, 31 Dec 2023 13:12:02 -0500
4 Subject: [PATCH 1/3] fix: rename `openssl/md5.h` to avoid include conflicts
5 with OpenSSL
6
7 Ref: #7987
8 ---
9 erts/emulator/openssl/README | 2 +-
10 erts/emulator/openssl/crypto/md5/md5_local.h | 2 +-
11 erts/emulator/openssl/include/erl_md5.h | 2 +-
12 .../emulator/openssl/include/{openssl => openssl_local}/md5.h | 0
13 erts/emulator/openssl/openssl.diff | 4 ++--
14 erts/emulator/openssl/openssl.mk | 2 +-
15 lib/erl_interface/src/openssl/README | 2 +-
16 lib/erl_interface/src/openssl/crypto/md5/md5_local.h | 2 +-
17 lib/erl_interface/src/openssl/include/erl_md5.h | 2 +-
18 .../src/openssl/include/{openssl => openssl_local}/md5.h | 0
19 lib/erl_interface/src/openssl/openssl.diff | 4 ++--
20 11 files changed, 11 insertions(+), 11 deletions(-)
21 rename erts/emulator/openssl/include/{openssl => openssl_local}/md5.h (100%)
22 rename lib/erl_interface/src/openssl/include/{openssl => openssl_local}/md5.h (100%)
23
24 --- a/erts/emulator/openssl/README
25 +++ b/erts/emulator/openssl/README
26 @@ -7,7 +7,7 @@ The files that has been taken from the 3
27 ./crypto/md5/md5_local.h
28 ./crypto/md5/md5_dgst.c
29 ./include/crypto/md32_common.h
30 -./include/openssl/md5.h
31 +./include/openssl_local/md5.h (renamed from include/openssl/md5.h)
32
33 The openssl.diff file contains the diff between the original files and the ones
34 included in OTP.
35 --- a/erts/emulator/openssl/crypto/md5/md5_local.h
36 +++ b/erts/emulator/openssl/crypto/md5/md5_local.h
37 @@ -10,7 +10,7 @@
38 #include <stdlib.h>
39 #include <string.h>
40 #if defined(ERLANG_OPENSSL_INTEGRATION)
41 -#include "openssl/md5.h"
42 +#include "openssl_local/md5.h"
43 #define md5_block_data_order MD5_BLOCK_DATA_ORDER_FUNCTION_NAME
44 #undef MD5_ASM
45 #else
46 --- a/erts/emulator/openssl/include/erl_md5.h
47 +++ b/erts/emulator/openssl/include/erl_md5.h
48 @@ -30,6 +30,6 @@
49 #define MD5_TRANSFORM_FUNCTION_NAME MD5Transform
50 #define MD5_BLOCK_DATA_ORDER_FUNCTION_NAME MD5BlockDataOrder
51
52 -#include "openssl/md5.h"
53 +#include "openssl_local/md5.h"
54
55 #endif
56 --- a/erts/emulator/openssl/openssl.diff
57 +++ b/erts/emulator/openssl/openssl.diff
58 @@ -46,7 +46,7 @@ diff -u original/crypto/md5/md5_local.h
59 #include <stdlib.h>
60 #include <string.h>
61 +#if defined(ERLANG_OPENSSL_INTEGRATION)
62 -+#include "openssl/md5.h"
63 ++#include "openssl_local/md5.h"
64 +#define md5_block_data_order MD5_BLOCK_DATA_ORDER_FUNCTION_NAME
65 +#undef MD5_ASM
66 +#else
67 @@ -116,7 +116,7 @@ diff -u original/include/crypto/md32_com
68 # error "HASH_MAKE_STRING must be defined!"
69 diff -u original/include/openssl/md5.h include/openssl/md5.h
70 --- original/include/openssl/md5.h 2023-11-24 15:58:28.610171865 +0100
71 -+++ include/openssl/md5.h 2023-11-24 23:10:52.570854593 +0100
72 ++++ include/openssl_local/md5.h 2023-11-24 23:10:52.570854593 +0100
73 @@ -11,6 +11,15 @@
74 # define OPENSSL_MD5_H
75 # pragma once
76 --- a/erts/emulator/openssl/openssl.mk
77 +++ b/erts/emulator/openssl/openssl.mk
78 @@ -50,4 +50,4 @@ $(OPENSSL_OBJDIR)/%.o: $(OPENSSL_DIR)/cr
79 $(OPENSSL_OBJDIR)/md5_dgst.o: $(OPENSSL_DIR)/crypto/md5/md5_dgst.c \
80 $(OPENSSL_DIR)/crypto/md5/md5_local.h \
81 $(OPENSSL_DIR)/include/crypto/md32_common.h \
82 - $(OPENSSL_DIR)/include/openssl/md5.h
83 + $(OPENSSL_DIR)/include/openssl_local/md5.h
84 --- a/erts/lib_src/common/erl_misc_utils.c
85 +++ b/erts/lib_src/common/erl_misc_utils.c
86 @@ -42,7 +42,7 @@
87 # include <sys/select.h>
88 # endif
89 # include <time.h>
90 -# if HAVE_SYS_TIME_H
91 +# ifdef HAVE_SYS_TIME_H
92 # include <sys/time.h>
93 # endif
94 # include <string.h>
95 --- a/lib/erl_interface/src/openssl/crypto/md5/md5_local.h
96 +++ b/lib/erl_interface/src/openssl/crypto/md5/md5_local.h
97 @@ -10,7 +10,7 @@
98 #include <stdlib.h>
99 #include <string.h>
100 #if defined(ERLANG_OPENSSL_INTEGRATION)
101 -#include "openssl/md5.h"
102 +#include "openssl_local/md5.h"
103 #define md5_block_data_order MD5_BLOCK_DATA_ORDER_FUNCTION_NAME
104 #undef MD5_ASM
105 #else
106 --- a/lib/erl_interface/src/openssl/include/erl_md5.h
107 +++ b/lib/erl_interface/src/openssl/include/erl_md5.h
108 @@ -30,6 +30,6 @@
109 #define MD5_TRANSFORM_FUNCTION_NAME ei_MD5Transform
110 #define MD5_BLOCK_DATA_ORDER_FUNCTION_NAME ei_MD5BlockDataOrder
111
112 -#include "openssl/md5.h"
113 +#include "openssl_local/md5.h"
114
115 #endif
116 --- a/erts/emulator/openssl/include/openssl/md5.h
117 +++ /dev/null
118 @@ -1,82 +0,0 @@
119 -/*
120 - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
121 - *
122 - * Licensed under the Apache License 2.0 (the "License"). You may not use
123 - * this file except in compliance with the License. You can obtain a copy
124 - * in the file LICENSE in the source distribution or at
125 - * https://www.openssl.org/source/license.html
126 - */
127 -
128 -#ifndef OPENSSL_MD5_H
129 -# define OPENSSL_MD5_H
130 -# pragma once
131 -
132 -#if defined(ERLANG_OPENSSL_INTEGRATION)
133 -
134 -#include "erl_md5.h"
135 -
136 -#undef OPENSSL_NO_MD5
137 -#undef OPENSSL_NO_DEPRECATED_3_0
138 -
139 -#else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
140 -
141 -# include <openssl/macros.h>
142 -# ifndef OPENSSL_NO_DEPRECATED_3_0
143 -# define HEADER_MD5_H
144 -# endif
145 -
146 -# include <openssl/opensslconf.h>
147 -
148 -#endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
149 -
150 -# ifndef OPENSSL_NO_MD5
151 -#if !defined(ERLANG_OPENSSL_INTEGRATION)
152 -# include <openssl/e_os2.h>
153 -#endif
154 -# include <stddef.h>
155 -# ifdef __cplusplus
156 -extern "C" {
157 -# endif
158 -
159 -# define MD5_DIGEST_LENGTH 16
160 -
161 -# if !defined(OPENSSL_NO_DEPRECATED_3_0)
162 -/*
163 - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
164 - * ! MD5_LONG has to be at least 32 bits wide. !
165 - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
166 - */
167 -# define MD5_LONG unsigned int
168 -
169 -# define MD5_CBLOCK 64
170 -# define MD5_LBLOCK (MD5_CBLOCK/4)
171 -
172 -typedef struct MD5state_st {
173 - MD5_LONG A, B, C, D;
174 - MD5_LONG Nl, Nh;
175 - MD5_LONG data[MD5_LBLOCK];
176 - unsigned int num;
177 -} MD5_CTX;
178 -# endif
179 -# ifndef OPENSSL_NO_DEPRECATED_3_0
180 -# if defined(ERLANG_OPENSSL_INTEGRATION)
181 -int MD5_INIT_FUNCTION_NAME(MD5_CTX *c);
182 -int MD5_UPDATE_FUNCTION_NAME(MD5_CTX *c, const void *data, size_t len);
183 -int MD5_FINAL_FUNCTION_NAME(unsigned char *md, MD5_CTX *c);
184 -void MD5_TRANSFORM_FUNCTION_NAME(MD5_CTX *c, const unsigned char *b);
185 -# else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
186 -OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
187 -OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
188 -OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
189 -OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
190 - unsigned char *md);
191 -OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b);
192 -# endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
193 -# endif
194 -
195 -# ifdef __cplusplus
196 -}
197 -# endif
198 -# endif
199 -
200 -#endif
201 --- /dev/null
202 +++ b/erts/emulator/openssl/include/openssl_local/md5.h
203 @@ -0,0 +1,82 @@
204 +/*
205 + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
206 + *
207 + * Licensed under the Apache License 2.0 (the "License"). You may not use
208 + * this file except in compliance with the License. You can obtain a copy
209 + * in the file LICENSE in the source distribution or at
210 + * https://www.openssl.org/source/license.html
211 + */
212 +
213 +#ifndef OPENSSL_MD5_H
214 +# define OPENSSL_MD5_H
215 +# pragma once
216 +
217 +#if defined(ERLANG_OPENSSL_INTEGRATION)
218 +
219 +#include "erl_md5.h"
220 +
221 +#undef OPENSSL_NO_MD5
222 +#undef OPENSSL_NO_DEPRECATED_3_0
223 +
224 +#else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
225 +
226 +# include <openssl/macros.h>
227 +# ifndef OPENSSL_NO_DEPRECATED_3_0
228 +# define HEADER_MD5_H
229 +# endif
230 +
231 +# include <openssl/opensslconf.h>
232 +
233 +#endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
234 +
235 +# ifndef OPENSSL_NO_MD5
236 +#if !defined(ERLANG_OPENSSL_INTEGRATION)
237 +# include <openssl/e_os2.h>
238 +#endif
239 +# include <stddef.h>
240 +# ifdef __cplusplus
241 +extern "C" {
242 +# endif
243 +
244 +# define MD5_DIGEST_LENGTH 16
245 +
246 +# if !defined(OPENSSL_NO_DEPRECATED_3_0)
247 +/*
248 + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
249 + * ! MD5_LONG has to be at least 32 bits wide. !
250 + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
251 + */
252 +# define MD5_LONG unsigned int
253 +
254 +# define MD5_CBLOCK 64
255 +# define MD5_LBLOCK (MD5_CBLOCK/4)
256 +
257 +typedef struct MD5state_st {
258 + MD5_LONG A, B, C, D;
259 + MD5_LONG Nl, Nh;
260 + MD5_LONG data[MD5_LBLOCK];
261 + unsigned int num;
262 +} MD5_CTX;
263 +# endif
264 +# ifndef OPENSSL_NO_DEPRECATED_3_0
265 +# if defined(ERLANG_OPENSSL_INTEGRATION)
266 +int MD5_INIT_FUNCTION_NAME(MD5_CTX *c);
267 +int MD5_UPDATE_FUNCTION_NAME(MD5_CTX *c, const void *data, size_t len);
268 +int MD5_FINAL_FUNCTION_NAME(unsigned char *md, MD5_CTX *c);
269 +void MD5_TRANSFORM_FUNCTION_NAME(MD5_CTX *c, const unsigned char *b);
270 +# else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
271 +OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
272 +OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
273 +OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
274 +OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
275 + unsigned char *md);
276 +OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b);
277 +# endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
278 +# endif
279 +
280 +# ifdef __cplusplus
281 +}
282 +# endif
283 +# endif
284 +
285 +#endif
286 --- a/lib/erl_interface/src/openssl/include/openssl/md5.h
287 +++ /dev/null
288 @@ -1,82 +0,0 @@
289 -/*
290 - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
291 - *
292 - * Licensed under the Apache License 2.0 (the "License"). You may not use
293 - * this file except in compliance with the License. You can obtain a copy
294 - * in the file LICENSE in the source distribution or at
295 - * https://www.openssl.org/source/license.html
296 - */
297 -
298 -#ifndef OPENSSL_MD5_H
299 -# define OPENSSL_MD5_H
300 -# pragma once
301 -
302 -#if defined(ERLANG_OPENSSL_INTEGRATION)
303 -
304 -#include "erl_md5.h"
305 -
306 -#undef OPENSSL_NO_MD5
307 -#undef OPENSSL_NO_DEPRECATED_3_0
308 -
309 -#else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
310 -
311 -# include <openssl/macros.h>
312 -# ifndef OPENSSL_NO_DEPRECATED_3_0
313 -# define HEADER_MD5_H
314 -# endif
315 -
316 -# include <openssl/opensslconf.h>
317 -
318 -#endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
319 -
320 -# ifndef OPENSSL_NO_MD5
321 -#if !defined(ERLANG_OPENSSL_INTEGRATION)
322 -# include <openssl/e_os2.h>
323 -#endif
324 -# include <stddef.h>
325 -# ifdef __cplusplus
326 -extern "C" {
327 -# endif
328 -
329 -# define MD5_DIGEST_LENGTH 16
330 -
331 -# if !defined(OPENSSL_NO_DEPRECATED_3_0)
332 -/*
333 - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
334 - * ! MD5_LONG has to be at least 32 bits wide. !
335 - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
336 - */
337 -# define MD5_LONG unsigned int
338 -
339 -# define MD5_CBLOCK 64
340 -# define MD5_LBLOCK (MD5_CBLOCK/4)
341 -
342 -typedef struct MD5state_st {
343 - MD5_LONG A, B, C, D;
344 - MD5_LONG Nl, Nh;
345 - MD5_LONG data[MD5_LBLOCK];
346 - unsigned int num;
347 -} MD5_CTX;
348 -# endif
349 -# ifndef OPENSSL_NO_DEPRECATED_3_0
350 -# if defined(ERLANG_OPENSSL_INTEGRATION)
351 -int MD5_INIT_FUNCTION_NAME(MD5_CTX *c);
352 -int MD5_UPDATE_FUNCTION_NAME(MD5_CTX *c, const void *data, size_t len);
353 -int MD5_FINAL_FUNCTION_NAME(unsigned char *md, MD5_CTX *c);
354 -void MD5_TRANSFORM_FUNCTION_NAME(MD5_CTX *c, const unsigned char *b);
355 -# else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
356 -OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
357 -OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
358 -OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
359 -OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
360 - unsigned char *md);
361 -OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b);
362 -# endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
363 -# endif
364 -
365 -# ifdef __cplusplus
366 -}
367 -# endif
368 -# endif
369 -
370 -#endif
371 --- /dev/null
372 +++ b/lib/erl_interface/src/openssl/include/openssl_local/md5.h
373 @@ -0,0 +1,82 @@
374 +/*
375 + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
376 + *
377 + * Licensed under the Apache License 2.0 (the "License"). You may not use
378 + * this file except in compliance with the License. You can obtain a copy
379 + * in the file LICENSE in the source distribution or at
380 + * https://www.openssl.org/source/license.html
381 + */
382 +
383 +#ifndef OPENSSL_MD5_H
384 +# define OPENSSL_MD5_H
385 +# pragma once
386 +
387 +#if defined(ERLANG_OPENSSL_INTEGRATION)
388 +
389 +#include "erl_md5.h"
390 +
391 +#undef OPENSSL_NO_MD5
392 +#undef OPENSSL_NO_DEPRECATED_3_0
393 +
394 +#else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
395 +
396 +# include <openssl/macros.h>
397 +# ifndef OPENSSL_NO_DEPRECATED_3_0
398 +# define HEADER_MD5_H
399 +# endif
400 +
401 +# include <openssl/opensslconf.h>
402 +
403 +#endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
404 +
405 +# ifndef OPENSSL_NO_MD5
406 +#if !defined(ERLANG_OPENSSL_INTEGRATION)
407 +# include <openssl/e_os2.h>
408 +#endif
409 +# include <stddef.h>
410 +# ifdef __cplusplus
411 +extern "C" {
412 +# endif
413 +
414 +# define MD5_DIGEST_LENGTH 16
415 +
416 +# if !defined(OPENSSL_NO_DEPRECATED_3_0)
417 +/*
418 + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
419 + * ! MD5_LONG has to be at least 32 bits wide. !
420 + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
421 + */
422 +# define MD5_LONG unsigned int
423 +
424 +# define MD5_CBLOCK 64
425 +# define MD5_LBLOCK (MD5_CBLOCK/4)
426 +
427 +typedef struct MD5state_st {
428 + MD5_LONG A, B, C, D;
429 + MD5_LONG Nl, Nh;
430 + MD5_LONG data[MD5_LBLOCK];
431 + unsigned int num;
432 +} MD5_CTX;
433 +# endif
434 +# ifndef OPENSSL_NO_DEPRECATED_3_0
435 +# if defined(ERLANG_OPENSSL_INTEGRATION)
436 +int MD5_INIT_FUNCTION_NAME(MD5_CTX *c);
437 +int MD5_UPDATE_FUNCTION_NAME(MD5_CTX *c, const void *data, size_t len);
438 +int MD5_FINAL_FUNCTION_NAME(unsigned char *md, MD5_CTX *c);
439 +void MD5_TRANSFORM_FUNCTION_NAME(MD5_CTX *c, const unsigned char *b);
440 +# else /* !defined(ERLANG_OPENSSL_INTEGRATION) */
441 +OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
442 +OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
443 +OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
444 +OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
445 + unsigned char *md);
446 +OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b);
447 +# endif /* !defined(ERLANG_OPENSSL_INTEGRATION) */
448 +# endif
449 +
450 +# ifdef __cplusplus
451 +}
452 +# endif
453 +# endif
454 +
455 +#endif