xref: /aosp_15_r20/system/security/keystore2/Android.bp (revision e1997b9af69e3155ead6e072d106a0077849ffba)
1*e1997b9aSAndroid Build Coastguard Worker// Copyright 2020, The Android Open Source Project
2*e1997b9aSAndroid Build Coastguard Worker//
3*e1997b9aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*e1997b9aSAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*e1997b9aSAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*e1997b9aSAndroid Build Coastguard Worker//
7*e1997b9aSAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*e1997b9aSAndroid Build Coastguard Worker//
9*e1997b9aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*e1997b9aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*e1997b9aSAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*e1997b9aSAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*e1997b9aSAndroid Build Coastguard Worker// limitations under the License.
14*e1997b9aSAndroid Build Coastguard Worker
15*e1997b9aSAndroid Build Coastguard Workerpackage {
16*e1997b9aSAndroid Build Coastguard Worker    default_team: "trendy_team_android_hardware_backed_security",
17*e1997b9aSAndroid Build Coastguard Worker    // See: http://go/android-license-faq
18*e1997b9aSAndroid Build Coastguard Worker    // A large-scale-change added 'default_applicable_licenses' to import
19*e1997b9aSAndroid Build Coastguard Worker    // all of the 'license_kinds' from "system_security_license"
20*e1997b9aSAndroid Build Coastguard Worker    // to get the below license kinds:
21*e1997b9aSAndroid Build Coastguard Worker    //   SPDX-license-identifier-Apache-2.0
22*e1997b9aSAndroid Build Coastguard Worker    default_applicable_licenses: ["system_security_license"],
23*e1997b9aSAndroid Build Coastguard Worker}
24*e1997b9aSAndroid Build Coastguard Worker
25*e1997b9aSAndroid Build Coastguard Workerrust_defaults {
26*e1997b9aSAndroid Build Coastguard Worker    name: "libkeystore2_defaults",
27*e1997b9aSAndroid Build Coastguard Worker    crate_name: "keystore2",
28*e1997b9aSAndroid Build Coastguard Worker    srcs: ["src/lib.rs"],
29*e1997b9aSAndroid Build Coastguard Worker    defaults: [
30*e1997b9aSAndroid Build Coastguard Worker        "keymint_use_latest_hal_aidl_rust",
31*e1997b9aSAndroid Build Coastguard Worker        "keystore2_use_latest_aidl_rust",
32*e1997b9aSAndroid Build Coastguard Worker        "structured_log_rust_defaults",
33*e1997b9aSAndroid Build Coastguard Worker    ],
34*e1997b9aSAndroid Build Coastguard Worker    cfgs: select(release_flag("RELEASE_AVF_ENABLE_EARLY_VM"), {
35*e1997b9aSAndroid Build Coastguard Worker        true: ["early_vm"],
36*e1997b9aSAndroid Build Coastguard Worker        default: [],
37*e1997b9aSAndroid Build Coastguard Worker    }),
38*e1997b9aSAndroid Build Coastguard Worker    rustlibs: [
39*e1997b9aSAndroid Build Coastguard Worker        "android.hardware.security.rkp-V3-rust",
40*e1997b9aSAndroid Build Coastguard Worker        "android.hardware.security.secureclock-V1-rust",
41*e1997b9aSAndroid Build Coastguard Worker        "android.hardware.security.sharedsecret-V1-rust",
42*e1997b9aSAndroid Build Coastguard Worker        "android.os.permissions_aidl-rust",
43*e1997b9aSAndroid Build Coastguard Worker        "android.security.apc-rust",
44*e1997b9aSAndroid Build Coastguard Worker        "android.security.authorization-rust",
45*e1997b9aSAndroid Build Coastguard Worker        "android.security.compat-rust",
46*e1997b9aSAndroid Build Coastguard Worker        "android.security.maintenance-rust",
47*e1997b9aSAndroid Build Coastguard Worker        "android.security.metrics-rust",
48*e1997b9aSAndroid Build Coastguard Worker        "android.security.rkp_aidl-rust",
49*e1997b9aSAndroid Build Coastguard Worker        "libaconfig_android_hardware_biometrics_rust",
50*e1997b9aSAndroid Build Coastguard Worker        "libandroid_security_flags_rust",
51*e1997b9aSAndroid Build Coastguard Worker        "libanyhow",
52*e1997b9aSAndroid Build Coastguard Worker        "libbinder_rs",
53*e1997b9aSAndroid Build Coastguard Worker        "libbssl_crypto",
54*e1997b9aSAndroid Build Coastguard Worker        "libder",
55*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_aaid-rust",
56*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_apc_compat-rust",
57*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_crypto_rust",
58*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_flags_rust",
59*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_hal_names_rust",
60*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_km_compat",
61*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_selinux",
62*e1997b9aSAndroid Build Coastguard Worker        "liblibc",
63*e1997b9aSAndroid Build Coastguard Worker        "liblog_rust",
64*e1997b9aSAndroid Build Coastguard Worker        "libmessage_macro",
65*e1997b9aSAndroid Build Coastguard Worker        "libpostprocessor_client",
66*e1997b9aSAndroid Build Coastguard Worker        "librand",
67*e1997b9aSAndroid Build Coastguard Worker        "librkpd_client",
68*e1997b9aSAndroid Build Coastguard Worker        "librustutils",
69*e1997b9aSAndroid Build Coastguard Worker        "libserde",
70*e1997b9aSAndroid Build Coastguard Worker        "libserde_cbor",
71*e1997b9aSAndroid Build Coastguard Worker        "libthiserror",
72*e1997b9aSAndroid Build Coastguard Worker        "libtokio",
73*e1997b9aSAndroid Build Coastguard Worker        "libwatchdog_rs",
74*e1997b9aSAndroid Build Coastguard Worker    ],
75*e1997b9aSAndroid Build Coastguard Worker    shared_libs: [
76*e1997b9aSAndroid Build Coastguard Worker        "libcutils",
77*e1997b9aSAndroid Build Coastguard Worker    ],
78*e1997b9aSAndroid Build Coastguard Worker    features: [
79*e1997b9aSAndroid Build Coastguard Worker        "watchdog",
80*e1997b9aSAndroid Build Coastguard Worker    ],
81*e1997b9aSAndroid Build Coastguard Worker}
82*e1997b9aSAndroid Build Coastguard Worker
83*e1997b9aSAndroid Build Coastguard Workerrust_library {
84*e1997b9aSAndroid Build Coastguard Worker    name: "libkeystore2",
85*e1997b9aSAndroid Build Coastguard Worker    defaults: ["libkeystore2_defaults"],
86*e1997b9aSAndroid Build Coastguard Worker    rustlibs: [
87*e1997b9aSAndroid Build Coastguard Worker        "liblibsqlite3_sys",
88*e1997b9aSAndroid Build Coastguard Worker        "librusqlite",
89*e1997b9aSAndroid Build Coastguard Worker    ],
90*e1997b9aSAndroid Build Coastguard Worker}
91*e1997b9aSAndroid Build Coastguard Worker
92*e1997b9aSAndroid Build Coastguard Workerrust_library {
93*e1997b9aSAndroid Build Coastguard Worker    name: "libkeystore2_with_test_utils",
94*e1997b9aSAndroid Build Coastguard Worker    defaults: ["libkeystore2_defaults"],
95*e1997b9aSAndroid Build Coastguard Worker    features: [
96*e1997b9aSAndroid Build Coastguard Worker        "keystore2_blob_test_utils",
97*e1997b9aSAndroid Build Coastguard Worker    ],
98*e1997b9aSAndroid Build Coastguard Worker    rustlibs: [
99*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_test_utils",
100*e1997b9aSAndroid Build Coastguard Worker        "liblibsqlite3_sys",
101*e1997b9aSAndroid Build Coastguard Worker        "librusqlite",
102*e1997b9aSAndroid Build Coastguard Worker    ],
103*e1997b9aSAndroid Build Coastguard Worker}
104*e1997b9aSAndroid Build Coastguard Worker
105*e1997b9aSAndroid Build Coastguard Workerrust_test {
106*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2_test",
107*e1997b9aSAndroid Build Coastguard Worker    crate_name: "keystore2",
108*e1997b9aSAndroid Build Coastguard Worker    test_suites: ["general-tests"],
109*e1997b9aSAndroid Build Coastguard Worker    auto_gen_config: true,
110*e1997b9aSAndroid Build Coastguard Worker    compile_multilib: "first",
111*e1997b9aSAndroid Build Coastguard Worker    defaults: ["libkeystore2_defaults"],
112*e1997b9aSAndroid Build Coastguard Worker    rustlibs: [
113*e1997b9aSAndroid Build Coastguard Worker        "libandroid_logger",
114*e1997b9aSAndroid Build Coastguard Worker        "libhex",
115*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_test_utils",
116*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2_with_test_utils",
117*e1997b9aSAndroid Build Coastguard Worker        "liblibsqlite3_sys",
118*e1997b9aSAndroid Build Coastguard Worker        "libnix",
119*e1997b9aSAndroid Build Coastguard Worker        "librusqlite",
120*e1997b9aSAndroid Build Coastguard Worker        "libtempfile",
121*e1997b9aSAndroid Build Coastguard Worker    ],
122*e1997b9aSAndroid Build Coastguard Worker    // The test should always include watchdog.
123*e1997b9aSAndroid Build Coastguard Worker    features: [
124*e1997b9aSAndroid Build Coastguard Worker        "keystore2_blob_test_utils",
125*e1997b9aSAndroid Build Coastguard Worker        "watchdog",
126*e1997b9aSAndroid Build Coastguard Worker    ],
127*e1997b9aSAndroid Build Coastguard Worker    require_root: true,
128*e1997b9aSAndroid Build Coastguard Worker}
129*e1997b9aSAndroid Build Coastguard Worker
130*e1997b9aSAndroid Build Coastguard Workervintf_fragment {
131*e1997b9aSAndroid Build Coastguard Worker    name: "android.system.keystore2-service.xml",
132*e1997b9aSAndroid Build Coastguard Worker    src: "android.system.keystore2-service.xml",
133*e1997b9aSAndroid Build Coastguard Worker}
134*e1997b9aSAndroid Build Coastguard Worker
135*e1997b9aSAndroid Build Coastguard Workerrust_defaults {
136*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2_defaults",
137*e1997b9aSAndroid Build Coastguard Worker    srcs: ["src/keystore2_main.rs"],
138*e1997b9aSAndroid Build Coastguard Worker    rustlibs: [
139*e1997b9aSAndroid Build Coastguard Worker        "libandroid_logger",
140*e1997b9aSAndroid Build Coastguard Worker        "libbinder_rs",
141*e1997b9aSAndroid Build Coastguard Worker        "liblog_rust",
142*e1997b9aSAndroid Build Coastguard Worker    ],
143*e1997b9aSAndroid Build Coastguard Worker    init_rc: ["keystore2.rc"],
144*e1997b9aSAndroid Build Coastguard Worker
145*e1997b9aSAndroid Build Coastguard Worker    // In S, keystore2 is the only process using dynamically linked Rust from
146*e1997b9aSAndroid Build Coastguard Worker    // /system. As a result, the usual savings from sharing libraries don't
147*e1997b9aSAndroid Build Coastguard Worker    // apply.
148*e1997b9aSAndroid Build Coastguard Worker    // Remove `prefer_rlib: true` once we have several processes, once a space
149*e1997b9aSAndroid Build Coastguard Worker    // calculation shows net RAM savings, or once we have automatic variant
150*e1997b9aSAndroid Build Coastguard Worker    // selection available in the build system.
151*e1997b9aSAndroid Build Coastguard Worker    prefer_rlib: true,
152*e1997b9aSAndroid Build Coastguard Worker
153*e1997b9aSAndroid Build Coastguard Worker    vintf_fragment_modules: ["android.system.keystore2-service.xml"],
154*e1997b9aSAndroid Build Coastguard Worker
155*e1997b9aSAndroid Build Coastguard Worker    required: ["keystore_cli_v2"],
156*e1997b9aSAndroid Build Coastguard Worker}
157*e1997b9aSAndroid Build Coastguard Worker
158*e1997b9aSAndroid Build Coastguard Workerrust_binary {
159*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2",
160*e1997b9aSAndroid Build Coastguard Worker    defaults: ["keystore2_defaults"],
161*e1997b9aSAndroid Build Coastguard Worker    rustlibs: [
162*e1997b9aSAndroid Build Coastguard Worker        "libkeystore2",
163*e1997b9aSAndroid Build Coastguard Worker        "liblegacykeystore-rust",
164*e1997b9aSAndroid Build Coastguard Worker        "librusqlite",
165*e1997b9aSAndroid Build Coastguard Worker    ],
166*e1997b9aSAndroid Build Coastguard Worker    afdo: true,
167*e1997b9aSAndroid Build Coastguard Worker}
168*e1997b9aSAndroid Build Coastguard Worker
169*e1997b9aSAndroid Build Coastguard Worker// Keystore Flag definitions
170*e1997b9aSAndroid Build Coastguard Workeraconfig_declarations {
171*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2_flags",
172*e1997b9aSAndroid Build Coastguard Worker    package: "android.security.keystore2",
173*e1997b9aSAndroid Build Coastguard Worker    container: "system",
174*e1997b9aSAndroid Build Coastguard Worker    srcs: ["aconfig/flags.aconfig"],
175*e1997b9aSAndroid Build Coastguard Worker}
176*e1997b9aSAndroid Build Coastguard Worker
177*e1997b9aSAndroid Build Coastguard Workerjava_aconfig_library {
178*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2_flags_java",
179*e1997b9aSAndroid Build Coastguard Worker    aconfig_declarations: "keystore2_flags",
180*e1997b9aSAndroid Build Coastguard Worker}
181*e1997b9aSAndroid Build Coastguard Worker
182*e1997b9aSAndroid Build Coastguard Workerjava_aconfig_library {
183*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2_flags_java-host",
184*e1997b9aSAndroid Build Coastguard Worker    aconfig_declarations: "keystore2_flags",
185*e1997b9aSAndroid Build Coastguard Worker    host_supported: true,
186*e1997b9aSAndroid Build Coastguard Worker}
187*e1997b9aSAndroid Build Coastguard Worker
188*e1997b9aSAndroid Build Coastguard Workerjava_aconfig_library {
189*e1997b9aSAndroid Build Coastguard Worker    name: "keystore2_flags_java-framework",
190*e1997b9aSAndroid Build Coastguard Worker    aconfig_declarations: "keystore2_flags",
191*e1997b9aSAndroid Build Coastguard Worker    defaults: ["framework-minus-apex-aconfig-java-defaults"],
192*e1997b9aSAndroid Build Coastguard Worker}
193*e1997b9aSAndroid Build Coastguard Worker
194*e1997b9aSAndroid Build Coastguard Workerrust_aconfig_library {
195*e1997b9aSAndroid Build Coastguard Worker    name: "libkeystore2_flags_rust",
196*e1997b9aSAndroid Build Coastguard Worker    crate_name: "keystore2_flags",
197*e1997b9aSAndroid Build Coastguard Worker    aconfig_declarations: "keystore2_flags",
198*e1997b9aSAndroid Build Coastguard Worker}
199*e1997b9aSAndroid Build Coastguard Worker
200*e1997b9aSAndroid Build Coastguard Workerrust_aconfig_library {
201*e1997b9aSAndroid Build Coastguard Worker    name: "libaconfig_android_hardware_biometrics_rust",
202*e1997b9aSAndroid Build Coastguard Worker    crate_name: "aconfig_android_hardware_biometrics_rust",
203*e1997b9aSAndroid Build Coastguard Worker    aconfig_declarations: "android.hardware.biometrics.flags-aconfig",
204*e1997b9aSAndroid Build Coastguard Worker}
205