blob: e0e73bc9dfb61cded0c597fb0cc4afd56b5dce30 [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",
Qi Wud8b79212021-02-08 01:18:52 +080083 "android_keymaster/pure_soft_secure_key_storage.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -070084 "android_keymaster/serializable.cpp",
85 "key_blob_utils/auth_encrypted_key_blob.cpp",
86 "key_blob_utils/integrity_assured_key_blob.cpp",
87 "key_blob_utils/ocb.c",
88 "key_blob_utils/ocb_utils.cpp",
89 "key_blob_utils/software_keyblobs.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -070090 "km_openssl/aes_key.cpp",
91 "km_openssl/aes_operation.cpp",
92 "km_openssl/asymmetric_key.cpp",
93 "km_openssl/asymmetric_key_factory.cpp",
94 "km_openssl/attestation_record.cpp",
Mustafa Yigit Bilgen01a9b8b2018-11-07 16:08:08 -080095 "km_openssl/attestation_utils.cpp",
Shawn Willdena2f1a9b2018-01-09 09:37:43 -070096 "km_openssl/block_cipher_operation.cpp",
Janis Danisevskis197c17f2020-10-30 15:25:52 -070097 "km_openssl/certificate_utils.cpp",
Shawn Willden8b940582018-01-02 10:53:39 -070098 "km_openssl/ckdf.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -070099 "km_openssl/ec_key.cpp",
100 "km_openssl/ec_key_factory.cpp",
David Zeuthena843b3d2021-01-19 16:01:00 -0500101 "km_openssl/ecdh_operation.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -0700102 "km_openssl/ecdsa_operation.cpp",
103 "km_openssl/ecies_kem.cpp",
104 "km_openssl/hkdf.cpp",
105 "km_openssl/hmac.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700106 "km_openssl/hmac_key.cpp",
107 "km_openssl/hmac_operation.cpp",
Shawn Willdenfb9b2a42017-12-21 12:35:06 -0700108 "km_openssl/iso18033kdf.cpp",
109 "km_openssl/kdf.cpp",
110 "km_openssl/nist_curve_key_exchange.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700111 "km_openssl/openssl_err.cpp",
112 "km_openssl/openssl_utils.cpp",
113 "km_openssl/rsa_key.cpp",
114 "km_openssl/rsa_key_factory.cpp",
115 "km_openssl/rsa_operation.cpp",
Janis Danisevskis41d5a742017-05-12 10:43:12 -0700116 "km_openssl/software_random_source.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700117 "km_openssl/symmetric_key.cpp",
Shawn Willden7efc7722018-01-08 22:00:12 -0700118 "km_openssl/triple_des_key.cpp",
119 "km_openssl/triple_des_operation.cpp",
Shawn Willdendd7e8a02018-01-12 13:03:37 -0700120 "km_openssl/wrapped_key.cpp",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700121 ],
122
123 shared_libs: [
124 "libcrypto",
Bram Bonné738feea2020-09-15 21:17:07 +0200125 "libcppbor_external",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700126 ],
Colin Cross79277d32020-12-10 12:08:19 -0800127 export_shared_lib_headers: ["libcppbor_external"],
128 header_libs: ["libhardware_headers"],
129 export_header_lib_headers: ["libhardware_headers"],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700130 defaults: ["keymaster_defaults" ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700131 cflags: [
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700132 "-DBORINGSSL_NO_CXX",
133 ],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700134 host_supported: true,
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700135 export_include_dirs: ["include"],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700136 target: {
137 host: {
138 clang_cflags: [
139 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
140 ],
141 },
142 },
Steven Moreland7d6416c2017-04-18 10:06:28 -0700143}
144
145// libsoftkeymaster provides a software-based keymaster HAL implementation.
146// This is used by keystore as a fallback for when the hardware keymaster does
147// not support the request.
Tri Vo0b674d02017-08-04 13:00:33 -0700148cc_library {
Steven Moreland7d6416c2017-04-18 10:06:28 -0700149 name: "libsoftkeymasterdevice",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700150 srcs: [
Janis Danisevskis3bfda162017-05-12 13:10:41 -0700151 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700152 "contexts/pure_soft_keymaster_context.cpp",
153 "contexts/soft_attestation_context.cpp",
154 "contexts/soft_keymaster_context.cpp",
155 "contexts/soft_keymaster_device.cpp",
156 "contexts/soft_keymaster_logger.cpp",
157 "km_openssl/soft_keymaster_enforcement.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700158 "legacy_support/ec_keymaster1_key.cpp",
159 "legacy_support/ecdsa_keymaster1_operation.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700160 "legacy_support/keymaster1_engine.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700161 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700162 "legacy_support/rsa_keymaster1_key.cpp",
163 "legacy_support/rsa_keymaster1_operation.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",
Shawn Willden903367c2020-12-15 09:48:08 -0700196 "contexts/soft_attestation_context.cpp",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700197 "contexts/pure_soft_keymaster_context.cpp",
198 "contexts/soft_keymaster_logger.cpp",
199 "km_openssl/soft_keymaster_enforcement.cpp",
200 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700201 defaults: ["keymaster_defaults"],
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700202 shared_libs: [
203 "libkeymaster_messages",
204 "libkeymaster_portable",
Selene Huangb0d38302020-02-14 17:39:36 -0800205 "libsoft_attestation_cert",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700206 "liblog",
207 "libcrypto",
208 "libcutils",
Wei Wangc33ecdf2018-06-27 11:53:26 -0700209 "libbase",
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700210 ],
Janis Danisevskis1f8b1c92017-05-08 11:24:41 -0700211 export_include_dirs: ["include"],
212}
213
A. Cody Schuffelen24ba1e22020-05-06 19:41:36 -0700214cc_library {
215 name: "libpuresoftkeymasterdevice_host",
216 srcs: [
217 "contexts/pure_soft_keymaster_context.cpp",
Shawn Willden903367c2020-12-15 09:48:08 -0700218 "contexts/soft_attestation_context.cpp",
A. Cody Schuffelen24ba1e22020-05-06 19:41:36 -0700219 "contexts/soft_keymaster_logger.cpp",
220 "km_openssl/soft_keymaster_enforcement.cpp",
221 ],
222 defaults: ["keymaster_defaults"],
223 host_supported: true,
224 device_supported: false,
225 shared_libs: [
226 "libkeymaster_messages",
227 "libkeymaster_portable",
228 "libsoft_attestation_cert",
229 "liblog",
230 "libcrypto",
231 "libcutils",
232 "libbase",
233 ],
234 clang_cflags: [
235 "-DKEYMASTER_NAME_TAGS",
236 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
237 ],
238 export_include_dirs: ["include"],
239}
240
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000241cc_library_shared {
242 name: "libkeymaster3device",
243 srcs: [
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700244 "legacy_support/keymaster_passthrough_key.cpp",
245 "legacy_support/keymaster_passthrough_engine.cpp",
246 "legacy_support/keymaster_passthrough_operation.cpp",
247 "contexts/keymaster1_passthrough_context.cpp",
248 "contexts/keymaster2_passthrough_context.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000249 "ng/AndroidKeymaster3Device.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700250 "android_keymaster/keymaster_configuration.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700251 "legacy_support/ec_keymaster1_key.cpp",
252 "legacy_support/ecdsa_keymaster1_operation.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700253 "legacy_support/keymaster1_engine.cpp",
254 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700255 "legacy_support/rsa_keymaster1_key.cpp",
256 "legacy_support/rsa_keymaster1_operation.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000257 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700258 defaults: ["keymaster_defaults"],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000259 shared_libs: [
260 "libkeymaster_messages",
261 "android.hardware.keymaster@3.0",
262 "libcrypto",
263 "libcutils",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700264 "libbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000265 "libhidlbase",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000266 "libkeymaster_portable",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000267 "liblog",
Selene Huangb0d38302020-02-14 17:39:36 -0800268 "libpuresoftkeymasterdevice",
269 "libsoft_attestation_cert",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000270 "libutils",
271 ],
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000272 export_include_dirs: ["include", "ng/include"],
273}
274
Shawn Willden9e149572017-10-30 16:08:21 -0600275cc_library_shared {
276 name: "libkeymaster4",
Shawn Willden9e149572017-10-30 16:08:21 -0600277 srcs: [
278 "legacy_support/keymaster_passthrough_key.cpp",
279 "legacy_support/keymaster_passthrough_engine.cpp",
280 "legacy_support/keymaster_passthrough_operation.cpp",
Shawn Willdenefd06732017-11-30 19:34:16 -0700281 "ng/AndroidKeymaster4Device.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600282 "android_keymaster/keymaster_configuration.cpp",
Shawn Willden9e149572017-10-30 16:08:21 -0600283 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700284 defaults: ["keymaster_defaults"],
Shawn Willden9e149572017-10-30 16:08:21 -0600285 shared_libs: [
286 "libkeymaster_messages",
287 "android.hardware.keymaster@4.0",
288 "libcrypto",
289 "libcutils",
290 "libbase",
291 "libhidlbase",
Shawn Willden9e149572017-10-30 16:08:21 -0600292 "libkeymaster_portable",
Shawn Willden9e149572017-10-30 16:08:21 -0600293 "libpuresoftkeymasterdevice",
294 "liblog",
295 "libutils",
296 "libkeymaster4support",
297 ],
Shawn Willden6daf9842020-11-19 10:11:47 -0700298 export_include_dirs: [
299 "ng/include",
300 "include"
301 ],
Shawn Willden9e149572017-10-30 16:08:21 -0600302}
303
Shawn Willden8ae41b52019-10-28 12:54:16 -0600304cc_library_shared {
305 name: "libkeymaster41",
306 vendor_available: true,
307 srcs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600308 "ng/AndroidKeymaster41Device.cpp",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600309 ],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700310 defaults: ["keymaster_defaults"],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600311 shared_libs: [
Shawn Willden8ae41b52019-10-28 12:54:16 -0600312 "android.hardware.keymaster@4.0",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700313 "android.hardware.keymaster@4.1",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600314 "libbase",
315 "libcrypto",
316 "libcutils",
317 "libhidlbase",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700318 "libkeymaster4",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600319 "libkeymaster4_1support",
Shawn Willdenf7375d12020-01-15 17:01:27 -0700320 "libkeymaster4support",
Shawn Willden8ae41b52019-10-28 12:54:16 -0600321 "libkeymaster_messages",
322 "libkeymaster_portable",
323 "liblog",
324 "libpuresoftkeymasterdevice",
325 "libutils",
326 ],
Shawn Willden8ae41b52019-10-28 12:54:16 -0600327 export_include_dirs: ["ng/include"],
328}
329
Shawn Willden815e8962020-12-11 13:05:27 +0000330cc_library {
331 name: "libkeymint",
332 vendor_available: true,
333 srcs: [
334 "android_keymaster/keymaster_configuration.cpp",
335 "legacy_support/keymaster_passthrough_engine.cpp",
336 "legacy_support/keymaster_passthrough_key.cpp",
337 "legacy_support/keymaster_passthrough_operation.cpp",
338 "ng/AndroidKeyMintDevice.cpp",
339 "ng/AndroidKeyMintOperation.cpp",
340 "ng/KeyMintUtils.cpp",
341 ],
342 defaults: ["keymaster_defaults"],
343 shared_libs: [
344 "libhidlbase",
Jeongik Chaa3202fa2021-01-26 22:35:10 +0900345 "android.hardware.security.keymint-V1-ndk_platform",
Shawn Willden815e8962020-12-11 13:05:27 +0000346 "libbase",
347 "libbinder_ndk",
348 "libcppbor",
349 "libcrypto",
350 "libcutils",
351 "libkeymaster_messages",
352 "libkeymaster_messages",
353 "libkeymaster_portable",
354 "liblog",
355 "libpuresoftkeymasterdevice",
356 "libutils",
357 ],
358 export_include_dirs: ["include", "ng/include"],
359}
Selene Huangfb818292020-05-27 04:58:16 -0700360
Steven Moreland7d6416c2017-04-18 10:06:28 -0700361// libkeymasterfiles is an empty library that exports all of the files in keymaster as includes.
362cc_library_static {
363 name: "libkeymasterfiles",
364 export_include_dirs: [
365 ".",
366 "include",
367 ],
368}
Corbin Souffrante9474442020-08-28 16:46:58 -0700369
370cc_defaults {
371 name: "keymaster_fuzz_defaults",
372 header_libs: ["libhardware_headers"],
373 shared_libs: [
374 "libkeymaster_messages",
375 ],
376 // Not using defaults because the fuzzer relies on sanitizers that are explicitly disabled there.
377 cflags: [
378 "-Wall",
379 "-Werror",
380 "-Wunused",
381 "-Wno-error=unused-const-variable",
382 "-Wno-error=unused-private-field",
383 "-Wimplicit-fallthrough",
384 "-DKEYMASTER_NAME_TAGS",
385 ],
386 host_supported: true,
387 target: {
388 host: {
389 clang_cflags: [
390 "-fno-rtti", // TODO(b/156427382): Remove when default library removes this
391 ],
392 },
393 },
394}
395
396cc_fuzz {
397 name: "libkeymaster_fuzz_buffer",
398 defaults: ["keymaster_fuzz_defaults"],
399 srcs: [
400 "tests/fuzzers/buffer_fuzz.cpp",
401 ],
402}
403
404cc_fuzz {
405 name: "libkeymaster_fuzz_serializable",
406 defaults: ["keymaster_fuzz_defaults"],
407 srcs: [
408 "tests/fuzzers/message_serializable_fuzz.cpp",
409 ],
410}