| # Copyright 2018 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//common-mk/generate-dbus-adaptors.gni") |
| import("//common-mk/generate-dbus-proxies.gni") |
| import("//common-mk/pkg_config.gni") |
| import("//common-mk/proto_library.gni") |
| |
| group("all") { |
| deps = [ |
| ":install_freezer_tmpfilesd", |
| ":install_tmpfiles_config", |
| ":install_trunksd_conf", |
| ":libtrunks", |
| ":pinweaver_client", |
| ":trunks", |
| ":trunks_client", |
| ":trunks_send", |
| ":trunks_test", |
| ":trunksd", |
| ] |
| |
| # TODO(b/265866896): provider better abstraction by adding trunks-pre-init |
| # event instead |
| # TODO(b/267399953): remove use.generic_tpm2 once keeby-cq is removed. |
| if (!use.cr50_onboard && !use.ti50_onboard && !use.generic_tpm2) { |
| deps += [ ":install_pre_init_config" ] |
| } |
| if (use.test) { |
| deps += [ ":trunks_testrunner" ] |
| } |
| if (use.fuzzer) { |
| deps += [ |
| ":trunks_creation_blob_fuzzer", |
| ":trunks_hmac_authorization_delegate_fuzzer", |
| ":trunks_key_blob_fuzzer", |
| ":trunks_password_authorization_delegate_fuzzer", |
| ":trunks_resource_manager_fuzzer", |
| ":trunks_tpm_pinweaver_fuzzer", |
| ] |
| } |
| } |
| |
| pkg_config("target_default_pkg_deps") { |
| pkg_deps = [ |
| "libbrillo", |
| "libchrome", |
| "libmetrics", |
| "openssl", |
| ] |
| if (use.fuzzer) { |
| pkg_deps += [ "protobuf" ] |
| } else { |
| pkg_deps += [ "protobuf-lite" ] |
| } |
| } |
| |
| config("target_defaults") { |
| configs = [ ":target_default_pkg_deps" ] |
| defines = [ "USE_GENERIC_TPM2=${use.generic_tpm2}" ] |
| libs = [ "hwsec-foundation" ] |
| } |
| |
| proto_library("interface_proto") { |
| proto_in_dir = "." |
| proto_out_dir = "include/trunks" |
| sources = [ "${proto_in_dir}/trunks_interface.proto" ] |
| |
| # Use -fPIC so this code can be linked into a shared library. |
| use_pic = true |
| standalone = true |
| } |
| |
| proto_library("pinweaver_proto") { |
| proto_in_dir = "." |
| proto_out_dir = "include/trunks" |
| sources = [ "${proto_in_dir}/pinweaver.proto" ] |
| |
| # Use -fPIC so this code can be linked into a shared library. |
| use_pic = true |
| standalone = true |
| } |
| |
| shared_library("trunks") { |
| sources = [ |
| "background_command_transceiver.cc", |
| "blob_parser.cc", |
| "command_codes.cc", |
| "error_codes.cc", |
| "hmac_authorization_delegate.cc", |
| "hmac_session_impl.cc", |
| "multiple_authorization_delegate.cc", |
| "openssl_utility.cc", |
| "password_authorization_delegate.cc", |
| "policy_session_impl.cc", |
| "real_command_parser.cc", |
| "real_response_serializer.cc", |
| "scoped_key_handle.cc", |
| "session_manager_impl.cc", |
| "tpm_cache_impl.cc", |
| "tpm_extended.cc", |
| "tpm_generated.cc", |
| "tpm_pinweaver.cc", |
| "tpm_state_impl.cc", |
| "tpm_structure_parser.cc", |
| "tpm_u2f.cc", |
| "tpm_utility_impl.cc", |
| "trunks_dbus_proxy.cc", |
| "trunks_factory_impl.cc", |
| "vtpm_client_support/create_dbus_proxy.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| if (use.ftdi_tpm) { |
| sources += [ |
| "ftdi/mpsse.c", |
| "ftdi/support.c", |
| "trunks_ftdi_spi.cc", |
| ] |
| libs += [ "ftdi1" ] |
| defines += [ "SPI_OVER_FTDI=1" ] |
| } |
| pkg_deps = [ "absl" ] |
| deps = [ |
| ":interface_proto", |
| ":pinweaver_proto", |
| ":trunks_proxies", |
| ] |
| } |
| |
| executable("pinweaver_client") { |
| sources = [ "pinweaver_client.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":trunks" ] |
| } |
| |
| executable("trunks_client") { |
| sources = [ |
| "trunks_client.cc", |
| "trunks_client_test.cc", |
| ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":trunks" ] |
| } |
| |
| executable("trunks_send") { |
| sources = [ "trunks_send.cc" ] |
| configs += [ ":target_defaults" ] |
| deps = [ ":trunks" ] |
| } |
| |
| pkg_config("trunksd_lib_config") { |
| pkg_deps = [ "libpower_manager-client" ] |
| } |
| |
| config("trunksd_lib_all_dependent_configs") { |
| libs = [ "system_api-power_manager-protos" ] |
| } |
| |
| pkg_config("trunksd_lib_all_dependent_pkg_deps") { |
| pkg_deps = [ "libpower_manager-client" ] |
| } |
| |
| static_library("trunksd_lib") { |
| sources = [ |
| "power_manager.cc", |
| "resilience/write_error_tracker_impl.cc", |
| "resource_manager.cc", |
| "tpm_handle.cc", |
| "trunks_dbus_service.cc", |
| "trunks_metrics.cc", |
| ] |
| all_dependent_configs = [ |
| ":trunksd_lib_all_dependent_configs", |
| ":trunksd_lib_all_dependent_pkg_deps", |
| ] |
| configs += [ |
| ":target_defaults", |
| ":trunksd_lib_all_dependent_pkg_deps", |
| ":trunksd_lib_config", |
| ] |
| configs -= [ "//common-mk:use_thin_archive" ] |
| configs += [ "//common-mk:nouse_thin_archive" ] |
| deps = [ ":trunks" ] |
| } |
| |
| pkg_config("trunksd_pkg_deps") { |
| pkg_deps = [ "libminijail" ] |
| } |
| |
| executable("trunksd") { |
| sources = [ "trunksd.cc" ] |
| libs = [ "hwsec-profiling" ] |
| configs += [ |
| ":target_defaults", |
| ":trunksd_pkg_deps", |
| ] |
| if (use.ftdi_tpm) { |
| defines = [ "SPI_OVER_FTDI=1" ] |
| } |
| deps = [ |
| ":trunks", |
| ":trunks_adaptors", |
| ":trunksd_lib", |
| ] |
| } |
| |
| static_library("trunks_test") { |
| sources = [ |
| "fuzzed_command_transceiver.cc", |
| "mock_authorization_delegate.cc", |
| "mock_blob_parser.cc", |
| "mock_command_transceiver.cc", |
| "mock_hmac_session.cc", |
| "mock_policy_session.cc", |
| "mock_session_manager.cc", |
| "mock_tpm.cc", |
| "mock_tpm_cache.cc", |
| "mock_tpm_state.cc", |
| "mock_tpm_utility.cc", |
| "tpm_simulator_handle.cc", |
| "trunks_factory_for_test.cc", |
| ] |
| libs = [ "tpm2" ] |
| configs -= [ "//common-mk:use_thin_archive" ] |
| configs += [ |
| "//common-mk:nouse_thin_archive", |
| ":target_defaults", |
| ] |
| deps = [ ":trunks" ] |
| } |
| |
| if (use.test) { |
| pkg_config("trunks_testrunner_pkg_deps") { |
| pkg_deps = [ |
| "libchrome-test", |
| "libpower_manager-client-test", |
| ] |
| } |
| executable("trunks_testrunner") { |
| sources = [ |
| "background_command_transceiver_test.cc", |
| "hmac_authorization_delegate_test.cc", |
| "hmac_session_test.cc", |
| "multiple_authorization_delegate_test.cc", |
| "openssl_utility_test.cc", |
| "password_authorization_delegate_test.cc", |
| "policy_session_test.cc", |
| "power_manager_test.cc", |
| "real_command_parser_test.cc", |
| "real_response_serializer_test.cc", |
| "resource_manager_test.cc", |
| "scoped_global_session_test.cc", |
| "scoped_key_handle_test.cc", |
| "session_manager_test.cc", |
| "tpm_cache_test.cc", |
| "tpm_generated_test.cc", |
| "tpm_state_test.cc", |
| "tpm_structure_parser_test.cc", |
| "tpm_u2f_test.cc", |
| "tpm_utility_test.cc", |
| "trunks_dbus_proxy_test.cc", |
| "trunks_factory_test.cc", |
| "trunks_testrunner.cc", |
| ] |
| configs += [ |
| "//common-mk:test", |
| ":target_defaults", |
| ":trunks_testrunner_pkg_deps", |
| ] |
| deps = [ |
| ":trunks", |
| ":trunks_test", |
| ":trunksd_lib", |
| ] |
| } |
| } |
| |
| if (use.fuzzer) { |
| executable("trunks_key_blob_fuzzer") { |
| sources = [ "key_blob_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer:common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ ":trunks" ] |
| } |
| |
| executable("trunks_creation_blob_fuzzer") { |
| sources = [ "creation_blob_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer:common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ ":trunks" ] |
| } |
| |
| executable("trunks_hmac_authorization_delegate_fuzzer") { |
| sources = [ "hmac_authorization_delegate_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer:common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ ":trunks" ] |
| } |
| |
| pkg_config("trunks_resource_manager_fuzzer_pkg_deps") { |
| pkg_deps = [ "libchrome-test" ] # For FuzzedDataProvider |
| } |
| |
| executable("trunks_resource_manager_fuzzer") { |
| sources = [ "resource_manager_fuzzer.cc" ] |
| configs += [ |
| "//common-mk:test", |
| "//common-mk/common_fuzzer:common_fuzzer", |
| ":target_defaults", |
| ":trunks_resource_manager_fuzzer_pkg_deps", |
| ] |
| deps = [ |
| ":trunks", |
| ":trunks_test", |
| ":trunksd_lib", |
| ] |
| } |
| |
| executable("trunks_password_authorization_delegate_fuzzer") { |
| sources = [ "password_authorization_delegate_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer:common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ ":trunks" ] |
| } |
| |
| executable("trunks_tpm_pinweaver_fuzzer") { |
| sources = [ "tpm_pinweaver_fuzzer.cc" ] |
| configs += [ |
| "//common-mk/common_fuzzer:common_fuzzer", |
| ":target_defaults", |
| ] |
| deps = [ ":trunks" ] |
| } |
| } |
| |
| install_config("install_trunksd_conf") { |
| sources = [ "trunksd.conf" ] |
| install_path = "upstart" |
| } |
| |
| # We invoke systemd-tmpfiles explicitly from the upstart config |
| # since it needs to run when /sys/fs/cgroup is available. |
| install_config("install_freezer_tmpfilesd") { |
| sources = [ "tmpfiles.d/trunks_freezer.conf" ] |
| install_path = "tmpfiled_ondemand" |
| } |
| |
| # TODO(b/265866896): provider better abstraction by adding trunks-pre-init event |
| # instead. |
| install_config("install_pre_init_config") { |
| sources = [ "placeholders/cr50-result.conf" ] |
| install_path = "upstart" |
| } |
| |
| install_config("install_tmpfiles_config") { |
| sources = [ "tmpfiles.d/trunks.conf" ] |
| install_path = "tmpfilesd" |
| } |
| |
| generate_dbus_adaptors("trunks_adaptors") { |
| sources = [ "dbus_bindings/org.chromium.Trunks.xml" ] |
| dbus_adaptors_out_dir = "include/trunks/dbus_adaptors" |
| dbus_service_config = "dbus_bindings/dbus-service-config.json" |
| } |
| |
| generate_dbus_proxies("trunks_proxies") { |
| sources = [ "./dbus_bindings/org.chromium.Trunks.xml" ] |
| proxy_output_file = "include/trunks/dbus_proxies.h" |
| } |
| |
| generate_pkg_config("libtrunks") { |
| version = getenv("PV") |
| description = "Trunks shared library" |
| cflags = [ "-I/usr/include/trunks" ] |
| libs = [ "-ltrunks" ] |
| } |