blob: 4c43f6508db8a9be78eab551788c74883ca0474d [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",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -0700100 "km_openssl/ecdsa_operation.cpp",
101 "km_openssl/ecies_kem.cpp",
102 "km_openssl/hkdf.cpp",
103 "km_openssl/hmac.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700104 "km_openssl/hmac_key.cpp",
105 "km_openssl/hmac_operation.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -0700106 "km_openssl/iso18033kdf.cpp",
107 "km_openssl/kdf.cpp",
108 "km_openssl/nist_curve_key_exchange.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700109 "km_openssl/openssl_err.cpp",
110 "km_openssl/openssl_utils.cpp",
111 "km_openssl/rsa_key.cpp",
112 "km_openssl/rsa_key_factory.cpp",
113 "km_openssl/rsa_operation.cpp",
Janis Danisevskis41d5a742017-05-12 10:43:12 -0700114 "km_openssl/software_random_source.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700115 "km_openssl/symmetric_key.cpp",
Shawn Willden7efc7722018-01-08 22:00:12 -0700116 "km_openssl/triple_des_key.cpp",
117 "km_openssl/triple_des_operation.cpp",
Shawn Willdendd7e8a02018-01-12 13:03:37 -0700118 "km_openssl/wrapped_key.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700119 ],
120
121 shared_libs: [
122 "libcrypto",
Bram Bonné738feea2020-09-15 21:17:07 +0200123 "libcppbor_external",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700124 ],
Colin Cross79277d32020-12-10 12:08:19 -0800125 export_shared_lib_headers: ["libcppbor_external"],
126 header_libs: ["libhardware_headers"],
127 export_header_lib_headers: ["libhardware_headers"],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700128 defaults: ["keymaster_defaults" ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700129 cflags: [
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700130 "-DBORINGSSL_NO_CXX",
131 ],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700132 host_supported: true,
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700133 export_include_dirs: ["include"],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700134 target: {
135 host: {
136 clang_cflags: [
137 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
138 ],
139 },
140 },
Steven Moreland7d6416c2017-04-18 10:06:28 -0700141}
142
143// libsoftkeymaster provides a software-based keymaster HAL implementation.
144// This is used by keystore as a fallback for when the hardware keymaster does
145// not support the request.
Tri Vo0b674d02017-08-04 13:00:33 -0700146cc_library {
Steven Moreland7d6416c2017-04-18 10:06:28 -0700147 name: "libsoftkeymasterdevice",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700148 srcs: [
Janis Danisevskis3bfda162017-05-12 13:10:41 -0700149 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700150 "contexts/pure_soft_keymaster_context.cpp",
151 "contexts/soft_attestation_context.cpp",
152 "contexts/soft_keymaster_context.cpp",
153 "contexts/soft_keymaster_device.cpp",
154 "contexts/soft_keymaster_logger.cpp",
155 "km_openssl/soft_keymaster_enforcement.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700156 "legacy_support/ec_keymaster1_key.cpp",
157 "legacy_support/ecdsa_keymaster1_operation.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700158 "legacy_support/keymaster1_engine.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700159 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700160 "legacy_support/rsa_keymaster1_key.cpp",
161 "legacy_support/rsa_keymaster1_operation.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700162 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700163 defaults: ["keymaster_defaults"],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700164 shared_libs: [
165 "libkeymaster_messages",
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700166 "libkeymaster_portable",
Selene Huangb0d38302020-02-14 17:39:36 -0800167 "libsoft_attestation_cert",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700168 "liblog",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700169 "libbase",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700170 "libcrypto",
171 "libcutils",
172 ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700173 export_include_dirs: ["include"],
174}
175
Shawn Willden25814f02018-04-02 10:55:34 -0600176cc_library {
Selene Huangb0d38302020-02-14 17:39:36 -0800177 name: "libsoft_attestation_cert",
178 srcs: [
179 "contexts/soft_attestation_cert.cpp",
180 ],
181 defaults: ["keymaster_defaults"],
182 shared_libs: [
183 "libkeymaster_portable",
184 ],
185
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700186 host_supported: true,
Selene Huangb0d38302020-02-14 17:39:36 -0800187 export_include_dirs: ["include"],
188}
189
190cc_library {
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700191 name: "libpuresoftkeymasterdevice",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700192 srcs: [
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700193 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700194 "contexts/soft_attestation_context.cpp",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700195 "contexts/pure_soft_keymaster_context.cpp",
196 "contexts/soft_keymaster_logger.cpp",
197 "km_openssl/soft_keymaster_enforcement.cpp",
198 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700199 defaults: ["keymaster_defaults"],
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700200 shared_libs: [
201 "libkeymaster_messages",
202 "libkeymaster_portable",
Selene Huangb0d38302020-02-14 17:39:36 -0800203 "libsoft_attestation_cert",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700204 "liblog",
205 "libcrypto",
206 "libcutils",
Wei Wangc33ecdf2018-06-27 11:53:26 -0700207 "libbase",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700208 ],
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700209 export_include_dirs: ["include"],
210}
211
A. Cody Schuffelen24ba1e22020-05-06 19:41:36 -0700212cc_library {
213 name: "libpuresoftkeymasterdevice_host",
214 srcs: [
215 "contexts/pure_soft_keymaster_context.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700216 "contexts/soft_attestation_context.cpp",
A. Cody Schuffelen24ba1e22020-05-06 19:41:36 -0700217 "contexts/soft_keymaster_logger.cpp",
218 "km_openssl/soft_keymaster_enforcement.cpp",
219 ],
220 defaults: ["keymaster_defaults"],
221 host_supported: true,
222 device_supported: false,
223 shared_libs: [
224 "libkeymaster_messages",
225 "libkeymaster_portable",
226 "libsoft_attestation_cert",
227 "liblog",
228 "libcrypto",
229 "libcutils",
230 "libbase",
231 ],
232 clang_cflags: [
233 "-DKEYMASTER_NAME_TAGS",
234 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
235 ],
236 export_include_dirs: ["include"],
237}
238
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000239cc_library_shared {
240 name: "libkeymaster3device",
241 srcs: [
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700242 "legacy_support/keymaster_passthrough_key.cpp",
243 "legacy_support/keymaster_passthrough_engine.cpp",
244 "legacy_support/keymaster_passthrough_operation.cpp",
245 "contexts/keymaster1_passthrough_context.cpp",
246 "contexts/keymaster2_passthrough_context.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000247 "ng/AndroidKeymaster3Device.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700248 "android_keymaster/keymaster_configuration.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700249 "legacy_support/ec_keymaster1_key.cpp",
250 "legacy_support/ecdsa_keymaster1_operation.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700251 "legacy_support/keymaster1_engine.cpp",
252 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700253 "legacy_support/rsa_keymaster1_key.cpp",
254 "legacy_support/rsa_keymaster1_operation.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000255 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700256 defaults: ["keymaster_defaults"],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000257 shared_libs: [
258 "libkeymaster_messages",
259 "android.hardware.keymaster@3.0",
260 "libcrypto",
261 "libcutils",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700262 "libbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000263 "libhidlbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000264 "libkeymaster_portable",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000265 "liblog",
Selene Huangb0d38302020-02-14 17:39:36 -0800266 "libpuresoftkeymasterdevice",
267 "libsoft_attestation_cert",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000268 "libutils",
269 ],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000270 export_include_dirs: ["include", "ng/include"],
271}
272
Shawn Willden9e149572017-10-30 16:08:21 -0600273cc_library_shared {
274 name: "libkeymaster4",
Shawn Willden9e149572017-10-30 16:08:21 -0600275 srcs: [
276 "legacy_support/keymaster_passthrough_key.cpp",
277 "legacy_support/keymaster_passthrough_engine.cpp",
278 "legacy_support/keymaster_passthrough_operation.cpp",
Shawn Willdenefd06732017-11-30 19:34:16 -0700279 "ng/AndroidKeymaster4Device.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600280 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600281 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700282 defaults: ["keymaster_defaults"],
Shawn Willden9e149572017-10-30 16:08:21 -0600283 shared_libs: [
284 "libkeymaster_messages",
285 "android.hardware.keymaster@4.0",
286 "libcrypto",
287 "libcutils",
288 "libbase",
289 "libhidlbase",
Shawn Willden9e149572017-10-30 16:08:21 -0600290 "libkeymaster_portable",
Shawn Willden9e149572017-10-30 16:08:21 -0600291 "libpuresoftkeymasterdevice",
292 "liblog",
293 "libutils",
294 "libkeymaster4support",
295 ],
Shawn Willden6daf9842020-11-19 10:11:47 -0700296 export_include_dirs: [
297 "ng/include",
298 "include"
299 ],
Shawn Willden9e149572017-10-30 16:08:21 -0600300}
301
Shawn Willden8ae41b52019-10-28 12:54:16 -0600302cc_library_shared {
303 name: "libkeymaster41",
304 vendor_available: true,
305 srcs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600306 "ng/AndroidKeymaster41Device.cpp",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600307 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700308 defaults: ["keymaster_defaults"],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600309 shared_libs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600310 "android.hardware.keymaster@4.0",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700311 "android.hardware.keymaster@4.1",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600312 "libbase",
313 "libcrypto",
314 "libcutils",
315 "libhidlbase",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700316 "libkeymaster4",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600317 "libkeymaster4_1support",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700318 "libkeymaster4support",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600319 "libkeymaster_messages",
320 "libkeymaster_portable",
321 "liblog",
322 "libpuresoftkeymasterdevice",
323 "libutils",
324 ],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600325 export_include_dirs: ["ng/include"],
326}
327
Shawn Willden815e8962020-12-11 13:05:27 +0000328cc_library {
329 name: "libkeymint",
330 vendor_available: true,
331 srcs: [
332 "android_keymaster/keymaster_configuration.cpp",
333 "legacy_support/keymaster_passthrough_engine.cpp",
334 "legacy_support/keymaster_passthrough_key.cpp",
335 "legacy_support/keymaster_passthrough_operation.cpp",
336 "ng/AndroidKeyMintDevice.cpp",
337 "ng/AndroidKeyMintOperation.cpp",
338 "ng/KeyMintUtils.cpp",
339 ],
340 defaults: ["keymaster_defaults"],
341 shared_libs: [
342 "libhidlbase",
Jeongik Chaa3202fa2021-01-26 22:35:10 +0900343 "android.hardware.security.keymint-V1-ndk_platform",
Shawn Willden815e8962020-12-11 13:05:27 +0000344 "libbase",
345 "libbinder_ndk",
346 "libcppbor",
347 "libcrypto",
348 "libcutils",
349 "libkeymaster_messages",
350 "libkeymaster_messages",
351 "libkeymaster_portable",
352 "liblog",
353 "libpuresoftkeymasterdevice",
354 "libutils",
355 ],
356 export_include_dirs: ["include", "ng/include"],
357}
Selene Huangfb818292020-05-27 04:58:16 -0700358
Steven Moreland7d6416c2017-04-18 10:06:28 -0700359// libkeymasterfiles is an empty library that exports all of the files in keymaster as includes.
360cc_library_static {
361 name: "libkeymasterfiles",
362 export_include_dirs: [
363 ".",
364 "include",
365 ],
366}
Corbin Souffrante9474442020-08-28 16:46:58 -0700367
368cc_defaults {
369 name: "keymaster_fuzz_defaults",
370 header_libs: ["libhardware_headers"],
371 shared_libs: [
372 "libkeymaster_messages",
373 ],
374 // Not using defaults because the fuzzer relies on sanitizers that are explicitly disabled there.
375 cflags: [
376 "-Wall",
377 "-Werror",
378 "-Wunused",
379 "-Wno-error=unused-const-variable",
380 "-Wno-error=unused-private-field",
381 "-Wimplicit-fallthrough",
382 "-DKEYMASTER_NAME_TAGS",
383 ],
384 host_supported: true,
385 target: {
386 host: {
387 clang_cflags: [
388 "-fno-rtti", // TODO(b/156427382): Remove when default library removes this
389 ],
390 },
391 },
392}
393
394cc_fuzz {
395 name: "libkeymaster_fuzz_buffer",
396 defaults: ["keymaster_fuzz_defaults"],
397 srcs: [
398 "tests/fuzzers/buffer_fuzz.cpp",
399 ],
400}
401
402cc_fuzz {
403 name: "libkeymaster_fuzz_serializable",
404 defaults: ["keymaster_fuzz_defaults"],
405 srcs: [
406 "tests/fuzzers/message_serializable_fuzz.cpp",
407 ],
408}