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",
    ]),
    propagated_pp_flags = ["-DFIZZ_HAVE_OQS"],
    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:crypto",
        "//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"),
    ],
)

# TODO (zale): Remove this.
# this is temporary for things outside backend/openssl that still need to
# reference some openssl Propertis. But those will be cleaned up and this
# target will be removed.
cpp_library(
    name = "openssl_hasher",
    headers = [
        "openssl/Hasher.h",
        "openssl/Properties.h",
        "openssl/crypto/Sha.h",
        "openssl/crypto/Sha-inl.h",
        "openssl/crypto/Sha256.h",
        "openssl/crypto/Sha384.h",
        "openssl/crypto/Sha512.h",
    ],
    exported_deps = [
        "//fizz/crypto:crypto",
        "//folly:range",
        "//folly/io:iobuf",
        "//folly/ssl:openssl_hash",
    ],
    exported_external_deps = [
        ("openssl", None, "crypto"),
    ],
)
