Skip to content

Commit

Permalink
openssl: update to 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-pierre committed Dec 20, 2024
1 parent 73cd8c1 commit bd68a14
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 62 deletions.
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ endif()
declare_project(thirdparty/openssh ${EXCLUDE_FROM_ALL})

# openssl
# NOTE: `EXCLUDE_FROM_ALL` is not used because `ffi/crypto` needs `libcrypto`.
declare_project(thirdparty/openssl)

# pcre2
Expand Down
2 changes: 1 addition & 1 deletion ffi/crypto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LuaJIT FFI wrapper for libcrypto (OpenSSL).
local ffi = require("ffi")
require("ffi/crypto_h")

local libcrypto = ffi.loadlib("crypto", "1.1")
local libcrypto = ffi.loadlib("crypto", "3")
local crypto = {}

function crypto.pbkdf2_hmac_sha1(pass, salt, iterations, key_len)
Expand Down
87 changes: 62 additions & 25 deletions thirdparty/openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
list(APPEND PATCH_FILES
openssl-1.1.0j-parallel_install_fix.patch
reduce_build_verbosity.patch
macos_rpath.patch
)
Expand Down Expand Up @@ -27,7 +26,62 @@ if(CHOST)
list(APPEND CFG_ENV_VAR CROSS_COMPILE=${CHOST}-)
endif()

set(CFG_OPTS shared)
if(MONOLIBTIC)
set(CFG_OPTS no-shared)
else()
set(CFG_OPTS shared)
endif()

list(APPEND CFG_OPTS
--api=1.1.1
no-afalgeng
no-apps
no-argon2
no-async
no-bf
no-capieng
no-cast
no-cmac
no-cms
no-comp
no-default-thread-pool
no-deprecated
no-des
no-dsa
no-dynamic-engine
no-ecx
no-gost
no-idea
no-legacy
no-md4
no-padlockeng
no-quic
no-rc2
no-rc4
no-rc5
no-rmd160
no-seed
no-srp
no-tests
no-thread-pool
no-ts
no-ui-console
no-uplink
no-whirlpool
)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND CFG_OPTS
no-err
no-filenames
)
endif()

# Do we support SIMD?
if(WANT_SIMD)
list(APPEND CFG_OPTS enable-asm)
else()
list(APPEND CFG_OPTS no-asm)
endif()

if(ANDROID)
assert_var_defined(ENV{NDKABI})
Expand All @@ -52,13 +106,6 @@ else()
endif()
endif()

# Do we support SIMD?
if(WANT_SIMD)
set(ASM_OPT enable-asm)
else()
set(ASM_OPT no-asm)
endif()

if(APPLE)
list(APPEND CONFIGURE_CMD ${SOURCE_DIR}/Configure)
if(DARWIN_AARCH64)
Expand All @@ -74,17 +121,13 @@ else()
list(APPEND CONFIGURE_CMD ${SOURCE_DIR}/Configure)
endif()

set(CFG_OPTS ${CFG_OPTS} ${ASM_OPT} no-async no-idea no-mdc2 no-rc5 no-tests)
list(APPEND CFG_CMD COMMAND
env ${CFG_ENV_VAR}
${CONFIGURE_CMD}
--prefix=${STAGING_DIR}
--libdir=lib
${CFG_OPTS}
)
if(ANDROID)
# Disable versioning of shared objects.
list(APPEND CFG_CMD COMMAND ${ISED} "s|^SHLIB_EXT=.*|SHLIB_EXT=${LIB_EXT}|" Makefile)
endif()

