chromium/components/web_package/BUILD.gn

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

import("//testing/libfuzzer/fuzzer_test.gni")

static_library("web_package") {
  sources = [
    "input_reader.cc",
    "input_reader.h",
    "signed_web_bundles/attribute_map_parser.cc",
    "signed_web_bundles/attribute_map_parser.h",
    "signed_web_bundles/constants.h",
    "signed_web_bundles/identity_validator.cc",
    "signed_web_bundles/identity_validator.h",
    "signed_web_bundles/integrity_block_parser.cc",
    "signed_web_bundles/integrity_block_parser.h",
    "signed_web_bundles/signature_entry_parser.cc",
    "signed_web_bundles/signature_entry_parser.h",
    "signed_web_bundles/signed_web_bundle_id.cc",
    "signed_web_bundles/signed_web_bundle_id.h",
    "signed_web_bundles/signed_web_bundle_integrity_block.cc",
    "signed_web_bundles/signed_web_bundle_integrity_block.h",
    "signed_web_bundles/signed_web_bundle_signature_stack.cc",
    "signed_web_bundles/signed_web_bundle_signature_stack.h",
    "signed_web_bundles/signed_web_bundle_signature_stack_entry.cc",
    "signed_web_bundles/signed_web_bundle_signature_stack_entry.h",
    "signed_web_bundles/signed_web_bundle_signature_verifier.cc",
    "signed_web_bundles/signed_web_bundle_signature_verifier.h",
    "signed_web_bundles/signed_web_bundle_utils.cc",
    "signed_web_bundles/signed_web_bundle_utils.h",
    "signed_web_bundles/types.h",
    "web_bundle_builder.cc",
    "web_bundle_builder.h",
    "web_bundle_parser.cc",
    "web_bundle_parser.h",
    "web_bundle_parser_factory.cc",
    "web_bundle_parser_factory.h",
    "web_bundle_utils.cc",
    "web_bundle_utils.h",
  ]

  deps = [
    "//base",
    "//components/base32",
    "//components/cbor",
    "//mojo/public/cpp/bindings",
    "//net",
    "//services/network/public/mojom",
  ]

  public_deps = [
    "//components/web_package:mojom_mapped_types",
    "//components/web_package/mojom",
  ]
}

source_set("mojom_mapped_types") {
  visibility = [ "./*" ]

  sources = [
    "signed_web_bundles/ecdsa_p256_public_key.cc",
    "signed_web_bundles/ecdsa_p256_public_key.h",
    "signed_web_bundles/ecdsa_p256_sha256_signature.cc",
    "signed_web_bundles/ecdsa_p256_sha256_signature.h",
    "signed_web_bundles/ecdsa_p256_utils.cc",
    "signed_web_bundles/ecdsa_p256_utils.h",
    "signed_web_bundles/ed25519_public_key.cc",
    "signed_web_bundles/ed25519_public_key.h",
    "signed_web_bundles/ed25519_signature.cc",
    "signed_web_bundles/ed25519_signature.h",
    "signed_web_bundles/integrity_block_attributes.cc",
    "signed_web_bundles/integrity_block_attributes.h",
  ]

  deps = [
    "//base",
    "//crypto",
    "//mojo/public/cpp/bindings",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "mojom/web_bundle_parser_mojom_traits_unittest.cc",
    "signed_web_bundles/ecdsa_p256_public_key_unittest.cc",
    "signed_web_bundles/ecdsa_p256_utils_unittest.cc",
    "signed_web_bundles/ed25519_public_key_unittest.cc",
    "signed_web_bundles/ed25519_signature_unittest.cc",
    "signed_web_bundles/signed_web_bundle_id_unittest.cc",
    "signed_web_bundles/signed_web_bundle_integrity_block_unittest.cc",
    "signed_web_bundles/signed_web_bundle_signature_stack_entry_unittest.cc",
    "signed_web_bundles/signed_web_bundle_signature_stack_unittest.cc",
    "signed_web_bundles/signed_web_bundle_signature_verifier_unittest.cc",
    "signed_web_bundles/signed_web_bundle_utils_unittest.cc",
    "web_bundle_builder_unittest.cc",
    "web_bundle_parser_factory_unittest.cc",
    "web_bundle_parser_unittest.cc",
    "web_bundle_utils_unittest.cc",
  ]
  deps = [
    ":web_package",
    "//base/test:test_support",
    "//components/cbor",
    "//components/web_package/test_support",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/test_support:test_utils",
    "//testing/gtest",
  ]

  if (is_ios) {
    deps += [ "//components/test:web_package_test_bundle_data" ]
  }
}

fuzzer_test("web_bundle_parser_fuzzer") {
  sources = [ "web_bundle_parser_fuzzer.cc" ]
  deps = [
    ":web_package",
    "//base",
    "//mojo/core/embedder",
  ]
  seed_corpus = "//components/test/data/web_package"
}