From 3ae23976862fa9036ab52e47c8a22025f5d76ca0 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 18 Mar 2024 22:43:46 +1000 Subject: [PATCH 1/2] Rework the test data story We originally embedded test data because of deficiencies in Android's build. Android had no way to specify test data with tests. That has since been resolved, and the embedding mechanism has gotten unwieldy. This unifies pki_test and crypto_test's test data story, and does so in a way that all tests can participate in. (We can now use FileTest in decrepit_test.) Update-Note: This will require some tweaks to downstream builds. We no longer emit an (unwieldy) crypto_test_data.cc file. Instead, tests will expect test data be available at the current working directory. This can be overridden with the BORINGSSL_TEST_DATA_ROOT environment variable. Callers with more complex needs can build with BORINGSSL_CUSTOM_GET_TEST_DATA and then link in an alternate implementation of this function. On the off chance some project needs it, I've kept the embed_test_data.go script around for now, but I expect we can delete it in the future. Fixed: 681 Change-Id: If181ce043e1eea3148838f1bb4db9ee4bfda0d08 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67295 Commit-Queue: David Benjamin Reviewed-by: Bob Beck --- CMakeLists.txt | 22 +-------------- build.json | 6 ++-- crypto/pkcs8/pkcs12_test.cc | 3 +- crypto/test/file_test_gtest.cc | 2 +- crypto/test/test_data.cc | 51 ++++++++++++++++++++++++++++++++++ crypto/test/test_data.h | 31 +++++++++++++++++++++ crypto/x509/x509_test.cc | 3 +- gen/sources.cmake | 3 +- gen/sources.json | 3 +- pki/test_helpers.cc | 51 +++------------------------------- util/generate_build_files.py | 34 +++++++---------------- 11 files changed, 106 insertions(+), 103 deletions(-) create mode 100644 crypto/test/test_data.cc create mode 100644 crypto/test/test_data.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 35fb5670d..1cff48f00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -490,26 +490,6 @@ target_include_directories( # themselves as dependencies next to the target definition. add_custom_target(all_tests) -# On Windows, CRYPTO_TEST_DATA is too long to fit in command-line limits. -# TODO(davidben): CMake 3.12 has a list(JOIN) command. Use that when we've -# updated the minimum version. -set(EMBED_TEST_DATA_ARGS "") -foreach(arg ${CRYPTO_TEST_DATA}) - set(EMBED_TEST_DATA_ARGS "${EMBED_TEST_DATA_ARGS}${arg}\n") -endforeach() -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt" - "${EMBED_TEST_DATA_ARGS}") - -add_custom_command( - OUTPUT crypto_test_data.cc - COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go -file-list - "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt" > - "${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc" - DEPENDS util/embed_test_data.go ${CRYPTO_TEST_DATA} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - -add_library(crypto_test_data OBJECT crypto_test_data.cc) - add_subdirectory(crypto) add_subdirectory(ssl/test) add_subdirectory(util/fipstools) @@ -550,7 +530,7 @@ add_executable(urandom_test ${URANDOM_TEST_SOURCES}) target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto) add_dependencies(all_tests urandom_test) -add_executable(crypto_test ${CRYPTO_TEST_SOURCES} $) +add_executable(crypto_test ${CRYPTO_TEST_SOURCES}) target_link_libraries(crypto_test test_support_lib boringssl_gtest crypto) add_dependencies(all_tests crypto_test) diff --git a/build.json b/build.json index 8c1de1e8f..0463e88b1 100644 --- a/build.json +++ b/build.json @@ -202,7 +202,9 @@ "srcs": [ "crypto/test/abi_test.cc", "crypto/test/file_test.cc", + "crypto/test/file_test_gtest.cc", "crypto/test/file_util.cc", + "crypto/test/test_data.cc", "crypto/test/test_util.cc", "crypto/test/wycheproof_util.cc" ], @@ -285,10 +287,6 @@ "crypto/siphash/siphash_test.cc", "crypto/spx/spx_test.cc", "crypto/thread_test.cc", - // TODO(crbug.com/boringssl/542): This should be in test_support, so - // that all tests can use it. But it depends on GetTestData, which - // is not currently usable outside of crypto_test. - "crypto/test/file_test_gtest.cc", "crypto/test/gtest_main.cc", "crypto/trust_token/trust_token_test.cc", "crypto/x509/tab_test.cc", diff --git a/crypto/pkcs8/pkcs12_test.cc b/crypto/pkcs8/pkcs12_test.cc index 459339d75..a21008915 100644 --- a/crypto/pkcs8/pkcs12_test.cc +++ b/crypto/pkcs8/pkcs12_test.cc @@ -25,11 +25,10 @@ #include #include +#include "../test/test_data.h" #include "../test/test_util.h" -std::string GetTestData(const char *path); - // kPassword is the password shared by most of the sample PKCS#12 files. static const char kPassword[] = "foo"; diff --git a/crypto/test/file_test_gtest.cc b/crypto/test/file_test_gtest.cc index 2cb089694..b1d35562a 100644 --- a/crypto/test/file_test_gtest.cc +++ b/crypto/test/file_test_gtest.cc @@ -25,8 +25,8 @@ #include +#include "test_data.h" -std::string GetTestData(const char *path); class StringLineReader : public FileTest::LineReader { public: diff --git a/crypto/test/test_data.cc b/crypto/test/test_data.cc new file mode 100644 index 000000000..9fe2aaaa0 --- /dev/null +++ b/crypto/test/test_data.cc @@ -0,0 +1,51 @@ +/* Copyright (c) 2024, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "test_data.h" + +#include +#include + +#include "file_util.h" + +#if !defined(BORINGSSL_CUSTOM_GET_TEST_DATA) +std::string GetTestData(const char *path) { + const char *root = getenv("BORINGSSL_TEST_DATA_ROOT"); + root = root != nullptr ? root : "."; + + std::string full_path = root; + full_path.push_back('/'); + full_path.append(path); + + ScopedFILE file(fopen(full_path.c_str(), "rb")); + if (file == nullptr) { + fprintf(stderr, "Could not open '%s'.\n", full_path.c_str()); + abort(); + } + + std::string ret; + for (;;) { + char buf[512]; + size_t n = fread(buf, 1, sizeof(buf), file.get()); + if (n == 0) { + if (feof(file.get())) { + return ret; + } + fprintf(stderr, "Error reading from '%s'.\n", full_path.c_str()); + abort(); + } + ret.append(buf, n); + } +} +#endif // !BORINGSSL_CUSTOM_GET_TEST_DATA diff --git a/crypto/test/test_data.h b/crypto/test/test_data.h new file mode 100644 index 000000000..b3f4b6ace --- /dev/null +++ b/crypto/test/test_data.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2024, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_CRYPTO_TEST_TEST_DATA_H +#define OPENSSL_HEADER_CRYPTO_TEST_TEST_DATA_H + +#include + +// GetTestData returns the test data for |path|, or aborts on error. |path| +// must be a slash-separated path, relative to the BoringSSL source tree. By +// default, this is implemented by reading from the filesystem, relative to +// the BORINGSSL_TEST_DATA_ROOT environment variable, or the current working +// directory if unset. +// +// Callers with more complex needs can build with +// BORINGSSL_CUSTOM_GET_TEST_DATA and then link in an alternate implementation +// of this function. +std::string GetTestData(const char *path); + +#endif // OPENSSL_HEADER_CRYPTO_TEST_TEST_DATA_H diff --git a/crypto/x509/x509_test.cc b/crypto/x509/x509_test.cc index 4559b221b..ffbcf7b86 100644 --- a/crypto/x509/x509_test.cc +++ b/crypto/x509/x509_test.cc @@ -37,6 +37,7 @@ #include "internal.h" #include "../internal.h" #include "../test/file_util.h" +#include "../test/test_data.h" #include "../test/test_util.h" #if defined(OPENSSL_THREADS) @@ -44,8 +45,6 @@ #endif -std::string GetTestData(const char *path); - static const char kCrossSigningRootPEM[] = R"( -----BEGIN CERTIFICATE----- MIICcTCCAdqgAwIBAgIIagJHiPvE0MowDQYJKoZIhvcNAQELBQAwPDEaMBgGA1UE diff --git a/gen/sources.cmake b/gen/sources.cmake index 9153d77d4..e88cb2441 100644 --- a/gen/sources.cmake +++ b/gen/sources.cmake @@ -277,7 +277,6 @@ set( crypto/siphash/siphash_test.cc crypto/spx/spx_test.cc crypto/stack/stack_test.cc - crypto/test/file_test_gtest.cc crypto/test/gtest_main.cc crypto/thread_test.cc crypto/trust_token/trust_token_test.cc @@ -2100,7 +2099,9 @@ set( crypto/test/abi_test.cc crypto/test/file_test.cc + crypto/test/file_test_gtest.cc crypto/test/file_util.cc + crypto/test/test_data.cc crypto/test/test_util.cc crypto/test/wycheproof_util.cc ) diff --git a/gen/sources.json b/gen/sources.json index 90b624717..d00a91067 100644 --- a/gen/sources.json +++ b/gen/sources.json @@ -249,7 +249,6 @@ "crypto/siphash/siphash_test.cc", "crypto/spx/spx_test.cc", "crypto/stack/stack_test.cc", - "crypto/test/file_test_gtest.cc", "crypto/test/gtest_main.cc", "crypto/thread_test.cc", "crypto/trust_token/trust_token_test.cc", @@ -2059,7 +2058,9 @@ "srcs": [ "crypto/test/abi_test.cc", "crypto/test/file_test.cc", + "crypto/test/file_test_gtest.cc", "crypto/test/file_util.cc", + "crypto/test/test_data.cc", "crypto/test/test_util.cc", "crypto/test/wycheproof_util.cc" ], diff --git a/pki/test_helpers.cc b/pki/test_helpers.cc index b6712af51..490fba5ae 100644 --- a/pki/test_helpers.cc +++ b/pki/test_helpers.cc @@ -12,9 +12,12 @@ #include #include + #include #include #include + +#include "../crypto/test/test_data.h" #include "cert_error_params.h" #include "cert_errors.h" #include "parser.h" @@ -90,41 +93,6 @@ std::vector SplitString(std::string_view str) { return out; } -bool ReadFileToString(const std::string &path, std::string *out) { - std::ifstream file(path, std::ios::binary); - file.unsetf(std::ios::skipws); - - file.seekg(0, std::ios::end); - if (file.tellg() == -1) { - return false; - } - out->reserve(file.tellg()); - file.seekg(0, std::ios::beg); - - out->assign(std::istreambuf_iterator(file), - std::istreambuf_iterator()); - - return true; -} - -std::string AppendComponent(const std::string &path, - const std::string &component) { - // Append a path component to a path. Use the \ separator if this appears to - // be a Windows path, otherwise the Unix one. - if (path.find(":\\") != std::string::npos) { - return path + "\\" + component; - } - return path + "/" + component; -} - -std::string GetTestRoot(void) { - // We expect our test data to live in "pki" underneath a - // test root directory, or in the current directry. - char *root_from_env = getenv("BORINGSSL_TEST_DATA_ROOT"); - std::string root = root_from_env ? root_from_env : "."; - return AppendComponent(root, "pki"); -} - } // namespace namespace der { @@ -450,18 +418,7 @@ bool ReadVerifyCertChainTestFromFile(const std::string &file_path_ascii, } std::string ReadTestFileToString(const std::string &file_path_ascii) { - // Compute the full path, relative to the src/ directory. - std::string src_root = GetTestRoot(); - std::string filepath = AppendComponent(src_root, file_path_ascii); - - // Read the full contents of the file. - std::string file_data; - if (!ReadFileToString(filepath, &file_data)) { - ADD_FAILURE() << "Couldn't read file: " << filepath; - return std::string(); - } - - return file_data; + return GetTestData(("pki/" + file_path_ascii).c_str()); } void VerifyCertPathErrors(const std::string &expected_errors_str, diff --git a/util/generate_build_files.py b/util/generate_build_files.py index 9e625c8fb..a54a614e1 100644 --- a/util/generate_build_files.py +++ b/util/generate_build_files.py @@ -24,7 +24,6 @@ import json PREFIX = None -EMBED_TEST_DATA = True def PathOf(x): @@ -80,12 +79,12 @@ class Android(object): non_bcm_asm = self.FilterBcmAsm(files['crypto_asm'], False) bcm_asm = self.FilterBcmAsm(files['crypto_asm'], True) - self.PrintDefaults(blueprint, 'libcrypto_sources', non_bcm_c_files, non_bcm_asm) - self.PrintDefaults(blueprint, 'libcrypto_bcm_sources', bcm_c_files, bcm_asm) + self.PrintDefaults(blueprint, 'libcrypto_sources', non_bcm_c_files, asm_files=non_bcm_asm) + self.PrintDefaults(blueprint, 'libcrypto_bcm_sources', bcm_c_files, asm_files=bcm_asm) self.PrintDefaults(blueprint, 'libssl_sources', files['ssl']) self.PrintDefaults(blueprint, 'bssl_sources', files['tool']) self.PrintDefaults(blueprint, 'boringssl_test_support_sources', files['test_support']) - self.PrintDefaults(blueprint, 'boringssl_crypto_test_sources', files['crypto_test']) + self.PrintDefaults(blueprint, 'boringssl_crypto_test_sources', files['crypto_test'], data=files['crypto_test_data']) self.PrintDefaults(blueprint, 'boringssl_ssl_test_sources', files['ssl_test']) self.PrintDefaults(blueprint, 'libpki_sources', files['pki']) @@ -97,7 +96,7 @@ class Android(object): self.PrintVariableSection(makefile, 'crypto_sources_asm', files['crypto_asm']) - def PrintDefaults(self, blueprint, name, files, asm_files=[]): + def PrintDefaults(self, blueprint, name, files, asm_files=[], data=[]): """Print a cc_defaults section from a list of C files and optionally assembly outputs""" if asm_files: blueprint.write('\n') @@ -113,6 +112,11 @@ class Android(object): for f in sorted(files): blueprint.write(' "%s",\n' % f) blueprint.write(' ],\n') + if data: + blueprint.write(' data: [\n') + for f in sorted(data): + blueprint.write(' "%s",\n' % f) + blueprint.write(' ],\n') if asm_files: blueprint.write(' target: {\n') @@ -655,19 +659,6 @@ def main(platforms): FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) + FindHeaderFiles(os.path.join('src', 'ssl', 'test'), NoTestRunnerFiles)) - crypto_test_files = [] - if EMBED_TEST_DATA: - # Generate crypto_test_data.cc - with open('crypto_test_data.cc', 'w+') as out: - subprocess.check_call( - ['go', 'run', 'util/embed_test_data.go'] + sources['crypto_test']['data'], - cwd='src', - stdout=out) - crypto_test_files.append('crypto_test_data.cc') - - crypto_test_files += PrefixWithSrc(sources['crypto_test']['srcs']) - crypto_test_files.sort() - fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests) ssl_h_files = FindHeaderFiles(os.path.join('src', 'include', 'openssl'), @@ -700,7 +691,7 @@ def main(platforms): 'crypto_nasm': PrefixWithSrc(crypto_nasm), 'crypto_headers': crypto_h_files, 'crypto_internal_headers': crypto_internal_h_files, - 'crypto_test': crypto_test_files, + 'crypto_test': PrefixWithSrc(sources['crypto_test']['srcs']), 'crypto_test_data': PrefixWithSrc(sources['crypto_test']['data']), 'fips_fragments': fips_fragments, 'fuzz': fuzz_c_files, @@ -744,13 +735,8 @@ if __name__ == '__main__': '|'.join(sorted(ALL_PLATFORMS.keys()))) parser.add_option('--prefix', dest='prefix', help='For Bazel, prepend argument to all source files') - parser.add_option( - '--embed_test_data', type='choice', dest='embed_test_data', - action='store', default="true", choices=["true", "false"], - help='For Bazel or GN, don\'t embed data files in crypto_test_data.cc') options, args = parser.parse_args(sys.argv[1:]) PREFIX = options.prefix - EMBED_TEST_DATA = (options.embed_test_data == "true") if not args: parser.print_help() From 49b92bc1ffb5fde787b5e4cc53ceec0ab3b1b7a4 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 18 Mar 2024 23:36:59 +1000 Subject: [PATCH 2/2] Specify public headers in build.json The CMake build doesn't use it, but this will be needed for the other builds to be driven by util/pregenerate. Bug: 542 Change-Id: If95cbcef1803e30ffc5ab7c9227fdcc6c53adf34 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67296 Commit-Queue: David Benjamin Reviewed-by: Bob Beck --- build.json | 97 ++++++++++++++++++++++++++++++++ gen/sources.cmake | 106 +++++++++++++++++++++++++++++++++++ gen/sources.json | 97 ++++++++++++++++++++++++++++++++ util/generate_build_files.py | 27 +-------- 4 files changed, 303 insertions(+), 24 deletions(-) diff --git a/build.json b/build.json index 0463e88b1..8003b5847 100644 --- a/build.json +++ b/build.json @@ -69,6 +69,92 @@ ] }, "crypto": { + "hdrs": [ + "include/openssl/aead.h", + "include/openssl/aes.h", + "include/openssl/arm_arch.h", + "include/openssl/asm_base.h", + "include/openssl/asn1.h", + "include/openssl/asn1_mac.h", + "include/openssl/asn1t.h", + "include/openssl/base.h", + "include/openssl/base64.h", + "include/openssl/bio.h", + "include/openssl/blake2.h", + "include/openssl/blowfish.h", + "include/openssl/bn.h", + "include/openssl/buf.h", + "include/openssl/buffer.h", + "include/openssl/bytestring.h", + "include/openssl/cast.h", + "include/openssl/chacha.h", + "include/openssl/cipher.h", + "include/openssl/cmac.h", + "include/openssl/conf.h", + "include/openssl/cpu.h", + "include/openssl/crypto.h", + "include/openssl/ctrdrbg.h", + "include/openssl/curve25519.h", + "include/openssl/des.h", + "include/openssl/dh.h", + "include/openssl/digest.h", + "include/openssl/dsa.h", + "include/openssl/e_os2.h", + "include/openssl/ec.h", + "include/openssl/ec_key.h", + "include/openssl/ecdh.h", + "include/openssl/ecdsa.h", + "include/openssl/engine.h", + "include/openssl/err.h", + "include/openssl/evp.h", + "include/openssl/evp_errors.h", + "include/openssl/ex_data.h", + "include/openssl/experimental/kyber.h", + "include/openssl/experimental/spx.h", + "include/openssl/hkdf.h", + "include/openssl/hmac.h", + "include/openssl/hpke.h", + "include/openssl/hrss.h", + "include/openssl/is_boringssl.h", + "include/openssl/kdf.h", + "include/openssl/lhash.h", + "include/openssl/md4.h", + "include/openssl/md5.h", + "include/openssl/mem.h", + "include/openssl/nid.h", + "include/openssl/obj.h", + "include/openssl/obj_mac.h", + "include/openssl/objects.h", + "include/openssl/opensslconf.h", + "include/openssl/opensslv.h", + "include/openssl/ossl_typ.h", + "include/openssl/pem.h", + "include/openssl/pkcs12.h", + "include/openssl/pkcs7.h", + "include/openssl/pkcs8.h", + "include/openssl/poly1305.h", + "include/openssl/pool.h", + "include/openssl/posix_time.h", + "include/openssl/rand.h", + "include/openssl/rc4.h", + "include/openssl/ripemd.h", + "include/openssl/rsa.h", + "include/openssl/safestack.h", + "include/openssl/service_indicator.h", + "include/openssl/sha.h", + "include/openssl/siphash.h", + "include/openssl/span.h", + "include/openssl/stack.h", + "include/openssl/target.h", + "include/openssl/thread.h", + "include/openssl/time.h", + "include/openssl/trust_token.h", + "include/openssl/type_check.h", + "include/openssl/x509.h", + "include/openssl/x509_vfy.h", + "include/openssl/x509v3.h", + "include/openssl/x509v3_errors.h" + ], "err_data": [ "crypto/err/*.errordata" ], @@ -133,6 +219,10 @@ "pki/verify_error.cc", "pki/verify_name_match.cc", "pki/verify_signed_data.cc" + ], + "hdrs": [ + "include/openssl/pki/certificate.h", + "include/openssl/pki/signature_verify_cache.h" ] }, "ssl": { @@ -175,6 +265,13 @@ "ssl/tls13_client.cc", "ssl/tls13_enc.cc", "ssl/tls13_server.cc" + ], + "hdrs": [ + "include/openssl/dtls1.h", + "include/openssl/srtp.h", + "include/openssl/ssl.h", + "include/openssl/ssl3.h", + "include/openssl/tls1.h" ] }, "decrepit": { diff --git a/gen/sources.cmake b/gen/sources.cmake index e88cb2441..efa91d448 100644 --- a/gen/sources.cmake +++ b/gen/sources.cmake @@ -175,6 +175,95 @@ set( gen/crypto/err_data.c ) +set( + CRYPTO_HEADERS + + include/openssl/aead.h + include/openssl/aes.h + include/openssl/arm_arch.h + include/openssl/asm_base.h + include/openssl/asn1.h + include/openssl/asn1_mac.h + include/openssl/asn1t.h + include/openssl/base.h + include/openssl/base64.h + include/openssl/bio.h + include/openssl/blake2.h + include/openssl/blowfish.h + include/openssl/bn.h + include/openssl/buf.h + include/openssl/buffer.h + include/openssl/bytestring.h + include/openssl/cast.h + include/openssl/chacha.h + include/openssl/cipher.h + include/openssl/cmac.h + include/openssl/conf.h + include/openssl/cpu.h + include/openssl/crypto.h + include/openssl/ctrdrbg.h + include/openssl/curve25519.h + include/openssl/des.h + include/openssl/dh.h + include/openssl/digest.h + include/openssl/dsa.h + include/openssl/e_os2.h + include/openssl/ec.h + include/openssl/ec_key.h + include/openssl/ecdh.h + include/openssl/ecdsa.h + include/openssl/engine.h + include/openssl/err.h + include/openssl/evp.h + include/openssl/evp_errors.h + include/openssl/ex_data.h + include/openssl/experimental/kyber.h + include/openssl/experimental/spx.h + include/openssl/hkdf.h + include/openssl/hmac.h + include/openssl/hpke.h + include/openssl/hrss.h + include/openssl/is_boringssl.h + include/openssl/kdf.h + include/openssl/lhash.h + include/openssl/md4.h + include/openssl/md5.h + include/openssl/mem.h + include/openssl/nid.h + include/openssl/obj.h + include/openssl/obj_mac.h + include/openssl/objects.h + include/openssl/opensslconf.h + include/openssl/opensslv.h + include/openssl/ossl_typ.h + include/openssl/pem.h + include/openssl/pkcs12.h + include/openssl/pkcs7.h + include/openssl/pkcs8.h + include/openssl/poly1305.h + include/openssl/pool.h + include/openssl/posix_time.h + include/openssl/rand.h + include/openssl/rc4.h + include/openssl/ripemd.h + include/openssl/rsa.h + include/openssl/safestack.h + include/openssl/service_indicator.h + include/openssl/sha.h + include/openssl/siphash.h + include/openssl/span.h + include/openssl/stack.h + include/openssl/target.h + include/openssl/thread.h + include/openssl/time.h + include/openssl/trust_token.h + include/openssl/type_check.h + include/openssl/x509.h + include/openssl/x509_vfy.h + include/openssl/x509v3.h + include/openssl/x509v3_errors.h +) + set( CRYPTO_SOURCES_ASM @@ -602,6 +691,13 @@ set( pki/verify_signed_data.cc ) +set( + PKI_HEADERS + + include/openssl/pki/certificate.h + include/openssl/pki/signature_verify_cache.h +) + set( PKI_TEST_SOURCES @@ -2085,6 +2181,16 @@ set( ssl/tls_record.cc ) +set( + SSL_HEADERS + + include/openssl/dtls1.h + include/openssl/srtp.h + include/openssl/ssl.h + include/openssl/ssl3.h + include/openssl/tls1.h +) + set( SSL_TEST_SOURCES diff --git a/gen/sources.json b/gen/sources.json index d00a91067..9c5f31879 100644 --- a/gen/sources.json +++ b/gen/sources.json @@ -153,6 +153,92 @@ "srcs": [ "gen/crypto/err_data.c" ], + "hdrs": [ + "include/openssl/aead.h", + "include/openssl/aes.h", + "include/openssl/arm_arch.h", + "include/openssl/asm_base.h", + "include/openssl/asn1.h", + "include/openssl/asn1_mac.h", + "include/openssl/asn1t.h", + "include/openssl/base.h", + "include/openssl/base64.h", + "include/openssl/bio.h", + "include/openssl/blake2.h", + "include/openssl/blowfish.h", + "include/openssl/bn.h", + "include/openssl/buf.h", + "include/openssl/buffer.h", + "include/openssl/bytestring.h", + "include/openssl/cast.h", + "include/openssl/chacha.h", + "include/openssl/cipher.h", + "include/openssl/cmac.h", + "include/openssl/conf.h", + "include/openssl/cpu.h", + "include/openssl/crypto.h", + "include/openssl/ctrdrbg.h", + "include/openssl/curve25519.h", + "include/openssl/des.h", + "include/openssl/dh.h", + "include/openssl/digest.h", + "include/openssl/dsa.h", + "include/openssl/e_os2.h", + "include/openssl/ec.h", + "include/openssl/ec_key.h", + "include/openssl/ecdh.h", + "include/openssl/ecdsa.h", + "include/openssl/engine.h", + "include/openssl/err.h", + "include/openssl/evp.h", + "include/openssl/evp_errors.h", + "include/openssl/ex_data.h", + "include/openssl/experimental/kyber.h", + "include/openssl/experimental/spx.h", + "include/openssl/hkdf.h", + "include/openssl/hmac.h", + "include/openssl/hpke.h", + "include/openssl/hrss.h", + "include/openssl/is_boringssl.h", + "include/openssl/kdf.h", + "include/openssl/lhash.h", + "include/openssl/md4.h", + "include/openssl/md5.h", + "include/openssl/mem.h", + "include/openssl/nid.h", + "include/openssl/obj.h", + "include/openssl/obj_mac.h", + "include/openssl/objects.h", + "include/openssl/opensslconf.h", + "include/openssl/opensslv.h", + "include/openssl/ossl_typ.h", + "include/openssl/pem.h", + "include/openssl/pkcs12.h", + "include/openssl/pkcs7.h", + "include/openssl/pkcs8.h", + "include/openssl/poly1305.h", + "include/openssl/pool.h", + "include/openssl/posix_time.h", + "include/openssl/rand.h", + "include/openssl/rc4.h", + "include/openssl/ripemd.h", + "include/openssl/rsa.h", + "include/openssl/safestack.h", + "include/openssl/service_indicator.h", + "include/openssl/sha.h", + "include/openssl/siphash.h", + "include/openssl/span.h", + "include/openssl/stack.h", + "include/openssl/target.h", + "include/openssl/thread.h", + "include/openssl/time.h", + "include/openssl/trust_token.h", + "include/openssl/type_check.h", + "include/openssl/x509.h", + "include/openssl/x509_vfy.h", + "include/openssl/x509v3.h", + "include/openssl/x509v3_errors.h" + ], "asm": [ "crypto/curve25519/asm/x25519-asm-arm.S", "crypto/hrss/asm/poly_rq_mul.S", @@ -566,6 +652,10 @@ "pki/verify_error.cc", "pki/verify_name_match.cc", "pki/verify_signed_data.cc" + ], + "hdrs": [ + "include/openssl/pki/certificate.h", + "include/openssl/pki/signature_verify_cache.h" ] }, "pki_test": { @@ -2044,6 +2134,13 @@ "ssl/tls13_server.cc", "ssl/tls_method.cc", "ssl/tls_record.cc" + ], + "hdrs": [ + "include/openssl/dtls1.h", + "include/openssl/srtp.h", + "include/openssl/ssl.h", + "include/openssl/ssl3.h", + "include/openssl/tls1.h" ] }, "ssl_test": { diff --git a/util/generate_build_files.py b/util/generate_build_files.py index a54a614e1..c56cd2eaf 100644 --- a/util/generate_build_files.py +++ b/util/generate_build_files.py @@ -564,18 +564,6 @@ def NoTestRunnerFiles(path, dent, is_dir): return not is_dir or dent != 'runner' -def SSLHeaderFiles(path, dent, is_dir): - return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h', 'srtp.h'] - - -def CryptoHeaderFiles(path, dent, is_dir): - if SSLHeaderFiles(path, dent, is_dir): - return False - if is_dir and dent == 'pki': - return False - return True - - def FindCFiles(directory, filter_func): """Recurses through directory and returns a list of paths to all the C source files that pass filter_func.""" @@ -661,16 +649,7 @@ def main(platforms): fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests) - ssl_h_files = FindHeaderFiles(os.path.join('src', 'include', 'openssl'), - SSLHeaderFiles) - pki_internal_h_files = FindHeaderFiles(os.path.join('src', 'pki'), AllFiles) - - crypto_h_files = FindHeaderFiles(os.path.join('src', 'include', 'openssl'), - CryptoHeaderFiles) - pki_h_files = FindHeaderFiles( - os.path.join('src', 'include', 'openssl', 'pki'), AllFiles) - ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests) crypto_internal_h_files = ( FindHeaderFiles(os.path.join('src', 'crypto'), NoTests) + @@ -689,21 +668,21 @@ def main(platforms): 'crypto': crypto_c_files, 'crypto_asm': PrefixWithSrc(crypto_asm), 'crypto_nasm': PrefixWithSrc(crypto_nasm), - 'crypto_headers': crypto_h_files, + 'crypto_headers': PrefixWithSrc(sources['crypto']['hdrs']), 'crypto_internal_headers': crypto_internal_h_files, 'crypto_test': PrefixWithSrc(sources['crypto_test']['srcs']), 'crypto_test_data': PrefixWithSrc(sources['crypto_test']['data']), 'fips_fragments': fips_fragments, 'fuzz': fuzz_c_files, 'pki': PrefixWithSrc(sources['pki']['srcs']), - 'pki_headers': pki_h_files, + 'pki_headers': PrefixWithSrc(sources['pki']['hdrs']), 'pki_internal_headers': sorted(list(pki_internal_h_files)), 'pki_test': PrefixWithSrc(sources['pki_test']['srcs']), 'pki_test_data': PrefixWithSrc(sources['pki_test']['data']), 'rust_bssl_crypto': bssl_crypto_files, 'rust_bssl_sys': bssl_sys_files, 'ssl': PrefixWithSrc(sources['ssl']['srcs']), - 'ssl_headers': ssl_h_files, + 'ssl_headers': PrefixWithSrc(sources['ssl']['hdrs']), 'ssl_internal_headers': ssl_internal_h_files, 'ssl_test': PrefixWithSrc(sources['ssl_test']['srcs']), 'tool': PrefixWithSrc(sources['bssl']['srcs']),