set(MAKE_CMD
make
Expand All @@ -102,20 +145,14 @@ list(APPEND BUILD_CMD COMMAND ${MAKE_CMD} build_libs)

list(APPEND INSTALL_CMD COMMAND ${MAKE_CMD} install_dev)

if(MONOLIBTIC)
list(APPEND INSTALL_CMD COMMAND sh -c "rm -v \"$1\"* \"$2\"*" --
${STAGING_DIR}/lib/libcrypto${LIB_EXT}
${STAGING_DIR}/lib/libssl${LIB_EXT}
)
else()
append_shared_lib_install_commands(INSTALL_CMD crypto VERSION 1.1)
append_shared_lib_install_commands(INSTALL_CMD ssl VERSION 1.1)
if(NOT MONOLIBTIC)
append_shared_lib_install_commands(INSTALL_CMD crypto VERSION 3)
append_shared_lib_install_commands(INSTALL_CMD ssl VERSION 3)
endif()

external_project(
DOWNLOAD URL 3f76825f195e52d4b10c70040681a275
https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
DOWNLOAD URL 34733f7be2d60ecd8bd9ddb796e182af
https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz
PATCH_FILES ${PATCH_FILES}
CONFIGURE_COMMAND ${CFG_CMD}
BUILD_COMMAND ${BUILD_CMD}
Expand Down
26 changes: 13 additions & 13 deletions thirdparty/openssl/fix_libcrypto_pkg-config_entry.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -974,8 +974,8 @@
echo 'Name: OpenSSL-libcrypto'; \
echo 'Description: OpenSSL cryptography library'; \
echo 'Version: '$(VERSION); \
- echo 'Libs: -L$${libdir} -lcrypto'; \
- echo 'Libs.private: $(LIB_EX_LIBS)'; \
+ echo 'Libs: -L$${libdir} -lcrypto $(LIB_EX_LIBS)'; \
+ echo 'Libs.private:'; \
echo 'Cflags: -I$${includedir}' ) > libcrypto.pc

libssl.pc:
--- i/exporters/pkg-config/libcrypto.pc.in
+++ w/exporters/pkg-config/libcrypto.pc.in
@@ -17,8 +17,8 @@
Name: OpenSSL-libcrypto
Description: OpenSSL cryptography library
Version: {- $OpenSSL::safe::installdata::VERSION -}
-Libs: -L${libdir} -lcrypto
-Libs.private: {- join(' ', @OpenSSL::safe::installdata::LDLIBS) -}
+Libs: -L${libdir} -lcrypto {- join(' ', @OpenSSL::safe::installdata::LDLIBS) -}
+Libs.private:
Cflags:{- $OUT = ' -I${includedir}';
if (scalar @OpenSSL::safe::installdata::INCLUDEDIR_REL_PREFIX > 1) {
$OUT = '';
4 changes: 2 additions & 2 deletions thirdparty/openssl/macos_rpath.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--- i/Configurations/shared-info.pl
+++ w/Configurations/shared-info.pl
@@ -44,7 +44,7 @@ my %shared_info;
@@ -49,7 +49,7 @@
'darwin-shared' => {
module_ldflags => '-bundle',
shared_ldflag => '-dynamiclib -current_version $(SHLIB_VERSION_NUMBER) -compatibility_version $(SHLIB_VERSION_NUMBER)',
- shared_sonameflag => '-install_name $(INSTALLTOP)/$(LIBDIR)/',
- shared_sonameflag => '-install_name $(libdir)/',
+ shared_sonameflag => '-install_name @rpath/',
},
'cygwin-shared' => {
Expand Down
21 changes: 0 additions & 21 deletions thirdparty/openssl/openssl-1.1.0j-parallel_install_fix.patch

This file was deleted.

2 changes: 2 additions & 0 deletions thirdparty/turbo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ list(APPEND PATCH_FILES
# libtffi_wrap library, and pull in upstream fixes.
turbo.patch
d7a8a247a4a2689b0f207162eb804141c87c4899.patch
# Fix some deprecated OpenSSL calls.
openssl.patch
)

# Remove the 7 years-old copy of a CA bundle that turbo doesn't actually use.
Expand Down
29 changes: 29 additions & 0 deletions thirdparty/turbo/openssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- i/deps/turbo_ffi_wrap.c
+++ w/deps/turbo_ffi_wrap.c
@@ -58,7 +58,7 @@
int common_name_loc = -1;
X509_NAME_ENTRY *common_name_entry = 0;
ASN1_STRING *common_name_asn1 = 0;
- char *common_name_str = 0;
+ const char *common_name_str = 0;

common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name(
(X509 *) server_cert),
@@ -77,7 +77,7 @@
if (!common_name_asn1) {
return Error;
}
- common_name_str = (char *) ASN1_STRING_data(common_name_asn1);
+ common_name_str = (const char *) ASN1_STRING_get0_data(common_name_asn1);
if (ASN1_STRING_length(common_name_asn1) != strlen(common_name_str)) {
return MalformedCertificate;
}
@@ -113,7 +113,7 @@
for (i=0; i<san_names_nb; i++){
const GENERAL_NAME *current_name = sk_GENERAL_NAME_value(san_names, i);
if (current_name->type == GEN_DNS){
- char *dns_name = (char *)ASN1_STRING_data(current_name->d.dNSName);
+ const char *dns_name = (const char *)ASN1_STRING_get0_data(current_name->d.dNSName);
dns_name_sz = strlen(dns_name);
if (ASN1_STRING_length(current_name->d.dNSName) != dns_name_sz){
result = MalformedCertificate;

0 comments on commit bd68a14

Please sign in to comment.