Skip to content

Commit 0153bf2

Browse files
committed
Update MD5 implementation from OpenSSL 3.5.0 to 3.6.0
1 parent 6d6a78d commit 0153bf2

File tree

6 files changed

+59
-27
lines changed

6 files changed

+59
-27
lines changed

erts/emulator/openssl/crypto/md5/md5_local.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License 2.0 (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -20,9 +20,10 @@
2020

2121
#ifdef MD5_ASM
2222
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
23-
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
24-
defined(_M_X64) || defined(__aarch64__) || \
25-
(defined(__loongarch__) && __loongarch_grlen == 64)
23+
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
24+
defined(_M_X64) || defined(__aarch64__) || \
25+
(defined(__loongarch__) && __loongarch_grlen == 64) || \
26+
(defined(__riscv) && __riscv_xlen == 64)
2627
# define md5_block_data_order ossl_md5_block_asm_data_order
2728
# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
2829
# define md5_block_data_order ossl_md5_block_asm_data_order

erts/emulator/openssl/include/crypto/md32_common.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1999-2025 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License 2.0 (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -65,6 +65,19 @@
6565

6666
#if !defined(ERLANG_OPENSSL_INTEGRATION)
6767
#include <openssl/crypto.h>
68+
/*
69+
* For ossl_(un)likely
70+
*/
71+
# include <internal/common.h>
72+
#else
73+
/* Cut from <internal/common.h> */
74+
# if defined(__GNUC__) || defined(__clang__)
75+
# define ossl_likely(x) __builtin_expect(!!(x), 1)
76+
# define ossl_unlikely(x) __builtin_expect(!!(x), 0)
77+
# else
78+
# define ossl_likely(x) (x)
79+
# define ossl_unlikely(x) (x)
80+
# endif
6881
#endif
6982

7083
#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)
156169
HASH_LONG l;
157170
size_t n;
158171

159-
if (len == 0)
172+
if (ossl_unlikely(len == 0))
160173
return 1;
161174

162175
l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
163-
if (l < c->Nl) /* overflow */
176+
if (ossl_unlikely(l < c->Nl)) /* overflow */
164177
c->Nh++;
165178
c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
166179
* 16-bit */
167180
c->Nl = l;
168181

169182
n = c->num;
170-
if (n != 0) {
183+
if (ossl_likely(n != 0)) {
171184
p = (unsigned char *)c->data;
172185

173186
if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {

erts/emulator/openssl/vendor.info

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
"homepage": "https://www.openssl.org/",
1515
"licenseDeclared": "Apache-2.0",
1616
"name": "openssl",
17-
"versionInfo": "3.5",
18-
"sha": "636dfadc70ce26f2473870570bfd9ec352806b1d",
17+
"versionInfo": "3.6.0",
18+
"sha": "7b371d80d959ec9ab4139d09d78e83c090de9779",
1919
"path": "./erts/emulator/openssl",
20-
"exclude": ["./erts/emulator/openssl/vendor.info",
21-
"./erts/emulator/openssl/README",
22-
"./erts/emulator/openssl/openssl.mk",
23-
"./erts/emulator/openssl/update"],
20+
"exclude": [
21+
"./erts/emulator/openssl/vendor.info",
22+
"./erts/emulator/openssl/README",
23+
"./erts/emulator/openssl/openssl.mk",
24+
"./erts/emulator/openssl/update"
25+
],
2426
"supplier": "Organization: OpenSSL Mission",
2527
"purl": "pkg:generic/openssl"
2628
}

lib/erl_interface/src/openssl/crypto/md5/md5_local.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License 2.0 (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -20,9 +20,10 @@
2020

2121
#ifdef MD5_ASM
2222
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
23-
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
24-
defined(_M_X64) || defined(__aarch64__) || \
25-
(defined(__loongarch__) && __loongarch_grlen == 64)
23+
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
24+
defined(_M_X64) || defined(__aarch64__) || \
25+
(defined(__loongarch__) && __loongarch_grlen == 64) || \
26+
(defined(__riscv) && __riscv_xlen == 64)
2627
# define md5_block_data_order ossl_md5_block_asm_data_order
2728
# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
2829
# define md5_block_data_order ossl_md5_block_asm_data_order

lib/erl_interface/src/openssl/include/crypto/md32_common.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1999-2025 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License 2.0 (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -65,6 +65,19 @@
6565

6666
#if !defined(ERLANG_OPENSSL_INTEGRATION)
6767
#include <openssl/crypto.h>
68+
/*
69+
* For ossl_(un)likely
70+
*/
71+
# include <internal/common.h>
72+
#else
73+
/* Cut from <internal/common.h> */
74+
# if defined(__GNUC__) || defined(__clang__)
75+
# define ossl_likely(x) __builtin_expect(!!(x), 1)
76+
# define ossl_unlikely(x) __builtin_expect(!!(x), 0)
77+
# else
78+
# define ossl_likely(x) (x)
79+
# define ossl_unlikely(x) (x)
80+
# endif
6881
#endif
6982

7083
#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)
156169
HASH_LONG l;
157170
size_t n;
158171

159-
if (len == 0)
172+
if (ossl_unlikely(len == 0))
160173
return 1;
161174

162175
l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
163-
if (l < c->Nl) /* overflow */
176+
if (ossl_unlikely(l < c->Nl)) /* overflow */
164177
c->Nh++;
165178
c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
166179
* 16-bit */
167180
c->Nl = l;
168181

169182
n = c->num;
170-
if (n != 0) {
183+
if (ossl_likely(n != 0)) {
171184
p = (unsigned char *)c->data;
172185

173186
if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {

lib/erl_interface/src/openssl/vendor.info

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
"homepage": "https://www.openssl.org/",
1515
"licenseDeclared": "Apache-2.0",
1616
"name": "openssl",
17-
"versionInfo": "3.5",
18-
"sha": "636dfadc70ce26f2473870570bfd9ec352806b1d",
17+
"versionInfo": "3.6.0",
18+
"sha": "7b371d80d959ec9ab4139d09d78e83c090de9779",
1919
"path": "./lib/erl_interface/src/openssl",
20-
"exclude": ["./lib/erl_interface/src/openssl/vendor.info",
21-
"./lib/erl_interface/src/openssl/README",
22-
"./lib/erl_interface/src/openssl/openssl.mk"],
20+
"exclude": [
21+
"./lib/erl_interface/src/openssl/vendor.info",
22+
"./lib/erl_interface/src/openssl/README",
23+
"./lib/erl_interface/src/openssl/openssl.mk"
24+
],
2325
"supplier": "Organization: OpenSSL Mission",
2426
"purl": "pkg:generic/openssl"
2527
}

0 commit comments

Comments
 (0)