package(default_visibility = ["//tensorflow:__subpackages__"])

licenses(["restricted"])  # OpenSSL license, partly BSD-like

# See https://boringssl.googlesource.com/boringssl/+/master/INCORPORATING.md
# on how to re-generate the list of source files.

ssl_headers = [
]

ssl_internal_headers = [
    "ssl/internal.h",
    "ssl/test/async_bio.h",
    "ssl/test/packeted_bio.h",
    "ssl/test/scoped_types.h",
    "ssl/test/test_config.h",
]

ssl_sources = [
    "ssl/custom_extensions.c",
    "ssl/d1_both.c",
    "ssl/d1_clnt.c",
    "ssl/d1_lib.c",
    "ssl/d1_meth.c",
    "ssl/d1_pkt.c",
    "ssl/d1_srtp.c",
    "ssl/d1_srvr.c",
    "ssl/dtls_record.c",
    "ssl/pqueue/pqueue.c",
    "ssl/s3_both.c",
    "ssl/s3_clnt.c",
    "ssl/s3_enc.c",
    "ssl/s3_lib.c",
    "ssl/s3_meth.c",
    "ssl/s3_pkt.c",
    "ssl/s3_srvr.c",
    "ssl/ssl_aead_ctx.c",
    "ssl/ssl_asn1.c",
    "ssl/ssl_buffer.c",
    "ssl/ssl_cert.c",
    "ssl/ssl_cipher.c",
    "ssl/ssl_ecdh.c",
    "ssl/ssl_file.c",
    "ssl/ssl_lib.c",
    "ssl/ssl_rsa.c",
    "ssl/ssl_session.c",
    "ssl/ssl_stat.c",
    "ssl/t1_enc.c",
    "ssl/t1_lib.c",
    "ssl/tls_record.c",
]

crypto_headers = [
    "include/openssl/aead.h",
    "include/openssl/aes.h",
    "include/openssl/arm_arch.h",
    "include/openssl/asn1.h",
    "include/openssl/asn1_mac.h",
    "include/openssl/asn1t.h",
    "include/openssl/base.h",
    "include/openssl/base64.h",
    "include/openssl/bio.h",
    "include/openssl/blowfish.h",
    "include/openssl/bn.h",
    "include/openssl/buf.h",
    "include/openssl/buffer.h",
    "include/openssl/bytestring.h",
    "include/openssl/cast.h",
    "include/openssl/chacha.h",
    "include/openssl/cipher.h",
    "include/openssl/cmac.h",
    "include/openssl/conf.h",
    "include/openssl/cpu.h",
    "include/openssl/crypto.h",
    "include/openssl/curve25519.h",
    "include/openssl/des.h",
    "include/openssl/dh.h",
    "include/openssl/digest.h",
    "include/openssl/dsa.h",
    "include/openssl/ec.h",
    "include/openssl/ec_key.h",
    "include/openssl/ecdh.h",
    "include/openssl/ecdsa.h",
    "include/openssl/engine.h",
    "include/openssl/err.h",
    "include/openssl/evp.h",
    "include/openssl/ex_data.h",
    "include/openssl/hkdf.h",
    "include/openssl/hmac.h",
    "include/openssl/lhash.h",
    "include/openssl/lhash_macros.h",
    "include/openssl/md4.h",
    "include/openssl/md5.h",
    "include/openssl/mem.h",
    "include/openssl/newhope.h",
    "include/openssl/nid.h",
    "include/openssl/obj.h",
    "include/openssl/obj_mac.h",
    "include/openssl/objects.h",
    "include/openssl/opensslconf.h",
    "include/openssl/opensslv.h",
    "include/openssl/ossl_typ.h",
    "include/openssl/pem.h",
    "include/openssl/pkcs12.h",
    "include/openssl/pkcs7.h",
    "include/openssl/pkcs8.h",
    "include/openssl/poly1305.h",
    "include/openssl/pqueue.h",
    "include/openssl/rand.h",
    "include/openssl/rc4.h",
    "include/openssl/ripemd.h",
    "include/openssl/rsa.h",
    "include/openssl/safestack.h",
    "include/openssl/sha.h",
    "include/openssl/srtp.h",
    "include/openssl/stack.h",
    "include/openssl/stack_macros.h",
    "include/openssl/thread.h",
    "include/openssl/time_support.h",
    "include/openssl/type_check.h",
    "include/openssl/x509.h",
    "include/openssl/x509_vfy.h",
    "include/openssl/x509v3.h",
]

