blob: 8efc3303e2a779d2d85e7e76b573b4686b8eb3f7 [file] [log] [blame]
Janis Danisevskis43c89712020-08-03 23:42:42 +00001// Copyright 2020, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Bob Badour4c7858c2021-02-12 15:40:29 -080015package {
16 // See: http://go/android-license-faq
17 // A large-scale-change added 'default_applicable_licenses' to import
18 // all of the 'license_kinds' from "system_security_license"
19 // to get the below license kinds:
20 // SPDX-license-identifier-Apache-2.0
21 default_applicable_licenses: ["system_security_license"],
22}
23
Paul Crowley7c57bf12021-02-02 16:26:57 -080024rust_defaults {
25 name: "libkeystore2_defaults",
Janis Danisevskis43c89712020-08-03 23:42:42 +000026 crate_name: "keystore2",
27 srcs: ["src/lib.rs"],
Janis Danisevskis7d77a762020-07-20 13:03:31 -070028
29 rustlibs: [
Jeongik Cha9f632c62021-01-23 09:33:35 +090030 "android.hardware.security.keymint-V1-rust",
31 "android.hardware.security.secureclock-V1-rust",
Janis Danisevskis84a83e42021-03-21 21:46:54 -070032 "android.hardware.security.sharedsecret-V1-rust",
Bram Bonné5d6c5102021-02-24 15:09:18 +010033 "android.os.permissions_aidl-rust",
Janis Danisevskis7a1cf382020-11-20 11:22:14 -080034 "android.security.apc-rust",
Janis Danisevskis9f10a6a2021-01-18 16:45:21 +000035 "android.security.authorization-rust",
Joel Galensonde386b42020-09-30 10:53:05 -070036 "android.security.compat-rust",
Janis Danisevskis34a0cf22021-03-08 09:19:03 -080037 "android.security.maintenance-rust",
Hasini Gunasinghe15891e62021-06-10 16:23:27 +000038 "android.security.metrics-rust",
Max Bires148c08e2020-10-13 13:41:41 -070039 "android.security.remoteprovisioning-rust",
Jeongik Cha9f632c62021-01-23 09:33:35 +090040 "android.system.keystore2-V1-rust",
Janis Danisevskis7d77a762020-07-20 13:03:31 -070041 "libanyhow",
Janis Danisevskise24f3472020-08-12 17:58:49 -070042 "libbinder_rs",
Janis Danisevskis212c68b2021-01-14 22:29:28 -080043 "libkeystore2_aaid-rust",
Janis Danisevskis7a1cf382020-11-20 11:22:14 -080044 "libkeystore2_apc_compat-rust",
Janis Danisevskisb42fc182020-12-15 08:41:27 -080045 "libkeystore2_crypto_rust",
Joel Galensonde386b42020-09-30 10:53:05 -070046 "libkeystore2_km_compat",
Janis Danisevskisce995432020-07-21 12:22:34 -070047 "libkeystore2_selinux",
Janis Danisevskisef14e1a2021-02-23 23:16:55 -080048 "libkeystore2_vintf_rust",
Janis Danisevskis4ad056f2020-08-05 19:46:46 +000049 "liblazy_static",
Hasini Gunasinghe557b1032020-11-10 01:35:30 +000050 "liblibc",
Pavel Grafov94243c22021-04-21 18:03:11 +010051 "liblog_event_list",
Janis Danisevskis7d77a762020-07-20 13:03:31 -070052 "liblog_rust",
Joel Galenson0891bc12020-07-20 10:37:03 -070053 "librand",
Joel Galenson7ead3a22021-07-29 15:27:34 -070054 "librustutils",
Janis Danisevskis7d77a762020-07-20 13:03:31 -070055 "libthiserror",
56 ],
Joel Galensonba41ca32020-12-28 14:14:07 -080057 shared_libs: [
58 "libcutils",
59 ],
Janis Danisevskis3d5a2142021-05-05 07:31:24 -070060 features: [
61 "watchdog",
62 ],
Janis Danisevskis43c89712020-08-03 23:42:42 +000063}
64
Janis Danisevskis2a8330a2021-01-20 15:34:26 -080065rust_library {
Paul Crowley7c57bf12021-02-02 16:26:57 -080066 name: "libkeystore2",
67 defaults: ["libkeystore2_defaults"],
Jiyong Park975906d2021-09-30 14:58:39 +090068 rustlibs: [
69 "liblibsqlite3_sys",
70 "librusqlite",
71 ],
72}
73
74rust_library {
75 name: "libkeystore2_noicu",
76 defaults: ["libkeystore2_defaults"],
77 rustlibs: [
78 "liblibsqlite3_sys_noicu",
79 "librusqlite_noicu",
80 ],
Paul Crowley7c57bf12021-02-02 16:26:57 -080081}
82
83rust_library {
Janis Danisevskis2a8330a2021-01-20 15:34:26 -080084 name: "libkeystore2_test_utils",
85 crate_name: "keystore2_test_utils",
86 srcs: ["test_utils/lib.rs"],
87 rustlibs: [
Janis Danisevskisa578d392021-09-20 15:44:06 -070088 "libkeystore2_selinux",
Janis Danisevskis2a8330a2021-01-20 15:34:26 -080089 "liblog_rust",
Janis Danisevskisa578d392021-09-20 15:44:06 -070090 "libnix",
Janis Danisevskis2a8330a2021-01-20 15:34:26 -080091 "librand",
Janis Danisevskisa578d392021-09-20 15:44:06 -070092 "libserde",
93 "libserde_cbor",
94 ],
95}
96
97rust_test {
98 name: "keystore2_test_utils_test",
99 srcs: ["test_utils/lib.rs"],
100 test_suites: ["general-tests"],
101 // TODO Remove custom test_config and enable the following two lines when
102 // b/200602232 was resolved.
103 // require_root: true,
104 // auto_gen_config: true,
105 test_config: "test_utils/AndroidTest.xml",
106 compile_multilib: "first",
107 rustlibs: [
108 "libkeystore2_selinux",
109 "liblog_rust",
110 "libnix",
111 "librand",
112 "libserde",
113 "libserde_cbor",
Matthew Maurer3ca82bc2021-04-29 13:08:40 -0700114 ],
Janis Danisevskis2a8330a2021-01-20 15:34:26 -0800115}
116
Janis Danisevskis43c89712020-08-03 23:42:42 +0000117rust_test {
118 name: "keystore2_test",
Joel Galenson26f4d012020-07-17 14:57:21 -0700119 crate_name: "keystore2",
Joel Galenson3f78dd82021-01-20 16:21:30 -0800120 test_suites: ["general-tests"],
121 auto_gen_config: true,
Janis Danisevskis66784c42021-01-27 08:40:25 -0800122 compile_multilib: "first",
Paul Crowley7c57bf12021-02-02 16:26:57 -0800123 defaults: ["libkeystore2_defaults"],
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700124 rustlibs: [
125 "libandroid_logger",
Janis Danisevskis2a8330a2021-01-20 15:34:26 -0800126 "libkeystore2_test_utils",
Jiyong Park975906d2021-09-30 14:58:39 +0900127 "liblibsqlite3_sys",
Janis Danisevskis5cb52dc2021-04-07 16:31:18 -0700128 "libnix",
Jiyong Park975906d2021-09-30 14:58:39 +0900129 "librusqlite",
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700130 ],
Janis Danisevskis3d5a2142021-05-05 07:31:24 -0700131 // The test should always include watchdog.
132 features: [
133 "watchdog",
134 ],
Janis Danisevskis43c89712020-08-03 23:42:42 +0000135}
Janis Danisevskis652f3812020-08-04 00:01:12 +0000136
Jiyong Park975906d2021-09-30 14:58:39 +0900137rust_defaults {
138 name: "keystore2_defaults",
Janis Danisevskis1af91262020-08-10 14:58:08 -0700139 srcs: ["src/keystore2_main.rs"],
140 rustlibs: [
141 "libandroid_logger",
142 "libbinder_rs",
Janis Danisevskis1af91262020-08-10 14:58:08 -0700143 "liblog_rust",
144 ],
145 init_rc: ["keystore2.rc"],
Stephen Crane56936e82021-03-10 17:48:26 -0800146
Matthew Maurer3ca82bc2021-04-29 13:08:40 -0700147 // In S, keystore2 is the only process using dynamically linked Rust from
148 // /system. As a result, the usual savings from sharing libraries don't
149 // apply.
150 // Remove `prefer_rlib: true` once we have several processes, once a space
151 // calculation shows net RAM savings, or once we have automatic variant
152 // selection available in the build system.
153 prefer_rlib: true,
154
155 // TODO(b/187412695)
156 // This is a hack to work around the build system not installing
157 // dynamic dependencies of rlibs to the device. This section should
158 // be removed once that works correctly.
159 shared_libs: [
160 "android.hardware.confirmationui@1.0",
Jiyong Park0d61dd62021-07-27 12:20:26 +0900161 "android.hardware.security.sharedsecret-V1-ndk",
162 "android.security.compat-ndk",
Matthew Maurer3ca82bc2021-04-29 13:08:40 -0700163 "libc",
164 "libdl_android",
165 "libdl",
Matthew Maurer3ca82bc2021-04-29 13:08:40 -0700166 "libkeymint",
167 "libkeystore2_aaid",
168 "libkeystore2_apc_compat",
169 "libkeystore2_crypto",
Matthew Maurer3ca82bc2021-04-29 13:08:40 -0700170 "libkm_compat_service",
171 "libkm_compat",
172 "libm",
173 "libstatspull",
174 "libstatssocket",
175 ],
176
Stephen Crane56936e82021-03-10 17:48:26 -0800177 vintf_fragments: ["android.system.keystore2-service.xml"],
Janis Danisevskis2cb4f092021-05-17 13:25:07 -0700178
179 required: ["keystore_cli_v2"],
Janis Danisevskis1af91262020-08-10 14:58:08 -0700180}
Jiyong Park975906d2021-09-30 14:58:39 +0900181
182rust_binary {
183 name: "keystore2",
184 defaults: ["keystore2_defaults"],
185 rustlibs: [
186 "libkeystore2",
187 "liblegacykeystore-rust",
188 "librusqlite",
189 ],
190}
191
192// Variant of keystore2 for use in microdroid. It doesn't depend on the ICU-enabled sqlite.
193// This can be used also in Android, but we choose not to because it will bring two
194// variants of sqlite to the system causing more RAM usage and CPU cycles when loading.
195rust_binary {
196 name: "keystore2_microdroid",
197 stem: "keystore2",
198 defaults: ["keystore2_defaults"],
199 rustlibs: [
200 "libkeystore2_noicu",
201 "liblegacykeystore-rust_noicu",
202 "librusqlite_noicu",
203 ],
204 installable: false, // don't install this to Android
205}