|
|
b0b627 |
diff -up comm/third_party/moz.build.D161379.diff comm/third_party/moz.build
|
|
|
b0b627 |
--- comm/third_party/moz.build.D161379.diff 2022-10-14 21:45:15.000000000 +0200
|
|
|
b0b627 |
+++ comm/third_party/moz.build 2022-11-10 11:49:44.194016978 +0100
|
|
|
b0b627 |
@@ -11,9 +11,11 @@ if CONFIG["TB_LIBOTR_PREBUILT"]:
|
|
|
b0b627 |
|
|
|
b0b627 |
if CONFIG["MZLA_LIBRNP"]:
|
|
|
b0b627 |
DIRS += [
|
|
|
b0b627 |
- "botan",
|
|
|
b0b627 |
"bzip2",
|
|
|
b0b627 |
"json-c",
|
|
|
b0b627 |
"rnp",
|
|
|
b0b627 |
"zlib",
|
|
|
b0b627 |
]
|
|
|
b0b627 |
+ if CONFIG["MZLA_LIBRNP_BACKEND"] == "botan":
|
|
|
b0b627 |
+ DIRS += [ "botan" ]
|
|
|
b0b627 |
+
|
|
|
b0b627 |
diff -up comm/third_party/openpgp.configure.D161379.diff comm/third_party/openpgp.configure
|
|
|
b0b627 |
--- comm/third_party/openpgp.configure.D161379.diff 2022-11-10 11:49:37.605024129 +0100
|
|
|
b0b627 |
+++ comm/third_party/openpgp.configure 2022-11-10 11:49:44.194016978 +0100
|
|
|
b0b627 |
@@ -199,16 +199,136 @@ with only_when(in_tree_librnp):
|
|
|
b0b627 |
set_config("MZLA_BZIP2_CFLAGS", bzip2_flags.cflags)
|
|
|
b0b627 |
set_config("MZLA_BZIP2_LIBS", bzip2_flags.ldflags)
|
|
|
b0b627 |
|
|
|
b0b627 |
- # BOTAN --with-system-botan
|
|
|
b0b627 |
- system_lib_option(
|
|
|
b0b627 |
- "--with-system-botan",
|
|
|
b0b627 |
- help="Use system Botan for librnp (located with pkgconfig)",
|
|
|
b0b627 |
- )
|
|
|
b0b627 |
-
|
|
|
b0b627 |
- botan_pkg = pkg_check_modules(
|
|
|
b0b627 |
- "MZLA_BOTAN", "botan-2 >= 2.8.0", when="--with-system-botan"
|
|
|
b0b627 |
- )
|
|
|
b0b627 |
- set_config("MZLA_SYSTEM_BOTAN", depends_if(botan_pkg)(lambda _: True))
|
|
|
b0b627 |
+ # librnp crypto backend selection
|
|
|
b0b627 |
+ option("--with-librnp-backend",
|
|
|
b0b627 |
+ help="Build librnp with the selected backend: {botan, openssl}",
|
|
|
b0b627 |
+ default="botan")
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ @depends("--with-librnp-backend")
|
|
|
b0b627 |
+ def librnp_backend(backend):
|
|
|
b0b627 |
+ allowed = ("botan", "openssl")
|
|
|
b0b627 |
+ if backend[0] in allowed:
|
|
|
b0b627 |
+ return backend[0]
|
|
|
b0b627 |
+ else:
|
|
|
b0b627 |
+ die(f"Unsupported librnp backend {backend[0]}.")
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ set_config("MZLA_LIBRNP_BACKEND", librnp_backend)
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ @depends(librnp_backend)
|
|
|
b0b627 |
+ def rnp_botan(backend):
|
|
|
b0b627 |
+ return backend == "botan"
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ @depends(librnp_backend)
|
|
|
b0b627 |
+ def rnp_openssl(backend):
|
|
|
b0b627 |
+ return backend == "openssl"
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ # Botan backend (--with-system-botan)
|
|
|
b0b627 |
+ with only_when(rnp_botan):
|
|
|
b0b627 |
+ system_lib_option(
|
|
|
b0b627 |
+ "--with-system-botan",
|
|
|
b0b627 |
+ help="Use system Botan for librnp (located with pkgconfig)",
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ botan_pkg = pkg_check_modules(
|
|
|
b0b627 |
+ "MZLA_BOTAN", "botan-2 >= 2.8.0", when="--with-system-botan"
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ set_config("MZLA_SYSTEM_BOTAN", depends_if(botan_pkg)(lambda _: True))
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ # OpenSSL backend
|
|
|
b0b627 |
+ with only_when(rnp_openssl):
|
|
|
b0b627 |
+ option(
|
|
|
b0b627 |
+ "--with-openssl",
|
|
|
b0b627 |
+ nargs=1,
|
|
|
b0b627 |
+ help="OpenSSL library prefix (when not found by pkgconfig)"
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ openssl_pkg = pkg_check_modules(
|
|
|
b0b627 |
+ "MZLA_LIBRNP_OPENSSL",
|
|
|
b0b627 |
+ "openssl > 1.1.1",
|
|
|
b0b627 |
+ allow_missing=True,
|
|
|
b0b627 |
+ config=False
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ @depends_if("--with-openssl", openssl_pkg)
|
|
|
b0b627 |
+ @imports(_from="os.path", _import="isdir")
|
|
|
b0b627 |
+ @imports(_from="os.path", _import="join")
|
|
|
b0b627 |
+ def openssl_flags(openssl_prefix, openssl_pkg):
|
|
|
b0b627 |
+ if openssl_prefix:
|
|
|
b0b627 |
+ openssl_prefix = openssl_prefix[0]
|
|
|
b0b627 |
+ include = join(openssl_prefix, "include")
|
|
|
b0b627 |
+ lib = join(openssl_prefix, "lib")
|
|
|
b0b627 |
+ if not isdir(lib):
|
|
|
b0b627 |
+ lib = join(openssl_prefix, "lib64")
|
|
|
b0b627 |
+ if isdir(include) and isdir(lib):
|
|
|
b0b627 |
+ log.info(f"Using OpenSSL at {openssl_prefix}.")
|
|
|
b0b627 |
+ return namespace(
|
|
|
b0b627 |
+ cflags=(f"-I{include}",),
|
|
|
b0b627 |
+ ldflags=(f"-L{lib}", "-lssl", "-lcrypto"),
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ if openssl_pkg:
|
|
|
b0b627 |
+ return namespace(
|
|
|
b0b627 |
+ cflags=openssl_pkg.cflags,
|
|
|
b0b627 |
+ ldflags=openssl_pkg.libs,
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ set_config("MZLA_LIBRNP_OPENSSL_CFLAGS", openssl_flags.cflags)
|
|
|
b0b627 |
+ set_config("MZLA_LIBRNP_OPENSSL_LIBS", openssl_flags.ldflags)
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ @depends(c_compiler, openssl_flags)
|
|
|
b0b627 |
+ @imports(_from="textwrap", _import="dedent")
|
|
|
b0b627 |
+ def openssl_version(compiler, openssl_flags):
|
|
|
b0b627 |
+ log.info("Checking for OpenSSL >= 1.1.1")
|
|
|
b0b627 |
+ if openssl_flags is None:
|
|
|
b0b627 |
+ die("OpenSSL not found. Must be locatable with pkg-config or use --with-openssl.")
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ def ossl_hexver(hex_str):
|
|
|
b0b627 |
+ # See opensshlv.h for description of OPENSSL_VERSION_NUMBER
|
|
|
b0b627 |
+ MIN_OSSL_VER = 0x1010100f # Version 1.1.1
|
|
|
b0b627 |
+ ver_as_int = int(hex_str[:-1], 16)
|
|
|
b0b627 |
+ ossl_major = (ver_as_int & 0xf0000000) >> 28
|
|
|
b0b627 |
+ ossl_minor = (ver_as_int & 0x0ff00000) >> 20
|
|
|
b0b627 |
+ ossl_fix = (ver_as_int & 0x000ff000) >> 12
|
|
|
b0b627 |
+ ossl_patch = chr(96 + (ver_as_int & 0x00000ff0) >> 4) # as a letter a-z
|
|
|
b0b627 |
+ ver_as_str = f"{ossl_major}.{ossl_minor}.{ossl_fix}{ossl_patch}"
|
|
|
b0b627 |
+ if ver_as_int < MIN_OSSL_VER:
|
|
|
b0b627 |
+ die(f"OpenSSL version {ver_as_str} is too old.")
|
|
|
b0b627 |
+ return ver_as_str
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ check = dedent(
|
|
|
b0b627 |
+ """\
|
|
|
b0b627 |
+ #include <openssl/opensslv.h>
|
|
|
b0b627 |
+ #ifdef OPENSSL_VERSION_STR
|
|
|
b0b627 |
+ OPENSSL_VERSION_STR
|
|
|
b0b627 |
+ #elif defined(OPENSSL_VERSION_NUMBER)
|
|
|
b0b627 |
+ OPENSSL_VERSION_NUMBER
|
|
|
b0b627 |
+ #else
|
|
|
b0b627 |
+ #error Unable to determine OpenSSL version.
|
|
|
b0b627 |
+ #endif
|
|
|
b0b627 |
+ """
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ result = try_preprocess(
|
|
|
b0b627 |
+ compiler.wrapper
|
|
|
b0b627 |
+ + [compiler.compiler]
|
|
|
b0b627 |
+ + compiler.flags
|
|
|
b0b627 |
+ + list(openssl_flags.cflags),
|
|
|
b0b627 |
+ "C",
|
|
|
b0b627 |
+ check
|
|
|
b0b627 |
+ )
|
|
|
b0b627 |
+ if result:
|
|
|
b0b627 |
+ openssl_ver = result.splitlines()[-1]
|
|
|
b0b627 |
+ if openssl_ver.startswith("0x"):
|
|
|
b0b627 |
+ # OpenSSL 1.x.x - like 0x1010107fL
|
|
|
b0b627 |
+ openssl_ver = ossl_hexver(openssl_ver)
|
|
|
b0b627 |
+ else:
|
|
|
b0b627 |
+ # OpenSSL 3.x.x - quoted version like "3.0.7"
|
|
|
b0b627 |
+ openssl_ver = openssl_ver.replace('"', "")
|
|
|
b0b627 |
+ major_version = openssl_ver.split(".")[0]
|
|
|
b0b627 |
+ if major_version != "3":
|
|
|
b0b627 |
+ die("Unrecognized OpenSSL version {openssl_version} found. Require >= 1.1.1 or 3.x.x")
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ log.info(f"Found OpenSSL {openssl_ver}.")
|
|
|
b0b627 |
+ return openssl_ver
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ set_config("MZLA_LIBRNP_OPENSSL_VERSION", openssl_version)
|
|
|
b0b627 |
|
|
|
b0b627 |
# Checks for building librnp itself
|
|
|
b0b627 |
# =================================
|
|
|
b0b627 |
diff -up comm/third_party/rnp/moz.build.D161379.diff comm/third_party/rnp/moz.build
|
|
|
b0b627 |
--- comm/third_party/rnp/moz.build.D161379.diff 2022-11-10 11:49:43.682017534 +0100
|
|
|
b0b627 |
+++ comm/third_party/rnp/moz.build 2022-11-10 11:51:22.878909880 +0100
|
|
|
b0b627 |
@@ -36,17 +36,53 @@ if CONFIG["CC_TYPE"] == "clang-cl":
|
|
|
b0b627 |
"/EHs",
|
|
|
b0b627 |
]
|
|
|
b0b627 |
|
|
|
b0b627 |
+LOCAL_INCLUDES = [
|
|
|
b0b627 |
+ "include",
|
|
|
b0b627 |
+ "src",
|
|
|
b0b627 |
+ "src/common",
|
|
|
b0b627 |
+ "src/lib",
|
|
|
b0b627 |
+]
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+IQuote(
|
|
|
b0b627 |
+ "{}/src/lib".format(OBJDIR),
|
|
|
b0b627 |
+ "{}/src/lib".format(SRCDIR),
|
|
|
b0b627 |
+)
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+# Set up defines for src/lib/config.h
|
|
|
b0b627 |
rnp_defines = {
|
|
|
b0b627 |
"HAVE_BZLIB_H": True,
|
|
|
b0b627 |
"HAVE_ZLIB_H": True,
|
|
|
b0b627 |
- "CRYPTO_BACKEND_OPENSSL": True,
|
|
|
b0b627 |
- "ENABLE_AEAD": True,
|
|
|
b0b627 |
- "ENABLE_TWOFISH": True,
|
|
|
b0b627 |
- "ENABLE_BRAINPOOL": True,
|
|
|
b0b627 |
"ENABLE_IDEA": True,
|
|
|
b0b627 |
"PACKAGE_BUGREPORT": '"https://bugzilla.mozilla.org/enter_bug.cgi?product=Thunderbird"',
|
|
|
b0b627 |
"PACKAGE_STRING": '"rnp {}"'.format(CONFIG["MZLA_LIBRNP_FULL_VERSION"])
|
|
|
b0b627 |
}
|
|
|
b0b627 |
+if CONFIG["MZLA_LIBRNP_BACKEND"] == "botan":
|
|
|
b0b627 |
+ LOCAL_INCLUDES += ["!../botan/build/include"]
|
|
|
b0b627 |
+ if CONFIG["MZLA_SYSTEM_BOTAN"]:
|
|
|
b0b627 |
+ CXXFLAGS += CONFIG["MZLA_BOTAN_CFLAGS"]
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ rnp_defines.update({
|
|
|
b0b627 |
+ "CRYPTO_BACKEND_BOTAN": True,
|
|
|
b0b627 |
+ "ENABLE_AEAD": True,
|
|
|
b0b627 |
+ "ENABLE_TWOFISH": True,
|
|
|
b0b627 |
+ "ENABLE_BRAINPOOL": True,
|
|
|
b0b627 |
+ })
|
|
|
b0b627 |
+elif CONFIG["MZLA_LIBRNP_BACKEND"] == "openssl":
|
|
|
b0b627 |
+ CXXFLAGS += CONFIG["MZLA_LIBRNP_OPENSSL_CFLAGS"]
|
|
|
b0b627 |
+ OS_LIBS += CONFIG["MZLA_LIBRNP_OPENSSL_LIBS"]
|
|
|
b0b627 |
+
|
|
|
b0b627 |
+ rnp_defines.update({
|
|
|
b0b627 |
+ "CRYPTO_BACKEND_OPENSSL": True,
|
|
|
b0b627 |
+ # Not supported with RNP+OpenSSL https://github.com/rnpgp/rnp/issues/1642
|
|
|
b0b627 |
+ "ENABLE_AEAD": False,
|
|
|
b0b627 |
+ # Not supported by OpenSSL https://github.com/openssl/openssl/issues/2046
|
|
|
b0b627 |
+ "ENABLE_TWOFISH": False,
|
|
|
b0b627 |
+ # Supported, but not with RHEL's OpenSSL, disabled for now;
|
|
|
b0b627 |
+ "ENABLE_BRAINPOOL": False,
|
|
|
b0b627 |
+ })
|
|
|
b0b627 |
+ if CONFIG["MZLA_LIBRNP_OPENSSL_VERSION"][0] == "3":
|
|
|
b0b627 |
+ rnp_defines["CRYPTO_BACKEND_OPENSSL3"] = True
|
|
|
b0b627 |
+
|
|
|
b0b627 |
GeneratedFile(
|
|
|
b0b627 |
"src/lib/config.h",
|
|
|
b0b627 |
script="/comm/python/rocbuild/process_cmake_define_files.py",
|
|
|
b0b627 |
@@ -57,23 +93,6 @@ GeneratedFile(
|
|
|
b0b627 |
],
|
|
|
b0b627 |
)
|
|
|
b0b627 |
|
|
|
b0b627 |
-LOCAL_INCLUDES = [
|
|
|
b0b627 |
- "include",
|
|
|
b0b627 |
- "src",
|
|
|
b0b627 |
- "src/common",
|
|
|
b0b627 |
- "src/lib",
|
|
|
b0b627 |
-]
|
|
|
b0b627 |
-
|
|
|
b0b627 |
-IQuote(
|
|
|
b0b627 |
- "{}/src/lib".format(OBJDIR),
|
|
|
b0b627 |
- "{}/src/lib".format(SRCDIR),
|
|
|
b0b627 |
-)
|
|
|
b0b627 |
-
|
|
|
b0b627 |
-if CONFIG["MZLA_SYSTEM_BOTAN"]:
|
|
|
b0b627 |
- CXXFLAGS += CONFIG["MZLA_BOTAN_CFLAGS"]
|
|
|
b0b627 |
-else:
|
|
|
b0b627 |
- LOCAL_INCLUDES += ["!../botan/build/include"]
|
|
|
b0b627 |
-
|
|
|
b0b627 |
if CONFIG["MOZ_SYSTEM_ZLIB"]:
|
|
|
b0b627 |
CXXFLAGS += CONFIG["MOZ_ZLIB_CFLAGS"]
|
|
|
b0b627 |
else:
|
|
|
b0b627 |
@@ -109,29 +128,16 @@ SOURCES += [
|
|
|
b0b627 |
"src/common/time-utils.cpp",
|
|
|
b0b627 |
"src/lib/crypto.cpp",
|
|
|
b0b627 |
"src/lib/crypto/backend_version.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/bn.cpp",
|
|
|
b0b627 |
"src/lib/crypto/cipher.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/cipher_botan.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/dsa.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/ec.cpp",
|
|
|
b0b627 |
"src/lib/crypto/ec_curves.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/ecdh.cpp",
|
|
|
b0b627 |
"src/lib/crypto/ecdh_utils.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/ecdsa.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/eddsa.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/elgamal.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/hash.cpp",
|
|
|
b0b627 |
"src/lib/crypto/hash_common.cpp",
|
|
|
b0b627 |
"src/lib/crypto/hash_sha1cd.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/mem.cpp",
|
|
|
b0b627 |
"src/lib/crypto/mpi.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/rng.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/rsa.cpp",
|
|
|
b0b627 |
"src/lib/crypto/s2k.cpp",
|
|
|
b0b627 |
"src/lib/crypto/sha1cd/sha1.c",
|
|
|
b0b627 |
"src/lib/crypto/sha1cd/ubc_check.c",
|
|
|
b0b627 |
"src/lib/crypto/signatures.cpp",
|
|
|
b0b627 |
- "src/lib/crypto/symmetric.cpp",
|
|
|
b0b627 |
"src/lib/fingerprint.cpp",
|
|
|
b0b627 |
"src/lib/generate-key.cpp",
|
|
|
b0b627 |
"src/lib/json-utils.cpp",
|
|
|
b0b627 |
@@ -159,4 +165,40 @@ SOURCES += [
|
|
|
b0b627 |
"src/librepgp/stream-write.cpp",
|
|
|
b0b627 |
]
|
|
|
b0b627 |
|
|
|
b0b627 |
+if CONFIG["MZLA_LIBRNP_BACKEND"] == "botan":
|
|
|
b0b627 |
+ SOURCES += [
|
|
|
b0b627 |
+ "src/lib/crypto/bn.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/cipher_botan.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/dsa.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/ec.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/ecdh.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/ecdsa.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/eddsa.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/elgamal.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/hash.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/mem.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/rng.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/rsa.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/symmetric.cpp",
|
|
|
b0b627 |
+ ]
|
|
|
b0b627 |
+if CONFIG["MZLA_LIBRNP_BACKEND"] == "openssl":
|
|
|
b0b627 |
+ SOURCES += [
|
|
|
b0b627 |
+ "src/lib/crypto/bn_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/cipher_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/dl_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/dsa_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/ec_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/ecdh_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/ecdsa_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/eddsa_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/elgamal_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/hash_crc24.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/hash_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/mem_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/rng_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/rsa_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/s2k_ossl.cpp",
|
|
|
b0b627 |
+ "src/lib/crypto/symmetric_ossl.cpp",
|
|
|
b0b627 |
+ ]
|
|
|
b0b627 |
+
|
|
|
b0b627 |
DIRS += ["src/rnp", "src/rnpkeys"]
|