Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit d4a12d8

Browse files
authored
update openssl to 3.4.0 (#567)
* update openssl to 3.4.0 * enforce the default install path for openssl config * attempt to fix path to config dir * fix openssldir arg * provide a context name * use the 3.3 naming for OPENSSL_CTX * attempt to workaround hardcoded path for windows * fix prefix being split at whitespace * fix copy * assume we're going to use openssl 3.4 * use the correct but undocumented define for OSSLCTX * fix preprocessor concatenation * update patch * update patch * update patch, again * update the patch, again again
1 parent 69ae9e6 commit d4a12d8

File tree

2 files changed

+125
-2
lines changed

2 files changed

+125
-2
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
From d5dacfca529711ba95662dc7411493ac6f1d99c7 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
3+
Date: Mon, 27 Jan 2025 08:36:07 +0100
4+
Subject: [PATCH] crypto: fix preprocessor concatenation
5+
6+
String litteral don't need the '##' operator, which causes build
7+
failures:
8+
crypto/defaults.c:kepi:23: error: pasting ""SOFTWARE\\WOW6432Node\\OpenSSL"" and ""-"" does not give a valid preprocessing token
9+
---
10+
crypto/cversion.c | 2 +-
11+
crypto/defaults.c | 38 ++++++++++++++++++++------------------
12+
2 files changed, 21 insertions(+), 19 deletions(-)
13+
14+
diff --git a/crypto/cversion.c b/crypto/cversion.c
15+
index 87154645b0..ae439c668b 100644
16+
--- a/crypto/cversion.c
17+
+++ b/crypto/cversion.c
18+
@@ -72,7 +72,7 @@ DEFINE_RUN_ONCE_STATIC(version_strings_setup)
19+
}
20+
21+
# define TOSTR(x) #x
22+
-# define OSSL_WINCTX_STRING "OSSL_WINCTX: \"" ## TOSTR(OSSL_WINCTX) ## "\""
23+
+# define OSSL_WINCTX_STRING "OSSL_WINCTX: \"" TOSTR(OSSL_WINCTX) "\""
24+
25+
#endif
26+
27+
diff --git a/crypto/defaults.c b/crypto/defaults.c
28+
index 908539cf31..3272087228 100644
29+
--- a/crypto/defaults.c
30+
+++ b/crypto/defaults.c
31+
@@ -19,7 +19,7 @@
32+
# define MAKESTR(x) TOSTR(x)
33+
# define NOQUOTE(x) x
34+
# if defined(OSSL_WINCTX)
35+
-# define REGISTRY_KEY "SOFTWARE\\WOW6432Node\\OpenSSL" ##"-"## MAKESTR(OPENSSL_VERSION_MAJOR) ##"."## MAKESTR(OPENSSL_VERSION_MINOR) ##"-"## MAKESTR(OSSL_WINCTX)
36+
+# define REGISTRY_KEY "SOFTWARE\\WOW6432Node\\OpenSSL" "-" MAKESTR(OPENSSL_VERSION_MAJOR) "." MAKESTR(OPENSSL_VERSION_MINOR) "-" MAKESTR(OSSL_WINCTX)
37+
# endif
38+
39+
/**
40+
@@ -60,44 +60,46 @@ static char *modulesdirptr = NULL;
41+
*
42+
* @return A pointer to a char array containing the registry directories.
43+
*/
44+
-static char *get_windows_regdirs(char *dst, LPCTSTR valuename)
45+
+static char *get_windows_regdirs(char *dst, DWORD dstsizebytes, LPCWSTR valuename)
46+
{
47+
char *retval = NULL;
48+
# ifdef REGISTRY_KEY
49+
- DWORD keysize;
50+
+ DWORD keysizebytes;
51+
DWORD ktype;
52+
HKEY hkey;
53+
LSTATUS ret;
54+
DWORD index = 0;
55+
- LPCTCH tempstr = NULL;
56+
-
57+
+ LPCWSTR tempstr = NULL;
58+
+
59+
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
60+
TEXT(REGISTRY_KEY), KEY_WOW64_32KEY,
61+
KEY_QUERY_VALUE, &hkey);
62+
if (ret != ERROR_SUCCESS)
63+
goto out;
64+
65+
- ret = RegQueryValueEx(hkey, valuename, NULL, &ktype, NULL,
66+
- &keysize);
67+
+ // Always use wide call so we can avoid extra encoding conversions on the output
68+
+ ret = RegQueryValueExW(hkey, valuename, NULL, &ktype, NULL,
69+
+ &keysizebytes);
70+
if (ret != ERROR_SUCCESS)
71+
goto out;
72+
- if (ktype != REG_EXPAND_SZ)
73+
+ if (ktype != REG_EXPAND_SZ && ktype != REG_SZ)
74+
goto out;
75+
- if (keysize > MAX_PATH)
76+
+ if (keysizebytes > MAX_PATH*sizeof(WCHAR))
77+
goto out;
78+
79+
- keysize++;
80+
- tempstr = OPENSSL_zalloc(keysize * sizeof(TCHAR));
81+
+ // RegQueryValueExW does not guarantee the buffer is null terminated,
82+
+ // so we make space for one in the allocation
83+
+ tempstr = OPENSSL_zalloc(keysizebytes+sizeof(WCHAR));
84+
85+
if (tempstr == NULL)
86+
goto out;
87+
88+
- if (RegQueryValueEx(hkey, valuename,
89+
- NULL, &ktype, tempstr, &keysize) != ERROR_SUCCESS)
90+
+ if (RegQueryValueExW(hkey, valuename,
91+
+ NULL, &ktype, (LPBYTE)tempstr, &keysizebytes) != ERROR_SUCCESS)
92+
goto out;
93+
94+
- if (!WideCharToMultiByte(CP_UTF8, 0, tempstr, -1, dst, keysize,
95+
- NULL, NULL))
96+
+ if (!WideCharToMultiByte(CP_UTF8, 0, tempstr, -1, dst, dstsizebytes,
97+
+ NULL, NULL))
98+
goto out;
99+
100+
retval = dst;
101+
@@ -117,9 +119,9 @@ static CRYPTO_ONCE defaults_setup_init = CRYPTO_ONCE_STATIC_INIT;
102+
*/
103+
DEFINE_RUN_ONCE_STATIC(do_defaults_setup)
104+
{
105+
- get_windows_regdirs(openssldir, TEXT("OPENSSLDIR"));
106+
- get_windows_regdirs(enginesdir, TEXT("ENGINESDIR"));
107+
- get_windows_regdirs(modulesdir, TEXT("MODULESDIR"));
108+
+ get_windows_regdirs(openssldir, sizeof(openssldir), L"OPENSSLDIR");
109+
+ get_windows_regdirs(enginesdir, sizeof(enginesdir), L"ENGINESDIR");
110+
+ get_windows_regdirs(modulesdir, sizeof(modulesdir), L"MODULESDIR");
111+
112+
/*
113+
* Set our pointers only if the directories are fetched properly
114+
--
115+
2.34.1
116+

config/software/openssl3.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Unless required by applicable law or agreed to in writing, software
1111
# distributed under the License is distributed on an "AS IS" BASIS,
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
13+
# See the License for the specific language governing permissions andopenssl
1414
# limitations under the License.
1515
#
1616

@@ -23,7 +23,7 @@
2323
dependency "zlib"
2424
dependency "cacerts"
2525

26-
default_version "3.3.2"
26+
default_version "3.4.0"
2727

2828
source url: "https://www.openssl.org/source/openssl-#{version}.tar.gz", extract: :lax_tar
2929

@@ -37,10 +37,12 @@
3737
version("3.3.0") { source sha256: "53e66b043322a606abf0087e7699a0e033a37fa13feb9742df35c3a33b18fb02" }
3838
version("3.3.1") { source sha256: "777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e" }
3939
version("3.3.2") { source sha256: "2e8a40b01979afe8be0bbfb3de5dc1c6709fedb46d6c89c10da114ab5fc3d281" }
40+
version("3.4.0") { source sha256: "e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf" }
4041

4142
relative_path "openssl-#{version}"
4243

4344
build do
45+
patch source: "0001-fix-preprocessor-concatenation.patch"
4446

4547
env = with_standard_compiler_flags(with_embedded_path)
4648
if windows?
@@ -79,6 +81,11 @@
7981

8082
if windows?
8183
configure_args << "zlib-dynamic"
84+
if ENV['AGENT_FLAVOR'] == "fips"
85+
configure_args << '--openssldir="C:/Program Files/Datadog/Datadog Agent/embedded3/ssl"'
86+
# Provide a context name for our configuration through the registry
87+
configure_args << "-DOSSL_WINCTX=datadog-fips-agent"
88+
end
8289
else
8390
configure_args << "zlib"
8491
end

0 commit comments

Comments
 (0)