crypto_internal_headers = [
    "crypto/aes/internal.h",
    "crypto/asn1/asn1_locl.h",
    "crypto/bio/internal.h",
    "crypto/bn/internal.h",
    "crypto/bn/rsaz_exp.h",
    "crypto/bytestring/internal.h",
    "crypto/cipher/internal.h",
    "crypto/conf/conf_def.h",
    "crypto/conf/internal.h",
    "crypto/curve25519/internal.h",
    "crypto/des/internal.h",
    "crypto/dh/internal.h",
    "crypto/digest/internal.h",
    "crypto/digest/md32_common.h",
    "crypto/ec/internal.h",
    "crypto/ec/p256-x86_64-table.h",
    "crypto/evp/internal.h",
    "crypto/internal.h",
    "crypto/modes/internal.h",
    "crypto/newhope/internal.h",
    "crypto/obj/obj_dat.h",
    "crypto/obj/obj_xref.h",
    "crypto/pkcs8/internal.h",
    "crypto/poly1305/internal.h",
    "crypto/rand/internal.h",
    "crypto/rsa/internal.h",
    "crypto/test/scoped_types.h",
    "crypto/test/test_util.h",
    "crypto/x509/charmap.h",
    "crypto/x509/internal.h",
    "crypto/x509/vpm_int.h",
    "crypto/x509v3/ext_dat.h",
    "crypto/x509v3/pcy_int.h",
]

