File 1522-Update-MD5-implementation-from-OpenSSL-3.5.0-to-3.6..patch of Package erlang

From 0153bf2cb030970804a6259f4cb8e4f813b48fc6 Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Tue, 25 Nov 2025 16:19:43 +0100
Subject: [PATCH 2/2] Update MD5 implementation from OpenSSL 3.5.0 to 3.6.0

---
 erts/emulator/openssl/crypto/md5/md5_local.h  |  9 ++++----
 .../openssl/include/crypto/md32_common.h      | 21 +++++++++++++++----
 erts/emulator/openssl/vendor.info             | 14 +++++++------
 .../src/openssl/crypto/md5/md5_local.h        |  9 ++++----
 .../src/openssl/include/crypto/md32_common.h  | 21 +++++++++++++++----
 lib/erl_interface/src/openssl/vendor.info     | 12 ++++++-----
 6 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/erts/emulator/openssl/crypto/md5/md5_local.h b/erts/emulator/openssl/crypto/md5/md5_local.h
index 3e4931b4de..5830ffd687 100644
--- a/erts/emulator/openssl/crypto/md5/md5_local.h
+++ b/erts/emulator/openssl/crypto/md5/md5_local.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -20,9 +20,10 @@
 
 #ifdef MD5_ASM
 # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
-     defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
-     defined(_M_X64) || defined(__aarch64__) || \
-     (defined(__loongarch__) && __loongarch_grlen == 64)
+    defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
+    defined(_M_X64) || defined(__aarch64__) || \
+    (defined(__loongarch__) && __loongarch_grlen == 64) || \
+    (defined(__riscv) && __riscv_xlen == 64)
 #  define md5_block_data_order ossl_md5_block_asm_data_order
 # elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
 #  define md5_block_data_order ossl_md5_block_asm_data_order
diff --git a/erts/emulator/openssl/include/crypto/md32_common.h b/erts/emulator/openssl/include/crypto/md32_common.h
index 1f68008c41..c448bbef3b 100644
--- a/erts/emulator/openssl/include/crypto/md32_common.h
+++ b/erts/emulator/openssl/include/crypto/md32_common.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2025 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -65,6 +65,19 @@
 
 #if !defined(ERLANG_OPENSSL_INTEGRATION)
 #include <openssl/crypto.h>
+/*
+ * For ossl_(un)likely
+ */
+# include <internal/common.h>
+#else
+/* Cut from <internal/common.h> */
+# if defined(__GNUC__) || defined(__clang__)
+#  define ossl_likely(x)     __builtin_expect(!!(x), 1)
+#  define ossl_unlikely(x)   __builtin_expect(!!(x), 0)
+# else
+#  define ossl_likely(x)     (x)
+#  define ossl_unlikely(x)   (x)
+# endif
 #endif
 
 #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
@@ -156,18 +169,18 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
     HASH_LONG l;
     size_t n;
 
-    if (len == 0)
+    if (ossl_unlikely(len == 0))
         return 1;
 
     l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
-    if (l < c->Nl)              /* overflow */
+    if (ossl_unlikely(l < c->Nl))              /* overflow */
         c->Nh++;
     c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
                                        * 16-bit */
     c->Nl = l;
 
     n = c->num;
