blob: 609e1d026c0ec96034d2744868067c42bb15ba72 [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 ],
Bram Bonné738feea2020-09-15 21:17:07 +0200125 header_libs: ["libhardware_headers", "libcppbor_external"],
126 export_header_lib_headers: ["libhardware_headers", "libcppbor_external"],
Shawn Willdenf7375d12020-01-15 17:01:27 -0700127 defaults: ["keymaster_defaults" ],
Steven Moreland7d6416c2017-04-18 10:06:28 -0700128 cflags: [
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700129 "-DBORINGSSL_NO_CXX",
130 ],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700131 host_supported: true,
Janis Danisevskisf38a0022017-04-26 14:44:46 -0700132 export_include_dirs: ["include"],
A. Cody Schuffelen65667f82020-04-29 14:52:49 -0700133 target: {
134 host: {
135 clang_cflags: [
136 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
137 ],
138 },
139 },
Steven Moreland7d6416c2017-04-18 10:06:28 -0700140}
141
142// libsoftkeymaster provides a software-based keymaster HAL implementation.
143// This is used by keystore as a fallback for when the hardware keymaster does
144// not support the request.
Tri Vo0b674d02017-08-04 13:00:33 -0700145cc_library {
Steven Moreland7d6416c2017-04-18 10:06:28 -0700146 name: "libsoftkeymasterdevice",
Steven Moreland7d6416c2017-04-18 10:06:28 -0700147 srcs: [
Janis Danisevskis3bfda162017-05-12 13:10:41 -0700148 "android_keymaster/keymaster_configuration.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700149 "legacy_support/ec_keymaster0_key.cpp",
150 "legacy_support/ec_keymaster1_key.cpp",
151 "legacy_support/ecdsa_keymaster1_operation.cpp",
152 "legacy_support/keymaster0_engine.cpp",
153 "legacy_support/keymaster1_engine.cpp",
154 "legacy_support/rsa_keymaster0_key.cpp",
155 "legacy_support/rsa_keymaster1_key.cpp",
156 "legacy_support/rsa_keymaster1_operation.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700157 "legacy_support/keymaster1_legacy_support.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700158 "contexts/soft_keymaster_context.cpp",
Shawn Willdendd7e8a02018-01-12 13:03:37 -0700159 "contexts/pure_soft_keymaster_context.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700160 "contexts/soft_keymaster_device.cpp",
Janis Danisevskis1455d2e2017-05-11 10:56:27 -0700161 "km_openssl/soft_keymaster_enforcement.cpp",
Janis Danisevskisf54cc932017-05-10 15:29:10 -0700162 "contexts/soft_keymaster_logger.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",
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",
216 "contexts/soft_keymaster_logger.cpp",
217 "km_openssl/soft_keymaster_enforcement.cpp",
218 ],
219 defaults: ["keymaster_defaults"],
220 host_supported: true,
221 device_supported: false,
222 shared_libs: [
223 "libkeymaster_messages",
224 "libkeymaster_portable",
225 "libsoft_attestation_cert",
226 "liblog",
227 "libcrypto",
228 "libcutils",
229 "libbase",
230 ],
231 clang_cflags: [
232 "-DKEYMASTER_NAME_TAGS",
233 "-fno-rtti", // TODO(b/156427382): Remove workaround when possible.
234 ],
235 export_include_dirs: ["include"],
236}
237
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000238cc_library_shared {
239 name: "libkeymaster3device",
240 srcs: [
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700241 "legacy_support/keymaster_passthrough_key.cpp",
242 "legacy_support/keymaster_passthrough_engine.cpp",
243 "legacy_support/keymaster_passthrough_operation.cpp",
244 "contexts/keymaster1_passthrough_context.cpp",
245 "contexts/keymaster2_passthrough_context.cpp",
Janis Danisevskisa68669b2017-02-06 11:46:54 +0000246 "ng/AndroidKeymaster3Device.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700247 "android_keymaster/keymaster_configuration.cpp",
Janis Danisevskis2fea2352017-07-26 16:52:33 -0700248 "legacy_support/ec_keymaster0_key.cpp",
249 "legacy_support/ec_keymaster1_key.cpp",
250 "legacy_support/ecdsa_keymaster1_operation.cpp",
251 "legacy_support/keymaster0_engine.cpp",
252 "legacy_support/keymaster1_engine.cpp",
253 "legacy_support/keymaster1_legacy_support.cpp",
254 "legacy_support/rsa_keymaster0_key.cpp",
255 "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
Selene Huangfb818292020-05-27 04:58:16 -0700330
331cc_library_shared {
332 name: "libkeymint1",
333 vendor_available: true,
334 srcs: [
335 "legacy_support/keymaster_passthrough_key.cpp",
336 "legacy_support/keymaster_passthrough_engine.cpp",
337 "legacy_support/keymaster_passthrough_operation.cpp",
338 "ng/KeyMintAidlUtils.cpp",
339 "ng/AndroidKeyMint1Device.cpp",
340 "ng/AndroidKeyMint1Operation.cpp",
341 "android_keymaster/keymaster_configuration.cpp",
342 ],
343 defaults: ["keymaster_defaults"],
344 shared_libs: [
345 "libkeymaster_messages",
346 "android.hardware.keymint-ndk_platform",
347 "libbase",
348 "libcrypto",
349 "libcutils",
350 "libbinder_ndk",
351 "libcppbor",
352 "libhidlbase",
353 "libkeymaster_portable",
354 "libkeymaster_messages",
355 "libpuresoftkeymasterdevice",
356 "liblog",
357 "libutils",
358 ],
359 export_include_dirs: ["include", "ng/include"],
360}
361
362
Steven Moreland7d6416c2017-04-18 10:06:28 -0700363// libkeymasterfiles is an empty library that exports all of the files in keymaster as includes.
364cc_library_static {
365 name: "libkeymasterfiles",
366 export_include_dirs: [
367 ".",
368 "include",
369 ],
370}
Corbin Souffrante9474442020-08-28 16:46:58 -0700371
372cc_defaults {
373 name: "keymaster_fuzz_defaults",
374 header_libs: ["libhardware_headers"],
375 shared_libs: [
376 "libkeymaster_messages",
377 ],
378 // Not using defaults because the fuzzer relies on sanitizers that are explicitly disabled there.
379 cflags: [
380 "-Wall",
381 "-Werror",
382 "-Wunused",
383 "-Wno-error=unused-const-variable",
384 "-Wno-error=unused-private-field",
385 "-Wimplicit-fallthrough",
386 "-DKEYMASTER_NAME_TAGS",
387 ],
388 host_supported: true,
389 target: {
390 host: {
391 clang_cflags: [
392 "-fno-rtti", // TODO(b/156427382): Remove when default library removes this
393 ],
394 },
395 },
396}
397
398cc_fuzz {
399 name: "libkeymaster_fuzz_buffer",
400 defaults: ["keymaster_fuzz_defaults"],
401 srcs: [
402 "tests/fuzzers/buffer_fuzz.cpp",
403 ],
404}
405
406cc_fuzz {
407 name: "libkeymaster_fuzz_serializable",
408 defaults: ["keymaster_fuzz_defaults"],
409 srcs: [
410 "tests/fuzzers/message_serializable_fuzz.cpp",
411 ],
412}