Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
+184
View File
@@ -0,0 +1,184 @@
openssl_headers = [
"aes.h",
"asn1.h",
"asn1_mac.h",
"asn1err.h",
"asn1t.h",
"async.h",
"asyncerr.h",
"bio.h",
"bioerr.h",
"blowfish.h",
"bn.h",
"bnerr.h",
"buffer.h",
"buffererr.h",
"camellia.h",
"cast.h",
"cmac.h",
"cms.h",
"cmserr.h",
"comp.h",
"comperr.h",
"conf.h",
"conf_api.h",
"conferr.h",
"crypto.h",
"cryptoerr.h",
"ct.h",
"cterr.h",
"des.h",
"dh.h",
"dherr.h",
"dsa.h",
"dsaerr.h",
"dtls1.h",
"e_os2.h",
"ebcdic.h",
"ec.h",
"ecdh.h",
"ecdsa.h",
"ecerr.h",
"engine.h",
"engineerr.h",
"err.h",
"evp.h",
"evperr.h",
"hmac.h",
"idea.h",
"kdf.h",
"kdferr.h",
"lhash.h",
"md2.h",
"md4.h",
"md5.h",
"mdc2.h",
"modes.h",
"obj_mac.h",
"objects.h",
"objectserr.h",
"ocsp.h",
"ocsperr.h",
"opensslconf.h",
"opensslv.h",
"ossl_typ.h",
"pem.h",
"pem2.h",
"pemerr.h",
"pkcs12.h",
"pkcs12err.h",
"pkcs7.h",
"pkcs7err.h",
"rand.h",
"rand_drbg.h",
"randerr.h",
"rc2.h",
"rc4.h",
"rc5.h",
"ripemd.h",
"rsa.h",
"rsaerr.h",
"safestack.h",
"seed.h",
"sha.h",
"srp.h",
"srtp.h",
"ssl.h",
"ssl2.h",
"ssl3.h",
"sslerr.h",
"stack.h",
"store.h",
"storeerr.h",
"symhacks.h",
"tls1.h",
"ts.h",
"tserr.h",
"txt_db.h",
"ui.h",
"uierr.h",
"whrlpool.h",
"x509.h",
"x509_vfy.h",
"x509err.h",
"x509v3.h",
"x509v3err.h",
]
openssl_libs = [
"libcrypto.a",
"libssl.a",
]
genrule(
name = "openssl_build",
srcs = [
"build-openssl-bazel.sh",
"openssl-1.1.1d.tar.gz",
"patch-conf.patch",
"patch-include.patch",
],
cmd_bash =
"""
if [ "$(TARGET_CPU)" == "ios_armv7" ]; then
BUILD_ARCH="armv7"
elif [ "$(TARGET_CPU)" == "ios_arm64" ]; then
BUILD_ARCH="arm64"
elif [ "$(TARGET_CPU)" == "ios_x86_64" ]; then
BUILD_ARCH="x86_64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi
BUILD_DIR="$(RULEDIR)/$$BUILD_ARCH"
rm -rf "$$BUILD_DIR"
mkdir -p "$$BUILD_DIR"
""" + "\n" +
"mkdir -p $$BUILD_DIR" + "\n" +
"cp $(SRCS) $$BUILD_DIR/" + "\n" +
"sh $$BUILD_DIR/build-openssl-bazel.sh $$BUILD_DIR $$BUILD_DIR $$BUILD_ARCH" + "\n" +
"\n".join([
"cp \"$$BUILD_DIR/build/$$BUILD_ARCH/include/openssl/{}\" \"$(location :{})\"\n".format(x, x) for x in openssl_headers
]) +
"\n".join([
"cp \"$$BUILD_DIR/build/$$BUILD_ARCH/lib/{}\" \"$(location :{})\"\n".format(x, x) for x in openssl_libs
]),
outs = openssl_headers + openssl_libs,
visibility = [
"//visibility:public",
]
)
genrule(
name = "openssl_include",
srcs = [":" + x for x in openssl_headers],
outs = ["Public/openssl/" + x for x in openssl_headers],
cmd_bash = " && ".join(["cp $(location :{}) $(location Public/openssl/{})".format(x, x) for x in openssl_headers]),
visibility = [
"//visibility:public",
],
)
cc_library(
name = "openssl_lib",
srcs = [":" + x for x in openssl_libs],
cxxopts = [
"-std=c++17",
],
)
objc_library(
name = "openssl",
module_name = "openssl",
enable_modules = True,
hdrs = ["Public/openssl/" + x for x in openssl_headers],
includes = [
"Public",
],
deps = [
":openssl_lib",
],
visibility = [
"//visibility:public",
]
)
+203
View File
@@ -0,0 +1,203 @@
#!/bin/bash
set -x
set -e
OUT_DIR="$1"
SRC_DIR="$2"
ARCH="$3"
if [ "$ARCH" != "arm64" ] && [ "$ARCH" != "armv7" ] && [ "$ARCH" != "x86_64" ]; then
echo "Invalid architecture $ARCH"
exit 1
fi
if [ -z "$OUT_DIR" ]; then
echo "Usage: sh build-openssl.sh OUT_DIR SRC_DIR ARCH"
exit 1
fi
if [ -z "$SRC_DIR" ]; then
echo "Usage: sh build-openssl.sh OUT_DIR SRC_DIR ARCH"
exit 1
fi
if [ ! -d "$SRC_DIR" ]; then
echo "$SRC_DIR does not exist"
exit 1
fi
mkdir -p "$OUT_DIR"
TMP_DIR_NAME="build"
TMP_DIR="$OUT_DIR/$TMP_DIR_NAME"
ABS_TMP_DIR="$(pwd)/$TMP_DIR"
rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"
CROSS_TOP_SIM="`xcode-select --print-path`/Platforms/iPhoneSimulator.platform/Developer"
CROSS_SDK_SIM="iPhoneSimulator.sdk"
CROSS_TOP_IOS="`xcode-select --print-path`/Platforms/iPhoneOS.platform/Developer"
CROSS_SDK_IOS="iPhoneOS.sdk"
SOURCE_DIR="$OUT_DIR/openssl-1.1.1d"
SOURCE_ARCHIVE="$SRC_DIR/openssl-1.1.1d.tar.gz"
rm -rf "$SOURCE_DIR"
tar -xzf "$SOURCE_ARCHIVE" --directory "$OUT_DIR"
export CROSS_COMPILE=`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/
function build_for ()
{
DIR="$(pwd)"
cd "$SOURCE_DIR"
PLATFORM="$1"
ARCH="$2"
CROSS_TOP_ENV="CROSS_TOP_$3"
CROSS_SDK_ENV="CROSS_SDK_$3"
make clean
export CROSS_TOP="${!CROSS_TOP_ENV}"
export CROSS_SDK="${!CROSS_SDK_ENV}"
MINIMAL_FLAGS=(\
"no-shared" \
"no-afalgeng" \
"no-aria" \
"no-asan" \
"no-async" \
"no-autoalginit" \
"no-autoerrinit" \
"no-autoload-config" \
"no-bf" \
"no-blake2" \
"no-buildtest-c++" \
"no-camellia" \
"no-capieng" \
"no-cast" \
"no-chacha" \
"no-cmac" \
"no-cms" \
"no-comp" \
"no-crypto-mdebug" \
"no-crypto-mdebug-backtrace" \
"no-ct" \
"no-deprecated" \
"no-des" \
"no-devcryptoeng" \
"no-dgram" \
"no-dh" \
"no-dsa" \
"no-dtls" \
"no-dynamic-engine" \
"no-ec" \
"no-ec2m" \
"no-ecdh" \
"no-ecdsa" \
"no-ec_nistp_64_gcc_128" \
"no-egd" \
"no-engine" \
"no-err" \
"no-external-tests" \
"no-filenames" \
"no-fuzz-libfuzzer" \
"no-fuzz-afl" \
"no-gost" \
"no-heartbeats" \
"no-idea" \
"no-makedepend" \
"no-md2" \
"no-md4" \
"no-mdc2" \
"no-msan" \
"no-multiblock" \
"no-nextprotoneg" \
"no-pinshared" \
"no-ocb" \
"no-ocsp" \
"no-pic" \
"no-poly1305" \
"no-posix-io" \
"no-psk" \
"no-rc2" \
"no-rc4" \
"no-rc5" \
"no-rfc3779" \
"no-rmd160" \
"no-scrypt" \
"no-sctp" \
"no-shared" \
"no-siphash" \
"no-sm2" \
"no-sm3" \
"no-sm4" \
"no-sock" \
"no-srp" \
"no-srtp" \
"no-sse2" \
"no-ssl" \
"no-ssl-trace" \
"no-static-engine" \
"no-stdio" \
"no-tests" \
"no-tls" \
"no-ts" \
"no-ubsan" \
"no-ui-console" \
"no-unit-test" \
"no-whirlpool" \
"no-weak-ssl-ciphers" \
"no-zlib" \
"no-zlib-dynamic" \
)
DEFAULT_FLAGS=(\
"no-shared" \
"no-asm" \
"no-ssl3" \
"no-comp" \
"no-hw" \
"no-engine" \
"no-async" \
"no-tests" \
)
./Configure $PLATFORM "-arch $ARCH" ${DEFAULT_FLAGS[@]} --prefix="${ABS_TMP_DIR}/${ARCH}" || exit 1
make && make install_sw || exit 2
unset CROSS_TOP
unset CROSS_SDK
cd "$DIR"
}
patch "$SOURCE_DIR/Configurations/10-main.conf" < "$SRC_DIR/patch-conf.patch" || exit 1
if [ "$ARCH" == "x86_64" ]; then
build_for ios64sim-cross x86_64 SIM || exit 2
elif [ "$ARCH" == "armv7" ]; then
build_for ios-cross armv7 IOS || exit 4
elif [ "$ARCH" == "arm64" ]; then
build_for ios64-cross arm64 IOS || exit 5
else
echo "Invalid architecture $ARCH"
exit 1
fi
cp -r "${TMP_DIR}/$ARCH/include" "${TMP_DIR}/"
if [ "$ARCH" == "arm64" ]; then
patch -p3 "${TMP_DIR}/include/openssl/opensslconf.h" < "$SRC_DIR/patch-include.patch" || exit 1
fi
DFT_DIST_DIR="$OUT_DIR/out"
rm -rf "$DFT_DIST_DIR"
mkdir -p "$DFT_DIST_DIR"
DIST_DIR="${DIST_DIR:-$DFT_DIST_DIR}"
mkdir -p "${DIST_DIR}"
cp -r "${TMP_DIR}/include" "${TMP_DIR}/$ARCH/lib" "${DIST_DIR}"
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
set -x
OUT_DIR="$1"
INCLUDE_DIR="$2"
shift
shift
LIBS="$@"
mkdir -p "$OUT_DIR/lib"
/usr/bin/lipo $LIBS -output "$OUT_DIR/lib/libssl.a" -create
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
set -x
OUT_DIR="$1"
INCLUDE_DIR="$2"
shift
shift
LIBS="$@"
mkdir -p "$OUT_DIR/lib"
/usr/bin/lipo $LIBS -output "$OUT_DIR/lib/libcrypto.a" -create
cp -r "$INCLUDE_DIR" "$OUT_DIR/"
+17
View File
@@ -0,0 +1,17 @@
diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -1640,6 +1640,13 @@ my %targets = (
sys_id => "VXWORKS",
lflags => add("-r"),
},
+ "ios64sim-cross" => {
+ inherit_from => [ "darwin-common", asm("no_asm") ],
+ cflags => add("-arch x86_64 -DOPENSSL_NO_ASM -mios-version-min=8.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
+ sys_id => "iOS",
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
+ perlasm_scheme => "ios64",
+ },
"vxworks-simlinux" => {
inherit_from => [ "BASE_unix" ],
CC => "ccpentium",
+28
View File
@@ -0,0 +1,28 @@
--- opensslconf.h 2020-01-06 02:41:46.000000000 +0400
+++ opensslconf_updated.h 2020-01-06 02:51:12.000000000 +0400
@@ -205,11 +205,21 @@
* The following are cipher-specific, but are part of the public API.
*/
#if !defined(OPENSSL_SYS_UEFI)
-# undef BN_LLONG
+# ifdef __LP64__
+# undef BN_LLONG
+# else
+# define BN_LLONG
+# endif
/* Only one for the following should be defined */
-# define SIXTY_FOUR_BIT_LONG
-# undef SIXTY_FOUR_BIT
-# undef THIRTY_TWO_BIT
+# ifdef __LP64__
+# define SIXTY_FOUR_BIT_LONG
+# undef SIXTY_FOUR_BIT
+# undef THIRTY_TWO_BIT
+# else
+# undef SIXTY_FOUR_BIT_LONG
+# undef SIXTY_FOUR_BIT
+# define THIRTY_TWO_BIT
+# endif
#endif
#define RC4_INT unsigned char