blob: 75e9096c56135ff6433989a6444ce856cc856fb1 [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",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700150 "legacy_support/ec_keymaster0_key.cpp",
151 "legacy_support/ec_keymaster1_key.cpp",
152 "legacy_support/ecdsa_keymaster1_operation.cpp",
153 "legacy_support/keymaster0_engine.cpp",
154 "legacy_support/keymaster1_engine.cpp",
155 "legacy_support/rsa_keymaster0_key.cpp",
156 "legacy_support/rsa_keymaster1_key.cpp",
157 "legacy_support/rsa_keymaster1_operation.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700158 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700159 "contexts/soft_keymaster_context.cpp",
Shawn Willdendd7e8a02018-01-12 13:03:37 -0700160 "contexts/pure_soft_keymaster_context.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700161 "contexts/soft_keymaster_device.cpp",
Janis Danisevskis1455d2e2017-05-11 10:56:27 -0700162 "km_openssl/soft_keymaster_enforcement.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700163 "contexts/soft_keymaster_logger.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700164 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700165 defaults: ["keymaster_defaults"],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700166 shared_libs: [
167 "libkeymaster_messages",
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700168 "libkeymaster_portable",
Selene Huangb0d38302020-02-14 17:39:36 -0800169 "libsoft_attestation_cert",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700170 "liblog",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700171 "libbase",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700172 "libcrypto",
173 "libcutils",
174 ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700175 export_include_dirs: ["include"],
176}
177
Shawn Willden25814f02018-04-02 10:55:34 -0600178cc_library {
Selene Huangb0d38302020-02-14 17:39:36 -0800179 name: "libsoft_attestation_cert",
180 srcs: [
181 "contexts/soft_attestation_cert.cpp",
182 ],
183 defaults: ["keymaster_defaults"],
184 shared_libs: [
185 "libkeymaster_portable",
186 ],
187
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700188 host_supported: true,
Selene Huangb0d38302020-02-14 17:39:36 -0800189 export_include_dirs: ["include"],
190}
191
192cc_library {
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700193 name: "libpuresoftkeymasterdevice",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700194 srcs: [
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700195 "android_keymaster/keymaster_configuration.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",
217 "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_keymaster0_key.cpp",
250 "legacy_support/ec_keymaster1_key.cpp",
251 "legacy_support/ecdsa_keymaster1_operation.cpp",
252 "legacy_support/keymaster0_engine.cpp",
253 "legacy_support/keymaster1_engine.cpp",
254 "legacy_support/keymaster1_legacy_support.cpp",
255 "legacy_support/rsa_keymaster0_key.cpp",
256 "legacy_support/rsa_keymaster1_key.cpp",
257 "legacy_support/rsa_keymaster1_operation.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000258 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700259 defaults: ["keymaster_defaults"],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000260 shared_libs: [
261 "libkeymaster_messages",
262 "android.hardware.keymaster@3.0",
263 "libcrypto",
264 "libcutils",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700265 "libbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000266 "libhidlbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000267 "libkeymaster_portable",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000268 "liblog",
Selene Huangb0d38302020-02-14 17:39:36 -0800269 "libpuresoftkeymasterdevice",
270 "libsoft_attestation_cert",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000271 "libutils",
272 ],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000273 export_include_dirs: ["include", "ng/include"],
274}
275
Shawn Willden9e149572017-10-30 16:08:21 -0600276cc_library_shared {
277 name: "libkeymaster4",
Shawn Willden9e149572017-10-30 16:08:21 -0600278 srcs: [
279 "legacy_support/keymaster_passthrough_key.cpp",
280 "legacy_support/keymaster_passthrough_engine.cpp",
281 "legacy_support/keymaster_passthrough_operation.cpp",
Shawn Willdenefd06732017-11-30 19:34:16 -0700282 "ng/AndroidKeymaster4Device.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600283 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600284 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700285 defaults: ["keymaster_defaults"],
Shawn Willden9e149572017-10-30 16:08:21 -0600286 shared_libs: [
287 "libkeymaster_messages",
288 "android.hardware.keymaster@4.0",
289 "libcrypto",
290 "libcutils",
291 "libbase",
292 "libhidlbase",
Shawn Willden9e149572017-10-30 16:08:21 -0600293 "libkeymaster_portable",
Shawn Willden9e149572017-10-30 16:08:21 -0600294 "libpuresoftkeymasterdevice",
295 "liblog",
296 "libutils",
297 "libkeymaster4support",
298 ],
Shawn Willden6daf9842020-11-19 10:11:47 -0700299 export_include_dirs: [
300 "ng/include",
301 "include"
302 ],
Shawn Willden9e149572017-10-30 16:08:21 -0600303}
304
Shawn Willden8ae41b52019-10-28 12:54:16 -0600305cc_library_shared {
306 name: "libkeymaster41",
307 vendor_available: true,
308 srcs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600309 "ng/AndroidKeymaster41Device.cpp",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600310 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700311 defaults: ["keymaster_defaults"],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600312 shared_libs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600313 "android.hardware.keymaster@4.0",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700314 "android.hardware.keymaster@4.1",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600315 "libbase",
316 "libcrypto",
317 "libcutils",
318 "libhidlbase",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700319 "libkeymaster4",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600320 "libkeymaster4_1support",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700321 "libkeymaster4support",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600322 "libkeymaster_messages",
323 "libkeymaster_portable",
324 "liblog",
325 "libpuresoftkeymasterdevice",
326 "libutils",
327 ],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600328 export_include_dirs: ["ng/include"],
329}
330
Selene Huangfb818292020-05-27 04:58:16 -0700331
332cc_library_shared {
333 name: "libkeymint1",
334 vendor_available: true,
335 srcs: [
336 "legacy_support/keymaster_passthrough_key.cpp",
337 "legacy_support/keymaster_passthrough_engine.cpp",
338 "legacy_support/keymaster_passthrough_operation.cpp",
339 "ng/KeyMintAidlUtils.cpp",
340 "ng/AndroidKeyMint1Device.cpp",
341 "ng/AndroidKeyMint1Operation.cpp",
342 "android_keymaster/keymaster_configuration.cpp",
343 ],
344 defaults: ["keymaster_defaults"],
345 shared_libs: [
346 "libkeymaster_messages",
347 "android.hardware.keymint-ndk_platform",
348 "libbase",
349 "libcrypto",
350 "libcutils",
351 "libbinder_ndk",
352 "libcppbor",
353 "libhidlbase",
354 "libkeymaster_portable",
355 "libkeymaster_messages",
356 "libpuresoftkeymasterdevice",
357 "liblog",
358 "libutils",
359 ],
360 export_include_dirs: ["include", "ng/include"],
361}
362
363
Steven Moreland7d6416c2017-04-18 10:06:28 -0700364// libkeymasterfiles is an empty library that exports all of the files in keymaster as includes.
365cc_library_static {
366 name: "libkeymasterfiles",
367 export_include_dirs: [
368 ".",
369 "include",
370 ],
371}
Corbin Souffrante9474442020-08-28 16:46:58 -0700372
373cc_defaults {
374 name: "keymaster_fuzz_defaults",
375 header_libs: ["libhardware_headers"],
376 shared_libs: [
377 "libkeymaster_messages",
378 ],
379 // Not using defaults because the fuzzer relies on sanitizers that are explicitly disabled there.
380 cflags: [
381 "-Wall",
382 "-Werror",
383 "-Wunused",
384 "-Wno-error=unused-const-variable",
385 "-Wno-error=unused-private-field",
386 "-Wimplicit-fallthrough",
387 "-DKEYMASTER_NAME_TAGS",
388 ],
389 host_supported: true,
390 target: {
391 host: {
392 clang_cflags: [
393 "-fno-rtti", // TODO(b/156427382): Remove when default library removes this
394 ],
395 },
396 },
397}
398
399cc_fuzz {
400 name: "libkeymaster_fuzz_buffer",
401 defaults: ["keymaster_fuzz_defaults"],
402 srcs: [
403 "tests/fuzzers/buffer_fuzz.cpp",
404 ],
405}
406
407cc_fuzz {
408 name: "libkeymaster_fuzz_serializable",
409 defaults: ["keymaster_fuzz_defaults"],
410 srcs: [
411 "tests/fuzzers/message_serializable_fuzz.cpp",
412 ],
413}