diff --git a/buck2 b/buck2 new file mode 100755 index 00000000000..123c0ac4f13 --- /dev/null +++ b/buck2 @@ -0,0 +1,67 @@ +#!/usr/bin/env dotslash + +{ + "name": "buck2", + "platforms": { + "macos-aarch64": { + "size": 23110012, + "hash": "blake3", + "digest": "2e534798cfa67c02357b9edc410ea0b65984af42aecab22f077f8b8b69b635ed", + "format": "zst", + "path": "buck2-aarch64-apple-darwin", + "providers": [ + { + "url": "https://github.com/facebook/buck2/releases/download/2024-04-15/buck2-aarch64-apple-darwin.zst" + } + ] + }, + "linux-aarch64": { + "size": 25625575, + "hash": "blake3", + "digest": "9b87f3af61a3aeaa78051c780c7c2ed5a19d5bffdabd2386a7a5925af3da9069", + "format": "zst", + "path": "buck2-aarch64-unknown-linux-musl", + "providers": [ + { + "url": "https://github.com/facebook/buck2/releases/download/2024-04-15/buck2-aarch64-unknown-linux-musl.zst" + } + ] + }, + "macos-x86_64": { + "size": 25044637, + "hash": "blake3", + "digest": "aaf132b70d317c7e3e8573de5f73783c8325a96badd539805bf56dcaf0e0a285", + "format": "zst", + "path": "buck2-x86_64-apple-darwin", + "providers": [ + { + "url": "https://github.com/facebook/buck2/releases/download/2024-04-15/buck2-x86_64-apple-darwin.zst" + } + ] + }, + "windows-x86_64": { + "size": 20557271, + "hash": "blake3", + "digest": "a750d714cedca0369f62ae3e6c6cd3bf6d8c65f2f79d53f5dce10e27fcc1c9a5", + "format": "zst", + "path": "buck2-x86_64-pc-windows-msvc.exe", + "providers": [ + { + "url": "https://github.com/facebook/buck2/releases/download/2024-04-15/buck2-x86_64-pc-windows-msvc.exe.zst" + } + ] + }, + "linux-x86_64": { + "size": 26368190, + "hash": "blake3", + "digest": "486cb1458f356863331cdeacb2491afb60e3d78e4fda33adb4112dfca7dc63dd", + "format": "zst", + "path": "buck2-x86_64-unknown-linux-musl", + "providers": [ + { + "url": "https://github.com/facebook/buck2/releases/download/2024-04-15/buck2-x86_64-unknown-linux-musl.zst" + } + ] + } + } +} diff --git a/fizz/BUCK b/fizz/BUCK new file mode 100644 index 00000000000..762de8a9f43 --- /dev/null +++ b/fizz/BUCK @@ -0,0 +1,11 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "config", + headers = select({ + "DEFAULT": {"fizz-config.h": "facebook/fizz-config-fbcode.h"}, + "ovr_config//toolchain/fb:arista": {"fizz-config.h": "facebook/fizz-config-xplat.h"}, + }), +) diff --git a/fizz/BUILD_MODE.bzl b/fizz/BUILD_MODE.bzl new file mode 100644 index 00000000000..0bc150dfe53 --- /dev/null +++ b/fizz/BUILD_MODE.bzl @@ -0,0 +1,36 @@ +""" build mode definitions for fizz """ + +load("@fbcode//:BUILD_MODE.bzl", get_parent_modes = "get_empty_modes") +load("@fbcode//fizz:defs.bzl", "FIZZ_CXX_WARNINGS") +load("@fbcode_macros//build_defs:create_build_mode.bzl", "extend_build_modes") + +_extra_cflags = [ +] + +_common_flags = FIZZ_CXX_WARNINGS + +_extra_clang_flags = _common_flags + [ + # Default value for clang (3.4) is 256, change it to GCC's default value + # (https://fburl.com/23278774). + "-ftemplate-depth=900", +] + +_extra_gcc_flags = _common_flags + [ + "-Wall", +] + +_tags = [ +] + +_modes = extend_build_modes( + get_parent_modes(), + c_flags = _extra_cflags, + clang_flags = _extra_clang_flags, + cxx_modular_headers = True, + gcc_flags = _extra_gcc_flags, + tags = _tags, +) + +def get_modes(): + """ Return modes for this file """ + return _modes diff --git a/fizz/backend/BUCK b/fizz/backend/BUCK new file mode 100644 index 00000000000..39d3b8206f5 --- /dev/null +++ b/fizz/backend/BUCK @@ -0,0 +1,59 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "openssl", + srcs = glob([ + "openssl/*.cpp", + "openssl/certificate/*.cpp", + "openssl/crypto/*.cpp", + "openssl/crypto/aead/*.cpp", + "openssl/crypto/exchange/*.cpp", + "openssl/crypto/signature/*.cpp", + ]), + headers = glob([ + "kex.h", + "openssl/*.h", + "openssl/certificate/*.h", + "openssl/crypto/*.h", + "openssl/crypto/aead/*.h", + "openssl/crypto/exchange/*.h", + "openssl/crypto/signature/*.h", + ]), + deps = [ + "//fizz/crypto/aead:aegiscipher", + "//fizz/crypto/aead:cryptoutil", + "//fizz/crypto/exchange:hybrid_exchange", + "//fizz/experimental/crypto/exchange:oqs_key_exchange", + "//folly:scope_guard", + "//folly/lang:checked_math", + ], + exported_deps = [ + "//fizz:config", + "//fizz/compression:certificate_compressor", + "//fizz/crypto/aead:aead", + "//fizz/crypto/aead:iobuf", + "//fizz/crypto/exchange:key_exchange", + "//fizz/crypto/exchange:x25519", + "//fizz/protocol:certificate", + "//fizz/protocol:default_factory", + "//fizz/record:record", + "//folly:conv", + "//folly:memory", + "//folly:range", + "//folly:string", + "//folly/io:iobuf", + "//folly/io/async/ssl:openssl_transport_certificate", + "//folly/lang:assume", + "//folly/lang:bits", + "//folly/portability:openssl", + "//folly/ssl:openssl_cert_utils", + "//folly/ssl:openssl_hash", + "//folly/ssl:openssl_ptr_types", + ], + exported_external_deps = [ + "glog", + ("openssl", None, "crypto"), + ], +) diff --git a/fizz/backend/openssl/crypto/aead/test/BUCK b/fizz/backend/openssl/crypto/aead/test/BUCK new file mode 100644 index 00000000000..9e068de3cf4 --- /dev/null +++ b/fizz/backend/openssl/crypto/aead/test/BUCK @@ -0,0 +1,22 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "evpciphers", + srcs = [ + "EVPCipherTest.cpp", + ], + supports_static_listing = False, + deps = [ + "//fizz:config", + "//fizz/backend:openssl", + "//fizz/crypto/aead:iobuf", + "//fizz/crypto/aead/test:test_util", + "//fizz/crypto/test:TestUtil", + "//fizz/record:record", + "//folly:exception_wrapper", + "//folly:string", + "//folly/portability:gtest", + ], +) diff --git a/fizz/backend/openssl/crypto/exchange/test/BUCK b/fizz/backend/openssl/crypto/exchange/test/BUCK new file mode 100644 index 00000000000..e398358839d --- /dev/null +++ b/fizz/backend/openssl/crypto/exchange/test/BUCK @@ -0,0 +1,21 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "ECKey", + srcs = [ + "ECKeyExchangeTest.cpp", + ], + supports_static_listing = False, + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//folly:string", + "//folly/portability:gtest", + "//folly/ssl:openssl_ptr_types", + ], + external_deps = [ + ("openssl", None, "crypto"), + ], +) diff --git a/fizz/backend/openssl/crypto/signature/test/BUCK b/fizz/backend/openssl/crypto/signature/test/BUCK new file mode 100644 index 00000000000..c60cf98758e --- /dev/null +++ b/fizz/backend/openssl/crypto/signature/test/BUCK @@ -0,0 +1,45 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "ec", + srcs = [ + "ECSignatureTest.cpp", + ], + supports_static_listing = False, + deps = [ + "//fizz/backend:openssl", + "//folly:string", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "ed", + srcs = [ + "EdSignatureTest.cpp", + ], + headers = [ + "EdSignatureTest.h", + ], + supports_static_listing = False, + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//folly:fixed_string", + "//folly:string", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "rsa_pss", + srcs = [ + "RSAPSSSignatureTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//folly/portability:gtest", + ], +) diff --git a/fizz/backend/openssl/crypto/test/BUCK b/fizz/backend/openssl/crypto/test/BUCK new file mode 100644 index 00000000000..fe2aa2f2e60 --- /dev/null +++ b/fizz/backend/openssl/crypto/test/BUCK @@ -0,0 +1,16 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "key_utils", + srcs = [ + "OpenSSLKeyUtilsTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//folly:string", + "//folly/portability:gtest", + ], +) diff --git a/fizz/client/BUCK b/fizz/client/BUCK new file mode 100644 index 00000000000..96bba9074a3 --- /dev/null +++ b/fizz/client/BUCK @@ -0,0 +1,210 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "fizz_client_context", + srcs = ["FizzClientContext.cpp"], + headers = [ + "FizzClientContext.h", + ], + deps = [ + "//fizz/backend:openssl", + ], + exported_deps = [ + ":ech_policy", + ":psk_cache", + "//fizz/compression:cert_decompression_manager", + "//fizz/protocol:certificate", + "//fizz/protocol:factory", + "//fizz/protocol/clock:system_clock", + "//fizz/record:record", + ], +) + +cpp_library( + name = "actions", + headers = [ + "Actions.h", + ], + exported_deps = [ + ":psk_cache", + "//fizz/protocol:actions", + "//fizz/protocol:params", + "//fizz/util:variant", + "//folly:c_portability", + ], +) + +cpp_library( + name = "state", + srcs = [ + "State.cpp", + ], + headers = [ + "State.h", + ], + exported_deps = [ + ":client_extensions", + ":fizz_client_context", + "//fizz/protocol:certificate", + "//fizz/protocol:key_scheduler", + "//fizz/protocol:types", + "//fizz/protocol/ech:encryption", + "//fizz/record:record_layer", + ], +) + +cpp_library( + name = "protocol", + srcs = [ + "ClientProtocol.cpp", + ], + headers = [ + "ClientProtocol.h", + ], + deps = [ + "//fizz/crypto:utils", + "//fizz/crypto/hpke:utils", + "//fizz/protocol:certificate_verifier", + "//fizz/protocol:protocol", + "//fizz/protocol:state_machine", + "//fizz/protocol/ech:encryption", + "//fizz/record:record", + ], + exported_deps = [ + ":actions", + ":client_extensions", + ":fizz_client_context", + ":psk_cache", + ":state", + "//fizz/protocol/ech:encrypted_client_hello", + ], +) + +cpp_library( + name = "early_data_rejection", + srcs = [ + "EarlyDataRejectionPolicy.cpp", + ], + headers = [ + "EarlyDataRejectionPolicy.h", + ], + exported_deps = [ + ":state", + ], +) + +cpp_library( + name = "fizz_client", + headers = [ + "FizzClient.h", + "FizzClient-inl.h", + ], + exported_deps = [ + ":fizz_client_context", + ":protocol", + ":psk_cache", + "//fizz/protocol:default_certificate_verifier", + "//fizz/protocol:fizz_base", + ], +) + +cpp_library( + name = "async_fizz_client", + headers = [ + "AsyncFizzClient.h", + "AsyncFizzClient-inl.h", + ], + exported_deps = [ + ":client_extensions", + ":early_data_rejection", + ":fizz_client", + ":fizz_client_context", + ":protocol", + "//fizz/protocol:async_fizz_base", + "//fizz/protocol:exporter", + "//fizz/util:tracer", + "//folly/io:socket_option_map", + ], +) + +cpp_library( + name = "psk_cache", + headers = [ + "PskCache.h", + ], + exported_deps = [ + "//fizz/protocol:certificate", + "//fizz/protocol:types", + "//fizz/record:record", + ], +) + +cpp_library( + name = "ech_policy", + headers = [ + "ECHPolicy.h", + ], + exported_deps = [ + "//fizz/protocol/ech:encrypted_client_hello", + "//folly:optional", + ], +) + +cpp_library( + name = "psk_serialization_utils", + srcs = [ + "PskSerializationUtils.cpp", + ], + headers = [ + "PskSerializationUtils.h", + ], + deps = [ + "//fizz/record:record", + "//folly/io/async/ssl:openssl_transport_certificate", + "//folly/ssl:openssl_cert_utils", + ], + exported_deps = [ + ":psk_cache", + "//fizz/protocol:factory", + ], +) + +cpp_library( + name = "synchronized_lru_psk_cache", + srcs = [ + "SynchronizedLruPskCache.cpp", + ], + headers = [ + "SynchronizedLruPskCache.h", + ], + exported_deps = [ + ":psk_cache", + "//folly:synchronized", + "//folly/container:evicting_cache_map", + ], +) + +cpp_library( + name = "client_extensions", + headers = [ + "ClientExtensions.h", + ], + exported_deps = [ + "//fizz/record:record", + ], +) + +cpp_library( + name = "multi_client_extensions", + srcs = [ + "MultiClientExtensions.cpp", + ], + headers = [ + "MultiClientExtensions.h", + ], + exported_deps = [ + ":client_extensions", + ], +) diff --git a/fizz/client/test/BUCK b/fizz/client/test/BUCK new file mode 100644 index 00000000000..c4214a7c799 --- /dev/null +++ b/fizz/client/test/BUCK @@ -0,0 +1,125 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "client_protocol_test", + srcs = [ + "ClientProtocolTest.cpp", + ], + deps = [ + ":mocks", + ":utilities", + "//fizz/client:fizz_client_context", + "//fizz/client:protocol", + "//fizz/compression/test:mocks", + "//fizz/crypto/hpke:utils", + "//fizz/crypto/hpke/test:mocks", + "//fizz/protocol/clock/test:mock_clock", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/protocol/ech/test:test_util", + "//fizz/protocol/test:matchers", + "//fizz/protocol/test:protocol_test", + "//fizz/protocol/test:test_messages", + "//fizz/record/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/client:async_fizz_client", + "//fizz/client:client_extensions", + "//fizz/client:ech_policy", + "//fizz/client:psk_cache", + "//folly/io/async/test:mocks", + ], +) + +cpp_library( + name = "utilities", + headers = [ + "Utilities.h", + ], + exported_deps = [ + "//fizz/client:psk_cache", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "fizz_client_test", + srcs = [ + "FizzClientTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/client:fizz_client", + "//fizz/client:psk_cache", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "async_fizz_client_test", + srcs = [ + "AsyncFizzClientTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/client:async_fizz_client", + "//fizz/protocol/test:mocks", + "//folly/io:socket_option_map", + "//folly/io/async/test:async_socket_test_lib", + "//folly/io/async/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "synchronized_lru_psk_cache_test", + srcs = [ + "SynchronizedLruPskCacheTest.cpp", + ], + deps = [ + ":utilities", + "//fizz/client:synchronized_lru_psk_cache", + "//folly:format", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "psk_serialization_test", + srcs = [ + "PskSerializationTest.cpp", + ], + deps = [ + ":utilities", + "//fizz/client:psk_serialization_utils", + "//fizz/protocol/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "multi_client_extensions_test", + srcs = [ + "MultiClientExtensionsTest.cpp", + ], + deps = [ + "//fizz/client:multi_client_extensions", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/compression/BUCK b/fizz/compression/BUCK new file mode 100644 index 00000000000..170f9561abb --- /dev/null +++ b/fizz/compression/BUCK @@ -0,0 +1,122 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "certificate_compressor", + headers = [ + "CertificateCompressor.h", + ], + exported_deps = [ + "//fizz/record:record", + ], +) + +cpp_library( + name = "cert_decompression_manager", + srcs = [ + "CertDecompressionManager.cpp", + ], + headers = [ + "CertDecompressionManager.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], +) + +cpp_library( + name = "brotli_certificate_compressor", + srcs = [ + "BrotliCertificateCompressor.cpp", + ], + headers = [ + "BrotliCertificateCompressor.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], + external_deps = [ + ("brotli", None, "brotlienc"), + ], +) + +cpp_library( + name = "brotli_certificate_decompressor", + srcs = [ + "BrotliCertificateDecompressor.cpp", + ], + headers = [ + "BrotliCertificateDecompressor.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], + external_deps = [ + ("brotli", None, "brotlidec"), + ], +) + +cpp_library( + name = "zlib_certificate_compressor", + srcs = [ + "ZlibCertificateCompressor.cpp", + ], + headers = [ + "ZlibCertificateCompressor.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], + exported_external_deps = [ + ("zlib", None, "z"), + ], +) + +cpp_library( + name = "zlib_certificate_decompressor", + srcs = [ + "ZlibCertificateDecompressor.cpp", + ], + headers = [ + "ZlibCertificateDecompressor.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], + exported_external_deps = [ + ("zlib", None, "z"), + ], +) + +cpp_library( + name = "zstd_certificate_compressor", + srcs = [ + "ZstdCertificateCompressor.cpp", + ], + headers = [ + "ZstdCertificateCompressor.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], + external_deps = [ + "zstd", + ], +) + +cpp_library( + name = "zstd_certificate_decompressor", + srcs = [ + "ZstdCertificateDecompressor.cpp", + ], + headers = [ + "ZstdCertificateDecompressor.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + ], + external_deps = [ + "zstd", + ], +) diff --git a/fizz/compression/test/BUCK b/fizz/compression/test/BUCK new file mode 100644 index 00000000000..123ab62285a --- /dev/null +++ b/fizz/compression/test/BUCK @@ -0,0 +1,74 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/compression:certificate_compressor", + "//folly/portability:gmock", + ], +) + +cpp_unittest( + name = "cert_decompression_manager_test", + srcs = [ + "CertDecompressionManagerTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/compression:cert_decompression_manager", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "brotli_certificate_compressor_test", + srcs = [ + "BrotliCertificateCompressorTest.cpp", + ], + deps = [ + "//fizz/compression:brotli_certificate_compressor", + "//fizz/compression:brotli_certificate_decompressor", + "//fizz/crypto:utils", + "//fizz/protocol/test:matchers", + "//fizz/protocol/test:utilities", + "//fizz/record:record", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "zlib_certificate_compressor_test", + srcs = [ + "ZlibCertificateCompressorTest.cpp", + ], + deps = [ + "//fizz/compression:zlib_certificate_compressor", + "//fizz/compression:zlib_certificate_decompressor", + "//fizz/protocol/test:matchers", + "//fizz/protocol/test:utilities", + "//fizz/record:record", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "zstd_certificate_compressor_test", + srcs = [ + "ZstdCertificateCompressorTest.cpp", + ], + deps = [ + "//fizz/compression:zstd_certificate_compressor", + "//fizz/compression:zstd_certificate_decompressor", + "//fizz/crypto:utils", + "//fizz/protocol/test:matchers", + "//fizz/protocol/test:utilities", + "//fizz/record:record", + "//folly/portability:gtest", + ], +) diff --git a/fizz/config/BUCK b/fizz/config/BUCK new file mode 100644 index 00000000000..733faa1677f --- /dev/null +++ b/fizz/config/BUCK @@ -0,0 +1,2 @@ +# For now, this file needs to exist for fbcode-target-determinator to work. +# See: https://fb.workplace.com/groups/td.users/permalink/3290301304599199/ diff --git a/fizz/constraints/BUCK b/fizz/constraints/BUCK new file mode 100644 index 00000000000..733faa1677f --- /dev/null +++ b/fizz/constraints/BUCK @@ -0,0 +1,2 @@ +# For now, this file needs to exist for fbcode-target-determinator to work. +# See: https://fb.workplace.com/groups/td.users/permalink/3290301304599199/ diff --git a/fizz/crypto/BUCK b/fizz/crypto/BUCK new file mode 100644 index 00000000000..740e1332d7b --- /dev/null +++ b/fizz/crypto/BUCK @@ -0,0 +1,112 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "sha", + headers = [ + "Sha.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + ], +) + +cpp_library( + name = "hmac_sha256", + headers = [ + "Sha256.h", + ], + exported_deps = [ + ":sha", + "//fizz/backend:openssl", + ], +) + +cpp_library( + name = "hmac_sha384", + headers = [ + "Sha384.h", + ], + exported_deps = [ + ":sha", + "//fizz/backend:openssl", + ], +) + +cpp_library( + name = "hmac_sha512", + headers = [ + "Sha512.h", + ], + exported_deps = [ + ":sha", + "//fizz/backend:openssl", + ], +) + +cpp_library( + name = "asymmetric", + headers = [ + "ECCurve.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + ], +) + +cpp_library( + name = "hkdf", + srcs = [ + "Hkdf.cpp", + ], + headers = [ + "Hkdf.h", + ], + exported_deps = [ + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "key_derivation", + srcs = [ + "KeyDerivation.cpp", + ], + headers = [ + "KeyDerivation.h", + ], + exported_deps = [ + ":hkdf", + "//fizz/record:record", + ], +) + +cpp_library( + name = "random", + headers = [ + "RandomGenerator.h", + ], + exported_deps = [ + "//folly/io:iobuf", + ], + exported_external_deps = [ + ("libsodium", None, "sodium"), + ], +) + +cpp_library( + name = "utils", + srcs = [ + "Utils.cpp", + ], + headers = [ + "Utils.h", + ], + exported_deps = [ + "//folly:range", + ], + external_deps = [ + ("libsodium", None, "sodium"), + ], +) diff --git a/fizz/crypto/aead/BUCK b/fizz/crypto/aead/BUCK new file mode 100644 index 00000000000..83ff60a0ff2 --- /dev/null +++ b/fizz/crypto/aead/BUCK @@ -0,0 +1,77 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "aead", + headers = [ + "Aead.h", + ], + exported_deps = [ + "//folly:optional", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "iobuf", + srcs = [ + "IOBufUtil.cpp", + ], + headers = [ + "IOBufUtil.h", + ], + exported_deps = [ + "//folly:range", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "cryptoutil", + headers = [ + "CryptoUtil.h", + ], + exported_deps = [ + ":aead", + ":iobuf", + "//folly:conv", + "//folly:memory", + "//folly:range", + ], +) + +cpp_library( + name = "aegiscipher", + srcs = ["AEGISCipher.cpp"], + headers = [ + "AEGISCipher.h", + ], + deps = [ + ":cryptoutil", + "//fizz:config", + "//folly/lang:checked_math", + ] + select({ + "DEFAULT": [ + "fbsource//third-party/libaegis:aegis", + ], + "ovr_config//toolchain/fb:arista": [], + }), + exported_deps = [ + ":aead", + ], +) + +cpp_library( + name = "evpcipher", + headers = [ + "AESGCM128.h", + "AESGCM256.h", + "AESOCB128.h", + "ChaCha20Poly1305.h", + "OpenSSLEVPCipher.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + ], +) diff --git a/fizz/crypto/aead/test/BUCK b/fizz/crypto/aead/test/BUCK new file mode 100644 index 00000000000..e606e203d03 --- /dev/null +++ b/fizz/crypto/aead/test/BUCK @@ -0,0 +1,45 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/crypto/aead:aead", + "//folly/portability:gmock", + ], +) + +cpp_library( + name = "test_util", + srcs = [ + "TestUtil.cpp", + ], + headers = [ + "TestUtil.h", + ], + deps = [ + "//fizz/crypto/aead:iobuf", + ], + exported_deps = [ + "//folly:memory", + "//folly:string", + "//folly/io:iobuf", + ], +) + +cpp_unittest( + name = "util_test", + srcs = [ + "IOBufUtilTest.cpp", + ], + deps = [ + "//fizz/crypto/aead:iobuf", + "//folly/io:iobuf", + "//folly/portability:gtest", + ], +) diff --git a/fizz/crypto/aead/test/facebook/BUCK b/fizz/crypto/aead/test/facebook/BUCK new file mode 100644 index 00000000000..ed36b9aadbe --- /dev/null +++ b/fizz/crypto/aead/test/facebook/BUCK @@ -0,0 +1,63 @@ +load( + "@fbsource//xplat/security/lionhead:defs.bzl", + "EXTERNAL_USERS", + "Metadata", + "Severity", +) +load("//security/lionhead/harnesses:defs.bzl", "cpp_lionhead_harness") + +oncall("secure_pipes") + +cpp_lionhead_harness( + name = "fizz_aead_encrypt_fuzzer", + srcs = ["AeadFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("AeadFuzzer", "Encrypt"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/test:TestUtil", + ], +) + +cpp_lionhead_harness( + name = "fizz_aead_inplace_encrypt_fuzzer", + srcs = ["AeadFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("AeadFuzzer", "InplaceEncrypt"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/test:TestUtil", + ], +) + +cpp_lionhead_harness( + name = "fizz_aead_decrypt_fuzzer", + srcs = ["AeadFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("AeadFuzzer", "Decrypt"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/test:TestUtil", + ], +) diff --git a/fizz/crypto/exchange/BUCK b/fizz/crypto/exchange/BUCK new file mode 100644 index 00000000000..932993ae301 --- /dev/null +++ b/fizz/crypto/exchange/BUCK @@ -0,0 +1,75 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "exchange", + headers = [ + "ECCurveKeyExchange.h", + "OpenSSLKeyExchange.h", + ], + exported_deps = [ + ":key_exchange", + "//fizz/backend:openssl", + "//fizz/crypto:asymmetric", + "//fizz/crypto/openssl:openssl", + ], +) + +cpp_library( + name = "x25519", + srcs = [ + "X25519.cpp", + ], + headers = [ + "X25519.h", + ], + deps = [ + "//fizz/crypto:utils", + "//folly:conv", + ], + exported_deps = [ + ":key_exchange", + "//folly:optional", + "//folly:range", + "//folly/io:iobuf", + ], + external_deps = [ + ("libsodium", None, "sodium"), + ], +) + +cpp_library( + name = "key_exchange", + headers = [ + "KeyExchange.h", + ], + exported_deps = [ + "//folly:range", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "async_key_exchange", + headers = [ + "AsyncKeyExchange.h", + ], + exported_deps = [ + ":key_exchange", + "//folly/futures:core", + ], +) + +cpp_library( + name = "hybrid_exchange", + srcs = [ + "HybridKeyExchange.cpp", + ], + headers = [ + "HybridKeyExchange.h", + ], + exported_deps = [ + ":key_exchange", + ], +) diff --git a/fizz/crypto/exchange/test/BUCK b/fizz/crypto/exchange/test/BUCK new file mode 100644 index 00000000000..7bd74435a26 --- /dev/null +++ b/fizz/crypto/exchange/test/BUCK @@ -0,0 +1,41 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/crypto/exchange:async_key_exchange", + "//fizz/crypto/exchange:key_exchange", + "//folly/portability:gmock", + ], +) + +cpp_unittest( + name = "x25519", + srcs = [ + "X25519KeyExchangeTest.cpp", + ], + deps = [ + "//fizz/crypto/exchange:x25519", + "//folly:range", + "//folly:string", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "HybridExchange", + srcs = [ + "HybridKeyExchangeTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/crypto/exchange:hybrid_exchange", + "//folly/portability:gtest", + ], +) diff --git a/fizz/crypto/hpke/BUCK b/fizz/crypto/hpke/BUCK new file mode 100644 index 00000000000..7fee9263c8e --- /dev/null +++ b/fizz/crypto/hpke/BUCK @@ -0,0 +1,115 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "utils", + srcs = [ + "Utils.cpp", + ], + headers = [ + "Utils.h", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/exchange:x25519", + ], + exported_deps = [ + ":hkdf", + ":types", + "//fizz/crypto:hmac_sha256", + "//fizz/crypto:hmac_sha384", + "//fizz/crypto:hmac_sha512", + "//fizz/crypto/aead:aead", + "//fizz/crypto/aead:evpcipher", + "//fizz/crypto/exchange:exchange", + "//fizz/crypto/exchange:key_exchange", + "//fizz/protocol:types", + ], +) + +cpp_library( + name = "hkdf", + srcs = [ + "Hkdf.cpp", + ], + headers = [ + "Hkdf.h", + ], + deps = [ + "//fizz/record:record", + ], + exported_deps = [ + "//fizz/crypto:hkdf", + ], +) + +cpp_library( + name = "dhkem", + srcs = [ + "DHKEM.cpp", + ], + headers = [ + "DHKEM.h", + ], + deps = [ + "//folly/io:iobuf", + ], + exported_deps = [ + ":hkdf", + ":types", + "//fizz/backend:openssl", + "//fizz/crypto:asymmetric", + "//fizz/crypto/exchange:exchange", + "//fizz/crypto/exchange:key_exchange", + "//fizz/record:record", + ], +) + +cpp_library( + name = "types", + headers = [ + "Types.h", + ], + exported_deps = [ + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "context", + srcs = [ + "Context.cpp", + ], + headers = [ + "Context.h", + ], + deps = [ + ":utils", + ], + exported_deps = [ + ":hkdf", + ":types", + "//fizz/crypto/aead:aead", + "//fizz/crypto/aead:evpcipher", + "//fizz/protocol:types", + ], +) + +cpp_library( + name = "hpke", + srcs = [ + "Hpke.cpp", + ], + headers = [ + "Hpke.h", + ], + deps = [ + ":types", + ], + exported_deps = [ + ":context", + ":dhkem", + "//fizz/crypto/aead:aead", + ], +) diff --git a/fizz/crypto/hpke/test/BUCK b/fizz/crypto/hpke/test/BUCK new file mode 100644 index 00000000000..74dceea9a42 --- /dev/null +++ b/fizz/crypto/hpke/test/BUCK @@ -0,0 +1,64 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "dhkem_test", + srcs = [ + "DHKEMTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/exchange:key_exchange", + "//fizz/crypto/hpke:dhkem", + "//fizz/crypto/test:TestUtil", + "//fizz/record:record", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "context_test", + srcs = [ + "ContextTest.cpp", + ], + supports_static_listing = False, + deps = [ + ":mocks", + "//fizz/backend:openssl", + "//fizz/crypto/aead/test:test_util", + "//fizz/crypto/hpke:context", + "//fizz/crypto/hpke:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/protocol:types", + "//fizz/record:record", + ], +) + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/crypto/aead:aead", + "//fizz/crypto/exchange:x25519", + "//fizz/crypto/hpke:context", + "//folly/portability:gmock", + ], +) + +cpp_unittest( + name = "hpke_test", + srcs = [ + "HpkeTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/backend:openssl", + "//fizz/crypto/hpke:hpke", + "//fizz/crypto/hpke:utils", + "//fizz/crypto/test:TestUtil", + ], +) diff --git a/fizz/crypto/openssl/BUCK b/fizz/crypto/openssl/BUCK new file mode 100644 index 00000000000..cc2dfab8dd9 --- /dev/null +++ b/fizz/crypto/openssl/BUCK @@ -0,0 +1,16 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "openssl", + srcs = [ + ], + headers = [ + "OpenSSL.h", + "OpenSSLKeyUtils.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + ], +) diff --git a/fizz/crypto/openssl/test/BUCK b/fizz/crypto/openssl/test/BUCK new file mode 100644 index 00000000000..f5fae50b525 --- /dev/null +++ b/fizz/crypto/openssl/test/BUCK @@ -0,0 +1,16 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "key_utils", + srcs = [ + "OpenSSLKeyUtilsTest.cpp", + ], + deps = [ + "//fizz/crypto/openssl:openssl", + "//fizz/crypto/test:TestUtil", + "//folly:string", + "//folly/portability:gtest", + ], +) diff --git a/fizz/crypto/signature/BUCK b/fizz/crypto/signature/BUCK new file mode 100644 index 00000000000..36575d7c295 --- /dev/null +++ b/fizz/crypto/signature/BUCK @@ -0,0 +1,14 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "signature", + headers = [ + "Signature.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/openssl:openssl", + ], +) diff --git a/fizz/crypto/signature/test/BUCK b/fizz/crypto/signature/test/BUCK new file mode 100644 index 00000000000..b5ff7b9cd30 --- /dev/null +++ b/fizz/crypto/signature/test/BUCK @@ -0,0 +1,46 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "ec", + srcs = [ + "ECSignatureTest.cpp", + ], + supports_static_listing = False, + deps = [ + "//fizz/crypto:asymmetric", + "//fizz/crypto/signature:signature", + "//folly:string", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "ed", + srcs = [ + "EdSignatureTest.cpp", + ], + headers = [ + "EdSignatureTest.h", + ], + supports_static_listing = False, + deps = [ + "//fizz/crypto/signature:signature", + "//fizz/crypto/test:TestUtil", + "//folly:fixed_string", + "//folly:string", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "rsa_pss", + srcs = [ + "RSAPSSSignatureTest.cpp", + ], + deps = [ + "//fizz/crypto/signature:signature", + "//folly/portability:gtest", + ], +) diff --git a/fizz/crypto/test/BUCK b/fizz/crypto/test/BUCK new file mode 100644 index 00000000000..56098b0f18e --- /dev/null +++ b/fizz/crypto/test/BUCK @@ -0,0 +1,94 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/crypto:key_derivation", + "//folly/portability:gmock", + ], +) + +cpp_library( + name = "TestUtil", + srcs = [ + "TestUtil.cpp", + ], + headers = [ + "TestUtil.h", + ], + deps = [ + "//fizz:config", + "//fizz/backend:openssl", + "//fizz/crypto/aead:aegiscipher", + "//folly/ssl:openssl_cert_utils", + ], + exported_deps = [ + "//fizz/crypto/aead:aead", + "//fizz/crypto/aead:evpcipher", + "//fizz/protocol:types", + "//folly:string", + "//folly/io:iobuf", + "//folly/ssl:openssl_ptr_types", + ], + external_deps = [ + ("libsodium", None, "sodium"), + ], +) + +cpp_unittest( + name = "hkdf_tests", + srcs = [ + "HkdfTest.cpp", + ], + supports_static_listing = False, + deps = [ + ":TestUtil", + "//fizz/backend:openssl", + "//fizz/crypto:hkdf", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "key_derivation", + srcs = [ + "KeyDerivationTest.cpp", + ], + supports_static_listing = False, + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto:key_derivation", + "//folly:string", + "//folly/io:iobuf", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "random_generator_test", + srcs = [ + "RandomGeneratorTest.cpp", + ], + deps = [ + ":TestUtil", + "//fizz/crypto:random", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "utils_test", + srcs = [ + "UtilsTest.cpp", + ], + deps = [ + "//fizz/crypto:utils", + "//folly/portability:gtest", + ], +) diff --git a/fizz/defs.bzl b/fizz/defs.bzl new file mode 100644 index 00000000000..2365ea398ee --- /dev/null +++ b/fizz/defs.bzl @@ -0,0 +1,138 @@ +load("@fbsource//tools/build_defs:buckconfig.bzl", "read_bool") +load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary") +load("@fbsource//tools/build_defs:fb_xplat_cxx_library.bzl", "fb_xplat_cxx_library") +load("@fbsource//tools/build_defs:fb_xplat_cxx_test.bzl", "fb_xplat_cxx_test") +load( + "@fbsource//tools/build_defs:platform_defs.bzl", + "ANDROID", + "APPLE", + "CXX", + "FBCODE", + "IOS", + "MACOSX", + "WATCHOS", + "WINDOWS", +) + +# Fizz is a cross platform library used across fbcode, fbobjc, fbandroid, etc. +# +# Each build environment defines a separate set of default warning flags. +# Since we primarily develop within fbcode, this meant that we would see our +# builds pass on our devserver, then fail a sandcastle xplat contbuild job at +# difftime (or worse, some contbuilds are asynchronous so we only find out +# about this after land) since some of these environments define `-Werror`. +# +FIZZ_CXX_WARNINGS = [ + "-Wno-error", + + # Apple builds warn against this, but Fizz requires static initializers + # so we *need* global-constructors. + "-Wno-error=global-constructors", + "-Werror=comment", + "-Werror=format", + "-Werror=format-security", + "-Werror=mismatched-tags", + "-Werror=missing-braces", + "-Werror=return-type", + "-Werror=shadow", + "-Werror=sign-compare", + "-Werror=uninitialized", + "-Werror=unused-function", + "-Werror=unused-local-typedefs", + "-Werror=unused-variable", + "-Werror=unused-exception-parameter", + "-Werror=constant-conversion", +] + +CXXFLAGS = [ + "-frtti", + "-fexceptions", + "-fstack-protector-strong", +] + FIZZ_CXX_WARNINGS + +FBANDROID_CXXFLAGS = [ + "-ffunction-sections", + "-fstack-protector-strong", +] + +FBOBJC_CXXFLAGS = [ + "-fstack-protector-strong", +] + +WINDOWS_MSVC_CXXFLAGS = [ + "/EHs", +] + +WINDOWS_CLANG_CXX_FLAGS_NO_SSE4 = [ + "-Wno-deprecated-declarations", + "-Wno-microsoft-cast", + "-DBOOST_HAS_THREADS", +] + +WINDOWS_CLANG_CXX_FLAGS = WINDOWS_CLANG_CXX_FLAGS_NO_SSE4 + [ + "-msse4.2", +] + +DEFAULT_APPLE_SDKS = (IOS, MACOSX, WATCHOS) +DEFAULT_PLATFORMS = (ANDROID, APPLE, CXX, FBCODE, WINDOWS) + +def fizz_cxx_library( + name, + platforms = None, + apple_sdks = None, + headers = [], + exported_headers = [], + enable_static_variant = True, + header_namespace = "", + srcs = None, + **kwargs): + """Translate a simpler declartion into the more complete library target""" + if apple_sdks == None: + apple_sdks = DEFAULT_APPLE_SDKS + if platforms == None: + platforms = DEFAULT_PLATFORMS + + windows_compiler_flags = WINDOWS_CLANG_CXX_FLAGS if read_bool("fizz", "enable_sse4", True) else WINDOWS_CLANG_CXX_FLAGS_NO_SSE4 + + if headers or exported_headers: + public_include_directories = [] + header_namespace = "fizz" + else: + public_include_directories = [".."] + header_namespace = "" + + fb_xplat_cxx_library( + name = name, + srcs = native.glob(srcs) if srcs else [], + enable_static_variant = enable_static_variant, + platforms = platforms, + apple_sdks = apple_sdks, + headers = headers, + exported_headers = exported_headers, + header_namespace = header_namespace, + public_include_directories = public_include_directories, + compiler_flags = kwargs.pop("compiler_flags", []) + CXXFLAGS, + windows_compiler_flags = kwargs.pop("windows_compiler_flags", []) + windows_compiler_flags, + fbobjc_compiler_flags = kwargs.pop("fbobjc_compiler_flags", []) + FBOBJC_CXXFLAGS, + fbobjc_exported_preprocessor_flags = kwargs.pop("fbobjc_exported_preprocessor_flags", []), + fbandroid_compiler_flags = kwargs.pop("fbandroid_compiler_flags", []) + FBANDROID_CXXFLAGS, + windows_msvc_compiler_flags_override = kwargs.pop("windows_msvc_compiler_flags_override", WINDOWS_MSVC_CXXFLAGS), + visibility = kwargs.pop("visibility", ["PUBLIC"]), + **kwargs + ) + +def fizz_cxx_binary(name, **kwargs): + fb_xplat_cxx_binary( + name = name, + platforms = (CXX,), + contacts = ["oncall+secure_pipes@xmail.facebook.com"], + **kwargs + ) + +def fizz_cxx_test(name, **kwargs): + fb_xplat_cxx_test( + name = name, + platforms = (CXX,), + contacts = ["oncall+secure_pipes@xmail.facebook.com"], + **kwargs + ) diff --git a/fizz/experimental/batcher/BUCK b/fizz/experimental/batcher/BUCK new file mode 100644 index 00000000000..5d42915029c --- /dev/null +++ b/fizz/experimental/batcher/BUCK @@ -0,0 +1,16 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "batcher", + headers = [ + "Batcher.h", + ], + exported_deps = [ + "//fizz/experimental/crypto:batch_signature", + "//fizz/experimental/protocol:batch_signature_types", + "//fizz/server:async_self_cert", + "//folly/futures:shared_promise", + ], +) diff --git a/fizz/experimental/batcher/test/BUCK b/fizz/experimental/batcher/test/BUCK new file mode 100644 index 00000000000..b0791cb0d15 --- /dev/null +++ b/fizz/experimental/batcher/test/BUCK @@ -0,0 +1,20 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "batcher_test", + srcs = [ + "BatcherTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//fizz/experimental/batcher:batcher", + "//fizz/experimental/client:batch_signature_peer_cert", + "//fizz/experimental/server:batch_signature_async_self_cert", + "//fizz/server:protocol", + "//fizz/server/test:mocks", + "//folly/portability:gtest", + ], +) diff --git a/fizz/experimental/client/BUCK b/fizz/experimental/client/BUCK new file mode 100644 index 00000000000..bd82e1258b4 --- /dev/null +++ b/fizz/experimental/client/BUCK @@ -0,0 +1,18 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "batch_signature_peer_cert", + srcs = [ + "BatchSignaturePeerCert.cpp", + ], + headers = [ + "BatchSignaturePeerCert.h", + ], + exported_deps = [ + "//fizz/experimental/crypto:batch_signature", + "//fizz/experimental/protocol:batch_signature_types", + "//fizz/protocol:certificate", + ], +) diff --git a/fizz/experimental/client/test/BUCK b/fizz/experimental/client/test/BUCK new file mode 100644 index 00000000000..efe7beb58a5 --- /dev/null +++ b/fizz/experimental/client/test/BUCK @@ -0,0 +1,20 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "batch_signature_peer_cert_test", + srcs = [ + "BatchSignaturePeerCertTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//fizz/experimental/batcher:batcher", + "//fizz/experimental/client:batch_signature_peer_cert", + "//fizz/experimental/server:batch_signature_async_self_cert", + "//fizz/protocol/test:mocks", + "//folly/executors:manual_executor", + "//folly/portability:gtest", + ], +) diff --git a/fizz/experimental/crypto/BUCK b/fizz/experimental/crypto/BUCK new file mode 100644 index 00000000000..3cbefe385d1 --- /dev/null +++ b/fizz/experimental/crypto/BUCK @@ -0,0 +1,28 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "merkle_tree", + headers = [ + "MerkleTree.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + "//fizz/crypto:hmac_sha256", + "//fizz/crypto:random", + "//fizz/record:record", + "//folly/container:f14_hash", + ], +) + +cpp_library( + name = "batch_signature", + headers = [ + "BatchSignature.h", + ], + exported_deps = [ + ":merkle_tree", + "//fizz/record:record", + ], +) diff --git a/fizz/experimental/crypto/exchange/BUCK b/fizz/experimental/crypto/exchange/BUCK new file mode 100644 index 00000000000..7dbdaee49e4 --- /dev/null +++ b/fizz/experimental/crypto/exchange/BUCK @@ -0,0 +1,19 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "oqs_key_exchange", + srcs = [ + "OQSKeyExchange.cpp", + ], + headers = [ + "OQSKeyExchange.h", + ], + exported_deps = [ + "fbsource//third-party/liboqs:oqs", + "//fizz/crypto/exchange:key_exchange", + "//fizz/protocol:factory", + "//folly:memory", + ], +) diff --git a/fizz/experimental/crypto/test/BUCK b/fizz/experimental/crypto/test/BUCK new file mode 100644 index 00000000000..5dc8b4b506c --- /dev/null +++ b/fizz/experimental/crypto/test/BUCK @@ -0,0 +1,40 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "merkle_tree_test", + srcs = [ + "MerkleTreeTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//fizz/experimental/crypto:merkle_tree", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "batch_signature_test", + srcs = [ + "BatchSignatureTest.cpp", + ], + deps = [ + "//fizz/crypto/test:TestUtil", + "//fizz/experimental/crypto:batch_signature", + "//folly/io:iobuf", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "oqs_key_exchange_test", + srcs = [ + "OQSKeyExchangeTest.cpp", + ], + deps = [ + "//fizz/experimental/crypto/exchange:oqs_key_exchange", + "//folly/portability:gtest", + ], +) diff --git a/fizz/experimental/ktls/BUCK b/fizz/experimental/ktls/BUCK new file mode 100644 index 00000000000..44cbd328f38 --- /dev/null +++ b/fizz/experimental/ktls/BUCK @@ -0,0 +1,43 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "ktls", + srcs = [ + "AsyncFizzBaseKTLS.cpp", + "AsyncKTLSSocket.cpp", + "FizzKTLSCallback.cpp", + "KTLS.cpp", + ], + headers = [ + "AsyncFizzBaseKTLS.h", + "AsyncKTLSSocket.h", + "FizzKTLSCallback.h", + "KTLS.h", + "LinuxKTLS.h", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/client:state", + "//folly:file", + "//folly/portability:sockets", + ], + exported_deps = [ + "//fizz/crypto/aead:aead", + "//fizz/experimental/util:cert_extraction", + "//fizz/protocol:async_fizz_base", + "//fizz/protocol:key_scheduler", + "//fizz/record:record", + "//fizz/record:record_layer", + "//folly:c_portability", + "//folly:exception_wrapper", + "//folly:expected", + "//folly:function", + "//folly/io/async:async_socket", + "//folly/net:network_socket", + ], + exported_external_deps = [ + "glog", + ], +) diff --git a/fizz/experimental/ktls/test/BUCK b/fizz/experimental/ktls/test/BUCK new file mode 100644 index 00000000000..494fd8047b5 --- /dev/null +++ b/fizz/experimental/ktls/test/BUCK @@ -0,0 +1,76 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "ktls_test", + srcs = [ + "KTLSTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/aead:aead", + "//fizz/experimental/ktls:ktls", + "//folly/test:test_utils", + ], +) + +cpp_unittest( + name = "async_fizz_base_ktls_test", + srcs = [ + "AsyncFizzBaseKTLSTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/client:async_fizz_client", + "//fizz/client:synchronized_lru_psk_cache", + "//fizz/crypto/test:TestUtil", + "//fizz/experimental/ktls:ktls", + "//fizz/protocol:certificate", + "//fizz/protocol/test:mocks", + "//fizz/server:aead_ticket_cipher", + "//fizz/server:async_fizz_server", + "//fizz/server:cert_manager", + "//fizz/server:fizz_server_context", + "//fizz/server:ticket_codec", + "//folly:function", + "//folly/futures:core", + "//folly/io/async:async_socket", + "//folly/io/async:server_socket", + "//folly/test:test_utils", + ], +) + +cpp_unittest( + name = "async_ktls_socket_test", + srcs = [ + "AsyncKTLSSocketTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/experimental/ktls:ktls", + "//fizz/record:encrypted_record_layer", + "//folly/futures:core", + "//folly/io/async:async_socket", + "//folly/io/async:server_socket", + "//folly/io/async/test:mocks", + "//folly/test:test_utils", + ], +) + +cpp_unittest( + name = "async_ktls_rx_socket_test", + srcs = [ + "AsyncKTLSRxSocketTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/experimental/ktls:ktls", + "//fizz/record:encrypted_record_layer", + "//folly/futures:core", + "//folly/io/async:async_socket", + "//folly/io/async:server_socket", + "//folly/io/async/test:mocks", + "//folly/test:test_utils", + ], +) diff --git a/fizz/experimental/protocol/BUCK b/fizz/experimental/protocol/BUCK new file mode 100644 index 00000000000..ae586d61b6b --- /dev/null +++ b/fizz/experimental/protocol/BUCK @@ -0,0 +1,29 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "batch_signature_factory", + headers = [ + "BatchSignatureFactory.h", + ], + exported_deps = [ + "//fizz/experimental/client:batch_signature_peer_cert", + "//fizz/protocol:factory", + ], +) + +cpp_library( + name = "batch_signature_types", + srcs = [ + "BatchSignatureTypes.cpp", + ], + headers = [ + "BatchSignatureTypes.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + "//fizz/crypto:hmac_sha256", + "//fizz/record:record", + ], +) diff --git a/fizz/experimental/protocol/test/BUCK b/fizz/experimental/protocol/test/BUCK new file mode 100644 index 00000000000..e3b1d73d994 --- /dev/null +++ b/fizz/experimental/protocol/test/BUCK @@ -0,0 +1,15 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "batch_signature_types_test", + srcs = [ + "BatchSignatureTypesTest.cpp", + ], + deps = [ + "//fizz/experimental/protocol:batch_signature_types", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/experimental/server/BUCK b/fizz/experimental/server/BUCK new file mode 100644 index 00000000000..01dbe18f51b --- /dev/null +++ b/fizz/experimental/server/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "batch_signature_async_self_cert", + headers = [ + "BatchSignatureAsyncSelfCert.h", + ], + exported_deps = [ + "//fizz/experimental/batcher:batcher", + "//fizz/experimental/crypto:batch_signature", + "//fizz/experimental/protocol:batch_signature_types", + "//fizz/server:async_self_cert", + "//fizz/server:protocol", + ], +) diff --git a/fizz/experimental/server/test/BUCK b/fizz/experimental/server/test/BUCK new file mode 100644 index 00000000000..96dbe203b92 --- /dev/null +++ b/fizz/experimental/server/test/BUCK @@ -0,0 +1,19 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "batch_signature_async_self_cert_test", + srcs = [ + "BatchSignatureAsyncSelfCertTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//fizz/experimental/batcher:batcher", + "//fizz/experimental/server:batch_signature_async_self_cert", + "//fizz/protocol/test:mocks", + "//fizz/server/test:mocks", + "//folly/portability:gtest", + ], +) diff --git a/fizz/experimental/util/BUCK b/fizz/experimental/util/BUCK new file mode 100644 index 00000000000..45ce6ea163a --- /dev/null +++ b/fizz/experimental/util/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "cert_extraction", + srcs = [], + headers = [ + "CertExtraction.h", + ], + deps = [ + ], + exported_deps = [ + "//fizz/client:async_fizz_client", + "//fizz/server:async_fizz_server", + ], +) diff --git a/fizz/extensions/delegatedcred/BUCK b/fizz/extensions/delegatedcred/BUCK new file mode 100644 index 00000000000..08f6e02ead1 --- /dev/null +++ b/fizz/extensions/delegatedcred/BUCK @@ -0,0 +1,123 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "delegated_credential", + srcs = [ + "Types.cpp", + ], + headers = [ + "Types.h", + ], + deps = [ + "//folly:string", + "//folly/io:iobuf", + ], + exported_deps = [ + "//fizz/record:record", + "//folly:optional", + ], +) + +cpp_library( + name = "delegated_credential_client_extension", + srcs = [ + "DelegatedCredentialClientExtension.cpp", + ], + headers = [ + "DelegatedCredentialClientExtension.h", + ], + exported_deps = [ + ":delegated_credential", + "//fizz/client:client_extensions", + ], +) + +cpp_library( + name = "delegated_credential_utils", + srcs = [ + "DelegatedCredentialUtils.cpp", + ], + headers = [ + "DelegatedCredentialUtils.h", + ], + deps = [ + "//fizz/backend:openssl", + "//folly/ssl:openssl_cert_utils", + ], + exported_deps = [ + ":delegated_credential", + "//fizz/protocol:certificate", + "//fizz/protocol/clock:clock", + "//folly/ssl:openssl_ptr_types", + ], +) + +cpp_library( + name = "peer_delegated_credential", + headers = [ + "PeerDelegatedCredential.h", + "PeerDelegatedCredential-inl.h", + ], + exported_deps = [ + ":delegated_credential", + ":delegated_credential_utils", + "//fizz/backend:openssl", + "//fizz/protocol:openssl_certificate", + "//fizz/protocol/clock:system_clock", + "//folly/ssl:openssl_cert_utils", + ], +) + +cpp_library( + name = "self_delegated_credential", + headers = [ + "SelfDelegatedCredential.h", + "SelfDelegatedCredential-inl.h", + ], + exported_deps = [ + ":delegated_credential", + ":delegated_credential_utils", + "//fizz/backend:openssl", + "//fizz/protocol:openssl_certificate", + "//folly/ssl:openssl_cert_utils", + ], +) + +cpp_library( + name = "delegated_credential_factory", + srcs = [ + "DelegatedCredentialFactory.cpp", + ], + headers = [ + "DelegatedCredentialFactory.h", + ], + deps = [ + ":peer_delegated_credential", + "//folly/portability:openssl", + ], + exported_deps = [ + ":delegated_credential", + "//fizz/backend:openssl", + "//fizz/protocol:openssl_factory", + ], +) + +cpp_library( + name = "delegated_credential_cert_manager", + srcs = [ + "DelegatedCredentialCertManager.cpp", + ], + headers = [ + "DelegatedCredentialCertManager.h", + ], + deps = [ + ":delegated_credential_utils", + ], + exported_deps = [ + ":delegated_credential", + ":self_delegated_credential", + "//fizz/server:cert_manager", + ], +) diff --git a/fizz/extensions/delegatedcred/test/BUCK b/fizz/extensions/delegatedcred/test/BUCK new file mode 100644 index 00000000000..9b087c93e60 --- /dev/null +++ b/fizz/extensions/delegatedcred/test/BUCK @@ -0,0 +1,106 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "delegated_credential_types_test", + srcs = [ + "DelegatedCredTypesTest.cpp", + ], + deps = [ + "//fizz/extensions/delegatedcred:delegated_credential", + "//folly/io:iobuf", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "delegated_credential_utils_test", + srcs = [ + "DelegatedCredentialUtilsTest.cpp", + ], + deps = [ + "//fizz/crypto:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/delegatedcred:delegated_credential_utils", + "//fizz/protocol/clock/test:mock_clock", + "//folly/portability:gmock", + "//folly/portability:gtest", + "//folly/ssl:openssl_ptr_types", + ], +) + +cpp_unittest( + name = "delegated_credential_factory_test", + srcs = [ + "DelegatedCredentialFactoryTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/delegatedcred:delegated_credential_factory", + "//fizz/extensions/delegatedcred:peer_delegated_credential", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "peer_delegated_credential_test", + srcs = [ + "PeerDelegatedCredentialTest.cpp", + ], + deps = [ + "//fizz/crypto:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/delegatedcred:peer_delegated_credential", + "//fizz/protocol/clock/test:mock_clock", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "self_delegated_credential_test", + srcs = [ + "SelfDelegatedCredentialTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/delegatedcred:delegated_credential_utils", + "//fizz/extensions/delegatedcred:self_delegated_credential", + "//folly/portability:gmock", + "//folly/portability:gtest", + "//folly/ssl:openssl_ptr_types", + ], +) + +cpp_unittest( + name = "delegated_credential_cert_manager_test", + srcs = [ + "DelegatedCredentialCertManagerTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/extensions/delegatedcred:delegated_credential_cert_manager", + "//fizz/protocol/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/extensions/delegatedcred:self_delegated_credential", + "//folly/io/async/test:mocks", + ], +) diff --git a/fizz/extensions/exportedauth/BUCK b/fizz/extensions/exportedauth/BUCK new file mode 100644 index 00000000000..ba579c116fb --- /dev/null +++ b/fizz/extensions/exportedauth/BUCK @@ -0,0 +1,24 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "exported_authenticator", + srcs = [ + "ExportedAuthenticator.cpp", + ], + headers = [ + "ExportedAuthenticator.h", + "Util.h", + ], + deps = ["//fizz/backend:openssl"], + exported_deps = [ + "//fizz/crypto:key_derivation", + "//fizz/protocol:async_fizz_base", + "//fizz/protocol:certificate", + "//fizz/protocol:exporter", + "//fizz/protocol:protocol", + "//fizz/record:record", + "//fizz/record:record_layer", + ], +) diff --git a/fizz/extensions/exportedauth/test/BUCK b/fizz/extensions/exportedauth/test/BUCK new file mode 100644 index 00000000000..1ab0c7c863d --- /dev/null +++ b/fizz/extensions/exportedauth/test/BUCK @@ -0,0 +1,21 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "exported_authenticator_test", + srcs = [ + "ExportedAuthenticatorTest.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/exportedauth:exported_authenticator", + "//fizz/protocol/test:mocks", + "//fizz/protocol/test:test_messages", + "//fizz/record:record", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/extensions/javacrypto/BUCK b/fizz/extensions/javacrypto/BUCK new file mode 100644 index 00000000000..d16a5efda95 --- /dev/null +++ b/fizz/extensions/javacrypto/BUCK @@ -0,0 +1,38 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "java_crypto", + srcs = [ + "JavaCryptoCertificateVerifier.cpp", + "JavaCryptoPeerCert.cpp", + "JniUtils.cpp", + "OnLoad.cpp", + ], + headers = [ + "JavaCryptoCertificateVerifier.h", + "JavaCryptoFactory.h", + "JavaCryptoPeerCert.h", + "JniUtils.h", + ], + # This library uses proxygen, which hasn't been modularized yet, so keep + # using textual inclusion for now. + modular_headers = False, + deps = [ + "//folly/ssl:openssl_cert_utils", + ], + exported_deps = [ + "fbsource//third-party/jvm:jvm", + "//fizz/backend:openssl", + "//fizz/crypto/signature:signature", + "//fizz/protocol:certificate", + "//fizz/protocol:certificate_verifier", + "//fizz/protocol:openssl_factory", + "//fizz/record:record", + "//folly:range", + ], + external_deps = [ + "glog", + ], +) diff --git a/fizz/extensions/tokenbinding/BUCK b/fizz/extensions/tokenbinding/BUCK new file mode 100644 index 00000000000..26617ccf061 --- /dev/null +++ b/fizz/extensions/tokenbinding/BUCK @@ -0,0 +1,107 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "token_binding", + srcs = [ + "Types.cpp", + ], + headers = [ + "Types.h", + ], + deps = [ + "//folly:string", + "//folly/io:iobuf", + ], + exported_deps = [ + "//fizz/record:record", + "//folly:optional", + ], +) + +cpp_library( + name = "token_binding_server_extension", + headers = [ + "TokenBindingServerExtension.h", + ], + exported_deps = [ + ":token_binding", + ":token_binding_context", + "//fizz/server:negotiator", + "//fizz/server:server_extensions", + ], +) + +cpp_library( + name = "token_binding_client_extension", + srcs = [ + "TokenBindingClientExtension.cpp", + ], + headers = [ + "TokenBindingClientExtension.h", + ], + exported_deps = [ + ":token_binding", + ":token_binding_context", + "//fizz/client:client_extensions", + "//folly:optional", + ], +) + +cpp_library( + name = "token_binding_context", + headers = [ + "TokenBindingContext.h", + ], + exported_deps = [ + ":token_binding", + ], +) + +cpp_library( + name = "token_binding_validator", + srcs = [ + "Validator.cpp", + ], + headers = [ + "Validator.h", + ], + deps = [ + ":utils", + ], + exported_deps = [ + ":token_binding", + "//fizz/backend:openssl", + "//fizz/crypto/signature:signature", + "//fizz/record:record", + ], +) + +cpp_library( + name = "utils", + headers = [ + "Utils.h", + ], + exported_deps = [ + ":token_binding", + ], +) + +cpp_library( + name = "token_binding_constructor", + srcs = [ + "TokenBindingConstructor.cpp", + ], + headers = [ + "TokenBindingConstructor.h", + ], + deps = [ + ":utils", + "//fizz/backend:openssl", + ], + exported_deps = [ + ":token_binding", + "//folly/ssl:openssl_ptr_types", + ], +) diff --git a/fizz/extensions/tokenbinding/test/BUCK b/fizz/extensions/tokenbinding/test/BUCK new file mode 100644 index 00000000000..d5163d232e3 --- /dev/null +++ b/fizz/extensions/tokenbinding/test/BUCK @@ -0,0 +1,72 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "token_binding_test", + srcs = [ + "TokenBindingTest.cpp", + ], + deps = [ + "//fizz/extensions/tokenbinding:token_binding", + "//fizz/extensions/tokenbinding:token_binding_context", + "//fizz/record:record", + "//fizz/record/test:extension_tests_base", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "token_binding_server_extension_test", + srcs = [ + "TokenBindingServerExtensionTest.cpp", + ], + deps = [ + "//fizz/extensions/tokenbinding:token_binding", + "//fizz/extensions/tokenbinding:token_binding_context", + "//fizz/extensions/tokenbinding:token_binding_server_extension", + "//fizz/record:record", + "//fizz/server:server_extensions", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "validator_test", + srcs = [ + "ValidatorTest.cpp", + ], + deps = [ + "//fizz/extensions/tokenbinding:token_binding", + "//fizz/extensions/tokenbinding:token_binding_validator", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "token_binding_client_extension_test", + srcs = [ + "TokenBindingClientExtensionTest.cpp", + ], + deps = [ + "//fizz/extensions/tokenbinding:token_binding_client_extension", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "token_binding_constructor_test", + srcs = [ + "TokenBindingConstructorTest.cpp", + ], + deps = [ + "//fizz/extensions/tokenbinding:token_binding_constructor", + "//fizz/extensions/tokenbinding:token_binding_validator", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/facebook/debug/BUCK b/fizz/facebook/debug/BUCK new file mode 100644 index 00000000000..5da1cbfab66 --- /dev/null +++ b/fizz/facebook/debug/BUCK @@ -0,0 +1,16 @@ +load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") + +oncall("secure_pipes") + +python_binary( + # @autodeps-skip + name = "fizz_trace", + srcs = [ + "fizztrace.py", + ], + main_function = "fizz.facebook.debug.fizztrace.main", + deps = [ + "fbsource//third-party/bcc:bcc-py", + "fbsource//third-party/bcc:libbcc", + ], +) diff --git a/fizz/facebook/fizzy/test/BUCK b/fizz/facebook/fizzy/test/BUCK new file mode 100644 index 00000000000..5c4f482b5ea --- /dev/null +++ b/fizz/facebook/fizzy/test/BUCK @@ -0,0 +1 @@ +# This file needs to exist to avoid build system breakage, see https://fburl.com/workplace/jtdlgdmd diff --git a/fizz/facebook/fuzzer/BUCK b/fizz/facebook/fuzzer/BUCK new file mode 100644 index 00000000000..abe71870bed --- /dev/null +++ b/fizz/facebook/fuzzer/BUCK @@ -0,0 +1,119 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load( + "@fbsource//xplat/security/lionhead:defs.bzl", + "EXTERNAL_USERS", + "Metadata", + "Severity", +) +load("//security/lionhead/harnesses:defs.bzl", "cpp_lionhead_harness") + +oncall("secure_pipes") + +cpp_library( + name = "fuzz_aead", + srcs = ["FuzzAead.cpp"], + headers = ["FuzzAead.h"], + deps = [ + "//fizz:config", + "//fizz/backend:openssl", + "//fizz/crypto/aead:aegiscipher", + "//fizz/crypto/aead/test:mocks", + ], + exported_deps = [ + "//fizz/crypto/aead:aead", + "//fizz/record:record", + ], +) + +cpp_library( + name = "fuzz_handshake_context", + srcs = ["FuzzHandshakeContext.cpp"], + headers = ["FuzzHandshakeContext.h"], + deps = [ + "//fizz/backend:openssl", + ], + exported_deps = [ + "//fizz/protocol:handshake_context", + "//fizz/record:record", + ], +) + +cpp_library( + name = "fuzz_token_cipher", + headers = ["FuzzTokenCipher.h"], + exported_deps = [ + "//fizz/server/test:mocks", + ], +) + +cpp_library( + name = "fuzz_factory", + headers = ["FuzzFactory.h"], + exported_deps = [ + "//fizz/protocol/test:mocks", + ], +) + +cpp_library( + name = "fuzz_server_context_builder", + srcs = ["FuzzServerContextBuilder.cpp"], + headers = ["FuzzServerContextBuilder.h"], + deps = [ + ":fuzz_aead", + ":fuzz_factory", + ":fuzz_handshake_context", + ":fuzz_token_cipher", + "//fizz/crypto/hpke/test:mocks", + "//fizz/protocol/test:test_messages", + "//fizz/record:record", + "//fizz/server:aead_cookie_cipher", + "//fizz/server:aead_ticket_cipher", + "//fizz/server:aead_token_cipher", + "//fizz/server:dual_ticket_cipher", + "//fizz/server:ticket_codec", + "//fizz/server/test:mocks", + ], + exported_deps = [ + "//fizz/server:fizz_server_context", + ], +) + +cpp_lionhead_harness( + name = "FizzServerFuzzer", + srcs = ["FizzServerFuzzer.cpp"], + context_task = "T144013895", + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_SEV, + severity_service_takeover = Severity.FILE_SECURITY_SEV, + ), + deps = [ + "fbsource//xplat/security/lionhead:utils", + ":fuzz_server_context_builder", + "//fizz/server:fizz_server", + "//folly/io/async:async_base", + ], +) + +cpp_lionhead_harness( + name = "FizzClientFuzzer", + srcs = ["FizzClientFuzzer.cpp"], + context_task = "T131981406", #TODO: This is a template task. Please create your own copy and insert meaningful context for this fuzzer. Otherwise, security engineers will not know how to handle security issues found by this harness. + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, # missing severity, using default TODO: check and apply appropriate severity + severity_service_takeover = Severity.FILE_SECURITY_TASK, # missing severity, using default TODO: check and apply appropriate severity + ), + deps = [ + ":fuzz_factory", + "//fizz/client:fizz_client", + "//fizz/client/test:mocks", + "//fizz/client/test:utilities", + ], + external_deps = [ + "gflags", + "glog", + ], +) diff --git a/fizz/facebook/python/BUCK b/fizz/facebook/python/BUCK new file mode 100644 index 00000000000..b7391489713 --- /dev/null +++ b/fizz/facebook/python/BUCK @@ -0,0 +1,22 @@ +load("@fbcode_macros//build_defs:cpp_python_extension.bzl", "cpp_python_extension") + +oncall("secure_pipes") + +cpp_python_extension( + name = "pythonFizzUtils", + srcs = [ + "Wrapper.cpp", + ], + module_name = "PyFizzUtil", + deps = [ + "//common/encode:encode", + "//fizz/crypto/hpke:types", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/util:fizz_util", + "//folly/io:iobuf", + ], + external_deps = [ + ("boost", None, "boost_python"), + ("libsodium", None, "sodium"), + ], +) diff --git a/fizz/fizz_defs.bzl b/fizz/fizz_defs.bzl new file mode 100644 index 00000000000..2714a99eb48 --- /dev/null +++ b/fizz/fizz_defs.bzl @@ -0,0 +1,643 @@ +FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CONTEXT_HEADERS = [ + "extensions/tokenbinding/TokenBindingContext.h", +] + +FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_SERVER_EXTENSION_HEADERS = [ + "extensions/tokenbinding/TokenBindingServerExtension.h", +] + +FIZZ_SERVER_ASYNC_FIZZ_SERVER_HEADERS = [ + "server/AsyncFizzServer-inl.h", + "server/AsyncFizzServer.h", +] + +FIZZ_SERVER_TICKET_TYPES_HEADERS = [ + "server/TicketTypes.h", +] + +FIZZ_PROTOCOL_DEFAULT_CERTIFICATE_VERIFIER_HEADERS = [ + "protocol/DefaultCertificateVerifier.h", +] + +FIZZ_PROTOCOL_DEFAULT_CERTIFICATE_VERIFIER_SOURCES = [ + "protocol/DefaultCertificateVerifier.cpp", +] + +FIZZ_SERVER_FIZZ_SERVER_CONTEXT_HEADERS = [ + "server/FizzServerContext.h", +] + +FIZZ_UTIL_FIZZ_UTIL_HEADERS = [ + "util/FizzUtil.h", +] + +FIZZ_UTIL_FIZZ_UTIL_SOURCES = [ + "util/FizzUtil.cpp", +] + +FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_HEADERS = [ + "extensions/tokenbinding/Types.h", +] + +FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_SOURCES = [ + "extensions/tokenbinding/Types.cpp", +] + +FIZZ_RECORD_RECORD_HEADERS = [ + "record/Extensions-inl.h", + "record/Extensions.h", + "record/Types-inl.h", + "record/Types.h", +] + +FIZZ_RECORD_RECORD_SOURCES = [ + "record/Types.cpp", +] + +FIZZ_SERVER_NEGOTIATOR_HEADERS = [ + "server/Negotiator.h", +] + +FIZZ_SERVER_SERVER_EXTENSIONS_HEADERS = [ + "server/ServerExtensions.h", +] + +FIZZ_PROTOCOL_ASYNC_FIZZ_BASE_HEADERS = [ + "protocol/AsyncFizzBase.h", +] + +FIZZ_PROTOCOL_ASYNC_FIZZ_BASE_SOURCES = [ + "protocol/AsyncFizzBase.cpp", +] + +FIZZ_PROTOCOL_EXPORTER_HEADERS = [ + "protocol/Exporter.h", +] + +FIZZ_PROTOCOL_EXPORTER_SOURCES = [ + "protocol/Exporter.cpp", +] + +FIZZ_SERVER_FIZZ_SERVER_HEADERS = [ + "server/FizzServer-inl.h", + "server/FizzServer.h", +] + +FIZZ_SERVER_FIZZ_SERVER_SOURCES = [ + "server/FizzServer.cpp", +] + +FIZZ_SERVER_PROTOCOL_HEADERS = [ + "server/Actions.h", + "server/ServerProtocol.h", + "server/State.h", +] + +FIZZ_SERVER_PROTOCOL_SOURCES = [ + "server/ServerProtocol.cpp", + "server/State.cpp", +] + +FIZZ_CRYPTO_AEAD_EVPCIPHER_HEADERS = [ + "backend/openssl/crypto/aead/AESGCM128.h", + "backend/openssl/crypto/aead/AESGCM256.h", + "backend/openssl/crypto/aead/AESOCB128.h", + "backend/openssl/crypto/aead/ChaCha20Poly1305.h", + "backend/openssl/crypto/aead/OpenSSLEVPCipher-inl.h", + "backend/openssl/crypto/aead/OpenSSLEVPCipher.h", +] + +FIZZ_CRYPTO_AEAD_EVPCIPHER_SOURCES = [ + "backend/openssl/crypto/aead/OpenSSLEVPCipher.cpp", +] + +FIZZ_CRYPTO_HKDF_HEADERS = [ + "crypto/Hkdf.h", +] + +FIZZ_CRYPTO_HKDF_SOURCES = [ + "crypto/Hkdf.cpp", +] + +FIZZ_PROTOCOL_TYPES_HEADERS = [ + "protocol/Types.h", +] + +FIZZ_PROTOCOL_TYPES_SOURCES = [ + "protocol/Types.cpp", +] + +FIZZ_SERVER_AEAD_TICKET_CIPHER_HEADERS = [ + "server/AeadTicketCipher.h", +] + +FIZZ_SERVER_TICKET_CODEC_HEADERS = [ + "server/TicketCodec-inl.h", + "server/TicketCodec.h", +] + +FIZZ_SERVER_TICKET_CODEC_SOURCES = [ + "server/TicketCodec.cpp", +] + +FIZZ_PROTOCOL_CERTIFICATE_VERIFIER_HEADERS = [ + "protocol/CertificateVerifier.h", +] + +FIZZ_PROTOCOL_CERTIFICATE_HEADERS = [ + "protocol/Certificate-inl.h", + "protocol/Certificate.h", +] + +FIZZ_PROTOCOL_CERTIFICATE_SOURCES = [ + "protocol/Certificate.cpp", +] + +FIZZ_PROTOCOL_CLOCK_SYSTEM_CLOCK_HEADERS = [ + "protocol/clock/SystemClock.h", +] + +FIZZ_PROTOCOL_CLOCK_SYSTEM_CLOCK_SOURCES = [ + "protocol/clock/SystemClock.cpp", +] + +FIZZ_PROTOCOL_OPENSSL_FACTORY_HEADERS = [ + "backend/openssl/OpenSSLFactory.h", +] + +FIZZ_SERVER_CERT_MANAGER_HEADERS = [ + "server/CertManager.h", +] + +FIZZ_SERVER_CERT_MANAGER_SOURCES = [ + "server/CertManager.cpp", +] + +FIZZ_SERVER_COOKIE_CIPHER_HEADERS = [ + "server/CookieCipher.h", +] + +FIZZ_SERVER_COOKIE_CIPHER_SOURCES = [ + "server/CookieCipher.cpp", +] + +FIZZ_SERVER_AEAD_COOKIE_CIPHER_HEADERS = [ + "server/AeadCookieCipher.h", +] + +FIZZ_SERVER_AEAD_COOKIE_CIPHER_SOURCES = [ + "server/AeadCookieCipher.cpp", +] + +FIZZ_SERVER_REPLAY_CACHE_HEADERS = [ + "server/ReplayCache.h", +] + +FIZZ_SERVER_REPLAY_CACHE_SOURCES = [ + "server/ReplayCache.cpp", +] + +FIZZ_SERVER_TICKET_CIPHER_HEADERS = [ + "server/TicketCipher.h", +] + +FIZZ_PROTOCOL_KEY_SCHEDULER_HEADERS = [ + "protocol/KeyScheduler.h", +] + +FIZZ_PROTOCOL_KEY_SCHEDULER_SOURCES = [ + "protocol/KeyScheduler.cpp", +] + +FIZZ_CRYPTO_KEY_DERIVATION_HEADERS = [ + "crypto/KeyDerivation.h", +] + +FIZZ_CRYPTO_KEY_DERIVATION_SOURCES = [ + "crypto/KeyDerivation.cpp", +] + +FIZZ_PROTOCOL_FACTORY_HEADERS = [ + "protocol/Factory.h", +] + +FIZZ_PROTOCOL_FIZZ_BASE_HEADERS = [ + "protocol/FizzBase-inl.h", + "protocol/FizzBase.h", +] + +FIZZ_CRYPTO_UTILS_HEADERS = [ + "crypto/Utils.h", +] + +FIZZ_CRYPTO_UTILS_SOURCES = [ + "crypto/Utils.cpp", +] + +FIZZ_PROTOCOL_ACTIONS_HEADERS = [ + "protocol/Actions.h", +] + +FIZZ_PROTOCOL_PARAMS_HEADERS = [ + "protocol/Params.h", +] + +FIZZ_PROTOCOL_PROTOCOL_HEADERS = [ + "protocol/Protocol.h", +] + +FIZZ_PROTOCOL_STATE_MACHINE_HEADERS = [ + "protocol/StateMachine-inl.h", + "protocol/StateMachine.h", +] + +FIZZ_RECORD_PLAINTEXT_RECORD_LAYER_HEADERS = [ + "record/PlaintextRecordLayer.h", +] + +FIZZ_RECORD_PLAINTEXT_RECORD_LAYER_SOURCES = [ + "record/PlaintextRecordLayer.cpp", +] + +FIZZ_RECORD_RECORD_LAYER_HEADERS = [ + "record/RecordLayer.h", +] + +FIZZ_RECORD_RECORD_LAYER_SOURCES = [ + "record/RecordLayer.cpp", +] + +FIZZ_SERVER_ASYNC_SELF_CERT_HEADERS = [ + "server/AsyncSelfCert.h", +] + +FIZZ_SERVER_RESUMPTION_STATE_HEADERS = [ + "server/ResumptionState.h", +] + +FIZZ_UTIL_WORKAROUNDS_HEADERS = [ + "util/Workarounds.h", +] + +FIZZ_CRYPTO_AEAD_AEAD_HEADERS = [ + "crypto/aead/Aead.h", +] + +FIZZ_CRYPTO_AEAD_IOBUF_HEADERS = [ + "crypto/aead/IOBufUtil.h", +] + +FIZZ_CRYPTO_AEAD_IOBUF_SOURCES = [ + "crypto/aead/IOBufUtil.cpp", +] + +FIZZ_SERVER_TOKEN_CIPHER_HEADERS = [ + "server/TokenCipher.h", +] + +FIZZ_SERVER_AEAD_TOKEN_CIPHER_HEADERS = [ + "server/AeadTokenCipher.h", +] + +FIZZ_SERVER_AEAD_TOKEN_CIPHER_SOURCES = [ + "server/AeadTokenCipher.cpp", +] + +FIZZ_CRYPTO_SIGNATURE_SIGNATURE_HEADERS = [ + "backend/openssl/crypto/signature/Signature-inl.h", + "backend/openssl/crypto/signature/Signature.h", +] + +FIZZ_CRYPTO_SIGNATURE_SIGNATURE_SOURCES = [ + "backend/openssl/crypto/signature/Signature.cpp", +] + +FIZZ_PROTOCOL_CLOCK_CLOCK_HEADERS = [ + "protocol/clock/Clock.h", +] + +FIZZ_CRYPTO_HMAC_SHA256_HEADERS = [ + "crypto/Sha256.h", +] + +FIZZ_CRYPTO_HMAC_SHA256_SOURCES = [ + "crypto/Sha256.cpp", +] + +FIZZ_CRYPTO_HMAC_SHA384_HEADERS = [ + "crypto/Sha384.h", +] + +FIZZ_CRYPTO_HMAC_SHA384_SOURCES = [ + "crypto/Sha384.cpp", +] + +FIZZ_CRYPTO_HMAC_SHA512_HEADERS = [ + "crypto/Sha512.h", +] + +FIZZ_CRYPTO_HMAC_SHA512_SOURCES = [ + "crypto/Sha512.cpp", +] + +FIZZ_PROTOCOL_HANDSHAKE_CONTEXT_HEADERS = [ + "protocol/HandshakeContext-inl.h", + "protocol/HandshakeContext.h", +] + +FIZZ_CRYPTO_EXCHANGE_EXCHANGE_HEADERS = [ + "backend/openssl/crypto/exchange/OpenSSLKeyExchange-inl.h", + "backend/openssl/crypto/exchange/OpenSSLKeyExchange.h", +] + +FIZZ_CRYPTO_EXCHANGE_KEY_EXCHANGE_HEADERS = [ + "crypto/exchange/KeyExchange.h", +] + +FIZZ_CRYPTO_EXCHANGE_X25519_HEADERS = [ + "crypto/exchange/X25519.h", +] + +FIZZ_CRYPTO_EXCHANGE_X25519_SOURCES = [ + "crypto/exchange/X25519.cpp", +] + +FIZZ_CRYPTO_RANDOM_HEADERS = [ + "crypto/RandomGenerator.h", +] + +FIZZ_RECORD_ENCRYPTED_RECORD_LAYER_HEADERS = [ + "record/EncryptedRecordLayer.h", +] + +FIZZ_RECORD_ENCRYPTED_RECORD_LAYER_SOURCES = [ + "record/EncryptedRecordLayer.cpp", +] + +FIZZ_RECORD_BUF_AND_PADDING_POLICY_HEADERS = [ + "record/BufAndPaddingPolicy.h", +] + +FIZZ_RECORD_BUF_AND_PADDING_POLICY_SOURCES = [ + "record/BufAndPaddingPolicy.cpp", +] + +FIZZ_CLIENT_PSK_SERIALIZATION_HEADERS = [ + "client/PskSerializationUtils.h", +] + +FIZZ_CLIENT_PSK_SERIALIZATION_SOURCES = [ + "client/PskSerializationUtils.cpp", +] + +FIZZ_CLIENT_CLIENT_EXTENSIONS_HEADERS = [ + "client/ClientExtensions.h", +] + +FIZZ_CLIENT_PSK_CACHE_HEADERS = [ + "client/PskCache.h", +] + +FIZZ_PROTOCOL_EVENTS_HEADERS = [ + "protocol/Events.h", +] + +FIZZ_PROTOCOL_EVENTS_SOURCES = [ + "protocol/Events.cpp", +] + +FIZZ_BACKEND_BACKEND_HEADERS = [ + "backend/openssl/OpenSSL.h", +] + +FIZZ_CRYPTO_OPENSSL_OPENSSL_HEADERS = [ + "backend/openssl/crypto/OpenSSL.h", + "backend/openssl/crypto/OpenSSLKeyUtils.h", +] + +FIZZ_CRYPTO_OPENSSL_OPENSSL_SOURCES = [ + "backend/openssl/crypto/OpenSSLKeyUtils.cpp", +] + +FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CLIENT_EXTENSION_HEADERS = [ + "extensions/tokenbinding/TokenBindingClientExtension.h", +] + +FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CLIENT_EXTENSION_SOURCES = [ + "extensions/tokenbinding/TokenBindingClientExtension.cpp", +] + +FIZZ_CLIENT_EARLY_DATA_REJECTION_HEADERS = [ + "client/EarlyDataRejectionPolicy.h", +] + +FIZZ_CLIENT_EARLY_DATA_REJECTION_SOURCES = [ + "client/EarlyDataRejectionPolicy.cpp", +] + +FIZZ_CLIENT_PROTOCOL_HEADERS = [ + "client/ClientProtocol.h", +] + +FIZZ_CLIENT_PROTOCOL_SOURCES = [ + "client/ClientProtocol.cpp", +] + +FIZZ_CLIENT_ACTIONS_HEADERS = [ + "client/Actions.h", +] + +FIZZ_CLIENT_FIZZ_CLIENT_CONTEXT_HEADERS = [ + "client/FizzClientContext.h", +] + +FIZZ_CLIENT_STATE_HEADERS = [ + "client/State.h", +] + +FIZZ_CLIENT_STATE_SOURCES = [ + "client/State.cpp", +] + +FIZZ_UTIL_PARSE_HEADERS = [ + "util/Parse-inl.h", + "util/Parse.h", +] + +FIZZ_CRYPTO_SHA_HEADERS = [ + "crypto/Sha-inl.h", + "crypto/Sha.h", +] + +FIZZ_CRYPTO_ASYMMETRIC_HEADERS = [ + "backend/openssl/crypto/ECCurve.h", +] + +FIZZ_CLIENT_FIZZ_CLIENT_HEADERS = [ + "client/FizzClient-inl.h", + "client/FizzClient.h", +] + +FIZZ_CLIENT_ASYNC_FIZZ_CLIENT_HEADERS = [ + "client/AsyncFizzClient-inl.h", + "client/AsyncFizzClient.h", +] + +FIZZ_UTIL_VARIANT_HEADERS = [ + "util/Variant.h", +] + +FIZZ_COMPRESSION_CERTIFICATE_COMPRESSOR_HEADERS = [ + "compression/CertificateCompressor.h", +] + +FIZZ_COMPRESSION_CERT_DECOMPRESSION_MANAGER_HEADERS = [ + "compression/CertDecompressionManager.h", +] + +FIZZ_COMPRESSION_CERT_DECOMPRESSION_MANAGER_SOURCES = [ + "compression/CertDecompressionManager.cpp", +] + +FIZZ_COMPRESSION_ZLIB_CERTIFICATE_DECOMPRESSOR_HEADERS = [ + "compression/ZlibCertificateDecompressor.h", +] + +FIZZ_COMPRESSION_ZLIB_CERTIFICATE_DECOMPRESSOR_SOURCES = [ + "compression/ZlibCertificateDecompressor.cpp", +] + +FIZZ_COMPRESSION_ZSTD_CERTIFICATE_DECOMPRESSOR_HEADERS = [ + "compression/ZstdCertificateDecompressor.h", +] + +FIZZ_COMPRESSION_ZSTD_CERTIFICATE_DECOMPRESSOR_SOURCES = [ + "compression/ZstdCertificateDecompressor.cpp", +] + +# @unsorted-dict-items +XPLAT_FIZZ_SOURCE_MAP = { + "FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CONTEXT_HEADERS": FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CONTEXT_HEADERS, + "FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_SERVER_EXTENSION_HEADERS": FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_SERVER_EXTENSION_HEADERS, + "FIZZ_SERVER_ASYNC_FIZZ_SERVER_HEADERS": FIZZ_SERVER_ASYNC_FIZZ_SERVER_HEADERS, + "FIZZ_SERVER_TICKET_TYPES_HEADERS": FIZZ_SERVER_TICKET_TYPES_HEADERS, + "FIZZ_PROTOCOL_DEFAULT_CERTIFICATE_VERIFIER_HEADERS": FIZZ_PROTOCOL_DEFAULT_CERTIFICATE_VERIFIER_HEADERS, + "FIZZ_PROTOCOL_DEFAULT_CERTIFICATE_VERIFIER_SOURCES": FIZZ_PROTOCOL_DEFAULT_CERTIFICATE_VERIFIER_SOURCES, + "FIZZ_SERVER_FIZZ_SERVER_CONTEXT_HEADERS": FIZZ_SERVER_FIZZ_SERVER_CONTEXT_HEADERS, + "FIZZ_UTIL_FIZZ_UTIL_HEADERS": FIZZ_UTIL_FIZZ_UTIL_HEADERS, + "FIZZ_UTIL_FIZZ_UTIL_SOURCES": FIZZ_UTIL_FIZZ_UTIL_SOURCES, + "FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_HEADERS": FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_HEADERS, + "FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_SOURCES": FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_SOURCES, + "FIZZ_RECORD_RECORD_HEADERS": FIZZ_RECORD_RECORD_HEADERS, + "FIZZ_RECORD_RECORD_SOURCES": FIZZ_RECORD_RECORD_SOURCES, + "FIZZ_SERVER_NEGOTIATOR_HEADERS": FIZZ_SERVER_NEGOTIATOR_HEADERS, + "FIZZ_SERVER_SERVER_EXTENSIONS_HEADERS": FIZZ_SERVER_SERVER_EXTENSIONS_HEADERS, + "FIZZ_PROTOCOL_ASYNC_FIZZ_BASE_HEADERS": FIZZ_PROTOCOL_ASYNC_FIZZ_BASE_HEADERS, + "FIZZ_PROTOCOL_ASYNC_FIZZ_BASE_SOURCES": FIZZ_PROTOCOL_ASYNC_FIZZ_BASE_SOURCES, + "FIZZ_PROTOCOL_EXPORTER_HEADERS": FIZZ_PROTOCOL_EXPORTER_HEADERS, + "FIZZ_PROTOCOL_EXPORTER_SOURCES": FIZZ_PROTOCOL_EXPORTER_SOURCES, + "FIZZ_SERVER_FIZZ_SERVER_HEADERS": FIZZ_SERVER_FIZZ_SERVER_HEADERS, + "FIZZ_SERVER_FIZZ_SERVER_SOURCES": FIZZ_SERVER_FIZZ_SERVER_SOURCES, + "FIZZ_SERVER_PROTOCOL_HEADERS": FIZZ_SERVER_PROTOCOL_HEADERS, + "FIZZ_SERVER_PROTOCOL_SOURCES": FIZZ_SERVER_PROTOCOL_SOURCES, + "FIZZ_CRYPTO_AEAD_EVPCIPHER_HEADERS": FIZZ_CRYPTO_AEAD_EVPCIPHER_HEADERS, + "FIZZ_CRYPTO_AEAD_EVPCIPHER_SOURCES": FIZZ_CRYPTO_AEAD_EVPCIPHER_SOURCES, + "FIZZ_CRYPTO_HKDF_HEADERS": FIZZ_CRYPTO_HKDF_HEADERS, + "FIZZ_CRYPTO_HKDF_SOURCES": FIZZ_CRYPTO_HKDF_SOURCES, + "FIZZ_PROTOCOL_TYPES_HEADERS": FIZZ_PROTOCOL_TYPES_HEADERS, + "FIZZ_PROTOCOL_TYPES_SOURCES": FIZZ_PROTOCOL_TYPES_SOURCES, + "FIZZ_SERVER_AEAD_TICKET_CIPHER_HEADERS": FIZZ_SERVER_AEAD_TICKET_CIPHER_HEADERS, + "FIZZ_SERVER_TICKET_CODEC_HEADERS": FIZZ_SERVER_TICKET_CODEC_HEADERS, + "FIZZ_SERVER_TICKET_CODEC_SOURCES": FIZZ_SERVER_TICKET_CODEC_SOURCES, + "FIZZ_PROTOCOL_CERTIFICATE_VERIFIER_HEADERS": FIZZ_PROTOCOL_CERTIFICATE_VERIFIER_HEADERS, + "FIZZ_PROTOCOL_CERTIFICATE_HEADERS": FIZZ_PROTOCOL_CERTIFICATE_HEADERS, + "FIZZ_PROTOCOL_CERTIFICATE_SOURCES": FIZZ_PROTOCOL_CERTIFICATE_SOURCES, + "FIZZ_PROTOCOL_CLOCK_SYSTEM_CLOCK_HEADERS": FIZZ_PROTOCOL_CLOCK_SYSTEM_CLOCK_HEADERS, + "FIZZ_PROTOCOL_CLOCK_SYSTEM_CLOCK_SOURCES": FIZZ_PROTOCOL_CLOCK_SYSTEM_CLOCK_SOURCES, + "FIZZ_PROTOCOL_OPENSSL_FACTORY_HEADERS": FIZZ_PROTOCOL_OPENSSL_FACTORY_HEADERS, + "FIZZ_SERVER_CERT_MANAGER_HEADERS": FIZZ_SERVER_CERT_MANAGER_HEADERS, + "FIZZ_SERVER_CERT_MANAGER_SOURCES": FIZZ_SERVER_CERT_MANAGER_SOURCES, + "FIZZ_SERVER_COOKIE_CIPHER_HEADERS": FIZZ_SERVER_COOKIE_CIPHER_HEADERS, + "FIZZ_SERVER_COOKIE_CIPHER_SOURCES": FIZZ_SERVER_COOKIE_CIPHER_SOURCES, + "FIZZ_SERVER_AEAD_COOKIE_CIPHER_HEADERS": FIZZ_SERVER_AEAD_COOKIE_CIPHER_HEADERS, + "FIZZ_SERVER_AEAD_COOKIE_CIPHER_SOURCES": FIZZ_SERVER_AEAD_COOKIE_CIPHER_SOURCES, + "FIZZ_SERVER_REPLAY_CACHE_HEADERS": FIZZ_SERVER_REPLAY_CACHE_HEADERS, + "FIZZ_SERVER_REPLAY_CACHE_SOURCES": FIZZ_SERVER_REPLAY_CACHE_SOURCES, + "FIZZ_SERVER_TICKET_CIPHER_HEADERS": FIZZ_SERVER_TICKET_CIPHER_HEADERS, + "FIZZ_PROTOCOL_KEY_SCHEDULER_HEADERS": FIZZ_PROTOCOL_KEY_SCHEDULER_HEADERS, + "FIZZ_PROTOCOL_KEY_SCHEDULER_SOURCES": FIZZ_PROTOCOL_KEY_SCHEDULER_SOURCES, + "FIZZ_CRYPTO_KEY_DERIVATION_HEADERS": FIZZ_CRYPTO_KEY_DERIVATION_HEADERS, + "FIZZ_CRYPTO_KEY_DERIVATION_SOURCES": FIZZ_CRYPTO_KEY_DERIVATION_SOURCES, + "FIZZ_PROTOCOL_FACTORY_HEADERS": FIZZ_PROTOCOL_FACTORY_HEADERS, + "FIZZ_PROTOCOL_FIZZ_BASE_HEADERS": FIZZ_PROTOCOL_FIZZ_BASE_HEADERS, + "FIZZ_CRYPTO_UTILS_HEADERS": FIZZ_CRYPTO_UTILS_HEADERS, + "FIZZ_CRYPTO_UTILS_SOURCES": FIZZ_CRYPTO_UTILS_SOURCES, + "FIZZ_PROTOCOL_ACTIONS_HEADERS": FIZZ_PROTOCOL_ACTIONS_HEADERS, + "FIZZ_PROTOCOL_PARAMS_HEADERS": FIZZ_PROTOCOL_PARAMS_HEADERS, + "FIZZ_PROTOCOL_PROTOCOL_HEADERS": FIZZ_PROTOCOL_PROTOCOL_HEADERS, + "FIZZ_PROTOCOL_STATE_MACHINE_HEADERS": FIZZ_PROTOCOL_STATE_MACHINE_HEADERS, + "FIZZ_RECORD_PLAINTEXT_RECORD_LAYER_HEADERS": FIZZ_RECORD_PLAINTEXT_RECORD_LAYER_HEADERS, + "FIZZ_RECORD_PLAINTEXT_RECORD_LAYER_SOURCES": FIZZ_RECORD_PLAINTEXT_RECORD_LAYER_SOURCES, + "FIZZ_RECORD_RECORD_LAYER_HEADERS": FIZZ_RECORD_RECORD_LAYER_HEADERS, + "FIZZ_RECORD_RECORD_LAYER_SOURCES": FIZZ_RECORD_RECORD_LAYER_SOURCES, + "FIZZ_SERVER_ASYNC_SELF_CERT_HEADERS": FIZZ_SERVER_ASYNC_SELF_CERT_HEADERS, + "FIZZ_SERVER_RESUMPTION_STATE_HEADERS": FIZZ_SERVER_RESUMPTION_STATE_HEADERS, + "FIZZ_UTIL_WORKAROUNDS_HEADERS": FIZZ_UTIL_WORKAROUNDS_HEADERS, + "FIZZ_CRYPTO_AEAD_AEAD_HEADERS": FIZZ_CRYPTO_AEAD_AEAD_HEADERS, + "FIZZ_CRYPTO_AEAD_IOBUF_HEADERS": FIZZ_CRYPTO_AEAD_IOBUF_HEADERS, + "FIZZ_CRYPTO_AEAD_IOBUF_SOURCES": FIZZ_CRYPTO_AEAD_IOBUF_SOURCES, + "FIZZ_SERVER_TOKEN_CIPHER_HEADERS": FIZZ_SERVER_TOKEN_CIPHER_HEADERS, + "FIZZ_SERVER_AEAD_TOKEN_CIPHER_HEADERS": FIZZ_SERVER_AEAD_TOKEN_CIPHER_HEADERS, + "FIZZ_SERVER_AEAD_TOKEN_CIPHER_SOURCES": FIZZ_SERVER_AEAD_TOKEN_CIPHER_SOURCES, + "FIZZ_CRYPTO_SIGNATURE_SIGNATURE_HEADERS": FIZZ_CRYPTO_SIGNATURE_SIGNATURE_HEADERS, + "FIZZ_CRYPTO_SIGNATURE_SIGNATURE_SOURCES": FIZZ_CRYPTO_SIGNATURE_SIGNATURE_SOURCES, + "FIZZ_PROTOCOL_CLOCK_CLOCK_HEADERS": FIZZ_PROTOCOL_CLOCK_CLOCK_HEADERS, + "FIZZ_CRYPTO_HMAC_SHA256_HEADERS": FIZZ_CRYPTO_HMAC_SHA256_HEADERS, + "FIZZ_CRYPTO_HMAC_SHA256_SOURCES": FIZZ_CRYPTO_HMAC_SHA256_SOURCES, + "FIZZ_CRYPTO_HMAC_SHA384_HEADERS": FIZZ_CRYPTO_HMAC_SHA384_HEADERS, + "FIZZ_CRYPTO_HMAC_SHA384_SOURCES": FIZZ_CRYPTO_HMAC_SHA384_SOURCES, + "FIZZ_CRYPTO_HMAC_SHA512_HEADERS": FIZZ_CRYPTO_HMAC_SHA512_HEADERS, + "FIZZ_CRYPTO_HMAC_SHA512_SOURCES": FIZZ_CRYPTO_HMAC_SHA512_SOURCES, + "FIZZ_PROTOCOL_HANDSHAKE_CONTEXT_HEADERS": FIZZ_PROTOCOL_HANDSHAKE_CONTEXT_HEADERS, + "FIZZ_CRYPTO_EXCHANGE_EXCHANGE_HEADERS": FIZZ_CRYPTO_EXCHANGE_EXCHANGE_HEADERS, + "FIZZ_CRYPTO_EXCHANGE_KEY_EXCHANGE_HEADERS": FIZZ_CRYPTO_EXCHANGE_KEY_EXCHANGE_HEADERS, + "FIZZ_CRYPTO_EXCHANGE_X25519_HEADERS": FIZZ_CRYPTO_EXCHANGE_X25519_HEADERS, + "FIZZ_CRYPTO_EXCHANGE_X25519_SOURCES": FIZZ_CRYPTO_EXCHANGE_X25519_SOURCES, + "FIZZ_CRYPTO_RANDOM_HEADERS": FIZZ_CRYPTO_RANDOM_HEADERS, + "FIZZ_RECORD_ENCRYPTED_RECORD_LAYER_HEADERS": FIZZ_RECORD_ENCRYPTED_RECORD_LAYER_HEADERS, + "FIZZ_RECORD_ENCRYPTED_RECORD_LAYER_SOURCES": FIZZ_RECORD_ENCRYPTED_RECORD_LAYER_SOURCES, + "FIZZ_RECORD_BUF_AND_PADDING_POLICY_HEADERS": FIZZ_RECORD_BUF_AND_PADDING_POLICY_HEADERS, + "FIZZ_RECORD_BUF_AND_PADDING_POLICY_SOURCES": FIZZ_RECORD_BUF_AND_PADDING_POLICY_SOURCES, + "FIZZ_CLIENT_PSK_SERIALIZATION_HEADERS": FIZZ_CLIENT_PSK_SERIALIZATION_HEADERS, + "FIZZ_CLIENT_PSK_SERIALIZATION_SOURCES": FIZZ_CLIENT_PSK_SERIALIZATION_SOURCES, + "FIZZ_CLIENT_CLIENT_EXTENSIONS_HEADERS": FIZZ_CLIENT_CLIENT_EXTENSIONS_HEADERS, + "FIZZ_CLIENT_PSK_CACHE_HEADERS": FIZZ_CLIENT_PSK_CACHE_HEADERS, + "FIZZ_PROTOCOL_EVENTS_HEADERS": FIZZ_PROTOCOL_EVENTS_HEADERS, + "FIZZ_PROTOCOL_EVENTS_SOURCES": FIZZ_PROTOCOL_EVENTS_SOURCES, + "FIZZ_BACKEND_BACKEND_HEADERS": FIZZ_BACKEND_BACKEND_HEADERS, + "FIZZ_CRYPTO_OPENSSL_OPENSSL_HEADERS": FIZZ_CRYPTO_OPENSSL_OPENSSL_HEADERS, + "FIZZ_CRYPTO_OPENSSL_OPENSSL_SOURCES": FIZZ_CRYPTO_OPENSSL_OPENSSL_SOURCES, + "FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CLIENT_EXTENSION_HEADERS": FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CLIENT_EXTENSION_HEADERS, + "FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CLIENT_EXTENSION_SOURCES": FIZZ_EXTENSIONS_TOKENBINDING_TOKEN_BINDING_CLIENT_EXTENSION_SOURCES, + "FIZZ_CLIENT_EARLY_DATA_REJECTION_HEADERS": FIZZ_CLIENT_EARLY_DATA_REJECTION_HEADERS, + "FIZZ_CLIENT_EARLY_DATA_REJECTION_SOURCES": FIZZ_CLIENT_EARLY_DATA_REJECTION_SOURCES, + "FIZZ_CLIENT_PROTOCOL_HEADERS": FIZZ_CLIENT_PROTOCOL_HEADERS, + "FIZZ_CLIENT_PROTOCOL_SOURCES": FIZZ_CLIENT_PROTOCOL_SOURCES, + "FIZZ_CLIENT_ACTIONS_HEADERS": FIZZ_CLIENT_ACTIONS_HEADERS, + "FIZZ_CLIENT_FIZZ_CLIENT_CONTEXT_HEADERS": FIZZ_CLIENT_FIZZ_CLIENT_CONTEXT_HEADERS, + "FIZZ_CLIENT_STATE_HEADERS": FIZZ_CLIENT_STATE_HEADERS, + "FIZZ_CLIENT_STATE_SOURCES": FIZZ_CLIENT_STATE_SOURCES, + "FIZZ_UTIL_PARSE_HEADERS": FIZZ_UTIL_PARSE_HEADERS, + "FIZZ_CRYPTO_SHA_HEADERS": FIZZ_CRYPTO_SHA_HEADERS, + "FIZZ_CRYPTO_ASYMMETRIC_HEADERS": FIZZ_CRYPTO_ASYMMETRIC_HEADERS, + "FIZZ_CLIENT_FIZZ_CLIENT_HEADERS": FIZZ_CLIENT_FIZZ_CLIENT_HEADERS, + "FIZZ_CLIENT_ASYNC_FIZZ_CLIENT_HEADERS": FIZZ_CLIENT_ASYNC_FIZZ_CLIENT_HEADERS, + "FIZZ_UTIL_VARIANT_HEADERS": FIZZ_UTIL_VARIANT_HEADERS, + "FIZZ_COMPRESSION_CERTIFICATE_COMPRESSOR_HEADERS": FIZZ_COMPRESSION_CERTIFICATE_COMPRESSOR_HEADERS, + "FIZZ_COMPRESSION_CERT_DECOMPRESSION_MANAGER_HEADERS": FIZZ_COMPRESSION_CERT_DECOMPRESSION_MANAGER_HEADERS, + "FIZZ_COMPRESSION_CERT_DECOMPRESSION_MANAGER_SOURCES": FIZZ_COMPRESSION_CERT_DECOMPRESSION_MANAGER_SOURCES, + "FIZZ_COMPRESSION_ZLIB_CERTIFICATE_DECOMPRESSOR_HEADERS": FIZZ_COMPRESSION_ZLIB_CERTIFICATE_DECOMPRESSOR_HEADERS, + "FIZZ_COMPRESSION_ZLIB_CERTIFICATE_DECOMPRESSOR_SOURCES": FIZZ_COMPRESSION_ZLIB_CERTIFICATE_DECOMPRESSOR_SOURCES, + "FIZZ_COMPRESSION_ZSTD_CERTIFICATE_DECOMPRESSOR_HEADERS": FIZZ_COMPRESSION_ZSTD_CERTIFICATE_DECOMPRESSOR_HEADERS, + "FIZZ_COMPRESSION_ZSTD_CERTIFICATE_DECOMPRESSOR_SOURCES": FIZZ_COMPRESSION_ZSTD_CERTIFICATE_DECOMPRESSOR_SOURCES, +} diff --git a/fizz/fizzy_defs.bzl b/fizz/fizzy_defs.bzl new file mode 100644 index 00000000000..0442dbd5531 --- /dev/null +++ b/fizz/fizzy_defs.bzl @@ -0,0 +1,36 @@ +load("@fbsource//tools/build_defs:fb_xplat_cxx_library.bzl", "fb_xplat_cxx_library") +load(":defs.bzl", "CXXFLAGS") + +FIZZY_CXXFLAGS = [ + "-fvisibility=hidden", +] + +FIZZY_PUBLIC_RAW_HEADERS_GLOBEXPR = "facebook/fizzy/include/**/*.h" +FIZZY_INTERNAL_RAW_HEADERS_GLOBEXPR = "facebook/fizzy/src/**/*.h" + +def fizzy_library(name): + fb_xplat_cxx_library( + name = name, + raw_headers = native.glob([FIZZY_PUBLIC_RAW_HEADERS_GLOBEXPR, FIZZY_INTERNAL_RAW_HEADERS_GLOBEXPR]), + public_include_directories = ["facebook/fizzy/include"], + include_directories = [ + "facebook/fizzy/src", + ], + compiler_flags = CXXFLAGS + FIZZY_CXXFLAGS, + srcs = native.glob(["facebook/fizzy/src/**/*.c", "facebook/fizzy/src/**/*.cpp"]), + visibility = ["PUBLIC"], + deps = [ + ":client_fizz_client_context", + ":client_fizz_client", + ":client_psk_serialization", + ":backend_openssl", + "fbsource//third-party/boost:boost", + ], + ) + + fb_xplat_cxx_library( + name = "{}__internal-headers".format(name), + raw_headers = native.glob([FIZZY_INTERNAL_RAW_HEADERS_GLOBEXPR]), + public_include_directories = ["facebook/fizzy/src/"], + visibility = ["//xplat/fizz/..."], + ) diff --git a/fizz/platform/BUCK b/fizz/platform/BUCK new file mode 100644 index 00000000000..733faa1677f --- /dev/null +++ b/fizz/platform/BUCK @@ -0,0 +1,2 @@ +# For now, this file needs to exist for fbcode-target-determinator to work. +# See: https://fb.workplace.com/groups/td.users/permalink/3290301304599199/ diff --git a/fizz/protocol/BUCK b/fizz/protocol/BUCK new file mode 100644 index 00000000000..1949d014de7 --- /dev/null +++ b/fizz/protocol/BUCK @@ -0,0 +1,286 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "state_machine", + headers = [ + "StateMachine.h", + "StateMachine-inl.h", + ], + exported_external_deps = [ + "glog", + ], +) + +cpp_library( + name = "events", + srcs = [ + "Events.cpp", + ], + headers = [ + "Events.h", + ], + exported_deps = [ + "//folly:range", + ], +) + +cpp_library( + name = "params", + srcs = [ + "Params.cpp", + ], + headers = [ + "Params.h", + ], + exported_deps = [ + ":events", + "//fizz/client:client_extensions", + "//fizz/client:psk_cache", + "//fizz/crypto/aead:aead", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/record:record", + "//fizz/util:variant", + "//folly:executor", + "//folly/io:iobuf", + "//folly/io/async:write_flags", + ], +) + +cpp_library( + name = "key_scheduler", + srcs = [ + "KeyScheduler.cpp", + ], + headers = [ + "KeyScheduler.h", + ], + deps = [ + "//fizz/protocol/ech:encrypted_client_hello", + ], + exported_deps = [ + "//fizz/crypto:key_derivation", + "//fizz/crypto/aead:aead", + "//fizz/util:variant", + "//folly:optional", + ], +) + +cpp_library( + name = "certificate", + srcs = [ + "Certificate.cpp", + ], + headers = [ + "Certificate.h", + ], + exported_deps = [ + "//fizz:config", + "//fizz/record:record", + "//folly/io/async:async_transport_certificate", + "//folly/io/async/ssl:openssl_transport_certificate", + ], +) + +cpp_library( + name = "openssl_certificate", + headers = [ + "CertUtils.h", + "OpenSSLPeerCertImpl.h", + "OpenSSLSelfCertImpl.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/signature:signature", + ], +) + +cpp_library( + name = "handshake_context", + headers = [ + "HandshakeContext.h", + "HandshakeContext-inl.h", + ], + exported_deps = [ + "//fizz/crypto:key_derivation", + "//fizz/record:record", + ], +) + +cpp_library( + name = "factory", + headers = [ + "Factory.h", + ], + exported_deps = [ + ":certificate", + ":handshake_context", + ":key_scheduler", + ":types", + "//fizz/crypto:key_derivation", + "//fizz/crypto:random", + "//fizz/crypto/aead:aead", + "//fizz/crypto/exchange:key_exchange", + "//fizz/record:encrypted_record_layer", + "//fizz/record:plaintext_record_layer", + "//fizz/record:record", + ], +) + +cpp_library( + name = "default_factory", + headers = [ + "DefaultFactory.h", + ], + exported_deps = [ + ":factory", + ], +) + +cpp_library( + name = "openssl_factory", + headers = [ + "OpenSSLFactory.h", + ], + deps = [ + ":openssl_certificate", + "//fizz/crypto/exchange:hybrid_exchange", + "//fizz/experimental/crypto/exchange:oqs_key_exchange", + ], + exported_deps = [ + ":default_factory", + "//fizz/backend:openssl", + "//fizz/crypto:hmac_sha256", + "//fizz/crypto:hmac_sha384", + "//fizz/crypto:hmac_sha512", + "//fizz/crypto/aead:aegiscipher", + "//fizz/crypto/aead:evpcipher", + "//fizz/crypto/exchange:exchange", + "//fizz/crypto/exchange:x25519", + ], +) + +cpp_library( + name = "types", + srcs = [ + "Types.cpp", + ], + headers = [ + "Types.h", + ], + exported_deps = [ + "//fizz/record:record", + "//folly:range", + ], +) + +cpp_library( + name = "actions", + headers = [ + "Actions.h", + ], + exported_deps = [ + ":key_scheduler", + ":types", + "//fizz/record:record_layer", + "//folly:c_portability", + "//folly:exception_wrapper", + "//folly:range", + "//folly:small_vector", + "//folly/io:iobuf", + "//folly/io/async:write_flags", + ], +) + +cpp_library( + name = "protocol", + headers = [ + "Protocol.h", + ], + exported_deps = [ + ":factory", + ":key_scheduler", + "//fizz/record:record", + ], +) + +cpp_library( + name = "fizz_base", + headers = [ + "FizzBase.h", + "FizzBase-inl.h", + ], + exported_deps = [ + ":exporter", + ":factory", + ":params", + "//fizz/util:variant", + "//folly/io/async:async_socket_exception", + "//folly/io/async:delayed_destruction", + ], +) + +cpp_library( + name = "async_fizz_base", + srcs = [ + "AsyncFizzBase.cpp", + ], + headers = [ + "AsyncFizzBase.h", + ], + deps = [ + "//folly:conv", + ], + exported_deps = [ + ":certificate", + ":key_scheduler", + "//fizz/record:record", + "//folly/io:iobuf", + "//folly/io/async:async_socket", + "//folly/io/async:decorated_async_transport_wrapper", + ], +) + +cpp_library( + name = "default_certificate_verifier", + srcs = [ + "DefaultCertificateVerifier.cpp", + ], + headers = [ + "DefaultCertificateVerifier.h", + ], + deps = [ + "//folly:file_util", + "//folly/ssl:openssl_cert_utils", + ], + exported_deps = [ + ":certificate_verifier", + "//folly/ssl:openssl_ptr_types", + ], +) + +cpp_library( + name = "certificate_verifier", + headers = [ + "CertificateVerifier.h", + ], + exported_deps = [ + ":certificate", + "//fizz/record:record", + ], +) + +cpp_library( + name = "exporter", + srcs = [ + "Exporter.cpp", + ], + headers = [ + "Exporter.h", + ], + exported_deps = [ + ":factory", + "//fizz/crypto:key_derivation", + ], +) diff --git a/fizz/protocol/clock/BUCK b/fizz/protocol/clock/BUCK new file mode 100644 index 00000000000..83ebf4b608f --- /dev/null +++ b/fizz/protocol/clock/BUCK @@ -0,0 +1,23 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "clock", + headers = [ + "Clock.h", + ], +) + +cpp_library( + name = "system_clock", + srcs = [ + "SystemClock.cpp", + ], + headers = [ + "SystemClock.h", + ], + exported_deps = [ + ":clock", + ], +) diff --git a/fizz/protocol/clock/test/BUCK b/fizz/protocol/clock/test/BUCK new file mode 100644 index 00000000000..5f500b24636 --- /dev/null +++ b/fizz/protocol/clock/test/BUCK @@ -0,0 +1,14 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "mock_clock", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/protocol/clock:clock", + "//folly/portability:gmock", + ], +) diff --git a/fizz/protocol/ech/BUCK b/fizz/protocol/ech/BUCK new file mode 100644 index 00000000000..609be59bec2 --- /dev/null +++ b/fizz/protocol/ech/BUCK @@ -0,0 +1,54 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "encrypted_client_hello", + headers = [ + "ECHExtensions.h", + "ECHExtensions-inl.h", + "Types.h", + "Types-inl.h", + ], + exported_deps = [ + "//fizz/crypto/hpke:types", + "//fizz/record:record", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "encryption", + srcs = [ + "Encryption.cpp", + ], + headers = [ + "Encryption.h", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/hpke:utils", + "//fizz/protocol:protocol", + "//fizz/record:record", + ], + exported_deps = [ + ":encrypted_client_hello", + "//fizz/crypto/exchange:key_exchange", + "//fizz/crypto/hpke:hpke", + "//fizz/protocol:factory", + ], +) + +cpp_library( + name = "decrypter", + srcs = [ + "Decrypter.cpp", + ], + headers = [ + "Decrypter.h", + ], + exported_deps = [ + ":encrypted_client_hello", + ":encryption", + ], +) diff --git a/fizz/protocol/ech/test/BUCK b/fizz/protocol/ech/test/BUCK new file mode 100644 index 00000000000..6425f612ae5 --- /dev/null +++ b/fizz/protocol/ech/test/BUCK @@ -0,0 +1,68 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "ech_test", + srcs = [ + "ECHTest.cpp", + ], + deps = [ + ":test_util", + "//fizz/protocol/ech:encrypted_client_hello", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "encryption_test", + srcs = [ + "EncryptionTest.cpp", + ], + deps = [ + ":test_util", + "//fizz/crypto/hpke:hpke", + "//fizz/crypto/hpke:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/ech:encryption", + "//fizz/protocol/test:mocks", + "//fizz/protocol/test:test_messages", + "//fizz/record:record", + "//folly/lang:bits", + ], +) + +cpp_library( + name = "test_util", + srcs = [ + "TestUtil.cpp", + ], + headers = [ + "TestUtil.h", + ], + deps = [ + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/ech:encryption", + ], + exported_deps = [ + "//fizz/crypto/exchange:key_exchange", + "//fizz/protocol/ech:encrypted_client_hello", + ], +) + +cpp_unittest( + name = "decrypter_test", + srcs = [ + "DecrypterTest.cpp", + ], + deps = [ + ":test_util", + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/ech:decrypter", + "//fizz/protocol/test:test_messages", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/protocol/test/BUCK b/fizz/protocol/test/BUCK new file mode 100644 index 00000000000..52a9fc3616d --- /dev/null +++ b/fizz/protocol/test/BUCK @@ -0,0 +1,165 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "key_derivation", + srcs = [ + "KeySchedulerTest.cpp", + ], + deps = [ + "//fizz/crypto/test:mocks", + "//fizz/protocol:key_scheduler", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "cert_verifier", + srcs = [ + "DefaultCertificateVerifierTest.cpp", + ], + deps = [ + ":utilities", + "//fizz/protocol:default_certificate_verifier", + "//folly/portability:gtest", + "//folly/ssl:openssl_cert_utils", + ], +) + +cpp_unittest( + name = "handshake_context_test", + srcs = [ + "HandshakeContextTest.cpp", + ], + deps = [ + "//fizz/crypto:hmac_sha256", + "//fizz/protocol:handshake_context", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "cert_test", + srcs = [ + "CertTest.cpp", + ], + deps = [ + "//fizz/crypto/test:TestUtil", + "//fizz/protocol:openssl_certificate", + "//folly:string", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "fizz_base_test", + srcs = [ + "FizzBaseTest.cpp", + ], + deps = [ + "//fizz/protocol:fizz_base", + "//fizz/util:variant", + "//folly/futures:core", + "//folly/io/async:async_socket_exception", + "//folly/io/async/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "exporter_test", + srcs = [ + "ExporterTest.cpp", + ], + deps = [ + "//fizz/protocol:exporter", + "//fizz/protocol:openssl_factory", + "//folly/portability:gtest", + ], +) + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/crypto/aead/test:mocks", + "//fizz/crypto/exchange/test:mocks", + "//fizz/crypto/test:mocks", + "//fizz/protocol:async_fizz_base", + "//fizz/protocol:certificate", + "//fizz/protocol:certificate_verifier", + "//fizz/protocol:handshake_context", + "//fizz/protocol:key_scheduler", + "//fizz/protocol:openssl_factory", + "//fizz/protocol:types", + "//fizz/protocol/ech:decrypter", + "//fizz/record/test:mocks", + "//folly/io/async/test:mocks", + ], +) + +cpp_library( + name = "utilities", + headers = [ + "Utilities.h", + ], + exported_deps = [ + "//fizz/protocol:openssl_certificate", + ], +) + +cpp_library( + name = "matchers", + headers = [ + "Matchers.h", + ], + exported_deps = [ + "//folly/io:iobuf", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "openssl_factory_test", + srcs = [ + "OpenSSLFactoryTest.cpp", + ], + supports_static_listing = False, + deps = [ + "//fizz/protocol:openssl_factory", + "//fizz/test:handshake_test_lib", + ], +) + +cpp_library( + name = "protocol_test", + headers = [ + "ProtocolTest.h", + ], + exported_deps = [ + ":matchers", + ":mocks", + "//fizz/protocol:actions", + "//fizz/record/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_library( + name = "test_messages", + headers = [ + "TestMessages.h", + ], + exported_deps = [ + ":protocol_test", + "//fizz/protocol:params", + "//fizz/record:record", + ], +) diff --git a/fizz/record/BUCK b/fizz/record/BUCK new file mode 100644 index 00000000000..2ee73efc6e6 --- /dev/null +++ b/fizz/record/BUCK @@ -0,0 +1,88 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "record", + srcs = [ + "Types.cpp", + ], + headers = [ + "Extensions.h", + "Extensions-inl.h", + "Types.h", + "Types-inl.h", + ], + exported_deps = [ + "//fizz/protocol:events", + "//folly:conv", + "//folly:optional", + "//folly:string", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "record_layer", + srcs = [ + "RecordLayer.cpp", + ], + headers = [ + "RecordLayer.h", + ], + exported_deps = [ + ":record", + "//fizz/crypto/aead:aead", + "//fizz/protocol:params", + "//folly:optional", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "plaintext_record_layer", + srcs = [ + "PlaintextRecordLayer.cpp", + ], + headers = [ + "PlaintextRecordLayer.h", + ], + deps = [ + "//folly:string", + ], + exported_deps = [ + ":record_layer", + ], +) + +cpp_library( + name = "encrypted_record_layer", + srcs = [ + "EncryptedRecordLayer.cpp", + ], + headers = [ + "EncryptedRecordLayer.h", + ], + deps = [ + "//fizz/crypto/aead:iobuf", + ], + exported_deps = [ + ":buf_and_padding_policy", + ":record_layer", + "//fizz/crypto/aead:aead", + ], +) + +cpp_library( + name = "buf_and_padding_policy", + srcs = [ + "BufAndPaddingPolicy.cpp", + ], + headers = [ + "BufAndPaddingPolicy.h", + ], + exported_deps = [ + ":record", + "//folly/io:iobuf", + ], +) diff --git a/fizz/record/test/BUCK b/fizz/record/test/BUCK new file mode 100644 index 00000000000..6b96a8f917f --- /dev/null +++ b/fizz/record/test/BUCK @@ -0,0 +1,141 @@ +load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary") +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/protocol:types", + "//fizz/record:encrypted_record_layer", + "//fizz/record:plaintext_record_layer", + "//folly/portability:gmock", + ], +) + +cpp_library( + name = "extension_tests_base", + headers = [ + "ExtensionTestsBase.h", + ], + exported_deps = [ + "//fizz/record:record", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "handshake_types_test", + srcs = [ + "HandshakeTypesTest.cpp", + ], + deps = [ + "//fizz/record:record", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "extensions_test", + srcs = [ + "ExtensionsTest.cpp", + ], + deps = [ + ":extension_tests_base", + "//fizz/record:record", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "types_test", + srcs = [ + "TypesTest.cpp", + ], + deps = [ + "//fizz/record:record", + "//folly/io:iobuf", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "plaintext_record_test", + srcs = [ + "PlaintextRecordTest.cpp", + ], + deps = [ + "//fizz/record:plaintext_record_layer", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "record_test", + srcs = [ + "RecordTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/record:record_layer", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "encrypted_record_test", + srcs = [ + "EncryptedRecordTest.cpp", + ], + deps = [ + "//fizz/crypto/aead/test:mocks", + "//fizz/record:buf_and_padding_policy", + "//fizz/record:encrypted_record_layer", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "buf_and_padding_policy_test", + srcs = [ + "BufAndPaddingPolicyTest.cpp", + ], + deps = [ + "//fizz/record:buf_and_padding_policy", + "//folly/portability:gtest", + ], +) + +cpp_binary( + name = "record_bench", + srcs = [ + "EncryptedRecordBench.cpp", + ], + compiler_flags = ["-Wno-unused-variable"], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto:utils", + "//fizz/crypto/aead:aegiscipher", + "//fizz/record:encrypted_record_layer", + "//folly:benchmark", + "//folly:random", + "//folly/init:init", + ], +) diff --git a/fizz/record/test/facebook/BUCK b/fizz/record/test/facebook/BUCK new file mode 100644 index 00000000000..836020c13b3 --- /dev/null +++ b/fizz/record/test/facebook/BUCK @@ -0,0 +1,82 @@ +load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary") + +# @autodeps +load( + "@fbsource//xplat/security/lionhead:defs.bzl", + "EXTERNAL_USERS", + "Metadata", + "Severity", +) +load("//security/lionhead/harnesses:defs.bzl", "cpp_lionhead_harness") + +oncall("secure_pipes") + +cpp_binary( + name = "handshake_decode_fuzz_test.so", + srcs = [ + "HandshakeDecodeFuzzTest.cpp", + ], + dlopen_enabled = True, + deps = [ + "//common/testing/fuzztest:fuzz_main", + "//common/testing/fuzztest:headers", + "//fizz/protocol/test:test_messages", + "//fizz/record:record", + "//folly/portability:gtest", + ], +) + +cpp_binary( + name = "extension_decode_fuzz_test.so", + srcs = [ + "ExtensionDecodeFuzzTest.cpp", + ], + dlopen_enabled = True, + deps = [ + "//common/testing/fuzztest:fuzz_main", + "//common/testing/fuzztest:headers", + "//fizz/record:record", + "//folly/portability:gtest", + ], +) + +cpp_lionhead_harness( + name = "fizz_decode_extension", + srcs = ["ExtensionDecodeFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ExtensionDecodeFuzzer", "Decode"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/record:record", + "//folly/io:iobuf", + ], + external_deps = [ + "gflags", + "glog", + ], +) + +cpp_lionhead_harness( + name = "fizz_decode_handshake", + srcs = ["HandshakeDecodeFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("HandshakeDecodeFuzzer", "Decode"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/record:record_layer", + "//folly/io:iobuf", + ], +) diff --git a/fizz/server/BUCK b/fizz/server/BUCK new file mode 100644 index 00000000000..50c4b5cc406 --- /dev/null +++ b/fizz/server/BUCK @@ -0,0 +1,392 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "protocol", + srcs = [ + "ServerProtocol.cpp", + "State.cpp", + ], + headers = [ + "Actions.h", + "ServerProtocol.h", + "State.h", + ], + deps = [ + ":async_self_cert", + ":negotiator", + ":replay_cache", + "//fizz/crypto:utils", + "//fizz/crypto/exchange:async_key_exchange", + "//fizz/protocol:certificate_verifier", + "//fizz/protocol:protocol", + "//fizz/protocol:state_machine", + "//fizz/protocol/ech:decrypter", + "//fizz/record:plaintext_record_layer", + "//fizz/util:workarounds", + "//folly:overload", + "//folly/tracing:static_tracepoint", + ], + exported_deps = [ + ":fizz_server_context", + ":resumption_state", + ":server_extensions", + "//fizz/protocol:actions", + "//fizz/protocol:certificate", + "//fizz/protocol:key_scheduler", + "//fizz/protocol:params", + "//fizz/protocol:types", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/record:record", + "//fizz/record:record_layer", + "//fizz/util:variant", + "//folly:optional", + "//folly:small_vector", + "//folly/futures:core", + ], + exported_external_deps = [ + ("boost", None, "boost_variant"), + ], +) + +cpp_library( + name = "negotiator", + headers = [ + "Negotiator.h", + ], + exported_deps = [ + "//folly:optional", + ], +) + +cpp_library( + name = "fizz_server_context", + srcs = [ + "FizzServerContext.cpp", + ], + headers = [ + "FizzServerContext.h", + ], + deps = [ + "//fizz/backend:openssl", + ], + exported_deps = [ + ":cert_manager", + ":cookie_cipher", + ":negotiator", + ":replay_cache", + ":ticket_cipher", + "//fizz/protocol:certificate", + "//fizz/protocol:factory", + "//fizz/protocol/clock:system_clock", + "//fizz/protocol/ech:decrypter", + "//fizz/record:record", + ], +) + +cpp_library( + name = "ticket_policy", + headers = [ + "TicketPolicy.h", + ], + exported_deps = [ + ":resumption_state", + "//fizz/protocol:types", + "//fizz/protocol/clock:system_clock", + ], +) + +cpp_library( + name = "ticket_cipher", + headers = [ + "TicketCipher.h", + ], + exported_deps = [ + ":resumption_state", + "//folly:optional", + "//folly/futures:core", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "dual_ticket_cipher", + headers = [ + "DualTicketCipher.h", + ], + exported_deps = [ + ":ticket_cipher", + ], +) + +cpp_library( + name = "ticket_codec", + srcs = [ + "TicketCodec.cpp", + ], + headers = [ + "TicketCodec.h", + "TicketCodec-inl.h", + ], + deps = [ + "//folly/io/async/ssl:openssl_transport_certificate", + "//folly/ssl:openssl_cert_utils", + ], + exported_deps = [ + ":fizz_server_context", + ":resumption_state", + "//fizz/record:record", + ], +) + +cpp_library( + name = "aead_ticket_cipher", + headers = [ + "AeadTicketCipher.h", + ], + exported_deps = [ + ":aead_token_cipher", + ":fizz_server_context", + ":ticket_cipher", + ":ticket_policy", + ], +) + +cpp_library( + name = "token_cipher", + headers = [ + "TokenCipher.h", + ], + exported_deps = [ + "//folly:optional", + "//folly:range", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "aead_token_cipher", + srcs = [ + "AeadTokenCipher.cpp", + ], + headers = [ + "AeadTokenCipher.h", + ], + deps = [ + "//fizz/crypto:random", + "//fizz/crypto:utils", + "//fizz/crypto/aead:aead", + ], + exported_deps = [ + ":token_cipher", + "//fizz/backend:openssl", + "//fizz/crypto:hkdf", + "//fizz/crypto:hmac_sha256", + "//fizz/crypto/aead:evpcipher", + "//fizz/record:record", + "//folly:optional", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "ticket_types", + headers = [ + "TicketTypes.h", + ], + exported_deps = [ + ":aead_ticket_cipher", + ":ticket_codec", + "//fizz/backend:openssl", + "//fizz/crypto:hkdf", + "//fizz/crypto/aead:evpcipher", + "//fizz/protocol:types", + ], +) + +cpp_library( + name = "resumption_state", + headers = [ + "ResumptionState.h", + ], + exported_deps = [ + "//fizz/protocol:certificate", + "//fizz/protocol:types", + "//fizz/record:record", + ], +) + +cpp_library( + name = "cookie_cipher", + srcs = [ + "CookieCipher.cpp", + ], + headers = [ + "CookieCipher.h", + ], + deps = [ + ":negotiator", + "//fizz/protocol:handshake_context", + ], + exported_deps = [ + "//fizz/protocol:factory", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/record:record", + ], +) + +cpp_library( + name = "aead_cookie_cipher", + srcs = [ + "AeadCookieCipher.cpp", + ], + headers = [ + "AeadCookieCipher.h", + ], + deps = [ + "//fizz/record:record", + ], + exported_deps = [ + ":cookie_cipher", + ":fizz_server_context", + ":token_cipher", + ], + exported_external_deps = [ + ("boost", None, "boost_variant"), + ], +) + +cpp_library( + name = "cookie_types", + headers = [ + "CookieTypes.h", + ], + exported_deps = [ + ":aead_cookie_cipher", + "//fizz/backend:openssl", + "//fizz/crypto:hkdf", + "//fizz/protocol:types", + ], +) + +cpp_library( + name = "async_self_cert", + headers = [ + "AsyncSelfCert.h", + ], + exported_deps = [ + "//fizz/protocol:certificate", + "//folly/futures:core", + ], +) + +cpp_library( + name = "fizz_server", + srcs = [ + "FizzServer.cpp", + ], + headers = [ + "FizzServer.h", + "FizzServer-inl.h", + ], + exported_deps = [ + ":fizz_server_context", + ":protocol", + "//fizz/protocol:fizz_base", + "//fizz/util:workarounds", + "//folly:overload", + ], +) + +cpp_library( + name = "async_fizz_server", + headers = [ + "AsyncFizzServer.h", + "AsyncFizzServer-inl.h", + ], + exported_deps = [ + ":fizz_server", + ":fizz_server_context", + ":protocol", + "//fizz/protocol:async_fizz_base", + "//fizz/protocol:exporter", + "//fizz/util:tracer", + ], +) + +cpp_library( + name = "cert_manager", + srcs = [ + "CertManager.cpp", + ], + headers = [ + "CertManager.h", + ], + deps = [ + "//folly:string", + ], + exported_deps = [ + "//fizz/protocol:certificate", + ], +) + +cpp_library( + name = "server_extensions", + headers = [ + "ServerExtensions.h", + ], + exported_deps = [ + "//fizz/record:record", + ], +) + +cpp_library( + name = "replay_cache", + srcs = [ + "ReplayCache.cpp", + ], + headers = [ + "ReplayCache.h", + ], + exported_deps = [ + "//folly:range", + "//folly/futures:core", + "//folly/io:iobuf", + ], +) + +cpp_library( + name = "sliding_bloom_replay_cache", + srcs = [ + "SlidingBloomReplayCache.cpp", + ], + headers = [ + "SlidingBloomReplayCache.h", + ], + deps = [ + "//fizz/crypto:random", + "//folly:conv", + "//folly:range", + "//folly/hash:hash", + "//folly/io:iobuf", + "//folly/portability:unistd", + ], + exported_deps = [ + ":replay_cache", + "//folly/io/async:async_base", + ], +) + +cpp_library( + name = "multi_server_extensions", + srcs = [ + "MultiServerExtensions.cpp", + ], + headers = [ + "MultiServerExtensions.h", + ], + exported_deps = [ + ":server_extensions", + ], +) diff --git a/fizz/server/test/BUCK b/fizz/server/test/BUCK new file mode 100644 index 00000000000..4e4d20da41c --- /dev/null +++ b/fizz/server/test/BUCK @@ -0,0 +1,252 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_library( + name = "utils", + headers = [ + "Utils.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + "//fizz/protocol:default_certificate_verifier", + "//fizz/protocol/test:utilities", + "//fizz/server:async_fizz_server", + "//fizz/server:ticket_types", + "//folly/io/async:server_socket", + ], +) + +cpp_library( + name = "mocks", + headers = [ + "Mocks.h", + ], + exported_deps = [ + "//fizz/crypto/aead/test:mocks", + "//fizz/crypto/exchange/test:mocks", + "//fizz/protocol/test:mocks", + "//fizz/record/test:mocks", + "//fizz/server:async_fizz_server", + "//fizz/server:async_self_cert", + "//fizz/server:cookie_cipher", + "//fizz/server:protocol", + "//fizz/server:replay_cache", + "//fizz/server:server_extensions", + "//fizz/server:token_cipher", + "//folly/portability:gmock", + ], +) + +cpp_unittest( + name = "server_protocol_test", + srcs = [ + "ServerProtocolTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/crypto/exchange/test:mocks", + "//fizz/crypto/hpke/test:mocks", + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/clock/test:mock_clock", + "//fizz/protocol/ech/test:test_util", + "//fizz/protocol/test:mocks", + "//fizz/protocol/test:protocol_test", + "//fizz/protocol/test:test_messages", + "//fizz/record:record", + "//fizz/record/test:mocks", + "//fizz/server:protocol", + "//fizz/util:workarounds", + "//folly/executors:manual_executor", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], + external_deps = [ + ("boost", None, "boost_variant"), + ], +) + +cpp_unittest( + name = "negotiator_test", + srcs = [ + "NegotiatorTest.cpp", + ], + deps = [ + "//fizz/server:negotiator", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "ticket_policy_test", + srcs = [ + "TicketPolicyTest.cpp", + ], + deps = [ + "//fizz/crypto/test:TestUtil", + "//fizz/crypto/test:mocks", + "//fizz/protocol/clock/test:mock_clock", + "//fizz/server:ticket_policy", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "aead_ticket_cipher_test", + srcs = [ + "AeadTicketCipherTest.cpp", + ], + deps = [ + "//fizz/crypto/aead/test:mocks", + "//fizz/crypto/test:TestUtil", + "//fizz/crypto/test:mocks", + "//fizz/protocol/clock/test:mock_clock", + "//fizz/protocol/test:mocks", + "//fizz/server:aead_ticket_cipher", + "//folly:string", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "dual_ticket_cipher_test", + srcs = [ + "DualTicketCipherTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/server:dual_ticket_cipher", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "ticket_codec_test", + srcs = [ + "TicketCodecTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/test:mocks", + "//fizz/server:ticket_codec", + "//folly/io/async/ssl:openssl_transport_certificate", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "sliding_bloom_replay_cache_test", + srcs = [ + "SlidingBloomReplayCacheTest.cpp", + ], + deps = [ + "//fizz/server:sliding_bloom_replay_cache", + "//folly:random", + "//folly/io:iobuf", + "//folly/io/async:scoped_event_base_thread", + "//folly/portability:gmock", + "//folly/portability:gtest", + "//folly/synchronization:baton", + ], +) + +cpp_unittest( + name = "cookie_cipher_test", + srcs = [ + "CookieCipherTest.cpp", + ], + deps = [ + "//fizz/protocol/test:mocks", + "//fizz/protocol/test:test_messages", + "//fizz/server:cookie_cipher", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "aead_cookie_cipher_test", + srcs = [ + "AeadCookieCipherTest.cpp", + ], + deps = [ + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/test:test_messages", + "//fizz/server:aead_token_cipher", + "//fizz/server:cookie_types", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "fizz_server_test", + srcs = [ + "FizzServerTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/server:fizz_server", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "async_fizz_server_test", + srcs = [ + "AsyncFizzServerTest.cpp", + ], + deps = [ + ":mocks", + "//fizz/extensions/tokenbinding:token_binding", + "//fizz/server:async_fizz_server", + "//folly/io/async/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "cert_manager_test", + srcs = [ + "CertManagerTest.cpp", + ], + deps = [ + "//fizz/protocol/test:mocks", + "//fizz/server:cert_manager", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "multi_server_extensions_test", + srcs = [ + "MultiServerExtensionsTest.cpp", + ], + deps = [ + "//fizz/server:multi_server_extensions", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "aead_token_cipher_test", + srcs = ["AeadTokenCipherTest.cpp"], + deps = [ + "//fizz/server:aead_token_cipher", + "//folly:random", + "//folly/io:iobuf", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/server/test/facebook/BUCK b/fizz/server/test/facebook/BUCK new file mode 100644 index 00000000000..2b56dd3fe46 --- /dev/null +++ b/fizz/server/test/facebook/BUCK @@ -0,0 +1,241 @@ +load( + "@fbsource//xplat/security/lionhead:defs.bzl", + "EXTERNAL_USERS", + "Metadata", + "Severity", +) +load("//security/lionhead/harnesses:defs.bzl", "cpp_lionhead_harness") + +oncall("secure_pipes") + +cpp_lionhead_harness( + name = "fizz_expecting_client_hello", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "ExpectingClientHello"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_expecting_retry_client_hello", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "ExpectingRetryClientHello"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_expecting_retry_ech_client_hello", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "ExpectingRetryECHClientHello"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_expecting_certificate", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "ExpectingCertificate"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_expecting_certificate_verify", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "ExpectingCertificate"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_accepting_early_data", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "AcceptingEarlyData"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_expecting_finished", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "ExpectingFinished"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_accepting_data", + srcs = ["ServerProtocolFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerProtocolFuzzer", "AcceptingEarlyData"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/crypto/hpke/test:mocks", + "//fizz/facebook/fuzzer:fuzz_handshake_context", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/protocol/test:mocks", + "//fizz/server:fizz_server", + "//fizz/server:protocol", + "//folly/executors:manual_executor", + ], +) + +cpp_lionhead_harness( + name = "fizz_server_w_mocks", + srcs = ["ServerFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerFuzzer", "ServerWithMocksAccepting"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/server:fizz_server", + "//folly/io/async:async_base", + ], +) + +cpp_lionhead_harness( + name = "fizz_server_w_fakes", + srcs = ["ServerFuzzer.cpp"], + context_task = "T144013895", + ftest_name = ("ServerFuzzer", "ServerWithFakesAccepting"), + metadata = Metadata( + exposure = EXTERNAL_USERS, + project = "oncall_secure_pipes", + severity_denial_of_service = Severity.FILE_SECURITY_TASK, + severity_service_takeover = Severity.FILE_SECURITY_TASK, + ), + deps = [ + "fbsource//third-party/googletest:gtest", + "fbsource//xplat/security/lionhead/utils/lib_ftest:lib", + "//fizz/facebook/fuzzer:fuzz_server_context_builder", + "//fizz/server:fizz_server", + "//folly/io/async:async_base", + ], +) diff --git a/fizz/test/BUCK b/fizz/test/BUCK new file mode 100644 index 00000000000..d90020570a0 --- /dev/null +++ b/fizz/test/BUCK @@ -0,0 +1,96 @@ +load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary") +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "async_fizz_base_test", + srcs = [ + "AsyncFizzBaseTest.cpp", + ], + deps = [ + "//fizz/protocol:async_fizz_base", + "//folly/io/async/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_library( + name = "handshake_test_lib", + headers = [ + "HandshakeTest.h", + "LocalTransport.h", + ], + exported_deps = [ + "//fizz/backend:openssl", + "//fizz/client:async_fizz_client", + "//fizz/client/test:mocks", + "//fizz/compression:zlib_certificate_compressor", + "//fizz/compression:zlib_certificate_decompressor", + "//fizz/crypto:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/tokenbinding:token_binding_client_extension", + "//fizz/extensions/tokenbinding:token_binding_context", + "//fizz/extensions/tokenbinding:token_binding_server_extension", + "//fizz/protocol/test:matchers", + "//fizz/protocol/test:utilities", + "//fizz/server:async_fizz_server", + "//fizz/server:cookie_types", + "//fizz/server:ticket_types", + "//fizz/server/test:mocks", + "//folly/io:iobuf", + "//folly/io/async:async_transport", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "handshake_test", + srcs = [ + "HandshakeTest.cpp", + ], + supports_static_listing = False, + deps = [ + ":handshake_test_lib", + "//fizz/backend:openssl", + "//fizz/client:async_fizz_client", + "//fizz/client/test:mocks", + "//fizz/compression:zlib_certificate_compressor", + "//fizz/compression:zlib_certificate_decompressor", + "//fizz/crypto:utils", + "//fizz/crypto/test:TestUtil", + "//fizz/extensions/tokenbinding:token_binding_client_extension", + "//fizz/extensions/tokenbinding:token_binding_context", + "//fizz/extensions/tokenbinding:token_binding_server_extension", + "//fizz/protocol/test:matchers", + "//fizz/protocol/test:utilities", + "//fizz/server:async_fizz_server", + "//fizz/server:cookie_types", + "//fizz/server:ticket_types", + "//fizz/server/test:mocks", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) + +cpp_binary( + name = "bogo_shim", + srcs = [ + "BogoShim.cpp", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/client:async_fizz_client", + "//fizz/crypto:random", + "//fizz/crypto:utils", + "//fizz/server:async_fizz_server", + "//fizz/server:ticket_types", + "//folly:string", + "//folly/io/async:async_ssl_socket", + "//folly/io/async:ssl_context", + "//folly/portability:gflags", + ], +) diff --git a/fizz/tool/BUCK b/fizz/tool/BUCK new file mode 100644 index 00000000000..ef0002d29f4 --- /dev/null +++ b/fizz/tool/BUCK @@ -0,0 +1,99 @@ +load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary") +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "tool_lib", + srcs = [ + "FizzCommandCommon.cpp", + ], + headers = [ + "FizzCommandCommon.h", + ], + deps = [ + "//fizz/backend:openssl", + "//fizz/crypto/exchange:x25519", + "//fizz/protocol:certificate", + "//folly:base64", + "//folly:string", + ], + exported_deps = [ + "//fizz/crypto/exchange:key_exchange", + "//fizz/protocol:async_fizz_base", + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/util:parse", + "//folly:file_util", + "//folly/experimental/io:io_uring_backend", + "//folly/io:iobuf", + "//folly/io/async:async_base", + "//folly/json:dynamic", + ], +) + +cpp_binary( + name = "fizz", + srcs = [ + "FizzClientCommand.cpp", + "FizzClientLoadGenCommand.cpp", + "FizzGenerateDelegatedCredentialCommand.cpp", + "FizzServerBenchmarkCommand.cpp", + "FizzServerCommand.cpp", + "Main.cpp", + ], + headers = [ + "CertificateVerifiers.h", + "Commands.h", + ], + preprocessor_flags = [ + "-DFIZZ_TOOL_ENABLE_BROTLI", + "-DFIZZ_TOOL_ENABLE_ZSTD", + "-DFIZZ_TOOL_ENABLE_IO_URING", + ], + deps = [ + ":tool_lib", + "//fizz/backend:openssl", + "//fizz/client:async_fizz_client", + "//fizz/client:psk_serialization_utils", + "//fizz/compression:brotli_certificate_compressor", + "//fizz/compression:brotli_certificate_decompressor", + "//fizz/compression:zlib_certificate_compressor", + "//fizz/compression:zlib_certificate_decompressor", + "//fizz/compression:zstd_certificate_compressor", + "//fizz/compression:zstd_certificate_decompressor", + "//fizz/crypto/hpke:utils", + "//fizz/experimental/batcher:batcher", + "//fizz/experimental/protocol:batch_signature_factory", + "//fizz/experimental/server:batch_signature_async_self_cert", + "//fizz/extensions/delegatedcred:delegated_credential_cert_manager", + "//fizz/extensions/delegatedcred:delegated_credential_client_extension", + "//fizz/extensions/delegatedcred:delegated_credential_factory", + "//fizz/extensions/delegatedcred:delegated_credential_utils", + "//fizz/extensions/delegatedcred:self_delegated_credential", + "//fizz/protocol:certificate_verifier", + "//fizz/protocol:default_certificate_verifier", + "//fizz/protocol/test:utilities", + "//fizz/server:async_fizz_server", + "//fizz/server:sliding_bloom_replay_cache", + "//fizz/server:ticket_types", + "//fizz/util:fizz_util", + "//fizz/util:key_log_writer", + "//fizz/util:parse", + "//folly:conv", + "//folly:file_util", + "//folly:format", + "//folly/executors:io_thread_pool_executor", + "//folly/futures:core", + "//folly/io/async:async_ssl_socket", + "//folly/io/async:server_socket", + "//folly/io/async:ssl_context", + "//folly/io/async/ssl:openssl_transport_certificate", + "//folly/json:dynamic", + "//folly/portability:gflags", + "//folly/ssl:openssl_cert_utils", + "//folly/stats:histogram", + ], + external_deps = [ + "glog", + ], +) diff --git a/fizz/tool/test/BUCK b/fizz/tool/test/BUCK new file mode 100644 index 00000000000..14ab7d0ea90 --- /dev/null +++ b/fizz/tool/test/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "fizz_command_common", + srcs = [ + "FizzCommandCommonTest.cpp", + ], + deps = [ + "//fizz/protocol/ech:encrypted_client_hello", + "//fizz/tool:tool_lib", + "//folly/container:array", + "//folly/portability:gmock", + "//folly/portability:gtest", + ], +) diff --git a/fizz/util/BUCK b/fizz/util/BUCK new file mode 100644 index 00000000000..5429a97e49f --- /dev/null +++ b/fizz/util/BUCK @@ -0,0 +1,90 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") + +oncall("secure_pipes") + +cpp_library( + name = "fizz_util", + srcs = + [ + "FizzUtil.cpp", + ], + headers = + [ + "FizzUtil.h", + ], + deps = [ + "//fizz/crypto/exchange:x25519", + "//fizz/server:ticket_types", + "//folly:file_util", + "//folly:format", + "//folly/portability:openssl", + ], + exported_deps = [ + "//fizz/extensions/tokenbinding:token_binding_context", + "//fizz/protocol:certificate", + "//fizz/server:fizz_server_context", + "//fizz/server:ticket_policy", + "//folly/io/async:password_in_file", + "//folly/io/async:ssl_context", + "//folly/ssl:openssl_cert_utils", + ], + external_deps = [ + ("libsodium", None, "sodium"), + ("openssl", None, "crypto"), + ], +) + +cpp_library( + name = "parse", + headers = [ + "Parse.h", + "Parse-inl.h", + ], + exported_deps = [ + "//fizz/record:record", + "//folly:range", + ], +) + +cpp_library( + name = "workarounds", + headers = [ + "Workarounds.h", + ], +) + +cpp_library( + name = "variant", + headers = [ + "Variant.h", + ], +) + +cpp_library( + name = "key_log_writer", + headers = [ + "KeyLogWriter.h", + ], + exported_deps = [ + "fbsource//third-party/fmt:fmt", + "//fizz/protocol:key_scheduler", + "//fizz/protocol:types", + "//folly:range", + ], +) + +cpp_library( + name = "tracer", + srcs = [ + "Tracing.cpp", + ], + headers = [ + "Tracing.h", + ], + deps = [ + "//folly/tracing:static_tracepoint", + ], + exported_deps = [ + ":key_log_writer", + ], +) diff --git a/fizz/util/test/BUCK b/fizz/util/test/BUCK new file mode 100644 index 00000000000..02f71e54073 --- /dev/null +++ b/fizz/util/test/BUCK @@ -0,0 +1,43 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") + +oncall("secure_pipes") + +cpp_unittest( + name = "fizz_util_test", + srcs = [ + "FizzUtilTest.cpp", + ], + deps = [ + "//fizz/crypto/test:TestUtil", + "//fizz/protocol/clock/test:mock_clock", + "//fizz/protocol/test:mocks", + "//fizz/server:ticket_types", + "//fizz/util:fizz_util", + "//folly:file_util", + "//folly/experimental:test_util", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "variant_test", + srcs = [ + "FizzVariantTest.cpp", + ], + deps = [ + "//fizz/util:variant", + "//folly/portability:gtest", + ], +) + +cpp_unittest( + name = "key_log_writer_test", + srcs = [ + "KeyLogWriterTest.cpp", + ], + deps = [ + "//fizz/crypto:random", + "//fizz/util:key_log_writer", + "//folly/portability:gtest", + ], +) diff --git a/shim/.buckconfig b/shim/.buckconfig new file mode 100644 index 00000000000..e69de29bb2d diff --git a/shim/.gitignore b/shim/.gitignore new file mode 100644 index 00000000000..a1412f7fa8e --- /dev/null +++ b/shim/.gitignore @@ -0,0 +1,5 @@ +# We currently expect end users to run reindeer vendor themselves +# so mark these things as to ignore +/third-party/rust/.cargo/ +/third-party/rust/BUCK +/third-party/rust/vendor/ diff --git a/shim/BUCK b/shim/BUCK new file mode 100644 index 00000000000..9e740dde55d --- /dev/null +++ b/shim/BUCK @@ -0,0 +1,5 @@ +load("@prelude//toolchains:demo.bzl", "system_demo_toolchains") + +# All the default toolchains, suitable for a quick demo or early prototyping. +# Most real projects should copy/paste the implementation to configure them. +system_demo_toolchains() diff --git a/shim/README.md b/shim/README.md new file mode 100644 index 00000000000..7a83226e02a --- /dev/null +++ b/shim/README.md @@ -0,0 +1,4 @@ +# Open Source Shim + +These files are a shim that allow us to build Buck2 with Buck2 outside Meta in +the open source world. diff --git a/shim/buck2/buck_rust_binary.bzl b/shim/buck2/buck_rust_binary.bzl new file mode 100644 index 00000000000..aad0fdab72b --- /dev/null +++ b/shim/buck2/buck_rust_binary.bzl @@ -0,0 +1,13 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load( + "//:shims.bzl", + _rust_binary = "rust_binary", +) + +buck_rust_binary = _rust_binary diff --git a/shim/buck2/proto_defs.bzl b/shim/buck2/proto_defs.bzl new file mode 100644 index 00000000000..5cafa19acc3 --- /dev/null +++ b/shim/buck2/proto_defs.bzl @@ -0,0 +1,13 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load( + "//:shims.bzl", + _rust_protobuf_library = "rust_protobuf_library", +) + +rust_protobuf_library = _rust_protobuf_library diff --git a/shim/build_defs/cpp_library.bzl b/shim/build_defs/cpp_library.bzl new file mode 100644 index 00000000000..1e2d7877d3a --- /dev/null +++ b/shim/build_defs/cpp_library.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load("//:shims.bzl", _cpp_library = "cpp_library") + +cpp_library = _cpp_library diff --git a/shim/build_defs/custom_unittest.bzl b/shim/build_defs/custom_unittest.bzl new file mode 100644 index 00000000000..f5aa4cf8f06 --- /dev/null +++ b/shim/build_defs/custom_unittest.bzl @@ -0,0 +1,9 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def custom_unittest(**_): + pass diff --git a/shim/build_defs/export_files.bzl b/shim/build_defs/export_files.bzl new file mode 100644 index 00000000000..b34d9a4b6a6 --- /dev/null +++ b/shim/build_defs/export_files.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def export_file(visibility = ["PUBLIC"], **kwargs): + # @lint-ignore BUCKLINT: avoid "native is forbidden in fbcode" + native.export_file(visibility = visibility, **kwargs) diff --git a/shim/build_defs/lib/python_common.bzl b/shim/build_defs/lib/python_common.bzl new file mode 100644 index 00000000000..44dc7574685 --- /dev/null +++ b/shim/build_defs/lib/python_common.bzl @@ -0,0 +1,14 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def get_ldflags(*args): + _unused = args # @unused + return [] + +def get_strip_mode(*args): + _unused = args # @unused + return "" diff --git a/shim/build_defs/native_rules.bzl b/shim/build_defs/native_rules.bzl new file mode 100644 index 00000000000..fb9bddda7e9 --- /dev/null +++ b/shim/build_defs/native_rules.bzl @@ -0,0 +1,22 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def buck_genrule(visibility = ["PUBLIC"], **kwargs): + # @lint-ignore BUCKLINT: avoid "native is forbidden in fbcode" + native.genrule(visibility = visibility, **kwargs) + +def buck_command_alias(**_): + pass + +def buck_filegroup(visibility = ["PUBLIC"], **kwargs): + # @lint-ignore BUCKLINT: avoid "native is forbidden in fbcode" + native.filegroup(visibility = visibility, **kwargs) + +def alias(actual, visibility = ["PUBLIC"], **kwargs): + if actual.startswith("//buck2/"): + actual = "root//" + actual.removeprefix("//buck2/") + native.alias(actual = actual, visibility = visibility, **kwargs) diff --git a/shim/build_defs/ocaml_binary.bzl b/shim/build_defs/ocaml_binary.bzl new file mode 100644 index 00000000000..d5fd250f07a --- /dev/null +++ b/shim/build_defs/ocaml_binary.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load("//:shims.bzl", _ocaml_binary = "ocaml_binary") + +ocaml_binary = _ocaml_binary diff --git a/shim/build_defs/platform_utils.bzl b/shim/build_defs/platform_utils.bzl new file mode 100644 index 00000000000..2ea71572f96 --- /dev/null +++ b/shim/build_defs/platform_utils.bzl @@ -0,0 +1,11 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def _get_cxx_platform_for_base_path(_base_path): + return struct(target_platform = None) + +platform_utils = struct(get_cxx_platform_for_base_path = _get_cxx_platform_for_base_path) diff --git a/shim/build_defs/python_binary.bzl b/shim/build_defs/python_binary.bzl new file mode 100644 index 00000000000..5805fc30bd2 --- /dev/null +++ b/shim/build_defs/python_binary.bzl @@ -0,0 +1,12 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def python_binary(srcs = [], **kwargs): + _unused = srcs # @unused + + # @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." + native.python_binary(**kwargs) diff --git a/shim/build_defs/rust_binary.bzl b/shim/build_defs/rust_binary.bzl new file mode 100644 index 00000000000..188df9aa23f --- /dev/null +++ b/shim/build_defs/rust_binary.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load("//:shims.bzl", _rust_binary = "rust_binary") + +rust_binary = _rust_binary diff --git a/shim/build_defs/rust_library.bzl b/shim/build_defs/rust_library.bzl new file mode 100644 index 00000000000..da9da2f0cd0 --- /dev/null +++ b/shim/build_defs/rust_library.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load("//:shims.bzl", _rust_library = "rust_library") + +rust_library = _rust_library diff --git a/shim/build_defs/rust_unittest.bzl b/shim/build_defs/rust_unittest.bzl new file mode 100644 index 00000000000..17f03052fd1 --- /dev/null +++ b/shim/build_defs/rust_unittest.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +load("//:shims.bzl", _rust_unittest = "rust_unittest") + +rust_unittest = _rust_unittest diff --git a/shim/common/ocaml/interop/defs.bzl b/shim/common/ocaml/interop/defs.bzl new file mode 100644 index 00000000000..b8e7f978fe2 --- /dev/null +++ b/shim/common/ocaml/interop/defs.bzl @@ -0,0 +1,3 @@ +load("@root//defs.bzl", _RUST_FLAGS_2018 = "RUST_FLAGS_2018") + +RUST_FLAGS_2018 = _RUST_FLAGS_2018 diff --git a/shim/grpc_fb/codegen/buck_macros.bzl b/shim/grpc_fb/codegen/buck_macros.bzl new file mode 100644 index 00000000000..ed51cb69355 --- /dev/null +++ b/shim/grpc_fb/codegen/buck_macros.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def grpc_library(**kwargs): + _unused = kwargs # @unused + pass diff --git a/shim/shims.bzl b/shim/shims.bzl new file mode 100644 index 00000000000..4bc98f9fef9 --- /dev/null +++ b/shim/shims.bzl @@ -0,0 +1,250 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +# @lint-ignore-every FBCODEBZLADDLOADS + +prelude = native + +_SELECT_TYPE = type(select({"DEFAULT": []})) + +def is_select(thing): + return type(thing) == _SELECT_TYPE + +def cpp_library( + deps = [], + external_deps = [], + undefined_symbols = None, + visibility = ["PUBLIC"], + **kwargs): + _unused = undefined_symbols # @unused + + prelude.cxx_library( + deps = _maybe_select_map(deps + external_deps_to_targets(external_deps), _fix_deps), + visibility = visibility, + preferred_linkage = "static", + **kwargs + ) + +def rust_library( + rustc_flags = [], + deps = [], + named_deps = None, + os_deps = None, + test_deps = None, + test_env = None, + test_os_deps = None, + autocargo = None, + unittests = None, + mapped_srcs = {}, + visibility = ["PUBLIC"], + **kwargs): + _unused = (test_deps, test_env, test_os_deps, named_deps, autocargo, unittests, visibility) # @unused + deps = _maybe_select_map(deps, _fix_deps) + mapped_srcs = _maybe_select_map(mapped_srcs, _fix_mapped_srcs) + if os_deps: + deps += _select_os_deps(_fix_dict_deps(os_deps)) + + # Reset visibility because internal and external paths are different. + visibility = ["PUBLIC"] + + prelude.rust_library( + rustc_flags = rustc_flags + [_CFG_BUCK_BUILD], + deps = deps, + visibility = visibility, + mapped_srcs = mapped_srcs, + **kwargs + ) + +def rust_binary( + rustc_flags = [], + deps = [], + autocargo = None, + unittests = None, + allocator = None, + default_strip_mode = None, + visibility = ["PUBLIC"], + **kwargs): + _unused = (unittests, allocator, default_strip_mode, autocargo) # @unused + deps = _maybe_select_map(deps, _fix_deps) + + # @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." + prelude.rust_binary( + rustc_flags = rustc_flags + [_CFG_BUCK_BUILD], + deps = deps, + visibility = visibility, + **kwargs + ) + +def rust_unittest( + rustc_flags = [], + deps = [], + visibility = ["PUBLIC"], + **kwargs): + deps = _maybe_select_map(deps, _fix_deps) + + prelude.rust_test( + rustc_flags = rustc_flags + [_CFG_BUCK_BUILD], + deps = deps, + visibility = visibility, + **kwargs + ) + +def rust_protobuf_library( + name, + srcs, + build_script, + protos, + build_env = None, + deps = [], + test_deps = None, + doctests = True): + if build_env: + build_env = { + k: _fix_dep_in_string(v) + for k, v in build_env.items() + } + + build_name = name + "-build" + proto_name = name + "-proto" + + rust_binary( + name = build_name, + srcs = [build_script], + crate_root = build_script, + deps = [ + "fbsource//third-party/rust:tonic-build", + "//buck2/app/buck2_protoc_dev:buck2_protoc_dev", + ], + ) + + build_env = build_env or {} + build_env.update( + { + "PROTOC": "$(exe buck//third-party/proto:protoc)", + "PROTOC_INCLUDE": "$(location buck//third-party/proto:google_protobuf)", + }, + ) + + prelude.genrule( + name = proto_name, + srcs = protos + [ + "buck//third-party/proto:google_protobuf", + ], + out = ".", + cmd = "$(exe :" + build_name + ")", + env = build_env, + ) + + rust_library( + name = name, + srcs = srcs, + doctests = doctests, + env = { + # This is where prost looks for generated .rs files + "OUT_DIR": "$(location :{})".format(proto_name), + }, + test_deps = test_deps, + deps = [ + "fbsource//third-party/rust:prost", + "fbsource//third-party/rust:prost-types", + ] + (deps or []), + ) + + # For python tests only + for proto in protos: + prelude.export_file( + name = proto, + visibility = ["PUBLIC"], + ) + +def ocaml_binary( + deps = [], + visibility = ["PUBLIC"], + **kwargs): + deps = _maybe_select_map(deps, _fix_deps) + + prelude.ocaml_binary( + deps = deps, + visibility = visibility, + **kwargs + ) + +_CFG_BUCK_BUILD = "--cfg=buck_build" + +def _maybe_select_map(v, mapper): + if is_select(v): + return select_map(v, mapper) + return mapper(v) + +def _select_os_deps(xss: list[( + str, + list[str], +)]) -> Select: + d = { + "prelude//os:" + os: xs + for os, xs in xss + } + d["DEFAULT"] = [] + return select(d) + +def _fix_dict_deps(xss: list[( + str, + list[str], +)]) -> list[( + str, + list[str], +)]: + return [ + (k, _fix_deps(xs)) + for k, xs in xss + ] + +def _fix_mapped_srcs(xs: dict[str, str]): + # For reasons, this is source -> file path, which is the opposite of what + # it should be. + return {_fix_dep(k): v for (k, v) in xs.items()} + +def _fix_deps(xs: list[str]) -> list[str]: + return filter(None, map(_fix_dep, xs)) + +def _fix_dep(x: str) -> [ + None, + str, +]: + if x == "//common/rust/shed/fbinit:fbinit": + return "fbsource//third-party/rust:fbinit" + elif x == "//common/rust/shed/sorted_vector_map:sorted_vector_map": + return "fbsource//third-party/rust:sorted_vector_map" + elif x == "//watchman/rust/watchman_client:watchman_client": + return "fbsource//third-party/rust:watchman_client" + elif x.startswith("fbsource//third-party/rust:") or x.startswith(":"): + return x + elif x.startswith("//buck2/facebook/"): + return None + elif x.startswith("//buck2/"): + return "root//" + x.removeprefix("//buck2/") + elif x.startswith("fbcode//common/ocaml/interop/"): + return "root//" + x.removeprefix("fbcode//common/ocaml/interop/") + elif x.startswith("fbcode//third-party-buck/platform010/build/supercaml"): + return "shim//third-party/ocaml" + x.removeprefix("fbcode//third-party-buck/platform010/build/supercaml") + else: + fail("Dependency is unaccounted for `{}`.\n".format(x) + + "Did you forget 'oss-disable'?") + +def _fix_dep_in_string(x: str) -> str: + """Replace internal labels in string values such as env-vars.""" + return (x + .replace("//buck2/", "root//")) + +# Do a nasty conversion of e.g. ("supercaml", None, "ocaml-dev") to +# 'fbcode//third-party-buck/platform010/build/supercaml:ocaml-dev' +# (which will then get mapped to `shim//third-party/ocaml:ocaml-dev`). +def external_dep_to_target(t): + return "fbcode//third-party-buck/platform010/build/{}:{}".format(t[0], t[2]) + +def external_deps_to_targets(ts): + return [external_dep_to_target(t) for t in ts] diff --git a/shim/target_determinator/macros/ci.bzl b/shim/target_determinator/macros/ci.bzl new file mode 100644 index 00000000000..abbd47d8835 --- /dev/null +++ b/shim/target_determinator/macros/ci.bzl @@ -0,0 +1,26 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def _lbl(*_args): + return "" + +def _package( + _values, + # starlark-lint-disable unused-argument + overwrite = False): # @unused + pass + +ci = struct( + package = _package, + linux = _lbl, + mac = _lbl, + windows = _lbl, + skip_test = _lbl, + aarch64 = _lbl, + mode = _lbl, + opt = _lbl, +) diff --git a/shim/third-party/macros/rust_third_party.bzl b/shim/third-party/macros/rust_third_party.bzl new file mode 100644 index 00000000000..f6a0bd3d227 --- /dev/null +++ b/shim/third-party/macros/rust_third_party.bzl @@ -0,0 +1,11 @@ +# @nolint + +def third_party_rust_prebuilt_cxx_library(name, **kwargs): + # FIXME: This should probably be a fixup.toml, but it currently can't be expressed. + # The windows-sys crate does -lwindows to find windows. We pass libwindows.a on the command line, + # which resolves the symbols, but the linker still needs to "find" windows, so we also put its + # directory on the link options. + if name.endswith("libwindows.a"): + kwargs["exported_linker_flags"] = ["-Lshim/third-party/rust/" + kwargs["static_lib"].rpartition("/")[0]] + + native.prebuilt_cxx_library(name = name, **kwargs) diff --git a/shim/third-party/ocaml/BUCK b/shim/third-party/ocaml/BUCK new file mode 100644 index 00000000000..2343d7b5ee9 --- /dev/null +++ b/shim/third-party/ocaml/BUCK @@ -0,0 +1,7 @@ +# @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." +prebuilt_cxx_library( + name = "ocaml-dev", + header_dirs = ["opam/lib/ocaml"], + header_only = True, + visibility = ["PUBLIC"], +) diff --git a/shim/third-party/proto/BUCK b/shim/third-party/proto/BUCK new file mode 100644 index 00000000000..d8381b74dc0 --- /dev/null +++ b/shim/third-party/proto/BUCK @@ -0,0 +1,21 @@ +# @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." +load(":defs.bzl", "protoc_distribution") + +protoc_distribution( + name = "distribution", + version = "21.4", +) + +# @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." +alias( + name = "protoc", + actual = ":distribution[protoc]", + visibility = ["PUBLIC"], +) + +# @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." +alias( + name = "google_protobuf", + actual = ":distribution[google_protobuf]", + visibility = ["PUBLIC"], +) diff --git a/shim/third-party/proto/defs.bzl b/shim/third-party/proto/defs.bzl new file mode 100644 index 00000000000..18938c5a7fd --- /dev/null +++ b/shim/third-party/proto/defs.bzl @@ -0,0 +1,105 @@ +load("@prelude//http_archive/exec_deps.bzl", "HttpArchiveExecDeps") +load(":releases.bzl", "releases") + +ProtocReleaseInfo = provider(fields = [ + "version", + "url", + "sha256", +]) + +def _get_protoc_release( + version: str, + platform: str) -> ProtocReleaseInfo: + if not version in releases: + fail("Unknown protoc release version '{}'. Available versions: {}".format( + version, + ", ".join(releases.keys()), + )) + protoc_version = releases[version] + artifact = "protoc-{}-{}.zip".format(version, platform) + if not artifact in protoc_version: + fail("Unsupported platform '{}'. Available artifacts: {}".format( + platform, + ", ".join(protoc_version.keys()), + )) + protoc_artifact = protoc_version[artifact] + return ProtocReleaseInfo( + version = version, + url = protoc_artifact["url"], + sha256 = protoc_artifact["sha256"], + ) + +def _turn_http_archive_into_protoc_distribution( + providers: ProviderCollection, + protoc_filename: str) -> list[Provider]: + downloads = providers[DefaultInfo].sub_targets + include = downloads["include"][DefaultInfo] + protoc = downloads[protoc_filename][DefaultInfo] + + return [DefaultInfo( + sub_targets = { + "google_protobuf": [include], + "protoc": [ + protoc, + RunInfo(args = protoc.default_outputs[0]), + ], + }, + )] + +def _download_protoc_distribution_impl(ctx: AnalysisContext) -> Promise: + protoc_filename = "bin/protoc" + ctx.attrs.exe_extension + + # @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." + return ctx.actions.anon_target(native.http_archive, { + "exec_deps": ctx.attrs._http_archive_exec_deps, + "sha256": ctx.attrs.sha256, + "sub_targets": [ + protoc_filename, + "include", + ], + "urls": [ctx.attrs.url], + }).promise.map(lambda providers: _turn_http_archive_into_protoc_distribution( + providers = providers, + protoc_filename = protoc_filename, + )) + +download_protoc_distribution = rule( + impl = _download_protoc_distribution_impl, + attrs = { + "exe_extension": attrs.string(), + "sha256": attrs.string(), + "url": attrs.string(), + "_http_archive_exec_deps": attrs.default_only(attrs.exec_dep(providers = [HttpArchiveExecDeps], default = "prelude//http_archive/tools:exec_deps")), + }, +) + +def _host_platform(): + os = host_info().os + arch = host_info().arch + if os.is_linux and arch.is_x86_64: + return "linux-x86_64" + elif os.is_linux and arch.is_aarch64: + return "linux-aarch_64" + elif os.is_macos and arch.is_x86_64: + return "osx-x86_64" + elif os.is_macos and arch.is_aarch64: + return "osx-aarch_64" + elif os.is_windows and arch.is_x86_64: + return "win64" + else: + fail("Unknown platform: os={}, arch={}".format(os, arch)) + +def protoc_distribution( + name: str, + version: str, + platform: [None, str] = None): + if platform == None: + platform = _host_platform() + exe_extension = ".exe" if platform.startswith("win") else "" + release = _get_protoc_release(version, platform) + download_protoc_distribution( + name = name, + url = release.url, + sha256 = release.sha256, + exe_extension = exe_extension, + ) diff --git a/shim/third-party/proto/releases.bzl b/shim/third-party/proto/releases.bzl new file mode 100644 index 00000000000..153ca496e4c --- /dev/null +++ b/shim/third-party/proto/releases.bzl @@ -0,0 +1,46 @@ +# @generated +# Update with ./update.py > releases.bzl +releases = { + "21.4": { + "protoc-21.4-win32.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-win32.zip", + "sha256": "09760ff98f76ac30c8bca7433715c47161fe305bf41573a7cd00b0afcc518617" + }, + "protoc-21.4-osx-x86_64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-osx-x86_64.zip", + "sha256": "27ac01aee3e8b95ebec017b7b3aee55d4eb095cbd2a5148d2a20350af006072e" + }, + "protoc-21.4-osx-universal_binary.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-osx-universal_binary.zip", + "sha256": "0cf1a340d1fa1366cdf22043e3f92e5374096647037020b405acea706438c603" + }, + "protoc-21.4-osx-aarch_64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-osx-aarch_64.zip", + "sha256": "6a677c88a5e5b032aaff96767461788a316408d4ed0afef3f1455390a689ec18" + }, + "protoc-21.4-linux-x86_64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-x86_64.zip", + "sha256": "d51e8f030162f08823a4738ab0ac00bee537e30b583a562e6962dbb040d86736" + }, + "protoc-21.4-linux-x86_32.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-x86_32.zip", + "sha256": "2101e3a4dd490625c15d31274a599e3bfb1f8c9fdd381ca9501da17bb6f7a3d2" + }, + "protoc-21.4-linux-s390_64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-s390_64.zip", + "sha256": "e0b69b4242bf409c825d787669a4683d63320d6e52280750df971a3376e0af56" + }, + "protoc-21.4-linux-ppcle_64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-ppcle_64.zip", + "sha256": "58c1be8ca89b8b2712f95a9dd9aeb174f8f479be9f55e71f6ffe0b0e83ef8be9" + }, + "protoc-21.4-linux-aarch_64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-aarch_64.zip", + "sha256": "5a377b505cf8c3ed29ad0b6e3827c5eb27273c00147fcfd833b9686192143e8d" + }, + "protoc-21.4-win64.zip": { + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-win64.zip", + "sha256": "090af381392abaf5fd8ae3070d8fc2a4ba2d0a9f8e52915d69b439c33be72da5" + } + } +} diff --git a/shim/third-party/proto/update.py b/shim/third-party/proto/update.py new file mode 100755 index 00000000000..cfee489f671 --- /dev/null +++ b/shim/third-party/proto/update.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +"""Query recent Github release artifacts for protobuf. + +Use this script to update the releases.bzl file that contains metadata about +protoc releases. + +This script is not executed during the regular Buck2 build. +""" + +import aiohttp +import asyncio +from contextlib import asynccontextmanager +from copy import deepcopy +from gql import gql, Client +from gql.transport.aiohttp import AIOHTTPTransport +import hashlib +import json +import os + +GITHUB_GRAPHQL_URI = "https://api.github.com/graphql" +GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN") +GITHUB_QUERY = """\ +query { + repository(owner: "protocolbuffers", name: "protobuf") { + releases(last: 1) { + nodes { + tagName + releaseAssets(first: 100) { + nodes { + name + downloadUrl + } + } + } + } + } +} +""" + +async def query_releases(): + async with aiohttp.ClientSession(raise_for_status=True) as session: + assert GITHUB_TOKEN is not None, "Provide a Github API token in $GITHUB_TOKEN" + headers = {'Authorization': f'bearer {GITHUB_TOKEN}'} + body = {"query": GITHUB_QUERY} + async with session.post(GITHUB_GRAPHQL_URI, headers=headers, json=body) as resp: + response = await resp.json() + return response["data"] + + +def format_releases(releases): + return { + release["tagName"].strip("v"): { + asset["name"]: { + "url": asset["downloadUrl"], + } + for asset in release["releaseAssets"]["nodes"] + if asset["name"].startswith("protoc-") + } + for release in releases["repository"]["releases"]["nodes"] + } + + +async def fetch_sha256(session, url): + async with session.get(url) as resp: + hasher = hashlib.sha256() + async for chunk, _ in resp.content.iter_chunks(): + hasher.update(chunk) + return hasher.hexdigest() + + +async def hash_releases(releases): + async def hash_asset(session, version, name, url): + sha256 = await fetch_sha256(session, url) + return (version, name, sha256) + + tasks = [] + async with aiohttp.ClientSession() as session: + for version, assets in releases.items(): + for name, asset in assets.items(): + tasks.append(hash_asset(session, version, name, asset["url"])) + + result = deepcopy(releases) + hashes = await asyncio.gather(*tasks) + for version, name, sha256 in hashes: + result[version][name]["sha256"] = sha256 + + return result + + +async def main(): + releases = await query_releases() + formatted = format_releases(releases) + with_sha256 = await hash_releases(formatted) + print("# @" + "generated") + print("# Update with ./update.py > releases.bzl") + print("releases = ", json.dumps(with_sha256, indent=4)) + + +asyncio.run(main()) diff --git a/shim/third-party/rust/.gitignore b/shim/third-party/rust/.gitignore new file mode 100644 index 00000000000..c18f3dc437a --- /dev/null +++ b/shim/third-party/rust/.gitignore @@ -0,0 +1,31 @@ +# Ignore Cargo-related stuff +.cargo/registry +.cargo/git +/registry +/git +.package-cache + +# Various cruft in vendored packages +vendor/*/target +vendor/*/Cargo.lock +vendor/**/.buckconfig +vendor/**/BUCK +vendor/**/OWNERS +vendor/**/*~ +vendor/**/*.bzl +vendor/*/.github/** +vendor/*/.appveyor.yml +vendor/*/.travis.yml +/target/** + +# Bad Windows names - oh for case-insensitive regex matching! +vendor/**/[Aa][Uu][Xx] +vendor/**/[Aa][Uu][Xx].* +vendor/**/[Cc][Oo][Mm][1-9] +vendor/**/[Cc][Oo][Mm][1-9].* +vendor/**/[Cc][Oo][Nn] +vendor/**/[Cc][Oo][Nn].* +vendor/**/[Ll][Pp][Tt][1-9] +vendor/**/[Ll][Pp][Tt][1-9].* +vendor/**/[Nn][Uu][Ll] +vendor/**/[Nn][Uu][Ll].* diff --git a/shim/third-party/rust/Cargo.toml b/shim/third-party/rust/Cargo.toml new file mode 100644 index 00000000000..95749d12cbf --- /dev/null +++ b/shim/third-party/rust/Cargo.toml @@ -0,0 +1,225 @@ +# Definitions of third-party libraries used for buck2 build of buck2. +# This file is **not** used by cargo build of buck2. +# See the /docs/bootstrapping.md for more details. + +[workspace] + +[package] +# Pseudo-package whose dependencies are imported and buckified +name = "rust-third-party" +version = "0.0.0" +publish = false +edition = "2021" + +# Dummy target to keep Cargo happy +[[bin]] +name = "top" +path = "top/main.rs" + +# List of packages to be imported, with version constraints, features +# and all options Cargo supports. +[dependencies] + +gazebo = {version = "0.8.1", features = ["str_pattern_extensions"]} +fbinit = "0.1" +sorted_vector_map = "0.1" +watchman_client = "0.8.0" + +annotate-snippets = { version = "0.9.0", features = ["color"] } +anyhow = "1.0.65" +anymap = "0.12.1" +arc-swap = "1.6.0" +argfile = "0.1.0" +assert_matches = "1.5" +async-compression = { version = "0.4.1", features = ["tokio", "gzip", "zstd"] } +async-condvar-fair = { version = "0.2.2", features = ["parking_lot_0_11", "tokio"] } +async-recursion = "1.0" +async-scoped = { version = "0.8", features = ["use-tokio"] } +async-trait = "0.1.24" +atomic = "0.5.1" +backtrace = "0.3.51" +base64 = "0.13.0" +bincode = "1.3.3" +bitflags = "2.4" +blake3 = { version = "1.3.1", features = [ "default", "digest", "rayon", "std", "traits-preview" ] } +bstr = { version = "1.4.0", features = ["serde", "std", "unicode"] } +bumpalo = { version = "3.14.0", features = ["allocator_api", "collections"] } +byteorder = "1.4.3" +bytes = "1.0" +bytesize = "1.1.0" +chrono = "0.4.28" +clap = { package = "clap", version = "4.5.4", features = ["derive", "env", "string"] } +clap-3 = { package = "clap", version = "3.2.24", features = ["derive", "env", "regex", "unicode", "wrap_help"] } +common-path = "1.0.0" +compact_str = "0.6.1" +constant_time_eq = "0.2.4" +convert_case = "0.4.0" +criterion = { version = "0.3.1", features = [] } +crossbeam = "0.8" +crossbeam-channel = "0.5" +crossbeam-epoch = "0.9.7" +crossterm = "0.27" +csv = "1.1" +ctor = "0.1.16" +dashmap = "5.5.3" +debugserver-types = "0.5.0" +derivative = "2.2" +derive_more = "0.99.3" +digest = "0.10" +dirs = "3.0.1" +dunce = "1.0.2" +either = "1.8" +enum-iterator = "1.4.1" +enum-map = "0.6.3" +env_logger = "0.9.0" +equivalent = "1.0.0" +erased-serde = "0.3.20" +faccess = "0.2.3" +fancy-regex = "0.10.0" +flate2 = "1.0.22" +fnv = "1.0.7" +fs4 = { version = "0.6", features = ["sync"] } +futures = { version = "0.3.28", features = ["async-await", "compat"] } +futures-intrusive = "0.4" +fxhash = "0.2.1" +glob = "0.3.0" +globset = "0.4.10" +hashbrown = { version = "0.14.3", features = ["raw"] } +hex = "0.4.3" +higher-order-closure = "0.0.5" +hostname = "0.3.1" +http = "0.2" +httparse = "1.7.1" +httptest = "0.15" +humantime = "2.0.1" +hyper = { version = "0.14.26", features = ["client", "http1", "http2"] } +hyper-proxy = { git = "https://github.com/get9/hyper-proxy", rev = "205e9fee42d469444d654d9fa207897f4a77d5b6", features = ["rustls"], default_features = false } # branch = tokio-rustls-0.23 Many PRs to bump versions (#28, #30, #31) are several years old, possibly abandoned crate. This fork contains changes from #28 + changes to upgrade rustls to 0.21. +hyper-rustls = { version = "0.24.0", features = ["http2"] } +hyper-timeout = "0.4" +hyper-unix-connector = "0.2" +indent_write = "2.2.0" +indenter = "0.3.3" +indexmap = { version = "2.1.0", features = ["arbitrary", "rayon", "serde"] } +indoc = "1.0.3" +inferno = { version = "0.11.11", default-features = false } +internment = { version = "0.7", features = ["arc"] } +inventory = "0.3.8" +ipnetwork = "0.20.0" +is_proc_translated = "0.1.1" +itertools = "0.10.3" +jemallocator = { version = "0.5.0", features = ["profiling"] } +lalrpop = { version = "0.19.7", artifact = "bin", features = ["pico-args"] } +lalrpop-util = "0.19.7" +libc = "0.2.132" +linked-hash-map = { version = "0.5", features = ["serde_impl"] } +linkme = { version = "0.3.17", features = ["used_linker"] } +log = "0.4" +logos = "0.12" +lsp-server = "0.7.2" +lsp-types = "0.94.1" +maplit = "1.0.2" +mappable-rc = { version = "0.1.1", features = ["std"] } +md-5 = "0.10" +memchr = "2.4.1" +memmap2 = "0.5.0" +memoffset = "0.6.4" +multimap = "0.8.2" +nix = "0.22" +nom = "7.1.3" +notify = "=5.0.0-pre.16" +num-bigint = "0.4.3" +num-traits = "0.2" +num_cpus = "1.11" +num_enum = "0.5" +object = "0.29.0" +once_cell = "1.8" +os_str_bytes = { version = "6.6.0", features = ["conversions"] } +parking_lot = { version = "0.11.2", features = ["send_guard"] } +paste = "1.0" +pathdiff = "0.2" +perf-event = "0.4" +perf-event-open-sys = "4.0" +pin-project = "0.4.29" +plist = "0.5" +pretty_assertions = "1.2.1" +proc-macro2 = { version = "1.0.70", features = ["span-locations"] } +prost = "0.11.9" +prost-build = "0.11.9" +prost-derive = "0.11.9" +prost-types = "0.11.9" +protoc-bin-vendored = "3.0.0" +psutil = "3.2" +quote = "1.0.3" +rand = { version = "0.8.4", features = ["small_rng"] } +rand_chacha = "0.3" +rand_distr = "0.4" +ref-cast = "1.0.0" +regex = "1.5.4" +relative-path = { version = "1.7.0", features = ["serde"] } +ring = "=0.17.5" # Upgrading this is possible, but a pain, so we don't want to pick up every new minor version +rusqlite = { version = "0.29.0", features = ["bundled"] } +rustc-hash = "1.1.0" +rustls = "0.21.0" +rustls-native-certs = { package = "rustls-native-certs", version = "0.6.2" } +rustls-pemfile = { package = "rustls-pemfile", version = "1.0.0" } +rustyline = "11.0" +scopeguard = "1.0.0" +sequence_trie = "0.3.6" +serde = { version = "1.0.173", features = ["derive", "rc"] } +serde_json = "1.0.48" +sha1 = "0.10" +sha2 = "0.10" +shlex = "1.3" +similar = { version = "2.2.0", features = ["inline"] } +siphasher = "0.3.3" +slab = "0.4.7" +slog = "2.7.0" +smallvec = { version = "1.10", features = ["const_generics", "const_new", "serde", "specialization", "union", "write"] } +static_assertions = "1.1.0" +strsim = "0.10.0" +structopt = "0.3.23" +syn = { version = "2", features = ["extra-traits", "full", "visit"] } +syn1 = { package = "syn", version = "1.0.109", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] } +synstructure = "0.12" +sync_wrapper = "0.1.0" +sys-info = "0.9.1" +sysinfo = "0.26.8" +take_mut = "0.2.2" +tar = "0.4.38" +tempfile = "3.1.0" +termimad = "0.20.1" +termios = "0.3" +termwiz = "0.18" +test-case = "3.1.0" +textwrap = { version = "0.11", features = ["term_size"] } +thiserror = "1.0.36" +threadpool = "1.8.1" +tokio = { version = "1.25.0", features = ["full", "test-util", "tracing"] } +tokio-rustls = { package = "tokio-rustls", version = "0.24.0", features = ["dangerous_configuration"] } +tokio-stream = { version = "0.1.14", features = ["fs", "io-util", "net", "sync", "time", "signal"] } +tokio-util = { version = "0.6", features = ["full"] } +toml = "0.5" +tonic = { version = "0.9.2", features = ["tls", "tls-webpki-roots"] } +tonic-build = { version = "0.9.2", features = ["prost", "cleanup-markdown"] } +tower = "0.4" +tower-layer = "0.3.1" +tower-service = "0.3.2" +tracing = "0.1.22" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +triomphe = "0.1.11" +trybuild = "1.0.56" +twox-hash = "1.6.1" +unicode-segmentation = "1.7" +uuid = { version = "1.2", features = ["v4"] } +walkdir = "2.3.2" +which = "4.3.0" +windows_x86_64_msvc = "=0.48.0" # our fixup only works if we are on precisely 0.48.0 +winapi = { version = "0.3", features = ["everything"] } +xattr = "0.2.2" +zip = "0.5" +zstd = "0.13.0" + +[patch.crates-io] +# For https://github.com/jimblandy/perf-event/pull/29 +perf-event = { git = "https://github.com/krallin/perf-event.git", rev = "86224a9bc025d5d19f719542f27c8c629a08b167", version = "0.4" } +perf-event-open-sys = { git = "https://github.com/krallin/perf-event.git", rev = "86224a9bc025d5d19f719542f27c8c629a08b167", version = "4.0" } diff --git a/shim/third-party/rust/defs.bzl b/shim/third-party/rust/defs.bzl new file mode 100644 index 00000000000..6d295fdd565 --- /dev/null +++ b/shim/third-party/rust/defs.bzl @@ -0,0 +1,7 @@ +def rust_library_from_crates(name): + # @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." + native.export_file(name = name, src = "BUCK", visibility = ["PUBLIC"]) + +def rust_binary_from_crates(name): + # @lint-ignore BUCKLINT: avoid "Direct usage of native rules is not allowed." + native.genrule(name = name, cmd = "exit 1", executable = True, out = "out", visibility = ["PUBLIC"]) diff --git a/shim/third-party/rust/fixups/ahash/fixups.toml b/shim/third-party/rust/fixups/ahash/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/ahash/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/anyhow/fixups.toml b/shim/third-party/rust/fixups/anyhow/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/anyhow/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/async-trait/fixups.toml b/shim/third-party/rust/fixups/async-trait/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/async-trait/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/atomic/fixups.toml b/shim/third-party/rust/fixups/atomic/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/atomic/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/axum-core/fixups.toml b/shim/third-party/rust/fixups/axum-core/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/axum-core/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/axum/fixups.toml b/shim/third-party/rust/fixups/axum/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/axum/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/backtrace/fixups.toml b/shim/third-party/rust/fixups/backtrace/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/backtrace/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/blake3/fixups.toml b/shim/third-party/rust/fixups/blake3/fixups.toml new file mode 100644 index 00000000000..389fd57acfc --- /dev/null +++ b/shim/third-party/rust/fixups/blake3/fixups.toml @@ -0,0 +1,81 @@ +buildscript = [] + +## The various X86 platform fixups + +[platform_fixup.'cfg(target_arch = "x86_64")'] +cfgs = ["blake3_sse2_ffi", "blake3_sse41_ffi", "blake3_avx2_ffi", "blake3_avx512_ffi"] +buildscript = [] + +# , any(target_env = "fbcode", target_env = "gnu") +[[platform_fixup.'cfg(all(target_arch = "x86_64", any(target_os = "linux", target_os = "macos")))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", any(target_os = "linux", target_os = "macos")))'.buildscript.cxx_library] +name = "simd_x86_unix" +srcs = [ + "c/blake3.c", + "c/blake3_dispatch.c", + "c/blake3_portable.c", + "c/blake3_sse2_x86-64_unix.S", + "c/blake3_sse41_x86-64_unix.S", + "c/blake3_avx2_x86-64_unix.S", + "c/blake3_avx512_x86-64_unix.S" +] +# Older versions of Clang require these flags, even for assembly. See +# https://github.com/BLAKE3-team/BLAKE3/issues/79. +compiler_flags = ["-mavx512f", "-mavx512vl"] +headers = ["c/*.h"] +compatible_with = [ + "prelude//os/constraints:linux", + "prelude//os/constraints:macos", +] + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu"))'.buildscript.cxx_library] +name = "simd_x86_windows_gnu" +srcs = [ + "c/blake3.c", + "c/blake3_dispatch.c", + "c/blake3_portable.c", + "c/blake3_sse2_x86-64_windows_gnu.S", + "c/blake3_sse41_x86-64_windows_gnu.S", + "c/blake3_avx2_x86-64_windows_gnu.S", + "c/blake3_avx512_x86-64_windows_gnu.S" +] +# Older versions of Clang require these flags, even for assembly. See +# https://github.com/BLAKE3-team/BLAKE3/issues/79. +compiler_flags = ["-mavx512f", "-mavx512vl"] +headers = ["c/*.h"] +compatible_with = ["prelude//os/constraints:windows"] + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))'.buildscript.cxx_library] +name = "simd_x86_windows_msvc" +srcs = [ + "c/blake3.c", + "c/blake3_dispatch.c", + "c/blake3_portable.c", + "c/blake3_sse2_x86-64_windows_msvc.asm", + "c/blake3_sse41_x86-64_windows_msvc.asm", + "c/blake3_avx2_x86-64_windows_msvc.asm", + "c/blake3_avx512_x86-64_windows_msvc.asm" +] +headers = ["c/*.h"] +compatible_with = ["prelude//os/constraints:windows"] + +## ARM and AArch64 fixups + +[platform_fixup.'cfg(any(target_arch = "aarch64", target_arch = "arm"))'] +cfgs = ["blake3_neon"] +buildscript = [] + +[[platform_fixup.'cfg(target_arch = "aarch64")'.buildscript]] +[platform_fixup.'cfg(target_arch = "aarch64")'.buildscript.cxx_library] +name = "simd_neon-aarch64" +srcs = ["c/blake3_neon.c"] +headers = ["c/*.h"] + +[[platform_fixup.'cfg(target_arch = "arm")'.buildscript]] +[platform_fixup.'cfg(target_arch = "arm")'.buildscript.cxx_library] +name = "simd_neon-armv7" +srcs = ["c/blake3_neon.c"] +compiler_flags = ["-mfpu=neon-vfpv4", "-mfloat-abi=hard"] +headers = ["c/*.h"] diff --git a/shim/third-party/rust/fixups/bumpalo/fixups.toml b/shim/third-party/rust/fixups/bumpalo/fixups.toml new file mode 100644 index 00000000000..edd9a2079bd --- /dev/null +++ b/shim/third-party/rust/fixups/bumpalo/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["README.md"] diff --git a/shim/third-party/rust/fixups/bzip2-sys/fixups.toml b/shim/third-party/rust/fixups/bzip2-sys/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/bzip2-sys/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/clap/fixups.toml b/shim/third-party/rust/fixups/clap/fixups.toml new file mode 100644 index 00000000000..ee94fdc2f29 --- /dev/null +++ b/shim/third-party/rust/fixups/clap/fixups.toml @@ -0,0 +1 @@ +omit_features = ["deprecated"] diff --git a/shim/third-party/rust/fixups/clap_builder/fixups.toml b/shim/third-party/rust/fixups/clap_builder/fixups.toml new file mode 100644 index 00000000000..edd9a2079bd --- /dev/null +++ b/shim/third-party/rust/fixups/clap_builder/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["README.md"] diff --git a/shim/third-party/rust/fixups/clap_derive/fixups.toml b/shim/third-party/rust/fixups/clap_derive/fixups.toml new file mode 100644 index 00000000000..ee94fdc2f29 --- /dev/null +++ b/shim/third-party/rust/fixups/clap_derive/fixups.toml @@ -0,0 +1 @@ +omit_features = ["deprecated"] diff --git a/shim/third-party/rust/fixups/core-foundation-sys/fixups.toml b/shim/third-party/rust/fixups/core-foundation-sys/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/core-foundation-sys/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/crc32fast/fixups.toml b/shim/third-party/rust/fixups/crc32fast/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/crc32fast/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/criterion/fixups.toml b/shim/third-party/rust/fixups/criterion/fixups.toml new file mode 100644 index 00000000000..41439d3356a --- /dev/null +++ b/shim/third-party/rust/fixups/criterion/fixups.toml @@ -0,0 +1 @@ +cargo_env = true diff --git a/shim/third-party/rust/fixups/crossbeam-epoch/fixups.toml b/shim/third-party/rust/fixups/crossbeam-epoch/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/crossbeam-epoch/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/crossbeam-queue/fixups.toml b/shim/third-party/rust/fixups/crossbeam-queue/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/crossbeam-queue/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/crossbeam-utils/fixups.toml b/shim/third-party/rust/fixups/crossbeam-utils/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/crossbeam-utils/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/crunchy/fixups.toml b/shim/third-party/rust/fixups/crunchy/fixups.toml new file mode 100644 index 00000000000..ac9ebfb4af7 --- /dev/null +++ b/shim/third-party/rust/fixups/crunchy/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.gen_srcs] diff --git a/shim/third-party/rust/fixups/darwin-libproc-sys/fixups.toml b/shim/third-party/rust/fixups/darwin-libproc-sys/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/darwin-libproc-sys/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/debugserver-types/fixups.toml b/shim/third-party/rust/fixups/debugserver-types/fixups.toml new file mode 100644 index 00000000000..50645274fe7 --- /dev/null +++ b/shim/third-party/rust/fixups/debugserver-types/fixups.toml @@ -0,0 +1,2 @@ +extra_srcs = ["src/schema.json"] +cargo_env = true diff --git a/shim/third-party/rust/fixups/erased-serde/fixups.toml b/shim/third-party/rust/fixups/erased-serde/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/erased-serde/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/fs-err/fixups.toml b/shim/third-party/rust/fixups/fs-err/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/fs-err/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/fs4/fixups.toml b/shim/third-party/rust/fixups/fs4/fixups.toml new file mode 100644 index 00000000000..af7edb27e3b --- /dev/null +++ b/shim/third-party/rust/fixups/fs4/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/futures-channel/fixups.toml b/shim/third-party/rust/fixups/futures-channel/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/futures-channel/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/futures-core/fixups.toml b/shim/third-party/rust/fixups/futures-core/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/futures-core/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/futures-task/fixups.toml b/shim/third-party/rust/fixups/futures-task/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/futures-task/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/futures-util/fixups.toml b/shim/third-party/rust/fixups/futures-util/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/futures-util/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/generic-array/fixups.toml b/shim/third-party/rust/fixups/generic-array/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/generic-array/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/getrandom/fixups.toml b/shim/third-party/rust/fixups/getrandom/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/getrandom/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/httparse/fixups.toml b/shim/third-party/rust/fixups/httparse/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/httparse/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/hyper/fixups.toml b/shim/third-party/rust/fixups/hyper/fixups.toml new file mode 100644 index 00000000000..9118e9de767 --- /dev/null +++ b/shim/third-party/rust/fixups/hyper/fixups.toml @@ -0,0 +1,5 @@ +# reindeer cannot see through `cfg_proto!` macros and the like +extra_srcs = ["src/**/*.rs"] + +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/indexmap/fixups.toml b/shim/third-party/rust/fixups/indexmap/fixups.toml new file mode 100644 index 00000000000..4aa45eda12c --- /dev/null +++ b/shim/third-party/rust/fixups/indexmap/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cfgs = ["has_std"] diff --git a/shim/third-party/rust/fixups/io-lifetimes/fixups.toml b/shim/third-party/rust/fixups/io-lifetimes/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/io-lifetimes/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/jemalloc-sys/fixups.toml b/shim/third-party/rust/fixups/jemalloc-sys/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/jemalloc-sys/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/lalrpop/fixups.toml b/shim/third-party/rust/fixups/lalrpop/fixups.toml new file mode 100644 index 00000000000..41439d3356a --- /dev/null +++ b/shim/third-party/rust/fixups/lalrpop/fixups.toml @@ -0,0 +1 @@ +cargo_env = true diff --git a/shim/third-party/rust/fixups/lexical-core/fixups.toml b/shim/third-party/rust/fixups/lexical-core/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/lexical-core/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/libc/fixups.toml b/shim/third-party/rust/fixups/libc/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/libc/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/libm/fixups.toml b/shim/third-party/rust/fixups/libm/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/libm/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/libsqlite3-sys/fixups.toml b/shim/third-party/rust/fixups/libsqlite3-sys/fixups.toml new file mode 100644 index 00000000000..b82bb848a22 --- /dev/null +++ b/shim/third-party/rust/fixups/libsqlite3-sys/fixups.toml @@ -0,0 +1,19 @@ +# libsqlite3-sys uses a bindgen binding to libsqlite. +# We can't easily import bindgen because of its libclang dependency, +# so in the meantime we need to use pre-generated bindgen files. + +extra_mapped_srcs = {"sqlite3/bindgen_bundled_version.rs" = "src/bindgen.rs"} + +[env] +OUT_DIR = "." + +[[buildscript]] +[buildscript.cxx_library] +name = "sqlite3" +srcs = ["sqlite3/sqlite3.c"] +headers = ["sqlite3/*.h"] +preprocessor_flags = [ + "-DSQLITE_ENABLE_COLUMN_METADATA", + "-DSQLITE_ENABLE_FTS3", + "-DSQLITE_ENABLE_RTREE", +] diff --git a/shim/third-party/rust/fixups/lock_api/fixups.toml b/shim/third-party/rust/fixups/lock_api/fixups.toml new file mode 100644 index 00000000000..6c1a3d45a5a --- /dev/null +++ b/shim/third-party/rust/fixups/lock_api/fixups.toml @@ -0,0 +1,3 @@ +# the build script for lock_api is a version check for rust 1.61. +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/log/fixups.toml b/shim/third-party/rust/fixups/log/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/log/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/memchr/fixups.toml b/shim/third-party/rust/fixups/memchr/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/memchr/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/memoffset/fixups.toml b/shim/third-party/rust/fixups/memoffset/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/memoffset/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/mio/fixups.toml b/shim/third-party/rust/fixups/mio/fixups.toml new file mode 100644 index 00000000000..af7edb27e3b --- /dev/null +++ b/shim/third-party/rust/fixups/mio/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/native-tls/fixups.toml b/shim/third-party/rust/fixups/native-tls/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/native-tls/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/nix/fixups.toml b/shim/third-party/rust/fixups/nix/fixups.toml new file mode 100644 index 00000000000..1849ea069d2 --- /dev/null +++ b/shim/third-party/rust/fixups/nix/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/nom/fixups.toml b/shim/third-party/rust/fixups/nom/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/nom/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/ntapi/fixups.toml b/shim/third-party/rust/fixups/ntapi/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/ntapi/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/num-bigint/fixups.toml b/shim/third-party/rust/fixups/num-bigint/fixups.toml new file mode 100644 index 00000000000..df0b424f497 --- /dev/null +++ b/shim/third-party/rust/fixups/num-bigint/fixups.toml @@ -0,0 +1,5 @@ +[[buildscript]] +[buildscript.rustc_flags] + +[[buildscript]] +[buildscript.gen_srcs] diff --git a/shim/third-party/rust/fixups/num-integer/fixups.toml b/shim/third-party/rust/fixups/num-integer/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/num-integer/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/num-traits/fixups.toml b/shim/third-party/rust/fixups/num-traits/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/num-traits/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/parking_lot/fixups.toml b/shim/third-party/rust/fixups/parking_lot/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/parking_lot/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/parking_lot_core/fixups.toml b/shim/third-party/rust/fixups/parking_lot_core/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/parking_lot_core/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/paste/fixups.toml b/shim/third-party/rust/fixups/paste/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/paste/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/pest/fixups.toml b/shim/third-party/rust/fixups/pest/fixups.toml new file mode 100644 index 00000000000..af7edb27e3b --- /dev/null +++ b/shim/third-party/rust/fixups/pest/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/pin-project-internal/fixups.toml b/shim/third-party/rust/fixups/pin-project-internal/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/pin-project-internal/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/platforms/fixups.toml b/shim/third-party/rust/fixups/platforms/fixups.toml new file mode 100644 index 00000000000..e086791cd2f --- /dev/null +++ b/shim/third-party/rust/fixups/platforms/fixups.toml @@ -0,0 +1,26 @@ +# Buildscript sets TARGET in environment +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "linux", target_arch = "aarch64"))'] +env = { TARGET = "aarch64-unknown-linux-gnu" } +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "linux", target_arch = "x86_64"))'] +env = { TARGET = "x86_64-unknown-linux-gnu" } +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "macos", target_arch = "aarch64"))'] +env = { TARGET = "aarch64-apple-darwin" } +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "macos", target_arch = "x86_64"))'] +env = { TARGET = "x86_64-apple-darwin" } +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "windows", target_env = "gnu"))'] +env = { TARGET = "x86_64-pc-windows-gnu" } +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "windows", target_env = "msvc"))'] +env = { TARGET = "x86_64-pc-windows-msvc" } +buildscript = [] diff --git a/shim/third-party/rust/fixups/prettyplease/fixups.toml b/shim/third-party/rust/fixups/prettyplease/fixups.toml new file mode 100644 index 00000000000..3510928422a --- /dev/null +++ b/shim/third-party/rust/fixups/prettyplease/fixups.toml @@ -0,0 +1,2 @@ +buildscript = [] +cargo_env = true diff --git a/shim/third-party/rust/fixups/proc-macro-error-attr/fixups.toml b/shim/third-party/rust/fixups/proc-macro-error-attr/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/proc-macro-error-attr/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/proc-macro-error/fixups.toml b/shim/third-party/rust/fixups/proc-macro-error/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/proc-macro-error/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/proc-macro-hack/fixups.toml b/shim/third-party/rust/fixups/proc-macro-hack/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/proc-macro-hack/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/proc-macro2/fixups.toml b/shim/third-party/rust/fixups/proc-macro2/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/proc-macro2/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/prost-build/fixups.toml b/shim/third-party/rust/fixups/prost-build/fixups.toml new file mode 100644 index 00000000000..5865e690484 --- /dev/null +++ b/shim/third-party/rust/fixups/prost-build/fixups.toml @@ -0,0 +1,7 @@ +buildscript = [] + +# These are here because the crate uses the env! macro +# We override them at runtime. +[env] +PROTOC = "" +PROTOC_INCLUDE = "" diff --git a/shim/third-party/rust/fixups/pulldown-cmark/fixups.toml b/shim/third-party/rust/fixups/pulldown-cmark/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/pulldown-cmark/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/quote/fixups.toml b/shim/third-party/rust/fixups/quote/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/quote/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/radium/fixups.toml b/shim/third-party/rust/fixups/radium/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/radium/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/rayon-core/fixups.toml b/shim/third-party/rust/fixups/rayon-core/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/rayon-core/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/ref-cast/fixups.toml b/shim/third-party/rust/fixups/ref-cast/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/ref-cast/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/reqwest/fixups.toml b/shim/third-party/rust/fixups/reqwest/fixups.toml new file mode 100644 index 00000000000..af7edb27e3b --- /dev/null +++ b/shim/third-party/rust/fixups/reqwest/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/ring/fixups.toml b/shim/third-party/rust/fixups/ring/fixups.toml new file mode 100644 index 00000000000..d2c83589cf4 --- /dev/null +++ b/shim/third-party/rust/fixups/ring/fixups.toml @@ -0,0 +1,162 @@ +# Copied from fbsource fixup. + +buildscript = [] + +# Generate a C/C++ build rule for all the C code + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.buildscript.cxx_library] +name = "ring-c-asm-elf-x86_84" +srcs = [ "crypto/**/*.c", "pregenerated/*x86_64*-elf.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] + +# redundant `any` is needed to differentiate key for config specific to v0.17.5 version +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "linux")))'] +version = "=0.17.5" +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "linux")))'.env] +RING_CORE_PREFIX = "ring_core_0_17_5_" +[[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "linux")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "linux")))'.buildscript.cxx_library] +name = "ring-c-asm-elf-x86_84" +srcs = [ "crypto/**/*.c", "pregenerated/*x86_64*-elf.S", "third_party/fiat/asm/fiat_curve25519_adx_mul.S", "third_party/fiat/asm/fiat_curve25519_adx_square.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] +fixup_include_paths = ["include"] + +[[platform_fixup.'cfg(all(target_arch = "aarch64", target_os = "linux"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "aarch64", target_os = "linux"))'.buildscript.cxx_library] +name = "ring-c-asm-elf-aarch64" +srcs = [ "crypto/**/*.c", "pregenerated/*armv8*-linux64.S", "pregenerated/*armx*-linux64.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +exclude = [ "crypto/cpu-intel.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] + +[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "linux")))'] +version = "=0.17.5" +[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "linux")))'.env] +RING_CORE_PREFIX = "ring_core_0_17_5_" +[[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "linux")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "linux")))'.buildscript.cxx_library] +name = "ring-c-asm-elf-aarch64" +srcs = [ "crypto/**/*.c", "pregenerated/*armv8*-linux64.S", "pregenerated/*armx*-linux64.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +exclude = [ "crypto/cpu-intel.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] +fixup_include_paths = ["include"] + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "macos"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "macos"))'.buildscript.cxx_library] +name = "ring-c-asm-macos-x86_64" +srcs = [ "crypto/**/*.c", "pregenerated/*x86_64*-macosx.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] + +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "macos")))'] +version = "=0.17.5" +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "macos")))'.env] +RING_CORE_PREFIX = "ring_core_0_17_5_" +[[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "macos")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "macos")))'.buildscript.cxx_library] +name = "ring-c-asm-macos-x86_64" +srcs = [ "crypto/**/*.c", "pregenerated/*x86_64*-macosx.S", "third_party/fiat/asm/fiat_curve25519_adx_mul.S", "third_party/fiat/asm/fiat_curve25519_adx_square.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] +fixup_include_paths = ["include"] + +[[platform_fixup.'cfg(all(target_arch = "aarch64", target_os = "macos"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "aarch64", target_os = "macos"))'.buildscript.cxx_library] +name = "ring-c-asm-macos-arm64" +srcs = [ "crypto/**/*.c", "pregenerated/*armv8*-ios64.S", "pregenerated/*armx*-ios64.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +exclude = [ "crypto/cpu-intel.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] + +[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "macos")))'] +version = "=0.17.5" +[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "macos")))'.env] +RING_CORE_PREFIX = "ring_core_0_17_5_" +[[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "macos")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "aarch64", target_os = "macos")))'.buildscript.cxx_library] +name = "ring-c-asm-macos-arm64" +srcs = [ "crypto/**/*.c", "pregenerated/*armv8*-ios64.S", "pregenerated/*armx*-ios64.S" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +exclude = [ "crypto/cpu-intel.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] +fixup_include_paths = ["include"] + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu"))'.buildscript.cxx_library] +name = "ring-c-win-x86_84" +srcs = [ "crypto/**/*.c" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] + +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu")))'] +version = "=0.17.5" +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu")))'.env] +RING_CORE_PREFIX = "ring_core_0_17_5_" +[[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu")))'.buildscript.cxx_library] +name = "ring-c-win-x86_84" +srcs = [ "crypto/**/*.c" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +compiler_flags = ["-Wno-error"] +fixup_include_paths = ["include"] + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))'.buildscript.cxx_library] +name = "ring-c-win-msvc-x86_84" +srcs = [ "crypto/**/*.c" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] + +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")))'] +version = "=0.17.5" +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")))'.env] +RING_CORE_PREFIX = "ring_core_0_17_5_" +[[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")))'.buildscript.cxx_library] +name = "ring-c-win-msvc-x86_84" +srcs = [ "crypto/**/*.c" ] +headers = [ "include/**/*.h", "crypto/**/*.h", "third_party/**/*.h", "crypto/**/*.inl" ] +# Exclude C AES because we've got the x86_64 one +exclude = [ "crypto/fipsmodule/aes/aes.c" ] +include_paths = ["include"] +fixup_include_paths = ["include"] + +[[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows"))'.buildscript]] +[platform_fixup.'cfg(all(target_arch = "x86_64", target_os = "windows"))'.buildscript.prebuilt_cxx_library] +name = "ring-asm-windows-x86_84" +static_libs = [ "pregenerated/*x86_64*-nasm.obj" ] + +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows")))'] +version = "=0.17.5" +[[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows")))'.buildscript]] +[platform_fixup.'cfg(any(all(target_arch = "x86_64", target_os = "windows")))'.buildscript.prebuilt_cxx_library] +name = "ring-asm-windows-x86_84" +static_libs = [ "pregenerated/*x86_64*-nasm.o" ] diff --git a/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols.h b/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols.h new file mode 100644 index 00000000000..9ee40055efd --- /dev/null +++ b/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols.h @@ -0,0 +1,119 @@ + +#ifndef ring_core_generated_PREFIX_SYMBOLS_H +#define ring_core_generated_PREFIX_SYMBOLS_H + +#define ecp_nistz256_point_double p256_point_double +#define ecp_nistz256_point_add p256_point_add +#define ecp_nistz256_point_add_affine p256_point_add_affine +#define ecp_nistz256_ord_mul_mont p256_scalar_mul_mont +#define ecp_nistz256_ord_sqr_mont p256_scalar_sqr_rep_mont +#define ecp_nistz256_mul_mont p256_mul_mont +#define ecp_nistz256_sqr_mont p256_sqr_mont +#define CRYPTO_memcmp ring_core_0_17_5_CRYPTO_memcmp +#define CRYPTO_poly1305_finish ring_core_0_17_5_CRYPTO_poly1305_finish +#define CRYPTO_poly1305_finish_neon ring_core_0_17_5_CRYPTO_poly1305_finish_neon +#define CRYPTO_poly1305_init ring_core_0_17_5_CRYPTO_poly1305_init +#define CRYPTO_poly1305_init_neon ring_core_0_17_5_CRYPTO_poly1305_init_neon +#define CRYPTO_poly1305_update ring_core_0_17_5_CRYPTO_poly1305_update +#define CRYPTO_poly1305_update_neon ring_core_0_17_5_CRYPTO_poly1305_update_neon +#define ChaCha20_ctr32 ring_core_0_17_5_ChaCha20_ctr32 +#define LIMBS_add_mod ring_core_0_17_5_LIMBS_add_mod +#define LIMBS_are_even ring_core_0_17_5_LIMBS_are_even +#define LIMBS_are_zero ring_core_0_17_5_LIMBS_are_zero +#define LIMBS_equal ring_core_0_17_5_LIMBS_equal +#define LIMBS_equal_limb ring_core_0_17_5_LIMBS_equal_limb +#define LIMBS_less_than ring_core_0_17_5_LIMBS_less_than +#define LIMBS_less_than_limb ring_core_0_17_5_LIMBS_less_than_limb +#define LIMBS_reduce_once ring_core_0_17_5_LIMBS_reduce_once +#define LIMBS_select_512_32 ring_core_0_17_5_LIMBS_select_512_32 +#define LIMBS_shl_mod ring_core_0_17_5_LIMBS_shl_mod +#define LIMBS_sub_mod ring_core_0_17_5_LIMBS_sub_mod +#define LIMBS_window5_split_window ring_core_0_17_5_LIMBS_window5_split_window +#define LIMBS_window5_unsplit_window ring_core_0_17_5_LIMBS_window5_unsplit_window +#define LIMB_shr ring_core_0_17_5_LIMB_shr +#define OPENSSL_armcap_P ring_core_0_17_5_OPENSSL_armcap_P +#define OPENSSL_cpuid_setup ring_core_0_17_5_OPENSSL_cpuid_setup +#define OPENSSL_ia32cap_P ring_core_0_17_5_OPENSSL_ia32cap_P +#define aes_hw_ctr32_encrypt_blocks ring_core_0_17_5_aes_hw_ctr32_encrypt_blocks +#define aes_hw_encrypt ring_core_0_17_5_aes_hw_encrypt +#define aes_hw_set_encrypt_key ring_core_0_17_5_aes_hw_set_encrypt_key +#define aes_nohw_ctr32_encrypt_blocks ring_core_0_17_5_aes_nohw_ctr32_encrypt_blocks +#define aes_nohw_encrypt ring_core_0_17_5_aes_nohw_encrypt +#define aes_nohw_set_encrypt_key ring_core_0_17_5_aes_nohw_set_encrypt_key +#define aesni_gcm_decrypt ring_core_0_17_5_aesni_gcm_decrypt +#define aesni_gcm_encrypt ring_core_0_17_5_aesni_gcm_encrypt +#define bn_from_montgomery_in_place ring_core_0_17_5_bn_from_montgomery_in_place +#define bn_gather5 ring_core_0_17_5_bn_gather5 +#define bn_mul_mont ring_core_0_17_5_bn_mul_mont +#define bn_mul_mont_gather5 ring_core_0_17_5_bn_mul_mont_gather5 +#define bn_neg_inv_mod_r_u64 ring_core_0_17_5_bn_neg_inv_mod_r_u64 +#define bn_power5 ring_core_0_17_5_bn_power5 +#define bn_scatter5 ring_core_0_17_5_bn_scatter5 +#define bn_sqr8x_internal ring_core_0_17_5_bn_sqr8x_internal +#define bn_sqrx8x_internal ring_core_0_17_5_bn_sqrx8x_internal +#define bsaes_ctr32_encrypt_blocks ring_core_0_17_5_bsaes_ctr32_encrypt_blocks +#define bssl_constant_time_test_conditional_memcpy ring_core_0_17_5_bssl_constant_time_test_conditional_memcpy +#define bssl_constant_time_test_conditional_memxor ring_core_0_17_5_bssl_constant_time_test_conditional_memxor +#define bssl_constant_time_test_main ring_core_0_17_5_bssl_constant_time_test_main +#define chacha20_poly1305_open ring_core_0_17_5_chacha20_poly1305_open +#define chacha20_poly1305_seal ring_core_0_17_5_chacha20_poly1305_seal +#define fiat_curve25519_adx_mul ring_core_0_17_5_fiat_curve25519_adx_mul +#define fiat_curve25519_adx_square ring_core_0_17_5_fiat_curve25519_adx_square +#define gcm_ghash_avx ring_core_0_17_5_gcm_ghash_avx +#define gcm_ghash_clmul ring_core_0_17_5_gcm_ghash_clmul +#define gcm_ghash_neon ring_core_0_17_5_gcm_ghash_neon +#define gcm_gmult_clmul ring_core_0_17_5_gcm_gmult_clmul +#define gcm_gmult_neon ring_core_0_17_5_gcm_gmult_neon +#define gcm_init_avx ring_core_0_17_5_gcm_init_avx +#define gcm_init_clmul ring_core_0_17_5_gcm_init_clmul +#define gcm_init_neon ring_core_0_17_5_gcm_init_neon +#define k25519Precomp ring_core_0_17_5_k25519Precomp +#define limbs_mul_add_limb ring_core_0_17_5_limbs_mul_add_limb +#define little_endian_bytes_from_scalar ring_core_0_17_5_little_endian_bytes_from_scalar +#define ecp_nistz256_neg ring_core_0_17_5_ecp_nistz256_neg +#define ecp_nistz256_select_w5 ring_core_0_17_5_ecp_nistz256_select_w5 +#define ecp_nistz256_select_w7 ring_core_0_17_5_ecp_nistz256_select_w7 +#define p256_mul_mont ring_core_0_17_5_p256_mul_mont +#define p256_point_add ring_core_0_17_5_p256_point_add +#define p256_point_add_affine ring_core_0_17_5_p256_point_add_affine +#define p256_point_double ring_core_0_17_5_p256_point_double +#define p256_point_mul ring_core_0_17_5_p256_point_mul +#define p256_point_mul_base ring_core_0_17_5_p256_point_mul_base +#define p256_point_mul_base_vartime ring_core_0_17_5_p256_point_mul_base_vartime +#define p256_scalar_mul_mont ring_core_0_17_5_p256_scalar_mul_mont +#define p256_scalar_sqr_rep_mont ring_core_0_17_5_p256_scalar_sqr_rep_mont +#define p256_sqr_mont ring_core_0_17_5_p256_sqr_mont +#define p384_elem_div_by_2 ring_core_0_17_5_p384_elem_div_by_2 +#define p384_elem_mul_mont ring_core_0_17_5_p384_elem_mul_mont +#define p384_elem_neg ring_core_0_17_5_p384_elem_neg +#define p384_elem_sub ring_core_0_17_5_p384_elem_sub +#define p384_point_add ring_core_0_17_5_p384_point_add +#define p384_point_double ring_core_0_17_5_p384_point_double +#define p384_point_mul ring_core_0_17_5_p384_point_mul +#define p384_scalar_mul_mont ring_core_0_17_5_p384_scalar_mul_mont +#define openssl_poly1305_neon2_addmulmod ring_core_0_17_5_openssl_poly1305_neon2_addmulmod +#define openssl_poly1305_neon2_blocks ring_core_0_17_5_openssl_poly1305_neon2_blocks +#define sha256_block_data_order ring_core_0_17_5_sha256_block_data_order +#define sha512_block_data_order ring_core_0_17_5_sha512_block_data_order +#define vpaes_ctr32_encrypt_blocks ring_core_0_17_5_vpaes_ctr32_encrypt_blocks +#define vpaes_encrypt ring_core_0_17_5_vpaes_encrypt +#define vpaes_encrypt_key_to_bsaes ring_core_0_17_5_vpaes_encrypt_key_to_bsaes +#define vpaes_set_encrypt_key ring_core_0_17_5_vpaes_set_encrypt_key +#define x25519_NEON ring_core_0_17_5_x25519_NEON +#define x25519_fe_invert ring_core_0_17_5_x25519_fe_invert +#define x25519_fe_isnegative ring_core_0_17_5_x25519_fe_isnegative +#define x25519_fe_mul_ttt ring_core_0_17_5_x25519_fe_mul_ttt +#define x25519_fe_neg ring_core_0_17_5_x25519_fe_neg +#define x25519_fe_tobytes ring_core_0_17_5_x25519_fe_tobytes +#define x25519_ge_double_scalarmult_vartime ring_core_0_17_5_x25519_ge_double_scalarmult_vartime +#define x25519_ge_frombytes_vartime ring_core_0_17_5_x25519_ge_frombytes_vartime +#define x25519_ge_scalarmult_base ring_core_0_17_5_x25519_ge_scalarmult_base +#define x25519_ge_scalarmult_base_adx ring_core_0_17_5_x25519_ge_scalarmult_base_adx +#define x25519_public_from_private_generic_masked ring_core_0_17_5_x25519_public_from_private_generic_masked +#define x25519_sc_mask ring_core_0_17_5_x25519_sc_mask +#define x25519_sc_muladd ring_core_0_17_5_x25519_sc_muladd +#define x25519_sc_reduce ring_core_0_17_5_x25519_sc_reduce +#define x25519_scalar_mult_adx ring_core_0_17_5_x25519_scalar_mult_adx +#define x25519_scalar_mult_generic_masked ring_core_0_17_5_x25519_scalar_mult_generic_masked + +#endif diff --git a/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols_asm.h b/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols_asm.h new file mode 100644 index 00000000000..84e48709150 --- /dev/null +++ b/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols_asm.h @@ -0,0 +1,236 @@ + +#ifndef ring_core_generated_PREFIX_SYMBOLS_ASM_H +#define ring_core_generated_PREFIX_SYMBOLS_ASM_H + +#if defined(__APPLE__) +#define _ecp_nistz256_point_double _p256_point_double +#define _ecp_nistz256_point_add _p256_point_add +#define _ecp_nistz256_point_add_affine _p256_point_add_affine +#define _ecp_nistz256_ord_mul_mont _p256_scalar_mul_mont +#define _ecp_nistz256_ord_sqr_mont _p256_scalar_sqr_rep_mont +#define _ecp_nistz256_mul_mont _p256_mul_mont +#define _ecp_nistz256_sqr_mont _p256_sqr_mont +#define _CRYPTO_memcmp _ring_core_0_17_5_CRYPTO_memcmp +#define _CRYPTO_poly1305_finish _ring_core_0_17_5_CRYPTO_poly1305_finish +#define _CRYPTO_poly1305_finish_neon _ring_core_0_17_5_CRYPTO_poly1305_finish_neon +#define _CRYPTO_poly1305_init _ring_core_0_17_5_CRYPTO_poly1305_init +#define _CRYPTO_poly1305_init_neon _ring_core_0_17_5_CRYPTO_poly1305_init_neon +#define _CRYPTO_poly1305_update _ring_core_0_17_5_CRYPTO_poly1305_update +#define _CRYPTO_poly1305_update_neon _ring_core_0_17_5_CRYPTO_poly1305_update_neon +#define _ChaCha20_ctr32 _ring_core_0_17_5_ChaCha20_ctr32 +#define _LIMBS_add_mod _ring_core_0_17_5_LIMBS_add_mod +#define _LIMBS_are_even _ring_core_0_17_5_LIMBS_are_even +#define _LIMBS_are_zero _ring_core_0_17_5_LIMBS_are_zero +#define _LIMBS_equal _ring_core_0_17_5_LIMBS_equal +#define _LIMBS_equal_limb _ring_core_0_17_5_LIMBS_equal_limb +#define _LIMBS_less_than _ring_core_0_17_5_LIMBS_less_than +#define _LIMBS_less_than_limb _ring_core_0_17_5_LIMBS_less_than_limb +#define _LIMBS_reduce_once _ring_core_0_17_5_LIMBS_reduce_once +#define _LIMBS_select_512_32 _ring_core_0_17_5_LIMBS_select_512_32 +#define _LIMBS_shl_mod _ring_core_0_17_5_LIMBS_shl_mod +#define _LIMBS_sub_mod _ring_core_0_17_5_LIMBS_sub_mod +#define _LIMBS_window5_split_window _ring_core_0_17_5_LIMBS_window5_split_window +#define _LIMBS_window5_unsplit_window _ring_core_0_17_5_LIMBS_window5_unsplit_window +#define _LIMB_shr _ring_core_0_17_5_LIMB_shr +#define _OPENSSL_armcap_P _ring_core_0_17_5_OPENSSL_armcap_P +#define _OPENSSL_cpuid_setup _ring_core_0_17_5_OPENSSL_cpuid_setup +#define _OPENSSL_ia32cap_P _ring_core_0_17_5_OPENSSL_ia32cap_P +#define _aes_hw_ctr32_encrypt_blocks _ring_core_0_17_5_aes_hw_ctr32_encrypt_blocks +#define _aes_hw_encrypt _ring_core_0_17_5_aes_hw_encrypt +#define _aes_hw_set_encrypt_key _ring_core_0_17_5_aes_hw_set_encrypt_key +#define _aes_nohw_ctr32_encrypt_blocks _ring_core_0_17_5_aes_nohw_ctr32_encrypt_blocks +#define _aes_nohw_encrypt _ring_core_0_17_5_aes_nohw_encrypt +#define _aes_nohw_set_encrypt_key _ring_core_0_17_5_aes_nohw_set_encrypt_key +#define _aesni_gcm_decrypt _ring_core_0_17_5_aesni_gcm_decrypt +#define _aesni_gcm_encrypt _ring_core_0_17_5_aesni_gcm_encrypt +#define _bn_from_montgomery_in_place _ring_core_0_17_5_bn_from_montgomery_in_place +#define _bn_gather5 _ring_core_0_17_5_bn_gather5 +#define _bn_mul_mont _ring_core_0_17_5_bn_mul_mont +#define _bn_mul_mont_gather5 _ring_core_0_17_5_bn_mul_mont_gather5 +#define _bn_neg_inv_mod_r_u64 _ring_core_0_17_5_bn_neg_inv_mod_r_u64 +#define _bn_power5 _ring_core_0_17_5_bn_power5 +#define _bn_scatter5 _ring_core_0_17_5_bn_scatter5 +#define _bn_sqr8x_internal _ring_core_0_17_5_bn_sqr8x_internal +#define _bn_sqrx8x_internal _ring_core_0_17_5_bn_sqrx8x_internal +#define _bsaes_ctr32_encrypt_blocks _ring_core_0_17_5_bsaes_ctr32_encrypt_blocks +#define _bssl_constant_time_test_conditional_memcpy _ring_core_0_17_5_bssl_constant_time_test_conditional_memcpy +#define _bssl_constant_time_test_conditional_memxor _ring_core_0_17_5_bssl_constant_time_test_conditional_memxor +#define _bssl_constant_time_test_main _ring_core_0_17_5_bssl_constant_time_test_main +#define _chacha20_poly1305_open _ring_core_0_17_5_chacha20_poly1305_open +#define _chacha20_poly1305_seal _ring_core_0_17_5_chacha20_poly1305_seal +#define _fiat_curve25519_adx_mul _ring_core_0_17_5_fiat_curve25519_adx_mul +#define _fiat_curve25519_adx_square _ring_core_0_17_5_fiat_curve25519_adx_square +#define _gcm_ghash_avx _ring_core_0_17_5_gcm_ghash_avx +#define _gcm_ghash_clmul _ring_core_0_17_5_gcm_ghash_clmul +#define _gcm_ghash_neon _ring_core_0_17_5_gcm_ghash_neon +#define _gcm_gmult_clmul _ring_core_0_17_5_gcm_gmult_clmul +#define _gcm_gmult_neon _ring_core_0_17_5_gcm_gmult_neon +#define _gcm_init_avx _ring_core_0_17_5_gcm_init_avx +#define _gcm_init_clmul _ring_core_0_17_5_gcm_init_clmul +#define _gcm_init_neon _ring_core_0_17_5_gcm_init_neon +#define _k25519Precomp _ring_core_0_17_5_k25519Precomp +#define _limbs_mul_add_limb _ring_core_0_17_5_limbs_mul_add_limb +#define _little_endian_bytes_from_scalar _ring_core_0_17_5_little_endian_bytes_from_scalar +#define _ecp_nistz256_neg _ring_core_0_17_5_ecp_nistz256_neg +#define _ecp_nistz256_select_w5 _ring_core_0_17_5_ecp_nistz256_select_w5 +#define _ecp_nistz256_select_w7 _ring_core_0_17_5_ecp_nistz256_select_w7 +#define _p256_mul_mont _ring_core_0_17_5_p256_mul_mont +#define _p256_point_add _ring_core_0_17_5_p256_point_add +#define _p256_point_add_affine _ring_core_0_17_5_p256_point_add_affine +#define _p256_point_double _ring_core_0_17_5_p256_point_double +#define _p256_point_mul _ring_core_0_17_5_p256_point_mul +#define _p256_point_mul_base _ring_core_0_17_5_p256_point_mul_base +#define _p256_point_mul_base_vartime _ring_core_0_17_5_p256_point_mul_base_vartime +#define _p256_scalar_mul_mont _ring_core_0_17_5_p256_scalar_mul_mont +#define _p256_scalar_sqr_rep_mont _ring_core_0_17_5_p256_scalar_sqr_rep_mont +#define _p256_sqr_mont _ring_core_0_17_5_p256_sqr_mont +#define _p384_elem_div_by_2 _ring_core_0_17_5_p384_elem_div_by_2 +#define _p384_elem_mul_mont _ring_core_0_17_5_p384_elem_mul_mont +#define _p384_elem_neg _ring_core_0_17_5_p384_elem_neg +#define _p384_elem_sub _ring_core_0_17_5_p384_elem_sub +#define _p384_point_add _ring_core_0_17_5_p384_point_add +#define _p384_point_double _ring_core_0_17_5_p384_point_double +#define _p384_point_mul _ring_core_0_17_5_p384_point_mul +#define _p384_scalar_mul_mont _ring_core_0_17_5_p384_scalar_mul_mont +#define _openssl_poly1305_neon2_addmulmod _ring_core_0_17_5_openssl_poly1305_neon2_addmulmod +#define _openssl_poly1305_neon2_blocks _ring_core_0_17_5_openssl_poly1305_neon2_blocks +#define _sha256_block_data_order _ring_core_0_17_5_sha256_block_data_order +#define _sha512_block_data_order _ring_core_0_17_5_sha512_block_data_order +#define _vpaes_ctr32_encrypt_blocks _ring_core_0_17_5_vpaes_ctr32_encrypt_blocks +#define _vpaes_encrypt _ring_core_0_17_5_vpaes_encrypt +#define _vpaes_encrypt_key_to_bsaes _ring_core_0_17_5_vpaes_encrypt_key_to_bsaes +#define _vpaes_set_encrypt_key _ring_core_0_17_5_vpaes_set_encrypt_key +#define _x25519_NEON _ring_core_0_17_5_x25519_NEON +#define _x25519_fe_invert _ring_core_0_17_5_x25519_fe_invert +#define _x25519_fe_isnegative _ring_core_0_17_5_x25519_fe_isnegative +#define _x25519_fe_mul_ttt _ring_core_0_17_5_x25519_fe_mul_ttt +#define _x25519_fe_neg _ring_core_0_17_5_x25519_fe_neg +#define _x25519_fe_tobytes _ring_core_0_17_5_x25519_fe_tobytes +#define _x25519_ge_double_scalarmult_vartime _ring_core_0_17_5_x25519_ge_double_scalarmult_vartime +#define _x25519_ge_frombytes_vartime _ring_core_0_17_5_x25519_ge_frombytes_vartime +#define _x25519_ge_scalarmult_base _ring_core_0_17_5_x25519_ge_scalarmult_base +#define _x25519_ge_scalarmult_base_adx _ring_core_0_17_5_x25519_ge_scalarmult_base_adx +#define _x25519_public_from_private_generic_masked _ring_core_0_17_5_x25519_public_from_private_generic_masked +#define _x25519_sc_mask _ring_core_0_17_5_x25519_sc_mask +#define _x25519_sc_muladd _ring_core_0_17_5_x25519_sc_muladd +#define _x25519_sc_reduce _ring_core_0_17_5_x25519_sc_reduce +#define _x25519_scalar_mult_adx _ring_core_0_17_5_x25519_scalar_mult_adx +#define _x25519_scalar_mult_generic_masked _ring_core_0_17_5_x25519_scalar_mult_generic_masked + +#else +#define ecp_nistz256_point_double p256_point_double +#define ecp_nistz256_point_add p256_point_add +#define ecp_nistz256_point_add_affine p256_point_add_affine +#define ecp_nistz256_ord_mul_mont p256_scalar_mul_mont +#define ecp_nistz256_ord_sqr_mont p256_scalar_sqr_rep_mont +#define ecp_nistz256_mul_mont p256_mul_mont +#define ecp_nistz256_sqr_mont p256_sqr_mont +#define CRYPTO_memcmp ring_core_0_17_5_CRYPTO_memcmp +#define CRYPTO_poly1305_finish ring_core_0_17_5_CRYPTO_poly1305_finish +#define CRYPTO_poly1305_finish_neon ring_core_0_17_5_CRYPTO_poly1305_finish_neon +#define CRYPTO_poly1305_init ring_core_0_17_5_CRYPTO_poly1305_init +#define CRYPTO_poly1305_init_neon ring_core_0_17_5_CRYPTO_poly1305_init_neon +#define CRYPTO_poly1305_update ring_core_0_17_5_CRYPTO_poly1305_update +#define CRYPTO_poly1305_update_neon ring_core_0_17_5_CRYPTO_poly1305_update_neon +#define ChaCha20_ctr32 ring_core_0_17_5_ChaCha20_ctr32 +#define LIMBS_add_mod ring_core_0_17_5_LIMBS_add_mod +#define LIMBS_are_even ring_core_0_17_5_LIMBS_are_even +#define LIMBS_are_zero ring_core_0_17_5_LIMBS_are_zero +#define LIMBS_equal ring_core_0_17_5_LIMBS_equal +#define LIMBS_equal_limb ring_core_0_17_5_LIMBS_equal_limb +#define LIMBS_less_than ring_core_0_17_5_LIMBS_less_than +#define LIMBS_less_than_limb ring_core_0_17_5_LIMBS_less_than_limb +#define LIMBS_reduce_once ring_core_0_17_5_LIMBS_reduce_once +#define LIMBS_select_512_32 ring_core_0_17_5_LIMBS_select_512_32 +#define LIMBS_shl_mod ring_core_0_17_5_LIMBS_shl_mod +#define LIMBS_sub_mod ring_core_0_17_5_LIMBS_sub_mod +#define LIMBS_window5_split_window ring_core_0_17_5_LIMBS_window5_split_window +#define LIMBS_window5_unsplit_window ring_core_0_17_5_LIMBS_window5_unsplit_window +#define LIMB_shr ring_core_0_17_5_LIMB_shr +#define OPENSSL_armcap_P ring_core_0_17_5_OPENSSL_armcap_P +#define OPENSSL_cpuid_setup ring_core_0_17_5_OPENSSL_cpuid_setup +#define OPENSSL_ia32cap_P ring_core_0_17_5_OPENSSL_ia32cap_P +#define aes_hw_ctr32_encrypt_blocks ring_core_0_17_5_aes_hw_ctr32_encrypt_blocks +#define aes_hw_encrypt ring_core_0_17_5_aes_hw_encrypt +#define aes_hw_set_encrypt_key ring_core_0_17_5_aes_hw_set_encrypt_key +#define aes_nohw_ctr32_encrypt_blocks ring_core_0_17_5_aes_nohw_ctr32_encrypt_blocks +#define aes_nohw_encrypt ring_core_0_17_5_aes_nohw_encrypt +#define aes_nohw_set_encrypt_key ring_core_0_17_5_aes_nohw_set_encrypt_key +#define aesni_gcm_decrypt ring_core_0_17_5_aesni_gcm_decrypt +#define aesni_gcm_encrypt ring_core_0_17_5_aesni_gcm_encrypt +#define bn_from_montgomery_in_place ring_core_0_17_5_bn_from_montgomery_in_place +#define bn_gather5 ring_core_0_17_5_bn_gather5 +#define bn_mul_mont ring_core_0_17_5_bn_mul_mont +#define bn_mul_mont_gather5 ring_core_0_17_5_bn_mul_mont_gather5 +#define bn_neg_inv_mod_r_u64 ring_core_0_17_5_bn_neg_inv_mod_r_u64 +#define bn_power5 ring_core_0_17_5_bn_power5 +#define bn_scatter5 ring_core_0_17_5_bn_scatter5 +#define bn_sqr8x_internal ring_core_0_17_5_bn_sqr8x_internal +#define bn_sqrx8x_internal ring_core_0_17_5_bn_sqrx8x_internal +#define bsaes_ctr32_encrypt_blocks ring_core_0_17_5_bsaes_ctr32_encrypt_blocks +#define bssl_constant_time_test_conditional_memcpy ring_core_0_17_5_bssl_constant_time_test_conditional_memcpy +#define bssl_constant_time_test_conditional_memxor ring_core_0_17_5_bssl_constant_time_test_conditional_memxor +#define bssl_constant_time_test_main ring_core_0_17_5_bssl_constant_time_test_main +#define chacha20_poly1305_open ring_core_0_17_5_chacha20_poly1305_open +#define chacha20_poly1305_seal ring_core_0_17_5_chacha20_poly1305_seal +#define fiat_curve25519_adx_mul ring_core_0_17_5_fiat_curve25519_adx_mul +#define fiat_curve25519_adx_square ring_core_0_17_5_fiat_curve25519_adx_square +#define gcm_ghash_avx ring_core_0_17_5_gcm_ghash_avx +#define gcm_ghash_clmul ring_core_0_17_5_gcm_ghash_clmul +#define gcm_ghash_neon ring_core_0_17_5_gcm_ghash_neon +#define gcm_gmult_clmul ring_core_0_17_5_gcm_gmult_clmul +#define gcm_gmult_neon ring_core_0_17_5_gcm_gmult_neon +#define gcm_init_avx ring_core_0_17_5_gcm_init_avx +#define gcm_init_clmul ring_core_0_17_5_gcm_init_clmul +#define gcm_init_neon ring_core_0_17_5_gcm_init_neon +#define k25519Precomp ring_core_0_17_5_k25519Precomp +#define limbs_mul_add_limb ring_core_0_17_5_limbs_mul_add_limb +#define little_endian_bytes_from_scalar ring_core_0_17_5_little_endian_bytes_from_scalar +#define ecp_nistz256_neg ring_core_0_17_5_ecp_nistz256_neg +#define ecp_nistz256_select_w5 ring_core_0_17_5_ecp_nistz256_select_w5 +#define ecp_nistz256_select_w7 ring_core_0_17_5_ecp_nistz256_select_w7 +#define p256_mul_mont ring_core_0_17_5_p256_mul_mont +#define p256_point_add ring_core_0_17_5_p256_point_add +#define p256_point_add_affine ring_core_0_17_5_p256_point_add_affine +#define p256_point_double ring_core_0_17_5_p256_point_double +#define p256_point_mul ring_core_0_17_5_p256_point_mul +#define p256_point_mul_base ring_core_0_17_5_p256_point_mul_base +#define p256_point_mul_base_vartime ring_core_0_17_5_p256_point_mul_base_vartime +#define p256_scalar_mul_mont ring_core_0_17_5_p256_scalar_mul_mont +#define p256_scalar_sqr_rep_mont ring_core_0_17_5_p256_scalar_sqr_rep_mont +#define p256_sqr_mont ring_core_0_17_5_p256_sqr_mont +#define p384_elem_div_by_2 ring_core_0_17_5_p384_elem_div_by_2 +#define p384_elem_mul_mont ring_core_0_17_5_p384_elem_mul_mont +#define p384_elem_neg ring_core_0_17_5_p384_elem_neg +#define p384_elem_sub ring_core_0_17_5_p384_elem_sub +#define p384_point_add ring_core_0_17_5_p384_point_add +#define p384_point_double ring_core_0_17_5_p384_point_double +#define p384_point_mul ring_core_0_17_5_p384_point_mul +#define p384_scalar_mul_mont ring_core_0_17_5_p384_scalar_mul_mont +#define openssl_poly1305_neon2_addmulmod ring_core_0_17_5_openssl_poly1305_neon2_addmulmod +#define openssl_poly1305_neon2_blocks ring_core_0_17_5_openssl_poly1305_neon2_blocks +#define sha256_block_data_order ring_core_0_17_5_sha256_block_data_order +#define sha512_block_data_order ring_core_0_17_5_sha512_block_data_order +#define vpaes_ctr32_encrypt_blocks ring_core_0_17_5_vpaes_ctr32_encrypt_blocks +#define vpaes_encrypt ring_core_0_17_5_vpaes_encrypt +#define vpaes_encrypt_key_to_bsaes ring_core_0_17_5_vpaes_encrypt_key_to_bsaes +#define vpaes_set_encrypt_key ring_core_0_17_5_vpaes_set_encrypt_key +#define x25519_NEON ring_core_0_17_5_x25519_NEON +#define x25519_fe_invert ring_core_0_17_5_x25519_fe_invert +#define x25519_fe_isnegative ring_core_0_17_5_x25519_fe_isnegative +#define x25519_fe_mul_ttt ring_core_0_17_5_x25519_fe_mul_ttt +#define x25519_fe_neg ring_core_0_17_5_x25519_fe_neg +#define x25519_fe_tobytes ring_core_0_17_5_x25519_fe_tobytes +#define x25519_ge_double_scalarmult_vartime ring_core_0_17_5_x25519_ge_double_scalarmult_vartime +#define x25519_ge_frombytes_vartime ring_core_0_17_5_x25519_ge_frombytes_vartime +#define x25519_ge_scalarmult_base ring_core_0_17_5_x25519_ge_scalarmult_base +#define x25519_ge_scalarmult_base_adx ring_core_0_17_5_x25519_ge_scalarmult_base_adx +#define x25519_public_from_private_generic_masked ring_core_0_17_5_x25519_public_from_private_generic_masked +#define x25519_sc_mask ring_core_0_17_5_x25519_sc_mask +#define x25519_sc_muladd ring_core_0_17_5_x25519_sc_muladd +#define x25519_sc_reduce ring_core_0_17_5_x25519_sc_reduce +#define x25519_scalar_mult_adx ring_core_0_17_5_x25519_scalar_mult_adx +#define x25519_scalar_mult_generic_masked ring_core_0_17_5_x25519_scalar_mult_generic_masked + +#endif +#endif diff --git a/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols_nasm.inc b/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols_nasm.inc new file mode 100644 index 00000000000..50e986a6a6a --- /dev/null +++ b/shim/third-party/rust/fixups/ring/include/ring_core_generated/prefix_symbols_nasm.inc @@ -0,0 +1,236 @@ + +%ifndef ring_core_generated_PREFIX_SYMBOLS_NASM_INC +%define ring_core_generated_PREFIX_SYMBOLS_NASM_INC + +%ifidn __OUTPUT_FORMAT__,win32 +%define _ecp_nistz256_point_double _p256_point_double +%define _ecp_nistz256_point_add _p256_point_add +%define _ecp_nistz256_point_add_affine _p256_point_add_affine +%define _ecp_nistz256_ord_mul_mont _p256_scalar_mul_mont +%define _ecp_nistz256_ord_sqr_mont _p256_scalar_sqr_rep_mont +%define _ecp_nistz256_mul_mont _p256_mul_mont +%define _ecp_nistz256_sqr_mont _p256_sqr_mont +%define _CRYPTO_memcmp _ring_core_0_17_5_CRYPTO_memcmp +%define _CRYPTO_poly1305_finish _ring_core_0_17_5_CRYPTO_poly1305_finish +%define _CRYPTO_poly1305_finish_neon _ring_core_0_17_5_CRYPTO_poly1305_finish_neon +%define _CRYPTO_poly1305_init _ring_core_0_17_5_CRYPTO_poly1305_init +%define _CRYPTO_poly1305_init_neon _ring_core_0_17_5_CRYPTO_poly1305_init_neon +%define _CRYPTO_poly1305_update _ring_core_0_17_5_CRYPTO_poly1305_update +%define _CRYPTO_poly1305_update_neon _ring_core_0_17_5_CRYPTO_poly1305_update_neon +%define _ChaCha20_ctr32 _ring_core_0_17_5_ChaCha20_ctr32 +%define _LIMBS_add_mod _ring_core_0_17_5_LIMBS_add_mod +%define _LIMBS_are_even _ring_core_0_17_5_LIMBS_are_even +%define _LIMBS_are_zero _ring_core_0_17_5_LIMBS_are_zero +%define _LIMBS_equal _ring_core_0_17_5_LIMBS_equal +%define _LIMBS_equal_limb _ring_core_0_17_5_LIMBS_equal_limb +%define _LIMBS_less_than _ring_core_0_17_5_LIMBS_less_than +%define _LIMBS_less_than_limb _ring_core_0_17_5_LIMBS_less_than_limb +%define _LIMBS_reduce_once _ring_core_0_17_5_LIMBS_reduce_once +%define _LIMBS_select_512_32 _ring_core_0_17_5_LIMBS_select_512_32 +%define _LIMBS_shl_mod _ring_core_0_17_5_LIMBS_shl_mod +%define _LIMBS_sub_mod _ring_core_0_17_5_LIMBS_sub_mod +%define _LIMBS_window5_split_window _ring_core_0_17_5_LIMBS_window5_split_window +%define _LIMBS_window5_unsplit_window _ring_core_0_17_5_LIMBS_window5_unsplit_window +%define _LIMB_shr _ring_core_0_17_5_LIMB_shr +%define _OPENSSL_armcap_P _ring_core_0_17_5_OPENSSL_armcap_P +%define _OPENSSL_cpuid_setup _ring_core_0_17_5_OPENSSL_cpuid_setup +%define _OPENSSL_ia32cap_P _ring_core_0_17_5_OPENSSL_ia32cap_P +%define _aes_hw_ctr32_encrypt_blocks _ring_core_0_17_5_aes_hw_ctr32_encrypt_blocks +%define _aes_hw_encrypt _ring_core_0_17_5_aes_hw_encrypt +%define _aes_hw_set_encrypt_key _ring_core_0_17_5_aes_hw_set_encrypt_key +%define _aes_nohw_ctr32_encrypt_blocks _ring_core_0_17_5_aes_nohw_ctr32_encrypt_blocks +%define _aes_nohw_encrypt _ring_core_0_17_5_aes_nohw_encrypt +%define _aes_nohw_set_encrypt_key _ring_core_0_17_5_aes_nohw_set_encrypt_key +%define _aesni_gcm_decrypt _ring_core_0_17_5_aesni_gcm_decrypt +%define _aesni_gcm_encrypt _ring_core_0_17_5_aesni_gcm_encrypt +%define _bn_from_montgomery_in_place _ring_core_0_17_5_bn_from_montgomery_in_place +%define _bn_gather5 _ring_core_0_17_5_bn_gather5 +%define _bn_mul_mont _ring_core_0_17_5_bn_mul_mont +%define _bn_mul_mont_gather5 _ring_core_0_17_5_bn_mul_mont_gather5 +%define _bn_neg_inv_mod_r_u64 _ring_core_0_17_5_bn_neg_inv_mod_r_u64 +%define _bn_power5 _ring_core_0_17_5_bn_power5 +%define _bn_scatter5 _ring_core_0_17_5_bn_scatter5 +%define _bn_sqr8x_internal _ring_core_0_17_5_bn_sqr8x_internal +%define _bn_sqrx8x_internal _ring_core_0_17_5_bn_sqrx8x_internal +%define _bsaes_ctr32_encrypt_blocks _ring_core_0_17_5_bsaes_ctr32_encrypt_blocks +%define _bssl_constant_time_test_conditional_memcpy _ring_core_0_17_5_bssl_constant_time_test_conditional_memcpy +%define _bssl_constant_time_test_conditional_memxor _ring_core_0_17_5_bssl_constant_time_test_conditional_memxor +%define _bssl_constant_time_test_main _ring_core_0_17_5_bssl_constant_time_test_main +%define _chacha20_poly1305_open _ring_core_0_17_5_chacha20_poly1305_open +%define _chacha20_poly1305_seal _ring_core_0_17_5_chacha20_poly1305_seal +%define _fiat_curve25519_adx_mul _ring_core_0_17_5_fiat_curve25519_adx_mul +%define _fiat_curve25519_adx_square _ring_core_0_17_5_fiat_curve25519_adx_square +%define _gcm_ghash_avx _ring_core_0_17_5_gcm_ghash_avx +%define _gcm_ghash_clmul _ring_core_0_17_5_gcm_ghash_clmul +%define _gcm_ghash_neon _ring_core_0_17_5_gcm_ghash_neon +%define _gcm_gmult_clmul _ring_core_0_17_5_gcm_gmult_clmul +%define _gcm_gmult_neon _ring_core_0_17_5_gcm_gmult_neon +%define _gcm_init_avx _ring_core_0_17_5_gcm_init_avx +%define _gcm_init_clmul _ring_core_0_17_5_gcm_init_clmul +%define _gcm_init_neon _ring_core_0_17_5_gcm_init_neon +%define _k25519Precomp _ring_core_0_17_5_k25519Precomp +%define _limbs_mul_add_limb _ring_core_0_17_5_limbs_mul_add_limb +%define _little_endian_bytes_from_scalar _ring_core_0_17_5_little_endian_bytes_from_scalar +%define _ecp_nistz256_neg _ring_core_0_17_5_ecp_nistz256_neg +%define _ecp_nistz256_select_w5 _ring_core_0_17_5_ecp_nistz256_select_w5 +%define _ecp_nistz256_select_w7 _ring_core_0_17_5_ecp_nistz256_select_w7 +%define _p256_mul_mont _ring_core_0_17_5_p256_mul_mont +%define _p256_point_add _ring_core_0_17_5_p256_point_add +%define _p256_point_add_affine _ring_core_0_17_5_p256_point_add_affine +%define _p256_point_double _ring_core_0_17_5_p256_point_double +%define _p256_point_mul _ring_core_0_17_5_p256_point_mul +%define _p256_point_mul_base _ring_core_0_17_5_p256_point_mul_base +%define _p256_point_mul_base_vartime _ring_core_0_17_5_p256_point_mul_base_vartime +%define _p256_scalar_mul_mont _ring_core_0_17_5_p256_scalar_mul_mont +%define _p256_scalar_sqr_rep_mont _ring_core_0_17_5_p256_scalar_sqr_rep_mont +%define _p256_sqr_mont _ring_core_0_17_5_p256_sqr_mont +%define _p384_elem_div_by_2 _ring_core_0_17_5_p384_elem_div_by_2 +%define _p384_elem_mul_mont _ring_core_0_17_5_p384_elem_mul_mont +%define _p384_elem_neg _ring_core_0_17_5_p384_elem_neg +%define _p384_elem_sub _ring_core_0_17_5_p384_elem_sub +%define _p384_point_add _ring_core_0_17_5_p384_point_add +%define _p384_point_double _ring_core_0_17_5_p384_point_double +%define _p384_point_mul _ring_core_0_17_5_p384_point_mul +%define _p384_scalar_mul_mont _ring_core_0_17_5_p384_scalar_mul_mont +%define _openssl_poly1305_neon2_addmulmod _ring_core_0_17_5_openssl_poly1305_neon2_addmulmod +%define _openssl_poly1305_neon2_blocks _ring_core_0_17_5_openssl_poly1305_neon2_blocks +%define _sha256_block_data_order _ring_core_0_17_5_sha256_block_data_order +%define _sha512_block_data_order _ring_core_0_17_5_sha512_block_data_order +%define _vpaes_ctr32_encrypt_blocks _ring_core_0_17_5_vpaes_ctr32_encrypt_blocks +%define _vpaes_encrypt _ring_core_0_17_5_vpaes_encrypt +%define _vpaes_encrypt_key_to_bsaes _ring_core_0_17_5_vpaes_encrypt_key_to_bsaes +%define _vpaes_set_encrypt_key _ring_core_0_17_5_vpaes_set_encrypt_key +%define _x25519_NEON _ring_core_0_17_5_x25519_NEON +%define _x25519_fe_invert _ring_core_0_17_5_x25519_fe_invert +%define _x25519_fe_isnegative _ring_core_0_17_5_x25519_fe_isnegative +%define _x25519_fe_mul_ttt _ring_core_0_17_5_x25519_fe_mul_ttt +%define _x25519_fe_neg _ring_core_0_17_5_x25519_fe_neg +%define _x25519_fe_tobytes _ring_core_0_17_5_x25519_fe_tobytes +%define _x25519_ge_double_scalarmult_vartime _ring_core_0_17_5_x25519_ge_double_scalarmult_vartime +%define _x25519_ge_frombytes_vartime _ring_core_0_17_5_x25519_ge_frombytes_vartime +%define _x25519_ge_scalarmult_base _ring_core_0_17_5_x25519_ge_scalarmult_base +%define _x25519_ge_scalarmult_base_adx _ring_core_0_17_5_x25519_ge_scalarmult_base_adx +%define _x25519_public_from_private_generic_masked _ring_core_0_17_5_x25519_public_from_private_generic_masked +%define _x25519_sc_mask _ring_core_0_17_5_x25519_sc_mask +%define _x25519_sc_muladd _ring_core_0_17_5_x25519_sc_muladd +%define _x25519_sc_reduce _ring_core_0_17_5_x25519_sc_reduce +%define _x25519_scalar_mult_adx _ring_core_0_17_5_x25519_scalar_mult_adx +%define _x25519_scalar_mult_generic_masked _ring_core_0_17_5_x25519_scalar_mult_generic_masked + +%else +%define ecp_nistz256_point_double p256_point_double +%define ecp_nistz256_point_add p256_point_add +%define ecp_nistz256_point_add_affine p256_point_add_affine +%define ecp_nistz256_ord_mul_mont p256_scalar_mul_mont +%define ecp_nistz256_ord_sqr_mont p256_scalar_sqr_rep_mont +%define ecp_nistz256_mul_mont p256_mul_mont +%define ecp_nistz256_sqr_mont p256_sqr_mont +%define CRYPTO_memcmp ring_core_0_17_5_CRYPTO_memcmp +%define CRYPTO_poly1305_finish ring_core_0_17_5_CRYPTO_poly1305_finish +%define CRYPTO_poly1305_finish_neon ring_core_0_17_5_CRYPTO_poly1305_finish_neon +%define CRYPTO_poly1305_init ring_core_0_17_5_CRYPTO_poly1305_init +%define CRYPTO_poly1305_init_neon ring_core_0_17_5_CRYPTO_poly1305_init_neon +%define CRYPTO_poly1305_update ring_core_0_17_5_CRYPTO_poly1305_update +%define CRYPTO_poly1305_update_neon ring_core_0_17_5_CRYPTO_poly1305_update_neon +%define ChaCha20_ctr32 ring_core_0_17_5_ChaCha20_ctr32 +%define LIMBS_add_mod ring_core_0_17_5_LIMBS_add_mod +%define LIMBS_are_even ring_core_0_17_5_LIMBS_are_even +%define LIMBS_are_zero ring_core_0_17_5_LIMBS_are_zero +%define LIMBS_equal ring_core_0_17_5_LIMBS_equal +%define LIMBS_equal_limb ring_core_0_17_5_LIMBS_equal_limb +%define LIMBS_less_than ring_core_0_17_5_LIMBS_less_than +%define LIMBS_less_than_limb ring_core_0_17_5_LIMBS_less_than_limb +%define LIMBS_reduce_once ring_core_0_17_5_LIMBS_reduce_once +%define LIMBS_select_512_32 ring_core_0_17_5_LIMBS_select_512_32 +%define LIMBS_shl_mod ring_core_0_17_5_LIMBS_shl_mod +%define LIMBS_sub_mod ring_core_0_17_5_LIMBS_sub_mod +%define LIMBS_window5_split_window ring_core_0_17_5_LIMBS_window5_split_window +%define LIMBS_window5_unsplit_window ring_core_0_17_5_LIMBS_window5_unsplit_window +%define LIMB_shr ring_core_0_17_5_LIMB_shr +%define OPENSSL_armcap_P ring_core_0_17_5_OPENSSL_armcap_P +%define OPENSSL_cpuid_setup ring_core_0_17_5_OPENSSL_cpuid_setup +%define OPENSSL_ia32cap_P ring_core_0_17_5_OPENSSL_ia32cap_P +%define aes_hw_ctr32_encrypt_blocks ring_core_0_17_5_aes_hw_ctr32_encrypt_blocks +%define aes_hw_encrypt ring_core_0_17_5_aes_hw_encrypt +%define aes_hw_set_encrypt_key ring_core_0_17_5_aes_hw_set_encrypt_key +%define aes_nohw_ctr32_encrypt_blocks ring_core_0_17_5_aes_nohw_ctr32_encrypt_blocks +%define aes_nohw_encrypt ring_core_0_17_5_aes_nohw_encrypt +%define aes_nohw_set_encrypt_key ring_core_0_17_5_aes_nohw_set_encrypt_key +%define aesni_gcm_decrypt ring_core_0_17_5_aesni_gcm_decrypt +%define aesni_gcm_encrypt ring_core_0_17_5_aesni_gcm_encrypt +%define bn_from_montgomery_in_place ring_core_0_17_5_bn_from_montgomery_in_place +%define bn_gather5 ring_core_0_17_5_bn_gather5 +%define bn_mul_mont ring_core_0_17_5_bn_mul_mont +%define bn_mul_mont_gather5 ring_core_0_17_5_bn_mul_mont_gather5 +%define bn_neg_inv_mod_r_u64 ring_core_0_17_5_bn_neg_inv_mod_r_u64 +%define bn_power5 ring_core_0_17_5_bn_power5 +%define bn_scatter5 ring_core_0_17_5_bn_scatter5 +%define bn_sqr8x_internal ring_core_0_17_5_bn_sqr8x_internal +%define bn_sqrx8x_internal ring_core_0_17_5_bn_sqrx8x_internal +%define bsaes_ctr32_encrypt_blocks ring_core_0_17_5_bsaes_ctr32_encrypt_blocks +%define bssl_constant_time_test_conditional_memcpy ring_core_0_17_5_bssl_constant_time_test_conditional_memcpy +%define bssl_constant_time_test_conditional_memxor ring_core_0_17_5_bssl_constant_time_test_conditional_memxor +%define bssl_constant_time_test_main ring_core_0_17_5_bssl_constant_time_test_main +%define chacha20_poly1305_open ring_core_0_17_5_chacha20_poly1305_open +%define chacha20_poly1305_seal ring_core_0_17_5_chacha20_poly1305_seal +%define fiat_curve25519_adx_mul ring_core_0_17_5_fiat_curve25519_adx_mul +%define fiat_curve25519_adx_square ring_core_0_17_5_fiat_curve25519_adx_square +%define gcm_ghash_avx ring_core_0_17_5_gcm_ghash_avx +%define gcm_ghash_clmul ring_core_0_17_5_gcm_ghash_clmul +%define gcm_ghash_neon ring_core_0_17_5_gcm_ghash_neon +%define gcm_gmult_clmul ring_core_0_17_5_gcm_gmult_clmul +%define gcm_gmult_neon ring_core_0_17_5_gcm_gmult_neon +%define gcm_init_avx ring_core_0_17_5_gcm_init_avx +%define gcm_init_clmul ring_core_0_17_5_gcm_init_clmul +%define gcm_init_neon ring_core_0_17_5_gcm_init_neon +%define k25519Precomp ring_core_0_17_5_k25519Precomp +%define limbs_mul_add_limb ring_core_0_17_5_limbs_mul_add_limb +%define little_endian_bytes_from_scalar ring_core_0_17_5_little_endian_bytes_from_scalar +%define ecp_nistz256_neg ring_core_0_17_5_ecp_nistz256_neg +%define ecp_nistz256_select_w5 ring_core_0_17_5_ecp_nistz256_select_w5 +%define ecp_nistz256_select_w7 ring_core_0_17_5_ecp_nistz256_select_w7 +%define p256_mul_mont ring_core_0_17_5_p256_mul_mont +%define p256_point_add ring_core_0_17_5_p256_point_add +%define p256_point_add_affine ring_core_0_17_5_p256_point_add_affine +%define p256_point_double ring_core_0_17_5_p256_point_double +%define p256_point_mul ring_core_0_17_5_p256_point_mul +%define p256_point_mul_base ring_core_0_17_5_p256_point_mul_base +%define p256_point_mul_base_vartime ring_core_0_17_5_p256_point_mul_base_vartime +%define p256_scalar_mul_mont ring_core_0_17_5_p256_scalar_mul_mont +%define p256_scalar_sqr_rep_mont ring_core_0_17_5_p256_scalar_sqr_rep_mont +%define p256_sqr_mont ring_core_0_17_5_p256_sqr_mont +%define p384_elem_div_by_2 ring_core_0_17_5_p384_elem_div_by_2 +%define p384_elem_mul_mont ring_core_0_17_5_p384_elem_mul_mont +%define p384_elem_neg ring_core_0_17_5_p384_elem_neg +%define p384_elem_sub ring_core_0_17_5_p384_elem_sub +%define p384_point_add ring_core_0_17_5_p384_point_add +%define p384_point_double ring_core_0_17_5_p384_point_double +%define p384_point_mul ring_core_0_17_5_p384_point_mul +%define p384_scalar_mul_mont ring_core_0_17_5_p384_scalar_mul_mont +%define openssl_poly1305_neon2_addmulmod ring_core_0_17_5_openssl_poly1305_neon2_addmulmod +%define openssl_poly1305_neon2_blocks ring_core_0_17_5_openssl_poly1305_neon2_blocks +%define sha256_block_data_order ring_core_0_17_5_sha256_block_data_order +%define sha512_block_data_order ring_core_0_17_5_sha512_block_data_order +%define vpaes_ctr32_encrypt_blocks ring_core_0_17_5_vpaes_ctr32_encrypt_blocks +%define vpaes_encrypt ring_core_0_17_5_vpaes_encrypt +%define vpaes_encrypt_key_to_bsaes ring_core_0_17_5_vpaes_encrypt_key_to_bsaes +%define vpaes_set_encrypt_key ring_core_0_17_5_vpaes_set_encrypt_key +%define x25519_NEON ring_core_0_17_5_x25519_NEON +%define x25519_fe_invert ring_core_0_17_5_x25519_fe_invert +%define x25519_fe_isnegative ring_core_0_17_5_x25519_fe_isnegative +%define x25519_fe_mul_ttt ring_core_0_17_5_x25519_fe_mul_ttt +%define x25519_fe_neg ring_core_0_17_5_x25519_fe_neg +%define x25519_fe_tobytes ring_core_0_17_5_x25519_fe_tobytes +%define x25519_ge_double_scalarmult_vartime ring_core_0_17_5_x25519_ge_double_scalarmult_vartime +%define x25519_ge_frombytes_vartime ring_core_0_17_5_x25519_ge_frombytes_vartime +%define x25519_ge_scalarmult_base ring_core_0_17_5_x25519_ge_scalarmult_base +%define x25519_ge_scalarmult_base_adx ring_core_0_17_5_x25519_ge_scalarmult_base_adx +%define x25519_public_from_private_generic_masked ring_core_0_17_5_x25519_public_from_private_generic_masked +%define x25519_sc_mask ring_core_0_17_5_x25519_sc_mask +%define x25519_sc_muladd ring_core_0_17_5_x25519_sc_muladd +%define x25519_sc_reduce ring_core_0_17_5_x25519_sc_reduce +%define x25519_scalar_mult_adx ring_core_0_17_5_x25519_scalar_mult_adx +%define x25519_scalar_mult_generic_masked ring_core_0_17_5_x25519_scalar_mult_generic_masked + +%endif +%endif diff --git a/shim/third-party/rust/fixups/rustix/fixups.toml b/shim/third-party/rust/fixups/rustix/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/rustix/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/rustls/fixups.toml b/shim/third-party/rust/fixups/rustls/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/rustls/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/rustversion/fixups.toml b/shim/third-party/rust/fixups/rustversion/fixups.toml new file mode 100644 index 00000000000..ac9ebfb4af7 --- /dev/null +++ b/shim/third-party/rust/fixups/rustversion/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.gen_srcs] diff --git a/shim/third-party/rust/fixups/serde/fixups.toml b/shim/third-party/rust/fixups/serde/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/serde/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/serde_derive/fixups.toml b/shim/third-party/rust/fixups/serde_derive/fixups.toml new file mode 100644 index 00000000000..7de4ebb3e19 --- /dev/null +++ b/shim/third-party/rust/fixups/serde_derive/fixups.toml @@ -0,0 +1,3 @@ +# To set `CARGO_MANIFEST_DIR` +cargo_env = true +buildscript = [] diff --git a/shim/third-party/rust/fixups/serde_json/fixups.toml b/shim/third-party/rust/fixups/serde_json/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/serde_json/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/signal-hook/fixups.toml b/shim/third-party/rust/fixups/signal-hook/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/signal-hook/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/slab/fixups.toml b/shim/third-party/rust/fixups/slab/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/slab/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/slog/fixups.toml b/shim/third-party/rust/fixups/slog/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/slog/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/syn/fixups.toml b/shim/third-party/rust/fixups/syn/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/syn/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/sys-info/fixups.toml b/shim/third-party/rust/fixups/sys-info/fixups.toml new file mode 100644 index 00000000000..5d124b3ad7a --- /dev/null +++ b/shim/third-party/rust/fixups/sys-info/fixups.toml @@ -0,0 +1,19 @@ +buildscript = [] + +[[platform_fixup.'cfg(target_os = "linux")'.buildscript]] +[platform_fixup.'cfg(target_os = "linux")'.buildscript.cxx_library] +name = "linux" +srcs = ["c/linux.c"] +headers = ["c/*.h"] + +[[platform_fixup.'cfg(target_os = "macos")'.buildscript]] +[platform_fixup.'cfg(target_os = "macos")'.buildscript.cxx_library] +name = "macos" +srcs = ["c/darwin.c"] +headers = ["c/*.h"] + +[[platform_fixup.'cfg(target_os = "windows")'.buildscript]] +[platform_fixup.'cfg(target_os = "windows")'.buildscript.cxx_library] +name = "windows" +srcs = ["c/windows.c"] +headers = ["c/*.h"] diff --git a/shim/third-party/rust/fixups/sysinfo/fixups.toml b/shim/third-party/rust/fixups/sysinfo/fixups.toml new file mode 100644 index 00000000000..8518b189700 --- /dev/null +++ b/shim/third-party/rust/fixups/sysinfo/fixups.toml @@ -0,0 +1,11 @@ +extra_srcs = ["README.md", "md_doc/**/*.md"] +buildscript = [] + +[platform_fixup.'cfg(target_os = "macos")'] +buildscript = [] +rustc_flags = [ + "-lframework=IOKit", + "-lframework=Foundation", + "-lframework=CoreFoundation", + "-lframework=DiskArbitration", +] diff --git a/shim/third-party/rust/fixups/tempfile/fixups.toml b/shim/third-party/rust/fixups/tempfile/fixups.toml new file mode 100644 index 00000000000..5e026f75e0d --- /dev/null +++ b/shim/third-party/rust/fixups/tempfile/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/terminfo/fixups.toml b/shim/third-party/rust/fixups/terminfo/fixups.toml new file mode 100644 index 00000000000..ac9ebfb4af7 --- /dev/null +++ b/shim/third-party/rust/fixups/terminfo/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.gen_srcs] diff --git a/shim/third-party/rust/fixups/termwiz/fixups.toml b/shim/third-party/rust/fixups/termwiz/fixups.toml new file mode 100644 index 00000000000..fdba1eb21b8 --- /dev/null +++ b/shim/third-party/rust/fixups/termwiz/fixups.toml @@ -0,0 +1,2 @@ +cargo_env = true +extra_srcs = ["src/**/*.pest"] diff --git a/shim/third-party/rust/fixups/test-case/fixups.toml b/shim/third-party/rust/fixups/test-case/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/test-case/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/thiserror/fixups.toml b/shim/third-party/rust/fixups/thiserror/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/thiserror/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/tiny-keccak/fixups.toml b/shim/third-party/rust/fixups/tiny-keccak/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/tiny-keccak/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/tokio-stream/fixups.toml b/shim/third-party/rust/fixups/tokio-stream/fixups.toml new file mode 100644 index 00000000000..a1f4f0e7091 --- /dev/null +++ b/shim/third-party/rust/fixups/tokio-stream/fixups.toml @@ -0,0 +1,2 @@ +# reindeer cannot see through `cfg_sync!` macros and the like +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/tokio-util/fixups.toml b/shim/third-party/rust/fixups/tokio-util/fixups.toml new file mode 100644 index 00000000000..af7edb27e3b --- /dev/null +++ b/shim/third-party/rust/fixups/tokio-util/fixups.toml @@ -0,0 +1 @@ +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/tokio/fixups.toml b/shim/third-party/rust/fixups/tokio/fixups.toml new file mode 100644 index 00000000000..d69dcefddb3 --- /dev/null +++ b/shim/third-party/rust/fixups/tokio/fixups.toml @@ -0,0 +1,8 @@ +cfgs = ["tokio_unstable", "tokio_track_caller"] + +extra_srcs = ["src/**/*.rs"] + +buildscript = [] +features = ["tokio_track_caller"] + +extra_deps = [ ":tracing" ] diff --git a/shim/third-party/rust/fixups/tonic/fixups.toml b/shim/third-party/rust/fixups/tonic/fixups.toml new file mode 100644 index 00000000000..41439d3356a --- /dev/null +++ b/shim/third-party/rust/fixups/tonic/fixups.toml @@ -0,0 +1 @@ +cargo_env = true diff --git a/shim/third-party/rust/fixups/tracing-subscriber/fixups.toml b/shim/third-party/rust/fixups/tracing-subscriber/fixups.toml new file mode 100644 index 00000000000..28683dbe3cb --- /dev/null +++ b/shim/third-party/rust/fixups/tracing-subscriber/fixups.toml @@ -0,0 +1,2 @@ +# Reindeer can't find the dependencies due to being confused by the feature! macro. +extra_srcs = ["src/**/*.rs"] diff --git a/shim/third-party/rust/fixups/trybuild/fixups.toml b/shim/third-party/rust/fixups/trybuild/fixups.toml new file mode 100644 index 00000000000..ac9ebfb4af7 --- /dev/null +++ b/shim/third-party/rust/fixups/trybuild/fixups.toml @@ -0,0 +1,2 @@ +[[buildscript]] +[buildscript.gen_srcs] diff --git a/shim/third-party/rust/fixups/typenum/fixups.toml b/shim/third-party/rust/fixups/typenum/fixups.toml new file mode 100644 index 00000000000..7ab02e4fd17 --- /dev/null +++ b/shim/third-party/rust/fixups/typenum/fixups.toml @@ -0,0 +1,4 @@ +features = ["force_unix_path_separator"] + +[[buildscript]] +[buildscript.gen_srcs] diff --git a/shim/third-party/rust/fixups/unicase/fixups.toml b/shim/third-party/rust/fixups/unicase/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/unicase/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/winapi-x86_64-pc-windows-gnu/fixups.toml b/shim/third-party/rust/fixups/winapi-x86_64-pc-windows-gnu/fixups.toml new file mode 100644 index 00000000000..07c79834d92 --- /dev/null +++ b/shim/third-party/rust/fixups/winapi-x86_64-pc-windows-gnu/fixups.toml @@ -0,0 +1,9 @@ +buildscript = [] + +[[platform_fixup.'cfg(target_os = "windows")'.buildscript]] +[platform_fixup.'cfg(target_os = "windows")'.buildscript.prebuilt_cxx_library] +name = "extra_libraries" +# The static_libs this crate provides overlaps quite heavily with those in a default +# MinGW install, and there are also many that are DirectX specific. +# We list only those we actually need, since the others are more likely to cause problems. +static_libs = ["lib/libwinapi_ole32.a", "lib/libwinapi_shell32.a"] diff --git a/shim/third-party/rust/fixups/winapi/fixups.toml b/shim/third-party/rust/fixups/winapi/fixups.toml new file mode 100644 index 00000000000..ec4f86e500d --- /dev/null +++ b/shim/third-party/rust/fixups/winapi/fixups.toml @@ -0,0 +1,4 @@ +buildscript = [] + +[[platform_fixup.'cfg(target_os = "windows")'.buildscript]] +[platform_fixup.'cfg(target_os = "windows")'.buildscript.rustc_flags] diff --git a/shim/third-party/rust/fixups/windows-targets/fixups.toml b/shim/third-party/rust/fixups/windows-targets/fixups.toml new file mode 100644 index 00000000000..b3555c7795e --- /dev/null +++ b/shim/third-party/rust/fixups/windows-targets/fixups.toml @@ -0,0 +1,3 @@ +[platform_fixup.'cfg(any(target_os = "windows", target_os = "linux"))'] +version = ">=0.48.0" +cfgs = ["windows_raw_dylib"] diff --git a/shim/third-party/rust/fixups/windows_aarch64_gnullvm/fixups.toml b/shim/third-party/rust/fixups/windows_aarch64_gnullvm/fixups.toml new file mode 100644 index 00000000000..f40e9f9cbe6 --- /dev/null +++ b/shim/third-party/rust/fixups/windows_aarch64_gnullvm/fixups.toml @@ -0,0 +1,8 @@ +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "linux", target_arch = "aarch64"))'] +version = "=0.48.0" +[[platform_fixup.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.buildscript]] +[platform_fixup.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.buildscript.prebuilt_cxx_library] +name = "libwindows" +static_libs = ["lib/libwindows.0.48.0.a"] diff --git a/shim/third-party/rust/fixups/windows_x86_64_gnu/fixups.toml b/shim/third-party/rust/fixups/windows_x86_64_gnu/fixups.toml new file mode 100644 index 00000000000..b25e7f05fa5 --- /dev/null +++ b/shim/third-party/rust/fixups/windows_x86_64_gnu/fixups.toml @@ -0,0 +1,8 @@ +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "windows", target_env = "gnu"))'] +version = "=0.48.0" +[[platform_fixup.'cfg(all(target_os = "windows", target_env = "gnu"))'.buildscript]] +[platform_fixup.'cfg(all(target_os = "windows", target_env = "gnu"))'.buildscript.prebuilt_cxx_library] +name = "libwindows" +static_libs = ["lib/libwindows.0.48.0.a"] diff --git a/shim/third-party/rust/fixups/windows_x86_64_gnullvm/fixups.toml b/shim/third-party/rust/fixups/windows_x86_64_gnullvm/fixups.toml new file mode 100644 index 00000000000..a5579b6930e --- /dev/null +++ b/shim/third-party/rust/fixups/windows_x86_64_gnullvm/fixups.toml @@ -0,0 +1,8 @@ +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "linux", target_arch = "x86_64"))'] +version = "=0.48.0" +[[platform_fixup.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.buildscript]] +[platform_fixup.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.buildscript.prebuilt_cxx_library] +name = "libwindows" +static_libs = ["lib/libwindows.0.48.0.a"] diff --git a/shim/third-party/rust/fixups/windows_x86_64_msvc/fixups.toml b/shim/third-party/rust/fixups/windows_x86_64_msvc/fixups.toml new file mode 100644 index 00000000000..8e8dea35165 --- /dev/null +++ b/shim/third-party/rust/fixups/windows_x86_64_msvc/fixups.toml @@ -0,0 +1,8 @@ +buildscript = [] + +[platform_fixup.'cfg(all(target_os = "windows", target_env = "msvc"))'] +version = "=0.48.0" +[[platform_fixup.'cfg(all(target_os = "windows", target_env = "msvc"))'.buildscript]] +[platform_fixup.'cfg(all(target_os = "windows", target_env = "msvc"))'.buildscript.prebuilt_cxx_library] +name = "windows" +static_libs = ["lib/windows.0.48.0.lib"] diff --git a/shim/third-party/rust/fixups/winreg/fixups.toml b/shim/third-party/rust/fixups/winreg/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/winreg/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/zerocopy/fixups.toml b/shim/third-party/rust/fixups/zerocopy/fixups.toml new file mode 100644 index 00000000000..41439d3356a --- /dev/null +++ b/shim/third-party/rust/fixups/zerocopy/fixups.toml @@ -0,0 +1 @@ +cargo_env = true diff --git a/shim/third-party/rust/fixups/zstd-safe/fixups.toml b/shim/third-party/rust/fixups/zstd-safe/fixups.toml new file mode 100644 index 00000000000..db40d72cb2e --- /dev/null +++ b/shim/third-party/rust/fixups/zstd-safe/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/shim/third-party/rust/fixups/zstd-sys/fixups.toml b/shim/third-party/rust/fixups/zstd-sys/fixups.toml new file mode 100644 index 00000000000..164b6a7237b --- /dev/null +++ b/shim/third-party/rust/fixups/zstd-sys/fixups.toml @@ -0,0 +1,114 @@ +buildscript = [] + +[[platform_fixup.'cfg(not(all(target_os = "windows", target_env = "msvc")))'.buildscript]] +[platform_fixup.'cfg(not(all(target_os = "windows", target_env = "msvc")))'.buildscript.cxx_library] +name = "zstd" +srcs = [ + "zstd/lib/common/debug.c", + "zstd/lib/common/entropy_common.c", + "zstd/lib/common/error_private.c", + "zstd/lib/common/fse_decompress.c", + "zstd/lib/common/pool.c", + "zstd/lib/common/threading.c", + #"zstd/lib/common/xxhash.c", + "zstd/lib/common/zstd_common.c", + "zstd/lib/compress/**/*.c", + "zstd/lib/decompress/**/*.c", + "zstd/lib/decompress/huf_decompress_amd64.S", + "zstd/lib/dictBuilder/**/*.c", + "zstd/lib/legacy/**/*.c", +] +headers = [ + "zdict.h", + "zstd.h", + "zstd/lib/common/bitstream.h", + "zstd/lib/common/compiler.h", + "zstd/lib/common/cpu.h", + "zstd/lib/common/debug.h", + "zstd/lib/common/error_private.h", + "zstd/lib/common/fse.h", + "zstd/lib/common/huf.h", + "zstd/lib/common/mem.h", + "zstd/lib/common/pool.h", + "zstd/lib/common/portability_macros.h", + "zstd/lib/common/threading.h", + #"zstd/lib/common/xxhash.h", + "zstd/lib/common/zstd_deps.h", + "zstd/lib/common/zstd_internal.h", + "zstd/lib/common/zstd_trace.h", + "zstd/lib/compress/**/*.h", + "zstd/lib/decompress/**/*.h", + "zstd/lib/deprecated/zbuff.h", + "zstd/lib/dictBuilder/cover.h", + "zstd/lib/dictBuilder/divsufsort.h", + "zstd/lib/legacy/**/*.h", + "zstd/lib/zdict.h", + "zstd/lib/zstd_errors.h", + "zstd/lib/zstd.h", +] +compiler_flags = [ + "-O3", + "-DZSTD_LIB_DEPRECATED=0", + "-fvisibility=hidden", + "-DXXH_PRIVATE_API=", + "-DZSTDLIB_VISIBILITY=", + "-DZDICTLIB_VISIBILITY=", + "-DZSTDERRORLIB_VISIBILITY=", + "-DZSTD_LEGACY_SUPPORT=1" +] + +[[platform_fixup.'cfg(all(target_os = "windows", target_env = "msvc"))'.buildscript]] +[platform_fixup.'cfg(all(target_os = "windows", target_env = "msvc"))'.buildscript.cxx_library] +name = "zstd-msvc" +srcs = [ + "zstd/lib/common/debug.c", + "zstd/lib/common/entropy_common.c", + "zstd/lib/common/error_private.c", + "zstd/lib/common/fse_decompress.c", + "zstd/lib/common/pool.c", + "zstd/lib/common/threading.c", + #"zstd/lib/common/xxhash.c", + "zstd/lib/common/zstd_common.c", + "zstd/lib/compress/**/*.c", + "zstd/lib/decompress/**/*.c", + #"zstd/lib/decompress/huf_decompress_amd64.S", + "zstd/lib/dictBuilder/**/*.c", + "zstd/lib/legacy/**/*.c", +] +headers = [ + "zdict.h", + "zstd.h", + "zstd/lib/common/bitstream.h", + "zstd/lib/common/compiler.h", + "zstd/lib/common/cpu.h", + "zstd/lib/common/debug.h", + "zstd/lib/common/error_private.h", + "zstd/lib/common/fse.h", + "zstd/lib/common/huf.h", + "zstd/lib/common/mem.h", + "zstd/lib/common/pool.h", + "zstd/lib/common/portability_macros.h", + "zstd/lib/common/threading.h", + #"zstd/lib/common/xxhash.h", + "zstd/lib/common/zstd_deps.h", + "zstd/lib/common/zstd_internal.h", + "zstd/lib/common/zstd_trace.h", + "zstd/lib/compress/**/*.h", + "zstd/lib/decompress/**/*.h", + "zstd/lib/deprecated/zbuff.h", + "zstd/lib/dictBuilder/cover.h", + "zstd/lib/dictBuilder/divsufsort.h", + "zstd/lib/legacy/**/*.h", + "zstd/lib/zdict.h", + "zstd/lib/zstd_errors.h", + "zstd/lib/zstd.h", +] +compiler_flags = [ + "/O2", + "-DZSTD_LIB_DEPRECATED=0", + "-DXXH_PRIVATE_API=", + "-DZSTDLIB_VISIBILITY=", + "-DZDICTLIB_VISIBILITY=", + "-DZSTDERRORLIB_VISIBILITY=", + "-DZSTD_LEGACY_SUPPORT=1" +] diff --git a/shim/third-party/rust/reindeer.toml b/shim/third-party/rust/reindeer.toml new file mode 100644 index 00000000000..4aa852e04e1 --- /dev/null +++ b/shim/third-party/rust/reindeer.toml @@ -0,0 +1,29 @@ +# Configuration for Reindeer to generate Buck targets from Cargo.toml +# +# Overview of available options: +# https://github.com/facebookincubator/reindeer/blob/main/example/third-party/reindeer.toml + +# Parse Rust code to work out the precise set of source files for each crate. +precise_srcs = true + +# Include a public top-level target which depends on all other targets. +include_top_level = true + +[cargo] +# Support Cargo's unstable "artifact dependencies" functionality, RFC 3028. +bindeps = true + +[buck] +# Name of the generated file. +file_name = "BUCK" + +# Rules used for various kinds of targets. +rust_library = "cargo.rust_library" +rust_binary = "cargo.rust_binary" +prebuilt_cxx_library = "third_party_rust_prebuilt_cxx_library" + +buckfile_imports = """ +load("@prelude//rust:cargo_buildscript.bzl", "buildscript_run") +load("@prelude//rust:cargo_package.bzl", "cargo") +load("//third-party/macros:rust_third_party.bzl", "third_party_rust_prebuilt_cxx_library") +""" diff --git a/shim/third-party/rust/top/main.rs b/shim/third-party/rust/top/main.rs new file mode 100644 index 00000000000..7dde67dd19b --- /dev/null +++ b/shim/third-party/rust/top/main.rs @@ -0,0 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +#![allow(unused_crate_dependencies)] + +fn main() {} diff --git a/shim/tools/build_defs/audit_dependencies_test.bzl b/shim/tools/build_defs/audit_dependencies_test.bzl new file mode 100644 index 00000000000..a3174389f55 --- /dev/null +++ b/shim/tools/build_defs/audit_dependencies_test.bzl @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +# Noop in OSS +def audit_dependencies_test(**_kwargs): + pass diff --git a/shim/tools/build_defs/buck2/is_buck2.bzl b/shim/tools/build_defs/buck2/is_buck2.bzl new file mode 100644 index 00000000000..45140ef215f --- /dev/null +++ b/shim/tools/build_defs/buck2/is_buck2.bzl @@ -0,0 +1,9 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def is_buck2(): + return True diff --git a/shim/tools/build_defs/default_platform_defs.bzl b/shim/tools/build_defs/default_platform_defs.bzl new file mode 100644 index 00000000000..753ec6a3dcf --- /dev/null +++ b/shim/tools/build_defs/default_platform_defs.bzl @@ -0,0 +1 @@ +DEVSERVER_PLATFORM_REGEX = "UNUSED" diff --git a/shim/tools/build_defs/glob_defs.bzl b/shim/tools/build_defs/glob_defs.bzl new file mode 100644 index 00000000000..c119afa5564 --- /dev/null +++ b/shim/tools/build_defs/glob_defs.bzl @@ -0,0 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +glob = native.glob diff --git a/shim/xplat/executorch/kernels/optimized/lib_defs.bzl b/shim/xplat/executorch/kernels/optimized/lib_defs.bzl new file mode 100644 index 00000000000..39c94f70fd4 --- /dev/null +++ b/shim/xplat/executorch/kernels/optimized/lib_defs.bzl @@ -0,0 +1,142 @@ +load("@fbsource//tools/build_defs:default_platform_defs.bzl", "DEVSERVER_PLATFORM_REGEX") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +# Because vec exists as a collection of header files, compile and preprocessor +# flags applied to the vec target do not have any effect, since no compilation +# actually occurs for the target. +# +# Targets using the vec library must therefore call the get_vec_*_flags +# functions in order to declare the required compiler flags needed in order to +# access CPU vector intrinsics. + +def get_vec_android_preprocessor_flags(): + preprocessor_flags = [ + ( + "^android-arm64.*$", + [ + "-DET_BUILD_ARM_VEC256_WITH_SLEEF", + ], + ), + ] + return preprocessor_flags + +def get_vec_cxx_preprocessor_flags(): + preprocessor_flags = [ + ( + DEVSERVER_PLATFORM_REGEX, + [ + "-DCPU_CAPABILITY_AVX2", + ], + ), + ] + return preprocessor_flags + +def get_vec_fbcode_preprocessor_flags(): + preprocessor_flags = [ + "-DCPU_CAPABILITY_AVX2", + ] + return preprocessor_flags + +# Currently, having a dependency on fbsource//third-party/sleef:sleef may cause +# duplicate symbol errors when linking fbcode targets in opt mode that also +# depend on ATen. This is because ATen accesses sleef via the third-party folder +# in caffe2 (caffe2/third-party//sleef:sleef). +# TODO(ssjia): Enable -DCPU_CAPABILITY_AVX2 in fbcode, which requires sleef. +def define_libs(): + runtime.cxx_library( + name = "libvec", + srcs = [], + exported_headers = native.glob([ + "vec/**/*.h", + ]), + header_namespace = "executorch/kernels/optimized", + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + cxx_platform_deps = select({ + "DEFAULT": [ + ( + DEVSERVER_PLATFORM_REGEX, + [ + "fbsource//third-party/sleef:sleef", + ], + ), + ], + "ovr_config//cpu:arm64": [ + ( + DEVSERVER_PLATFORM_REGEX, + [ + "fbsource//third-party/sleef:sleef_arm", + ], + ), + ], + }), + fbandroid_platform_deps = [ + ( + "^android-arm64.*$", + [ + "fbsource//third-party/sleef:sleef_arm", + ], + ), + ], + ) + + runtime.cxx_library( + name = "libutils", + srcs = [], + exported_headers = native.glob([ + "utils/**/*.h", + ]), + header_namespace = "executorch/kernels/optimized", + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + exported_deps = [ + # Needed to access the __ET_INLINE macro + "//executorch/runtime/platform:compiler", + ], + ) + + runtime.cxx_library( + name = "libblas", + srcs = native.glob([ + "blas/**/*.cpp", + ]), + exported_headers = native.glob([ + "blas/**/*.h", + ]), + header_namespace = "executorch/kernels/optimized", + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + fbandroid_platform_preprocessor_flags = [ + ( + "^android-arm64.*$", + [ + "-DET_BUILD_WITH_BLAS", + ], + ), + ], + fbandroid_platform_deps = [ + ( + "^android-arm64.*$", + [ + "fbsource//third-party/openblas:openblas", + ], + ), + ], + fbobjc_exported_preprocessor_flags = [ + "-DET_BUILD_WITH_BLAS", + "-DET_BUILD_FOR_APPLE", + ], + fbobjc_frameworks = [ + "Accelerate", + ], + exported_deps = [ + "//executorch/kernels/optimized:libutils", + "//executorch/runtime/core/exec_aten:lib", + ], + ) diff --git a/shim/xplat/executorch/kernels/optimized/op_registration_util.bzl b/shim/xplat/executorch/kernels/optimized/op_registration_util.bzl new file mode 100644 index 00000000000..785c40187b8 --- /dev/null +++ b/shim/xplat/executorch/kernels/optimized/op_registration_util.bzl @@ -0,0 +1,131 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbsource//xplat/executorch/build:selects.bzl", "selects") +load( + "@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl", + "get_vec_android_preprocessor_flags", +) + +def op_target(name, deps = []): + """Registers an optimized implementation for an operator overload group. + + An operator overload group is a set of operator overloads with a common + operator name. That common operator name should be the base name of this + target. + + E.g., the "add" operator overload group, named "op_add" in this target, + might implement: + - add.Tensor + - add_.Tensor + - add.out + - add.Scalar + + If an op target would like to share a header/sources with a different op + target (e.g., helpers/utilities), it should declare a separate cxx_library + and add it as a dep. + + Args: + name: The name of the operator overload group; e.g., + "op_add". This directory must contain a source file named + ".cpp"; e.g., "op_add.cpp". + deps: Optional extra deps to add to the cxx_library(). Note: + - op targets may not depend on other op targets, to keep the + dependencies manageable. If two op targets would like to share + code, define a separate runtime.cxx_library that they both depend + on. + """ + + # Note that this doesn't actually define the target, but helps register + # it in a table that's used to define the target. + return { + "deps": deps, + "name": name, + } + +def _enforce_deps(deps, name): + """Fails if any of the deps are not allowed. + + Args: + deps: A list of build target strings. + name: The name of the target; e.g., "op_add" + """ + for dep in deps: + if dep.startswith(":op_"): + # op targets may not depend on other op targets, to keep the + # dependencies manageable. If two op targets would like to share + # code, define a separate runtime.cxx_library that they both depend + # on. + fail("op_target {} may not depend on other op_target {}".format( + name, + dep, + )) + +def define_op_library(name, deps): + """Defines a cxx_library target for the named operator overload group. + + Args: + name: The name of the target; e.g., "op_add" + deps: List of deps for the target. + """ + selects.apply(obj = deps, function = native.partial(_enforce_deps, name = name)) + + augmented_deps = deps + [ + "//executorch/kernels/optimized:libvec", + "//executorch/kernels/optimized:libutils", + ] + + runtime.cxx_library( + name = "{}".format(name), + srcs = [ + "{}.cpp".format(name), + ], + visibility = [ + "//executorch/kernels/portable/test/...", + "//executorch/kernels/quantized/test/...", + "//executorch/kernels/optimized/test/...", + "//executorch/kernels/test/...", + "@EXECUTORCH_CLIENTS", + ], + # kernels often have helpers with no prototypes just disabling the warning here as the headers + # are codegend and linked in later + compiler_flags = ["-Wno-missing-prototypes"], + deps = [ + "//executorch/runtime/kernel:kernel_includes", + ] + augmented_deps, + fbandroid_platform_preprocessor_flags = get_vec_android_preprocessor_flags(), + # sleef needs to be added as a direct dependency of the operator target when building for Android, + # or a linker error may occur. Not sure why this happens; it seems that fbandroid_platform_deps of + # dependencies are not transitive + fbandroid_platform_deps = [ + ( + "^android-arm64.*$", + [ + "fbsource//third-party/sleef:sleef_arm", + ], + ), + ], + # link_whole is necessary because the operators register themselves + # via static initializers that run at program startup. + # @lint-ignore BUCKLINT link_whole + link_whole = True, + ) + +def define_op_target(name, deps): + """Possibly defines cxx_library targets for the named operator group. + + Args: + name: The base name of the target; e.g., "op_add" + deps: List of deps for the targets. + """ + + # When building in ATen mode, ATen-compatible (non-custom) operators will + # use the implementations provided by ATen, so we should not build the + # versions defined here. + define_op_library( + name = name, + deps = deps, + ) + +def is_op_disabled(name): + # TODO (gjcomer) Enable ops with sleef dependency in OSS + disabled_ops = ["op_gelu", "op_log_softmax"] + return name in disabled_ops