-    if (n != 0) {
+    if (ossl_likely(n != 0)) {
         p = (unsigned char *)c->data;
 
         if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
diff --git a/erts/emulator/openssl/vendor.info b/erts/emulator/openssl/vendor.info
index 165b535dd2..89187f0d29 100644
--- a/erts/emulator/openssl/vendor.info
+++ b/erts/emulator/openssl/vendor.info
@@ -14,13 +14,15 @@
     "homepage": "https://www.openssl.org/",
     "licenseDeclared": "Apache-2.0",
     "name": "openssl",
-    "versionInfo": "3.5",
-    "sha": "636dfadc70ce26f2473870570bfd9ec352806b1d",
+    "versionInfo": "3.6.0",
+    "sha": "7b371d80d959ec9ab4139d09d78e83c090de9779",
     "path": "./erts/emulator/openssl",
-    "exclude": ["./erts/emulator/openssl/vendor.info",
-                "./erts/emulator/openssl/README",
-                "./erts/emulator/openssl/openssl.mk",
-                "./erts/emulator/openssl/update"],
+    "exclude": [
+      "./erts/emulator/openssl/vendor.info",
+      "./erts/emulator/openssl/README",
+      "./erts/emulator/openssl/openssl.mk",
+      "./erts/emulator/openssl/update"
+    ],
     "supplier": "Organization: OpenSSL Mission",
     "purl": "pkg:generic/openssl"
   }
diff --git a/lib/erl_interface/src/openssl/crypto/md5/md5_local.h b/lib/erl_interface/src/openssl/crypto/md5/md5_local.h
index 3e4931b4de..5830ffd687 100644
--- a/lib/erl_interface/src/openssl/crypto/md5/md5_local.h
+++ b/lib/erl_interface/src/openssl/crypto/md5/md5_local.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -20,9 +20,10 @@
 
 #ifdef MD5_ASM
 # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
-     defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
-     defined(_M_X64) || defined(__aarch64__) || \
-     (defined(__loongarch__) && __loongarch_grlen == 64)
+    defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
+    defined(_M_X64) || defined(__aarch64__) || \
+    (defined(__loongarch__) && __loongarch_grlen == 64) || \
+    (defined(__riscv) && __riscv_xlen == 64)
 #  define md5_block_data_order ossl_md5_block_asm_data_order
 # elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
 #  define md5_block_data_order ossl_md5_block_asm_data_order
diff --git a/lib/erl_interface/src/openssl/include/crypto/md32_common.h b/lib/erl_interface/src/openssl/include/crypto/md32_common.h
index 1f68008c41..c448bbef3b 100644
--- a/lib/erl_interface/src/openssl/include/crypto/md32_common.h
+++ b/lib/erl_interface/src/openssl/include/crypto/md32_common.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2025 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -65,6 +65,19 @@
 
 #if !defined(ERLANG_OPENSSL_INTEGRATION)
 #include <openssl/crypto.h>
+/*
+ * For ossl_(un)likely
+ */
+# include <internal/common.h>
+#else
+/* Cut from <internal/common.h> */
+# if defined(__GNUC__) || defined(__clang__)
+#  define ossl_likely(x)     __builtin_expect(!!(x), 1)
+#  define ossl_unlikely(x)   __builtin_expect(!!(x), 0)
+# else
+#  define ossl_likely(x)     (x)
+#  define ossl_unlikely(x)   (x)
+# endif
 #endif
 
 #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
@@ -156,18 +169,18 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
     HASH_LONG l;
     size_t n;
 
-    if (len == 0)
+    if (ossl_unlikely(len == 0))
         return 1;
 
     l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
-    if (l < c->Nl)              /* overflow */
+    if (ossl_unlikely(l < c->Nl))              /* overflow */
         c->Nh++;
     c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
                                        * 16-bit */
     c->Nl = l;
 
     n = c->num;
-    if (n != 0) {
+    if (ossl_likely(n != 0)) {
         p = (unsigned char *)c->data;
 
         if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
diff --git a/lib/erl_interface/src/openssl/vendor.info b/lib/erl_interface/src/openssl/vendor.info
index dccd469541..e1702fcd0a 100644
--- a/lib/erl_interface/src/openssl/vendor.info
+++ b/lib/erl_interface/src/openssl/vendor.info
@@ -14,12 +14,14 @@
     "homepage": "https://www.openssl.org/",
     "licenseDeclared": "Apache-2.0",
     "name": "openssl",
-    "versionInfo": "3.5",
-    "sha": "636dfadc70ce26f2473870570bfd9ec352806b1d",
+    "versionInfo": "3.6.0",
+    "sha": "7b371d80d959ec9ab4139d09d78e83c090de9779",
     "path": "./lib/erl_interface/src/openssl",
-    "exclude": ["./lib/erl_interface/src/openssl/vendor.info",
-                "./lib/erl_interface/src/openssl/README",
-                "./lib/erl_interface/src/openssl/openssl.mk"],
+    "exclude": [
+      "./lib/erl_interface/src/openssl/vendor.info",
+      "./lib/erl_interface/src/openssl/README",
+      "./lib/erl_interface/src/openssl/openssl.mk"
+    ],
     "supplier": "Organization: OpenSSL Mission",
     "purl": "pkg:generic/openssl"
   }
-- 
2.51.0

openSUSE Build Service is sponsored by