blob: 84cd0ff33f2f5150199494b05edf39f8262a46f0 [file] [log] [blame]
Steven Moreland7d6416c2017-04-18 10:06:28 -07001// Copyright (C) 2014 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
15// libkeymaster_messages contains just the code necessary to communicate with a
16// AndroidKeymaster implementation, e.g. one running in TrustZone.
Shawn Willdenf7375d12020-01-15 17:01:27 -070017cc_defaults {
18 name: "keymaster_defaults",
19 vendor_available: true,
20 cflags: [
21 "-Wall",
22 "-Werror",
23 "-Wunused",
24 ],
25 clang: true,
26 clang_cflags: [
27 "-Wno-error=unused-const-variable",
28 "-Wno-error=unused-private-field",
29 "-Wimplicit-fallthrough",
30 // TODO(krasin): reenable coverage flags, when the new Clang toolchain is released.
31 // Currently, if enabled, these flags will cause an internal error in Clang.
32 "-fno-sanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp"
33 ],
34 sanitize: {
35 integer_overflow: false,
36 },
37}
38
Steven Moreland7d6416c2017-04-18 10:06:28 -070039cc_library_shared {
40 name: "libkeymaster_messages",
41 srcs: [
Janis Danisevskisf54cc932017-05-10 15:29:10 -070042 "android_keymaster/android_keymaster_messages.cpp",
43 "android_keymaster/android_keymaster_utils.cpp",
44 "android_keymaster/authorization_set.cpp",
45 "android_keymaster/keymaster_tags.cpp",
46 "android_keymaster/logger.cpp",
47 "android_keymaster/serializable.cpp",
48 "android_keymaster/keymaster_stl.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -070049 ],
Yifan Hongf0b39bb2017-04-18 17:07:58 -070050 header_libs: ["libhardware_headers"],
Shawn Willdenf7375d12020-01-15 17:01:27 -070051 defaults: ["keymaster_defaults" ],
52 clang_cflags: [
Steven Moreland7d6416c2017-04-18 10:06:28 -070053 "-DKEYMASTER_NAME_TAGS",
54 ],
Janis Danisevskisf38a0022017-04-26 14:44:46 -070055 stl: "none",
Steven Moreland7d6416c2017-04-18 10:06:28 -070056 export_include_dirs: ["include"],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -070057 host_supported: true,
58 target: {
59 host: {
60 clang_cflags: [
61 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
62 ],
63 },
64 },
Steven Moreland7d6416c2017-04-18 10:06:28 -070065}
66
Janis Danisevskisf38a0022017-04-26 14:44:46 -070067// libkeymaster_portable contains almost everything needed for a keymaster
Steven Moreland7d6416c2017-04-18 10:06:28 -070068// implementation, lacking only a subclass of the (abstract) KeymasterContext
69// class to provide environment-specific services and a wrapper to translate from
70// the function-based keymaster HAL API to the message-based AndroidKeymaster API.
Shawn Willden25814f02018-04-02 10:55:34 -060071cc_library {
Janis Danisevskisf38a0022017-04-26 14:44:46 -070072 name: "libkeymaster_portable",
Steven Moreland7d6416c2017-04-18 10:06:28 -070073 srcs: [
Shawn Willdenfb9b2a42017-12-21 12:35:06 -070074 "android_keymaster/android_keymaster.cpp",
75 "android_keymaster/android_keymaster_messages.cpp",
76 "android_keymaster/android_keymaster_utils.cpp",
77 "android_keymaster/authorization_set.cpp",
78 "android_keymaster/keymaster_enforcement.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -070079 "android_keymaster/keymaster_tags.cpp",
80 "android_keymaster/logger.cpp",
81 "android_keymaster/operation.cpp",
82 "android_keymaster/operation_table.cpp",
83 "android_keymaster/serializable.cpp",
84 "key_blob_utils/auth_encrypted_key_blob.cpp",
85 "key_blob_utils/integrity_assured_key_blob.cpp",
86 "key_blob_utils/ocb.c",
87 "key_blob_utils/ocb_utils.cpp",
88 "key_blob_utils/software_keyblobs.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -070089 "km_openssl/aes_key.cpp",
90 "km_openssl/aes_operation.cpp",
91 "km_openssl/asymmetric_key.cpp",
92 "km_openssl/asymmetric_key_factory.cpp",
93 "km_openssl/attestation_record.cpp",
Mustafa Yigit Bilgen01a9b8b2018-11-07 16:08:08 -080094 "km_openssl/attestation_utils.cpp",
Shawn Willdena2f1a9b2018-01-09 09:37:43 -070095 "km_openssl/block_cipher_operation.cpp",
Janis Danisevskis197c17f2020-10-30 15:25:52 -070096 "km_openssl/certificate_utils.cpp",
Shawn Willden8b940582018-01-02 10:53:39 -070097 "km_openssl/ckdf.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -070098 "km_openssl/ec_key.cpp",
99 "km_openssl/ec_key_factory.cpp",
David Zeuthena843b3d2021-01-19 16:01:00 -0500100 "km_openssl/ecdh_operation.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -0700101 "km_openssl/ecdsa_operation.cpp",
102 "km_openssl/ecies_kem.cpp",
103 "km_openssl/hkdf.cpp",
104 "km_openssl/hmac.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700105 "km_openssl/hmac_key.cpp",
106 "km_openssl/hmac_operation.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -0700107 "km_openssl/iso18033kdf.cpp",
108 "km_openssl/kdf.cpp",
109 "km_openssl/nist_curve_key_exchange.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700110 "km_openssl/openssl_err.cpp",
111 "km_openssl/openssl_utils.cpp",
112 "km_openssl/rsa_key.cpp",
113 "km_openssl/rsa_key_factory.cpp",
114 "km_openssl/rsa_operation.cpp",
Janis Danisevskis41d5a742017-05-12 10:43:12 -0700115 "km_openssl/software_random_source.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700116 "km_openssl/symmetric_key.cpp",
Shawn Willden7efc7722018-01-08 22:00:12 -0700117 "km_openssl/triple_des_key.cpp",
118 "km_openssl/triple_des_operation.cpp",
Shawn Willdendd7e8a02018-01-12 13:03:37 -0700119 "km_openssl/wrapped_key.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700120 ],
121
122 shared_libs: [
123 "libcrypto",
Bram Bonné738feea2020-09-15 21:17:07 +0200124 "libcppbor_external",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700125 ],
Colin Cross79277d32020-12-10 12:08:19 -0800126 export_shared_lib_headers: ["libcppbor_external"],
127 header_libs: ["libhardware_headers"],
128 export_header_lib_headers: ["libhardware_headers"],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700129 defaults: ["keymaster_defaults" ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700130 cflags: [
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700131 "-DBORINGSSL_NO_CXX",
132 ],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700133 host_supported: true,
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700134 export_include_dirs: ["include"],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700135 target: {
136 host: {
137 clang_cflags: [
138 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
139 ],
140 },
141 },
Steven Moreland7d6416c2017-04-18 10:06:28 -0700142}
143
144// libsoftkeymaster provides a software-based keymaster HAL implementation.
145// This is used by keystore as a fallback for when the hardware keymaster does
146// not support the request.
Tri Vo0b674d02017-08-04 13:00:33 -0700147cc_library {
Steven Moreland7d6416c2017-04-18 10:06:28 -0700148 name: "libsoftkeymasterdevice",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700149 srcs: [
Janis Danisevskis3bfda162017-05-12 13:10:41 -0700150 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700151 "contexts/pure_soft_keymaster_context.cpp",
152 "contexts/soft_attestation_context.cpp",
153 "contexts/soft_keymaster_context.cpp",
154 "contexts/soft_keymaster_device.cpp",
155 "contexts/soft_keymaster_logger.cpp",
156 "km_openssl/soft_keymaster_enforcement.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700157 "legacy_support/ec_keymaster1_key.cpp",
158 "legacy_support/ecdsa_keymaster1_operation.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700159 "legacy_support/keymaster1_engine.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700160 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700161 "legacy_support/rsa_keymaster1_key.cpp",
162 "legacy_support/rsa_keymaster1_operation.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700163 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700164 defaults: ["keymaster_defaults"],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700165 shared_libs: [
166 "libkeymaster_messages",
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700167 "libkeymaster_portable",
Selene Huangb0d38302020-02-14 17:39:36 -0800168 "libsoft_attestation_cert",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700169 "liblog",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700170 "libbase",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700171 "libcrypto",
172 "libcutils",
173 ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700174 export_include_dirs: ["include"],
175}
176
Shawn Willden25814f02018-04-02 10:55:34 -0600177cc_library {
Selene Huangb0d38302020-02-14 17:39:36 -0800178 name: "libsoft_attestation_cert",
179 srcs: [
180 "contexts/soft_attestation_cert.cpp",
181 ],
182 defaults: ["keymaster_defaults"],
183 shared_libs: [
184 "libkeymaster_portable",
185 ],
186
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700187 host_supported: true,
Selene Huangb0d38302020-02-14 17:39:36 -0800188 export_include_dirs: ["include"],
189}
190
191cc_library {
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700192 name: "libpuresoftkeymasterdevice",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700193 srcs: [
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700194 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700195 "contexts/soft_attestation_context.cpp",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700196 "contexts/pure_soft_keymaster_context.cpp",
197 "contexts/soft_keymaster_logger.cpp",
198 "km_openssl/soft_keymaster_enforcement.cpp",
199 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700200 defaults: ["keymaster_defaults"],
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700201 shared_libs: [
202 "libkeymaster_messages",
203 "libkeymaster_portable",
Selene Huangb0d38302020-02-14 17:39:36 -0800204 "libsoft_attestation_cert",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700205 "liblog",
206 "libcrypto",
207 "libcutils",
Wei Wangc33ecdf2018-06-27 11:53:26 -0700208 "libbase",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700209 ],
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700210 export_include_dirs: ["include"],
211}
212
A. Cody Schuffelen24ba1e22020-05-06 19:41:36 -0700213cc_library {
214 name: "libpuresoftkeymasterdevice_host",
215 srcs: [
216 "contexts/pure_soft_keymaster_context.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700217 "contexts/soft_attestation_context.cpp",
A. Cody Schuffelen24ba1e22020-05-06 19:41:36 -0700218 "contexts/soft_keymaster_logger.cpp",
219 "km_openssl/soft_keymaster_enforcement.cpp",
220 ],
221 defaults: ["keymaster_defaults"],
222 host_supported: true,
223 device_supported: false,
224 shared_libs: [
225 "libkeymaster_messages",
226 "libkeymaster_portable",
227 "libsoft_attestation_cert",
228 "liblog",
229 "libcrypto",
230 "libcutils",
231 "libbase",
232 ],
233 clang_cflags: [
234 "-DKEYMASTER_NAME_TAGS",
235 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
236 ],
237 export_include_dirs: ["include"],
238}
239
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000240cc_library_shared {
241 name: "libkeymaster3device",
242 srcs: [
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700243 "legacy_support/keymaster_passthrough_key.cpp",
244 "legacy_support/keymaster_passthrough_engine.cpp",
245 "legacy_support/keymaster_passthrough_operation.cpp",
246 "contexts/keymaster1_passthrough_context.cpp",
247 "contexts/keymaster2_passthrough_context.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000248 "ng/AndroidKeymaster3Device.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700249 "android_keymaster/keymaster_configuration.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700250 "legacy_support/ec_keymaster1_key.cpp",
251 "legacy_support/ecdsa_keymaster1_operation.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700252 "legacy_support/keymaster1_engine.cpp",
253 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700254 "legacy_support/rsa_keymaster1_key.cpp",
255 "legacy_support/rsa_keymaster1_operation.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000256 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700257 defaults: ["keymaster_defaults"],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000258 shared_libs: [
259 "libkeymaster_messages",
260 "android.hardware.keymaster@3.0",
261 "libcrypto",
262 "libcutils",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700263 "libbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000264 "libhidlbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000265 "libkeymaster_portable",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000266 "liblog",
Selene Huangb0d38302020-02-14 17:39:36 -0800267 "libpuresoftkeymasterdevice",
268 "libsoft_attestation_cert",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000269 "libutils",
270 ],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000271 export_include_dirs: ["include", "ng/include"],
272}
273
Shawn Willden9e149572017-10-30 16:08:21 -0600274cc_library_shared {
275 name: "libkeymaster4",
Shawn Willden9e149572017-10-30 16:08:21 -0600276 srcs: [
277 "legacy_support/keymaster_passthrough_key.cpp",
278 "legacy_support/keymaster_passthrough_engine.cpp",
279 "legacy_support/keymaster_passthrough_operation.cpp",
Shawn Willdenefd06732017-11-30 19:34:16 -0700280 "ng/AndroidKeymaster4Device.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600281 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600282 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700283 defaults: ["keymaster_defaults"],
Shawn Willden9e149572017-10-30 16:08:21 -0600284 shared_libs: [
285 "libkeymaster_messages",
286 "android.hardware.keymaster@4.0",
287 "libcrypto",
288 "libcutils",
289 "libbase",
290 "libhidlbase",
Shawn Willden9e149572017-10-30 16:08:21 -0600291 "libkeymaster_portable",
Shawn Willden9e149572017-10-30 16:08:21 -0600292 "libpuresoftkeymasterdevice",
293 "liblog",
294 "libutils",
295 "libkeymaster4support",
296 ],
Shawn Willden6daf9842020-11-19 10:11:47 -0700297 export_include_dirs: [
298 "ng/include",
299 "include"
300 ],
Shawn Willden9e149572017-10-30 16:08:21 -0600301}
302
Shawn Willden8ae41b52019-10-28 12:54:16 -0600303cc_library_shared {
304 name: "libkeymaster41",
305 vendor_available: true,
306 srcs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600307 "ng/AndroidKeymaster41Device.cpp",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600308 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700309 defaults: ["keymaster_defaults"],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600310 shared_libs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600311 "android.hardware.keymaster@4.0",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700312 "android.hardware.keymaster@4.1",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600313 "libbase",
314 "libcrypto",
315 "libcutils",
316 "libhidlbase",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700317 "libkeymaster4",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600318 "libkeymaster4_1support",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700319 "libkeymaster4support",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600320 "libkeymaster_messages",
321 "libkeymaster_portable",
322 "liblog",
323 "libpuresoftkeymasterdevice",
324 "libutils",
325 ],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600326 export_include_dirs: ["ng/include"],
327}
328
Shawn Willden815e8962020-12-11 13:05:27 +0000329cc_library {
330 name: "libkeymint",
331 vendor_available: true,
332 srcs: [
333 "android_keymaster/keymaster_configuration.cpp",
334 "legacy_support/keymaster_passthrough_engine.cpp",
335 "legacy_support/keymaster_passthrough_key.cpp",
336 "legacy_support/keymaster_passthrough_operation.cpp",
337 "ng/AndroidKeyMintDevice.cpp",
338 "ng/AndroidKeyMintOperation.cpp",
339 "ng/KeyMintUtils.cpp",
340 ],
341 defaults: ["keymaster_defaults"],
342 shared_libs: [
343 "libhidlbase",
Jeongik Chaa3202fa2021-01-26 22:35:10 +0900344 "android.hardware.security.keymint-V1-ndk_platform",
Shawn Willden815e8962020-12-11 13:05:27 +0000345 "libbase",
346 "libbinder_ndk",
347 "libcppbor",
348 "libcrypto",
349 "libcutils",
350 "libkeymaster_messages",
351 "libkeymaster_messages",
352 "libkeymaster_portable",
353 "liblog",
354 "libpuresoftkeymasterdevice",
355 "libutils",
356 ],
357 export_include_dirs: ["include", "ng/include"],
358}
Selene Huangfb818292020-05-27 04:58:16 -0700359
Steven Moreland7d6416c2017-04-18 10:06:28 -0700360// libkeymasterfiles is an empty library that exports all of the files in keymaster as includes.
361cc_library_static {
362 name: "libkeymasterfiles",
363 export_include_dirs: [
364 ".",
365 "include",
366 ],
367}
Corbin Souffrante9474442020-08-28 16:46:58 -0700368
369cc_defaults {
370 name: "keymaster_fuzz_defaults",
371 header_libs: ["libhardware_headers"],
372 shared_libs: [
373 "libkeymaster_messages",
374 ],
375 // Not using defaults because the fuzzer relies on sanitizers that are explicitly disabled there.
376 cflags: [
377 "-Wall",
378 "-Werror",
379 "-Wunused",
380 "-Wno-error=unused-const-variable",
381 "-Wno-error=unused-private-field",
382 "-Wimplicit-fallthrough",
383 "-DKEYMASTER_NAME_TAGS",
384 ],
385 host_supported: true,
386 target: {
387 host: {
388 clang_cflags: [
389 "-fno-rtti", // TODO(b/156427382): Remove when default library removes this
390 ],
391 },
392 },
393}
394
395cc_fuzz {
396 name: "libkeymaster_fuzz_buffer",
397 defaults: ["keymaster_fuzz_defaults"],
398 srcs: [
399 "tests/fuzzers/buffer_fuzz.cpp",
400 ],
401}
402
403cc_fuzz {
404 name: "libkeymaster_fuzz_serializable",
405 defaults: ["keymaster_fuzz_defaults"],
406 srcs: [
407 "tests/fuzzers/message_serializable_fuzz.cpp",
408 ],
409}