crypto_sources = [
    ":err_data_c",
    "crypto/aes/aes.c",
    "crypto/aes/mode_wrappers.c",
    "crypto/asn1/a_bitstr.c",
    "crypto/asn1/a_bool.c",
    "crypto/asn1/a_bytes.c",
    "crypto/asn1/a_d2i_fp.c",
    "crypto/asn1/a_dup.c",
    "crypto/asn1/a_enum.c",
    "crypto/asn1/a_gentm.c",
    "crypto/asn1/a_i2d_fp.c",
    "crypto/asn1/a_int.c",
    "crypto/asn1/a_mbstr.c",
    "crypto/asn1/a_object.c",
    "crypto/asn1/a_octet.c",
    "crypto/asn1/a_print.c",
    "crypto/asn1/a_strnid.c",
    "crypto/asn1/a_time.c",
    "crypto/asn1/a_type.c",
    "crypto/asn1/a_utctm.c",
    "crypto/asn1/a_utf8.c",
    "crypto/asn1/asn1_lib.c",
    "crypto/asn1/asn1_par.c",
    "crypto/asn1/asn_pack.c",
    "crypto/asn1/bio_asn1.c",
    "crypto/asn1/bio_ndef.c",
    "crypto/asn1/f_enum.c",
    "crypto/asn1/f_int.c",
    "crypto/asn1/f_string.c",
    "crypto/asn1/t_bitst.c",
    "crypto/asn1/tasn_dec.c",
    "crypto/asn1/tasn_enc.c",
    "crypto/asn1/tasn_fre.c",
    "crypto/asn1/tasn_new.c",
    "crypto/asn1/tasn_prn.c",
    "crypto/asn1/tasn_typ.c",
    "crypto/asn1/tasn_utl.c",
    "crypto/asn1/x_bignum.c",
    "crypto/asn1/x_long.c",
    "crypto/base64/base64.c",
    "crypto/bio/bio.c",
    "crypto/bio/bio_mem.c",
    "crypto/bio/buffer.c",
    "crypto/bio/connect.c",
    "crypto/bio/fd.c",
    "crypto/bio/file.c",
    "crypto/bio/hexdump.c",
    "crypto/bio/pair.c",
    "crypto/bio/printf.c",
    "crypto/bio/socket.c",
    "crypto/bio/socket_helper.c",
    "crypto/bn/add.c",
    "crypto/bn/asm/x86_64-gcc.c",
    "crypto/bn/bn.c",
    "crypto/bn/bn_asn1.c",
    "crypto/bn/cmp.c",
    "crypto/bn/convert.c",
    "crypto/bn/ctx.c",
    "crypto/bn/div.c",
    "crypto/bn/exponentiation.c",
    "crypto/bn/gcd.c",
    "crypto/bn/generic.c",
    "crypto/bn/kronecker.c",
    "crypto/bn/montgomery.c",
    "crypto/bn/mul.c",
    "crypto/bn/prime.c",
    "crypto/bn/random.c",
    "crypto/bn/rsaz_exp.c",
    "crypto/bn/shift.c",
    "crypto/bn/sqrt.c",
    "crypto/buf/buf.c",
    "crypto/bytestring/asn1_compat.c",
    "crypto/bytestring/ber.c",
    "crypto/bytestring/cbb.c",
    "crypto/bytestring/cbs.c",
    "crypto/chacha/chacha.c",
    "crypto/cipher/aead.c",
    "crypto/cipher/cipher.c",
    "crypto/cipher/derive_key.c",
    "crypto/cipher/e_aes.c",
    "crypto/cipher/e_chacha20poly1305.c",
    "crypto/cipher/e_des.c",
    "crypto/cipher/e_null.c",
    "crypto/cipher/e_rc2.c",
    "crypto/cipher/e_rc4.c",
    "crypto/cipher/e_ssl3.c",
    "crypto/cipher/e_tls.c",
    "crypto/cipher/tls_cbc.c",
    "crypto/cmac/cmac.c",
    "crypto/conf/conf.c",
    "crypto/cpu-aarch64-linux.c",
    "crypto/cpu-arm-linux.c",
    "crypto/cpu-arm.c",
    "crypto/cpu-intel.c",
    "crypto/crypto.c",
    "crypto/curve25519/curve25519.c",
    "crypto/curve25519/spake25519.c",
    "crypto/curve25519/x25519-x86_64.c",
    "crypto/des/des.c",
    "crypto/dh/check.c",
    "crypto/dh/dh.c",
    "crypto/dh/dh_asn1.c",
    "crypto/dh/params.c",
    "crypto/digest/digest.c",
    "crypto/digest/digests.c",
    "crypto/dsa/dsa.c",
    "crypto/dsa/dsa_asn1.c",
    "crypto/ec/ec.c",
    "crypto/ec/ec_asn1.c",
    "crypto/ec/ec_key.c",
    "crypto/ec/ec_montgomery.c",
    "crypto/ec/oct.c",
    "crypto/ec/p224-64.c",
    "crypto/ec/p256-64.c",
    "crypto/ec/p256-x86_64.c",
    "crypto/ec/simple.c",
    "crypto/ec/util-64.c",
    "crypto/ec/wnaf.c",
    "crypto/ecdh/ecdh.c",
    "crypto/ecdsa/ecdsa.c",
    "crypto/ecdsa/ecdsa_asn1.c",
    "crypto/engine/engine.c",
    "crypto/err/err.c",
    "crypto/evp/digestsign.c",
    "crypto/evp/evp.c",
    "crypto/evp/evp_asn1.c",
    "crypto/evp/evp_ctx.c",
    "crypto/evp/p_dsa_asn1.c",
    "crypto/evp/p_ec.c",
    "crypto/evp/p_ec_asn1.c",
    "crypto/evp/p_rsa.c",
    "crypto/evp/p_rsa_asn1.c",
    "crypto/evp/pbkdf.c",
    "crypto/evp/print.c",
    "crypto/evp/sign.c",
    "crypto/ex_data.c",
    "crypto/hkdf/hkdf.c",
    "crypto/hmac/hmac.c",
    "crypto/lhash/lhash.c",
    "crypto/md4/md4.c",
    "crypto/md5/md5.c",
    "crypto/mem.c",
    "crypto/modes/cbc.c",
    "crypto/modes/cfb.c",
    "crypto/modes/ctr.c",
    "crypto/modes/gcm.c",
    "crypto/modes/ofb.c",
    "crypto/newhope/error_correction.c",
    "crypto/newhope/newhope.c",
    "crypto/newhope/ntt.c",
    "crypto/newhope/poly.c",
    "crypto/newhope/precomp.c",
    "crypto/newhope/reduce.c",
    "crypto/obj/obj.c",
    "crypto/obj/obj_xref.c",
    "crypto/pem/pem_all.c",
    "crypto/pem/pem_info.c",
    "crypto/pem/pem_lib.c",
    "crypto/pem/pem_oth.c",
    "crypto/pem/pem_pk8.c",
    "crypto/pem/pem_pkey.c",
    "crypto/pem/pem_x509.c",
    "crypto/pem/pem_xaux.c",
    "crypto/pkcs8/p5_pbe.c",
    "crypto/pkcs8/p5_pbev2.c",
    "crypto/pkcs8/p8_pkey.c",
    "crypto/pkcs8/pkcs8.c",
    "crypto/poly1305/poly1305.c",
    "crypto/poly1305/poly1305_arm.c",
    "crypto/poly1305/poly1305_vec.c",
    "crypto/rand/deterministic.c",
    "crypto/rand/rand.c",
    "crypto/rand/urandom.c",
    "crypto/rand/windows.c",
    "crypto/rc4/rc4.c",
    "crypto/refcount_c11.c",
    "crypto/refcount_lock.c",
    "crypto/rsa/blinding.c",
    "crypto/rsa/padding.c",
    "crypto/rsa/rsa.c",
    "crypto/rsa/rsa_asn1.c",
    "crypto/rsa/rsa_impl.c",
    "crypto/sha/sha1.c",
    "crypto/sha/sha256.c",
    "crypto/sha/sha512.c",
    "crypto/stack/stack.c",
    "crypto/thread.c",
    "crypto/thread_none.c",
    "crypto/thread_pthread.c",
    "crypto/thread_win.c",
    "crypto/time_support.c",
    "crypto/x509/a_digest.c",
    "crypto/x509/a_sign.c",
    "crypto/x509/a_strex.c",
    "crypto/x509/a_verify.c",
    "crypto/x509/algorithm.c",
    "crypto/x509/asn1_gen.c",
    "crypto/x509/by_dir.c",
    "crypto/x509/by_file.c",
    "crypto/x509/i2d_pr.c",
    "crypto/x509/pkcs7.c",
    "crypto/x509/rsa_pss.c",
    "crypto/x509/t_crl.c",
    "crypto/x509/t_req.c",
    "crypto/x509/t_x509.c",
    "crypto/x509/t_x509a.c",
    "crypto/x509/x509.c",
    "crypto/x509/x509_att.c",
    "crypto/x509/x509_cmp.c",
    "crypto/x509/x509_d2.c",
    "crypto/x509/x509_def.c",
    "crypto/x509/x509_ext.c",
    "crypto/x509/x509_lu.c",
    "crypto/x509/x509_obj.c",
    "crypto/x509/x509_r2x.c",
    "crypto/x509/x509_req.c",
    "crypto/x509/x509_set.c",
    "crypto/x509/x509_trs.c",
    "crypto/x509/x509_txt.c",
    "crypto/x509/x509_v3.c",
    "crypto/x509/x509_vfy.c",
    "crypto/x509/x509_vpm.c",
    "crypto/x509/x509cset.c",
    "crypto/x509/x509name.c",
    "crypto/x509/x509rset.c",
    "crypto/x509/x509spki.c",
    "crypto/x509/x509type.c",
    "crypto/x509/x_algor.c",
    "crypto/x509/x_all.c",
    "crypto/x509/x_attrib.c",
    "crypto/x509/x_crl.c",
    "crypto/x509/x_exten.c",
    "crypto/x509/x_info.c",
    "crypto/x509/x_name.c",
    "crypto/x509/x_pkey.c",
    "crypto/x509/x_pubkey.c",
    "crypto/x509/x_req.c",
    "crypto/x509/x_sig.c",
    "crypto/x509/x_spki.c",
    "crypto/x509/x_val.c",
    "crypto/x509/x_x509.c",
    "crypto/x509/x_x509a.c",
    "crypto/x509v3/pcy_cache.c",
    "crypto/x509v3/pcy_data.c",
    "crypto/x509v3/pcy_lib.c",
    "crypto/x509v3/pcy_map.c",
    "crypto/x509v3/pcy_node.c",
    "crypto/x509v3/pcy_tree.c",
    "crypto/x509v3/v3_akey.c",
    "crypto/x509v3/v3_akeya.c",
    "crypto/x509v3/v3_alt.c",
    "crypto/x509v3/v3_bcons.c",
    "crypto/x509v3/v3_bitst.c",
    "crypto/x509v3/v3_conf.c",
    "crypto/x509v3/v3_cpols.c",
    "crypto/x509v3/v3_crld.c",
    "crypto/x509v3/v3_enum.c",
    "crypto/x509v3/v3_extku.c",
    "crypto/x509v3/v3_genn.c",
    "crypto/x509v3/v3_ia5.c",
    "crypto/x509v3/v3_info.c",
    "crypto/x509v3/v3_int.c",
    "crypto/x509v3/v3_lib.c",
    "crypto/x509v3/v3_ncons.c",
    "crypto/x509v3/v3_pci.c",
    "crypto/x509v3/v3_pcia.c",
    "crypto/x509v3/v3_pcons.c",
    "crypto/x509v3/v3_pku.c",
    "crypto/x509v3/v3_pmaps.c",
    "crypto/x509v3/v3_prn.c",
    "crypto/x509v3/v3_purp.c",
    "crypto/x509v3/v3_skey.c",
    "crypto/x509v3/v3_sxnet.c",
    "crypto/x509v3/v3_utl.c",
]

# A trick to take the generated err_data.c from another package.
genrule(
    name = "err_data_c",
    srcs = ["//external:boringssl_err_data_c"],
    outs = ["err_data.c"],
    cmd = "cp $< $@",
)

cc_library(
    name = "crypto",
    srcs = crypto_internal_headers + crypto_sources,
    hdrs = crypto_headers,
    # To avoid linking platform-specific ASM files.
    defines = ["OPENSSL_NO_ASM"],
    includes = ["include"],
    visibility = ["//visibility:public"],
)

cc_library(
    name = "ssl",
    srcs = ssl_internal_headers + ssl_sources,
    hdrs = ssl_headers,
    includes = ["src/include"],
    visibility = ["//visibility:public"],
    deps = [
        ":crypto",
    ],
)
