chromium/third_party/beto-core/BUILD.gn

# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_chromeos, "beto-core is used by Nearby Presence which is CrOS only")

import("//build/rust/rust_static_library.gni")
import("//build/rust/rust_unit_test.gni")
import("//build/rust/rust_unit_tests_group.gni")
import("//testing/test.gni")

# this target tests build of all targets in this file
group("all") {
  testonly = true
  deps = [
    ":crypto_provider_boringssl_unittests",
    ":handle_map_unittests",
    ":ldt_all_tests",
    ":ldt_c_sample",
    ":ldt_ffi_tests",
    ":lock_adapter_unittests",
    ":np_adv_examples_v0",
    ":np_adv_examples_v1",
    ":np_adv_unittests",
    ":np_cpp_tests",
    ":np_rust_sample",
  ]
}

test("np_cpp_tests") {
  sources = [
    "src/nearby/presence/np_cpp_ffi/shared/shared_test_util.cc",
    "src/nearby/presence/np_cpp_ffi/tests/byte_buffer_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/credential_book_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/credential_slab_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/deserialize_result_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/np_cpp_test.cc",
    "src/nearby/presence/np_cpp_ffi/tests/np_cpp_test.h",
    "src/nearby/presence/np_cpp_ffi/tests/v0_encrypted_deserialization_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/v0_encrypted_serialization_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/v0_unencrypted_deserialization_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/v0_unencrypted_serialization_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/v1_encrypted_deserialization_tests.cc",
    "src/nearby/presence/np_cpp_ffi/tests/v1_unencrypted_deserialization_tests.cc",
  ]
  include_dirs = [
    "src/nearby/presence/np_cpp_ffi/include",
    "src/nearby/presence/np_c_ffi/include/cpp",
    "src/nearby/presence/np_cpp_ffi/shared",
  ]
  deps = [
    ":np_cpp_ffi",
    "//base/test:run_all_unittests",
    "//testing/gtest",
  ]
}

executable("np_rust_sample") {
  sources = [ "src/nearby/presence/np_cpp_ffi/sample/main.cc" ]
  include_dirs = [
    "src/nearby/presence/np_cpp_ffi/include",
    "src/nearby/presence/np_c_ffi/include/cpp",
  ]
  deps = [ ":np_cpp_ffi" ]
}

test("ldt_ffi_tests") {
  sources = [ "src/nearby/presence/ldt_np_adv_ffi/c/tests/ldt_ffi_tests.cc" ]
  include_dirs = [ "src/nearby/presence/ldt_np_adv_ffi/c/include" ]
  defines = [ "LDT_TEST_VECTORS=\"third_party/beto-core/src/nearby/presence/ldt_np_adv/resources/test/np_adv_test_vectors.json\"" ]
  deps = [
    ":ldt_np_adv_ffi",
    "//base/test:run_all_unittests",
    "//testing/gtest",
    "//third_party/jsoncpp:jsoncpp",
  ]
}

source_set("np_cpp_ffi") {
  sources = [
    "src/nearby/presence/np_c_ffi/include/cpp/np_cpp_ffi_types.h",
    "src/nearby/presence/np_cpp_ffi/include/nearby_protocol.h",
    "src/nearby/presence/np_cpp_ffi/nearby_protocol.cc",
  ]
  public = [
    "src/nearby/presence/np_c_ffi/include/cpp/np_cpp_ffi_types.h",
    "src/nearby/presence/np_cpp_ffi/include/nearby_protocol.h",
  ]
  include_dirs = [
    "src/nearby/presence/np_c_ffi/include/cpp",
    "src/nearby/presence/np_cpp_ffi/include",
  ]
  public_deps = [ "//third_party/abseil-cpp:absl" ]
  deps = [ ":np_c_ffi" ]
}

