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 = [
        "CertManagerBase.h",
        "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 = "handshake_context",
    srcs = [
        "HandshakeContext.cpp",
    ],
    headers = [
        "HandshakeContext.h",
    ],
    deps = [
        "//fizz/crypto:hkdf",
        "//fizz/crypto:key_derivation",
    ],
    exported_deps = [
        "//fizz/crypto:hasher",
        "//fizz/record:record",
    ],
)

cpp_library(
    name = "factory",
    srcs = [
        "Factory.cpp",
    ],
    headers = [
        "Factory.h",
    ],
    exported_deps = [
        ":certificate",
        ":handshake_context",
        ":key_scheduler",
        ":types",
        "//fizz/crypto:crypto",
        "//fizz/crypto:hasher",
        "//fizz/crypto:key_derivation",
        "//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 = [
        ":multi_backend_factory",  #@manual
        "//fizz:config",
    ],
)

cpp_library(
    name = "multi_backend_factory",
    srcs = [
        "MultiBackendFactory.cpp",
    ],
    headers = [
        "MultiBackendFactory.h",
    ],
    deps = [
        "//fizz:config",
        "//fizz/backend:libaegis",
        "//fizz/backend:liboqs",
        "//fizz/backend:libsodium",
        "//fizz/backend:openssl",
        "//fizz/crypto:hkdf",
        "//fizz/crypto/exchange:hybrid_key_exchange",
    ],
    exported_deps = [
        ":factory",
    ],
)

cpp_library(
    name = "types",
    srcs = [
        "Types.cpp",
    ],
    headers = [
        "Types.h",
    ],
    exported_deps = [
        "//fizz/crypto:crypto",
        "//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",
    ],
    deps = [
        "//fizz/crypto:hasher",
    ],
    exported_deps = [
        ":factory",
        "//fizz/crypto:key_derivation",
    ],
)
