platform_system_security/keystore2/Android.bp
Max Bires 48fc2e5a43 Replacing manual CBOR with serde-cbor
This change strips out all of the manually written CBOR parsing and
serialization code in favor of using the serde-cbor library in order to
make the code more robust and the error messages more actionable.

Fixes: 180392379
Test: atest RemoteProvisionerUnitTests
Change-Id: I1b08b26b6192763e393b061cd9b919cfd71c13c9
2021-11-22 10:46:14 -08:00

204 lines
5.6 KiB
Text

// Copyright 2020, The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "system_security_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["system_security_license"],
}
rust_defaults {
name: "libkeystore2_defaults",
crate_name: "keystore2",
srcs: ["src/lib.rs"],
rustlibs: [
"android.hardware.security.keymint-V1-rust",
"android.hardware.security.secureclock-V1-rust",
"android.hardware.security.sharedsecret-V1-rust",
"android.os.permissions_aidl-rust",
"android.security.apc-rust",
"android.security.authorization-rust",
"android.security.compat-rust",
"android.security.maintenance-rust",
"android.security.metrics-rust",
"android.security.remoteprovisioning-rust",
"android.system.keystore2-V1-rust",
"libanyhow",
"libbinder_rs",
"libkeystore2_aaid-rust",
"libkeystore2_apc_compat-rust",
"libkeystore2_crypto_rust",
"libkeystore2_km_compat",
"libkeystore2_selinux",
"libkeystore2_vintf_rust",
"liblazy_static",
"liblibc",
"liblog_event_list",
"liblog_rust",
"librand",
"librustutils",
"libserde",
"libserde_cbor",
"libthiserror",
],
shared_libs: [
"libcutils",
],
features: [
"watchdog",
],
}
rust_library {
name: "libkeystore2",
defaults: ["libkeystore2_defaults"],
rustlibs: [
"liblibsqlite3_sys",
"librusqlite",
],
}
rust_library {
name: "libkeystore2_noicu",
defaults: ["libkeystore2_defaults"],
rustlibs: [
"liblibsqlite3_sys_noicu",
"librusqlite_noicu",
],
}
rust_library {
name: "libkeystore2_test_utils",
crate_name: "keystore2_test_utils",
srcs: ["test_utils/lib.rs"],
rustlibs: [
"libkeystore2_selinux",
"liblog_rust",
"libnix",
"librand",
"libserde",
"libserde_cbor",
],
}
rust_test {
name: "keystore2_test_utils_test",
srcs: ["test_utils/lib.rs"],
test_suites: ["general-tests"],
require_root: true,
auto_gen_config: true,
compile_multilib: "first",
rustlibs: [
"libkeystore2_selinux",
"liblog_rust",
"libnix",
"librand",
"libserde",
"libserde_cbor",
],
}
rust_test {
name: "keystore2_test",
crate_name: "keystore2",
test_suites: ["general-tests"],
auto_gen_config: true,
compile_multilib: "first",
defaults: ["libkeystore2_defaults"],
rustlibs: [
"libandroid_logger",
"libkeystore2_test_utils",
"liblibsqlite3_sys",
"libnix",
"librusqlite",
],
// The test should always include watchdog.
features: [
"watchdog",
],
}
rust_defaults {
name: "keystore2_defaults",
srcs: ["src/keystore2_main.rs"],
rustlibs: [
"libandroid_logger",
"libbinder_rs",
"liblog_rust",
],
init_rc: ["keystore2.rc"],
// In S, keystore2 is the only process using dynamically linked Rust from
// /system. As a result, the usual savings from sharing libraries don't
// apply.
// Remove `prefer_rlib: true` once we have several processes, once a space
// calculation shows net RAM savings, or once we have automatic variant
// selection available in the build system.
prefer_rlib: true,
// TODO(b/187412695)
// This is a hack to work around the build system not installing
// dynamic dependencies of rlibs to the device. This section should
// be removed once that works correctly.
shared_libs: [
"android.hardware.confirmationui@1.0",
"android.hardware.security.sharedsecret-V1-ndk",
"android.security.compat-ndk",
"libc",
"libdl_android",
"libdl",
"libkeymint",
"libkeystore2_aaid",
"libkeystore2_apc_compat",
"libkeystore2_crypto",
"libkm_compat_service",
"libkm_compat",
"libm",
"libstatspull",
"libstatssocket",
],
vintf_fragments: ["android.system.keystore2-service.xml"],
required: ["keystore_cli_v2"],
}
rust_binary {
name: "keystore2",
defaults: ["keystore2_defaults"],
rustlibs: [
"libkeystore2",
"liblegacykeystore-rust",
"librusqlite",
],
}
// Variant of keystore2 for use in microdroid. It doesn't depend on the ICU-enabled sqlite.
// This can be used also in Android, but we choose not to because it will bring two
// variants of sqlite to the system causing more RAM usage and CPU cycles when loading.
rust_binary {
name: "keystore2_microdroid",
stem: "keystore2",
defaults: ["keystore2_defaults"],
rustlibs: [
"libkeystore2_noicu",
"liblegacykeystore-rust_noicu",
"librusqlite_noicu",
],
installable: false, // don't install this to Android
}