rust_static_library("np_c_ffi") {
  crate_name = "np_c_ffi"
  crate_root = "src/nearby/presence/np_c_ffi/src/lib.rs"
  sources = [
    "src/nearby/presence/np_c_ffi/src/credentials.rs",
    "src/nearby/presence/np_c_ffi/src/deserialize/mod.rs",
    "src/nearby/presence/np_c_ffi/src/deserialize/v0.rs",
    "src/nearby/presence/np_c_ffi/src/deserialize/v1.rs",
    "src/nearby/presence/np_c_ffi/src/lib.rs",
    "src/nearby/presence/np_c_ffi/src/serialize/mod.rs",
    "src/nearby/presence/np_c_ffi/src/serialize/v0.rs",
    "src/nearby/presence/np_c_ffi/src/serialize/v1.rs",
    "src/nearby/presence/np_c_ffi/src/v0.rs",
    "src/nearby/presence/np_c_ffi/src/v1.rs",
  ]
  deps = [
    ":lock_adapter",
    ":np_ffi_core",
  ]
  features = [ "boringssl" ]
  allow_unsafe = true
}

rust_static_library("np_ffi_core") {
  crate_name = "np_ffi_core"
  crate_root = "src/nearby/presence/np_ffi_core/src/lib.rs"
  sources = [
    "src/nearby/presence/np_ffi_core/src/common.rs",
    "src/nearby/presence/np_ffi_core/src/credentials.rs",
    "src/nearby/presence/np_ffi_core/src/deserialize.rs",
    "src/nearby/presence/np_ffi_core/src/deserialize/v0.rs",
    "src/nearby/presence/np_ffi_core/src/deserialize/v1.rs",
    "src/nearby/presence/np_ffi_core/src/lib.rs",
    "src/nearby/presence/np_ffi_core/src/serialize.rs",
    "src/nearby/presence/np_ffi_core/src/serialize/v0.rs",
    "src/nearby/presence/np_ffi_core/src/serialize/v1.rs",
    "src/nearby/presence/np_ffi_core/src/utils.rs",
    "src/nearby/presence/np_ffi_core/src/v0.rs",
    "src/nearby/presence/np_ffi_core/src/v1.rs",
  ]
  deps = [
    ":array_view",
    ":crypto_provider",
    ":crypto_provider_default",
    ":handle_map",
    ":ldt_np_adv",
    ":lock_adapter",
    ":np_adv",
    ":np_adv_dynamic",
    ":np_hkdf",
    "//third_party/rust/lazy_static/v1:lib",
    "//third_party/rust/strum/v0_25:lib",
    "//third_party/rust/strum_macros/v0_25:lib",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  features = [ "boringssl" ]
}

rust_static_library("np_adv_dynamic") {
  crate_name = "np_adv_dynamic"
  crate_root = "src/nearby/presence/np_adv_dynamic/src/lib.rs"
  sources = [
    "src/nearby/presence/np_adv_dynamic/src/extended.rs",
    "src/nearby/presence/np_adv_dynamic/src/legacy.rs",
    "src/nearby/presence/np_adv_dynamic/src/lib.rs",
  ]
  deps = [
    ":array_view",
    ":crypto_provider",
    ":np_adv",
    ":sink",
  ]
}

rust_static_library("handle_map") {
  crate_name = "handle_map"
  build_native_rust_unit_tests = true
  crate_root = "src/common/handle_map/src/lib.rs"
  sources = [
    "src/common/handle_map/src/declare_handle_map.rs",
    "src/common/handle_map/src/guard.rs",
    "src/common/handle_map/src/lib.rs",
    "src/common/handle_map/src/shard.rs",
    "src/common/handle_map/src/tests.rs",
  ]
  deps = [ ":lock_adapter" ]
}

rust_static_library("lock_adapter") {
  crate_name = "lock_adapter"
  build_native_rust_unit_tests = true
  crate_root = "src/common/lock_adapter/src/lib.rs"
  sources = [
    "src/common/lock_adapter/src/lib.rs",
    "src/common/lock_adapter/src/spin.rs",
    "src/common/lock_adapter/src/stdlib.rs",
  ]
  features = [ "std" ]
}

rust_static_library("np_adv") {
  crate_name = "np_adv"
  build_native_rust_unit_tests = true
  crate_root = "src/nearby/presence/np_adv/src/lib.rs"
  sources = [
    "src/nearby/presence/np_adv/benches/deser_adv.rs",
    "src/nearby/presence/np_adv/src/array_vec.rs",
    "src/nearby/presence/np_adv/src/credential/book.rs",
    "src/nearby/presence/np_adv/src/credential/matched.rs",
    "src/nearby/presence/np_adv/src/credential/metadata/mod.rs",
    "src/nearby/presence/np_adv/src/credential/metadata/tests.rs",
    "src/nearby/presence/np_adv/src/credential/mod.rs",
    "src/nearby/presence/np_adv/src/credential/source.rs",
    "src/nearby/presence/np_adv/src/credential/tests.rs",
    "src/nearby/presence/np_adv/src/credential/v0.rs",
    "src/nearby/presence/np_adv/src/credential/v1.rs",
    "src/nearby/presence/np_adv/src/deserialization_arena.rs",
    "src/nearby/presence/np_adv/src/extended/data_elements/mod.rs",
    "src/nearby/presence/np_adv/src/extended/data_elements/tests.rs",
    "src/nearby/presence/np_adv/src/extended/de_type.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/data_element/mod.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/data_element/tests.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/dev_tools.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/encrypted_section/mod.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/encrypted_section/tests.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/encrypted_section/tests/coverage_gaming.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/encrypted_section/tests/mic_decrypt_tests.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/encrypted_section/tests/signature_decrypt_tests.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/mod.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/section/header/mod.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/section/header/tests.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/section/intermediate/mod.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/section/intermediate/tests.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/section/mod.rs",
    "src/nearby/presence/np_adv/src/extended/deserialize/tests.rs",
    "src/nearby/presence/np_adv/src/extended/mod.rs",
    "src/nearby/presence/np_adv/src/extended/salt.rs",
    "src/nearby/presence/np_adv/src/extended/section_signature_payload.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/adv_tests.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/de_header_tests.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/mod.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/section/encoder.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/section/header.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/section/mod.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/section_tests.rs",
    "src/nearby/presence/np_adv/src/extended/serialize/test_vectors.rs",
    "src/nearby/presence/np_adv/src/filter/mod.rs",
    "src/nearby/presence/np_adv/src/filter/tests/actions_filter_tests.rs",
    "src/nearby/presence/np_adv/src/filter/tests/data_elements_filter_tests.rs",
    "src/nearby/presence/np_adv/src/filter/tests/mod.rs",
    "src/nearby/presence/np_adv/src/filter/tests/v0_filter_tests.rs",
    "src/nearby/presence/np_adv/src/header.rs",
    "src/nearby/presence/np_adv/src/helpers.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/actions/macros.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/actions/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/actions/tests.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/de_type/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/de_type/tests.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/tests.rs",
    "src/nearby/presence/np_adv/src/legacy/data_elements/tx_power.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/intermediate/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/intermediate/tests/error_conditions.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/intermediate/tests/happy_path.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/intermediate/tests/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/tests/error_conditions.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/tests/happy_path.rs",
    "src/nearby/presence/np_adv/src/legacy/deserialize/tests/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/random_data_elements.rs",
    "src/nearby/presence/np_adv/src/legacy/serialize/header.rs",
    "src/nearby/presence/np_adv/src/legacy/serialize/mod.rs",
    "src/nearby/presence/np_adv/src/legacy/serialize/tests/error_conditions.rs",
    "src/nearby/presence/np_adv/src/legacy/serialize/tests/happy_path.rs",
    "src/nearby/presence/np_adv/src/legacy/serialize/tests/helpers.rs",
    "src/nearby/presence/np_adv/src/legacy/serialize/tests/mod.rs",
    "src/nearby/presence/np_adv/src/lib.rs",
    "src/nearby/presence/np_adv/src/shared_data.rs",
    "src/nearby/presence/np_adv/src/tests.rs",
    "src/nearby/presence/np_adv/src/tests/deser_v0_tests.rs",
    "src/nearby/presence/np_adv/src/tests/deser_v1_tests.rs",
    "src/nearby/presence/np_adv/src/tests/deser_v1_tests/error_condition.rs",
    "src/nearby/presence/np_adv/src/tests/deser_v1_tests/happy_path.rs",
    "src/nearby/presence/np_adv/tests/examples_v0.rs",
    "src/nearby/presence/np_adv/tests/examples_v1.rs",
  ]
  deps = [
    ":array_view",
    ":crypto_provider",
    ":ldt",
    ":ldt_np_adv",
    ":np_ed25519",
    ":np_hkdf",
    ":sink",
    ":test_vector_hkdf",
    ":xts_aes",
    "//third_party/rust/lazy_static/v1:lib",
    "//third_party/rust/nom/v7:lib",
    "//third_party/rust/strum/v0_25:lib",
    "//third_party/rust/strum_macros/v0_25:lib",
    "//third_party/rust/tinyvec/v1:lib",
  ]
  test_deps = [
    ":crypto_provider_default",
    ":rand_ext",
    ":test_helper",
    "//third_party/rust/anyhow/v1:lib",
    "//third_party/rust/hex/v0_4:lib",
    "//third_party/rust/rand/v0_8:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
  features = [ "alloc" ]

  # TODO(https://crbug.com/357101056): fix and remove
  rustflags = [ "-Adead-code" ]
}

rust_unit_test("np_adv_examples_v0") {
  crate_root = "src/nearby/presence/np_adv/tests/examples_v0.rs"
  sources = [ "src/nearby/presence/np_adv/tests/examples_v0.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt_np_adv",
    ":np_adv",
    ":np_hkdf",
    "//third_party/rust/serde/v1:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
}

rust_unit_test("np_adv_examples_v1") {
  crate_root = "src/nearby/presence/np_adv/tests/examples_v1.rs"
  sources = [ "src/nearby/presence/np_adv/tests/examples_v1.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt_np_adv",
    ":np_adv",
    ":np_ed25519",
    ":np_hkdf",
    "//third_party/rust/serde/v1:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
}

rust_static_library("np_ed25519") {
  crate_name = "np_ed25519"
  crate_root = "src/nearby/presence/np_ed25519/src/lib.rs"
  sources = [ "src/nearby/presence/np_ed25519/src/lib.rs" ]
  deps = [
    ":array_view",
    ":crypto_provider",
    ":sink",
    "//third_party/rust/tinyvec/v1:lib",
  ]
  features = [ "std" ]
}

rust_static_library("sink") {
  crate_name = "sink"
  crate_root = "src/nearby/presence/sink/src/lib.rs"
  sources = [ "src/nearby/presence/sink/src/lib.rs" ]
  deps = [ "//third_party/rust/tinyvec/v1:lib" ]
  features = [ "std" ]
}

executable("ldt_c_sample") {
  sources = [ "src/nearby/presence/ldt_np_adv_ffi/c/sample/main.c" ]
  include_dirs = [ "src/nearby/presence/ldt_np_adv_ffi/c/include" ]
  deps = [ ":ldt_np_adv_ffi" ]
}

rust_static_library("ldt_np_adv_ffi") {
  crate_name = "ldt_np_adv_ffi"
  crate_root = "src/nearby/presence/ldt_np_adv_ffi/src/lib.rs"
  sources = [
    "src/nearby/presence/ldt_np_adv_ffi/src/handle_map.rs",
    "src/nearby/presence/ldt_np_adv_ffi/src/lib.rs",
  ]
  allow_unsafe = true
  features = [ "boringssl" ]
  public = [ "src/nearby/presence/ldt_np_adv_ffi/c/include/np_ldt.h" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt",
    ":ldt_np_adv",
    ":np_hkdf",
    "//third_party/rust/cfg_if/v1:lib",
    "//third_party/rust/lazy_static/v1:lib",
  ]
}

rust_static_library("crypto_provider_boringssl") {
  crate_name = "crypto_provider_boringssl"
  build_native_rust_unit_tests = true
  crate_root = "src/nearby/crypto/crypto_provider_boringssl/src/lib.rs"
  sources = [
    "src/nearby/crypto/crypto_provider_boringssl/src/aead/aes_gcm.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/aead/aes_gcm_siv.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/aead/mod.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/aes/cbc.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/aes/ctr.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/aes/mod.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/ed25519.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/hkdf.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/hmac.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/lib.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/p256.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/sha2.rs",
    "src/nearby/crypto/crypto_provider_boringssl/src/x25519.rs",
  ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_stubs",
    "//third_party/boringssl:bssl_crypto",
  ]
  test_deps = [ ":crypto_provider_test" ]
}

rust_static_library("crypto_provider") {
  crate_name = "crypto_provider"
  crate_root = "src/nearby/crypto/crypto_provider/src/lib.rs"
  sources = [
    "src/nearby/crypto/crypto_provider/src/aead.rs",
    "src/nearby/crypto/crypto_provider/src/aes/cbc.rs",
    "src/nearby/crypto/crypto_provider/src/aes/ctr.rs",
    "src/nearby/crypto/crypto_provider/src/aes/mod.rs",
    "src/nearby/crypto/crypto_provider/src/ed25519.rs",
    "src/nearby/crypto/crypto_provider/src/elliptic_curve.rs",
    "src/nearby/crypto/crypto_provider/src/hkdf.rs",
    "src/nearby/crypto/crypto_provider/src/hmac.rs",
    "src/nearby/crypto/crypto_provider/src/lib.rs",
    "src/nearby/crypto/crypto_provider/src/p256.rs",
    "src/nearby/crypto/crypto_provider/src/sha2.rs",
    "src/nearby/crypto/crypto_provider/src/x25519.rs",
  ]
  features = [
    "alloc",
    "std",
    "raw_private_key_permit",
    "test_vectors",
  ]
  deps = [ "//third_party/rust/tinyvec/v1:lib" ]
}

rust_static_library("crypto_provider_test") {
  crate_name = "crypto_provider_test"
  testonly = true
  crate_root = "src/nearby/crypto/crypto_provider_test/src/lib.rs"
  sources = [
    "src/nearby/crypto/crypto_provider_test/src/aead/aes_gcm.rs",
    "src/nearby/crypto/crypto_provider_test/src/aead/aes_gcm_siv.rs",
    "src/nearby/crypto/crypto_provider_test/src/aead/mod.rs",
    "src/nearby/crypto/crypto_provider_test/src/aes/cbc.rs",
    "src/nearby/crypto/crypto_provider_test/src/aes/ctr.rs",
    "src/nearby/crypto/crypto_provider_test/src/aes/mod.rs",
    "src/nearby/crypto/crypto_provider_test/src/ed25519.rs",
    "src/nearby/crypto/crypto_provider_test/src/ed25519.rs",
    "src/nearby/crypto/crypto_provider_test/src/ed25519.rs",
    "src/nearby/crypto/crypto_provider_test/src/elliptic_curve.rs",
    "src/nearby/crypto/crypto_provider_test/src/hkdf.rs",
    "src/nearby/crypto/crypto_provider_test/src/hmac.rs",
    "src/nearby/crypto/crypto_provider_test/src/lib.rs",
    "src/nearby/crypto/crypto_provider_test/src/p256.rs",
    "src/nearby/crypto/crypto_provider_test/src/sha2.rs",
    "src/nearby/crypto/crypto_provider_test/src/x25519.rs",
  ]
  deps = [
    ":crypto_provider",
    ":rand_ext",
    ":test_helper",
    "//third_party/rust/hex/v0_4:lib",
    "//third_party/rust/hex_literal/v0_4:lib",
    "//third_party/rust/rand/v0_8:lib",
    "//third_party/rust/rstest/v0_17:lib",
    "//third_party/rust/rstest_reuse/v0_5:lib",
    "//third_party/rust/wycheproof/v0_4:lib",
  ]
  inputs = [
    "src/nearby/crypto/crypto_provider_test/src/testdata/SHA256LongMsg.rsp",
    "src/nearby/crypto/crypto_provider_test/src/testdata/SHA256ShortMsg.rsp",
    "src/nearby/crypto/crypto_provider_test/src/testdata/SHA512LongMsg.rsp",
    "src/nearby/crypto/crypto_provider_test/src/testdata/SHA512ShortMsg.rsp",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

rust_static_library("crypto_provider_stubs") {
  crate_name = "crypto_provider_stubs"
  crate_root = "src/nearby/crypto/crypto_provider_stubs/src/lib.rs"
  sources = [ "src/nearby/crypto/crypto_provider_stubs/src/lib.rs" ]
  deps = [ ":crypto_provider" ]
}

rust_static_library("crypto_provider_default") {
  crate_name = "crypto_provider_default"
  crate_root = "src/nearby/crypto/crypto_provider_default/src/lib.rs"
  sources = [ "src/nearby/crypto/crypto_provider_default/src/lib.rs" ]
  edition = "2021"
  deps = [
    ":crypto_provider",
    ":crypto_provider_boringssl",
    "//third_party/rust/cfg_if/v1:lib",
  ]
  features = [ "boringssl" ]
}

rust_static_library("ldt_np_adv") {
  crate_name = "ldt_np_adv"
  build_native_rust_unit_tests = true
  crate_root = "src/nearby/presence/ldt_np_adv/src/lib.rs"
  sources = [
    "src/nearby/presence/ldt_np_adv/src/lib.rs",
    "src/nearby/presence/ldt_np_adv/src/np_adv_test_vectors.rs",
    "src/nearby/presence/ldt_np_adv/src/tests.rs",
  ]
  deps = [
    ":array_view",
    ":crypto_provider",
    ":ldt",
    ":ldt_tbc",
    ":np_hkdf",
    ":xts_aes",
  ]
  test_deps = [
    ":crypto_provider_default",
    ":rand_ext",
    ":test_helper",
    ":test_vector_hkdf",
    "//third_party/rust/anyhow/v1:lib",
    "//third_party/rust/hex/v0_4:lib",
    "//third_party/rust/rand/v0_8:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
}

rust_static_library("ldt") {
  crate_name = "ldt"
  crate_root = "src/nearby/presence/ldt/src/lib.rs"
  sources = [ "src/nearby/presence/ldt/src/lib.rs" ]
  deps = [
    ":crypto_provider",
    ":ldt_tbc",
  ]
}

rust_unit_tests_group("ldt_all_tests") {
  deps = [
    ":array_view_unittests",
    ":ldt_np_adv_unittests",
    ":ldt_roundtrip_tests",
    ":ldt_test_vectors",
    ":ldt_tests",
    ":np_hkdf_tests",
    ":xts_aes_unittests",
    ":xts_nist_test_vectors",
    ":xts_roundtrip_tests",
  ]
}

rust_unit_test("ldt_tests") {
  crate_root = "src/nearby/presence/ldt/tests/tests.rs"
  sources = [ "src/nearby/presence/ldt/tests/tests.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt",
    ":xts_aes",
  ]
}

rust_unit_test("ldt_roundtrip_tests") {
  crate_root = "src/nearby/presence/ldt/tests/ldt_roundtrip.rs"
  sources = [ "src/nearby/presence/ldt/tests/ldt_roundtrip.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt",
    ":ldt_tbc",
    ":rand_ext",
    ":xts_aes",
    "//third_party/rust/rand/v0_8:lib",
  ]
}

rust_unit_test("ldt_test_vectors") {
  crate_root = "src/nearby/presence/ldt/tests/ldt_test_vectors.rs"
  sources = [ "src/nearby/presence/ldt/tests/ldt_test_vectors.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt",
    ":ldt_tbc",
    ":test_helper",
    ":xts_aes",
    "//third_party/rust/anyhow/v1:lib",
    "//third_party/rust/rand/v0_8:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
}

rust_static_library("ldt_tbc") {
  crate_name = "ldt_tbc"
  crate_root = "src/nearby/presence/ldt_tbc/src/lib.rs"
  sources = [ "src/nearby/presence/ldt_tbc/src/lib.rs" ]
  deps = [ ":crypto_provider" ]
}

rust_static_library("array_view") {
  build_native_rust_unit_tests = true
  crate_name = "array_view"
  crate_root = "src/nearby/presence/array_view/src/lib.rs"
  sources = [ "src/nearby/presence/array_view/src/lib.rs" ]
}

rust_static_library("array_ref") {
  crate_name = "array_ref"
  crate_root = "src/nearby/presence/array_ref/src/lib.rs"
  sources = [ "src/nearby/presence/array_ref/src/lib.rs" ]
}

rust_static_library("np_hkdf") {
  crate_name = "np_hkdf"
  crate_root = "src/nearby/presence/np_hkdf/src/lib.rs"
  sources = [
    "src/nearby/presence/np_hkdf/src/lib.rs",
    "src/nearby/presence/np_hkdf/src/v1_salt.rs",
  ]
  deps = [
    ":crypto_provider",
    ":ldt",
    ":xts_aes",
  ]
}

rust_unit_test("np_hkdf_tests") {
  crate_root = "src/nearby/presence/np_hkdf/tests/test_vectors.rs"
  sources = [ "src/nearby/presence/np_hkdf/tests/test_vectors.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":np_hkdf",
    ":rand_ext",
    ":test_helper",
    ":test_vector_hkdf",
    "//third_party/rust/anyhow/v1:lib",
    "//third_party/rust/hex/v0_4:lib",
    "//third_party/rust/rand/v0_8:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
}

rust_static_library("xts_aes") {
  build_native_rust_unit_tests = true
  crate_name = "xts_aes"
  crate_root = "src/nearby/presence/xts_aes/src/lib.rs"
  sources = [
    "src/nearby/presence/xts_aes/src/lib.rs",
    "src/nearby/presence/xts_aes/src/tweak_tests.rs",
  ]
  deps = [
    ":array_ref",
    ":crypto_provider",
    ":ldt_tbc",
  ]
  test_deps = [
    ":test_helper",
    "//third_party/rust/hex/v0_4:lib",
  ]
}

rust_static_library("test_vector_hkdf") {
  crate_name = "test_vector_hkdf"
  crate_root = "src/nearby/presence/test_vector_hkdf/src/lib.rs"
  sources = [ "src/nearby/presence/test_vector_hkdf/src/lib.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
  ]
}

rust_unit_test("xts_roundtrip_tests") {
  crate_root = "src/nearby/presence/xts_aes/tests/xts_roundtrip_tests.rs"
  sources = [ "src/nearby/presence/xts_aes/tests/xts_roundtrip_tests.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt_tbc",
    ":rand_ext",
    ":xts_aes",
    "//third_party/rust/rand/v0_8:lib",
  ]
}

rust_unit_test("xts_nist_test_vectors") {
  crate_root = "src/nearby/presence/xts_aes/tests/xts_nist_test_vectors.rs"
  sources = [ "src/nearby/presence/xts_aes/tests/xts_nist_test_vectors.rs" ]
  deps = [
    ":crypto_provider",
    ":crypto_provider_default",
    ":ldt_tbc",
    ":test_helper",
    ":xts_aes",
    "//third_party/rust/anyhow/v1:lib",
    "//third_party/rust/hex/v0_4:lib",
    "//third_party/rust/regex/v1:lib",
  ]
}

rust_static_library("test_helper") {
  crate_name = "test_helper"
  testonly = true
  crate_root = "src/nearby/presence/test_helper/src/lib.rs"
  sources = [ "src/nearby/presence/test_helper/src/lib.rs" ]
  edition = "2021"
  rustenv = [ "WORKSPACE_DIR=" + rebase_path("src/nearby/") ]
  deps = [
    "//third_party/rust/hex/v0_4:lib",
    "//third_party/rust/itertools/v0_11:lib",
    "//third_party/rust/serde_json/v1:lib",
  ]
}

rust_static_library("rand_ext") {
  crate_name = "rand_ext"
  testonly = true
  crate_root = "src/nearby/presence/rand_ext/src/lib.rs"
  sources = [ "src/nearby/presence/rand_ext/src/lib.rs" ]
  edition = "2021"
  deps = [
    ":crypto_provider",
    "//third_party/rust/log/v0_4:lib",
    "//third_party/rust/rand/v0_8:lib",
    "//third_party/rust/rand_pcg/v0_3:lib",
  ]
}