1# 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
15LOCAL_PATH := $(call my-dir)
16
17###
18# libkeymaster_messages contains just the code necessary to communicate with a
19# AndroidKeymaster implementation, e.g. one running in TrustZone.
20##
21include $(CLEAR_VARS)
22LOCAL_MODULE:= libkeymaster_messages
23LOCAL_SRC_FILES:= \
24		android_keymaster_messages.cpp \
25		android_keymaster_utils.cpp \
26		authorization_set.cpp \
27		keymaster_tags.cpp \
28		logger.cpp \
29		serializable.cpp
30LOCAL_C_INCLUDES := \
31	$(LOCAL_PATH)/include
32LOCAL_CFLAGS = -Wall -Werror -Wunused -DKEYMASTER_NAME_TAGS
33LOCAL_CLANG := true
34# TODO(krasin): reenable coverage flags, when the new Clang toolchain is released.
35# Currently, if enabled, these flags will cause an internal error in Clang.
36LOCAL_CLANG_CFLAGS += -fno-sanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
37LOCAL_MODULE_TAGS := optional
38LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
39LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
40include $(BUILD_SHARED_LIBRARY)
41
42###
43# libkeymaster1 contains almost everything needed for a keymaster1
44# implementation, lacking only a subclass of the (abstract) KeymasterContext
45# class to provide environment-specific services and a wrapper to translate from
46# the function-based keymaster HAL API to the message-based AndroidKeymaster API.
47###
48include $(CLEAR_VARS)
49LOCAL_MODULE:= libkeymaster1
50LOCAL_SRC_FILES:= \
51		aes_key.cpp \
52		aes_operation.cpp \
53		android_keymaster.cpp \
54		android_keymaster_messages.cpp \
55		android_keymaster_utils.cpp \
56		asymmetric_key.cpp \
57		asymmetric_key_factory.cpp \
58		attestation_record.cpp \
59		auth_encrypted_key_blob.cpp \
60		ec_key.cpp \
61		ec_key_factory.cpp \
62		ecdsa_operation.cpp \
63		ecies_kem.cpp \
64		hkdf.cpp \
65		hmac.cpp \
66		hmac_key.cpp \
67		hmac_operation.cpp \
68		integrity_assured_key_blob.cpp \
69		iso18033kdf.cpp \
70		kdf.cpp \
71		key.cpp \
72		keymaster_enforcement.cpp \
73		nist_curve_key_exchange.cpp \
74		ocb.c \
75		ocb_utils.cpp \
76		openssl_err.cpp \
77		openssl_utils.cpp \
78		operation.cpp \
79		operation_table.cpp \
80		rsa_key.cpp \
81		rsa_key_factory.cpp \
82		rsa_operation.cpp \
83		symmetric_key.cpp
84LOCAL_C_INCLUDES := \
85	$(LOCAL_PATH)/include
86LOCAL_SHARED_LIBRARIES := libcrypto libkeymaster_messages
87LOCAL_CFLAGS = -Wall -Werror -Wunused
88LOCAL_CLANG := true
89LOCAL_CLANG_CFLAGS += -Wno-error=unused-const-variable -Wno-error=unused-private-field
90# TODO(krasin): reenable coverage flags, when the new Clang toolchain is released.
91# Currently, if enabled, these flags will cause an internal error in Clang.
92LOCAL_CLANG_CFLAGS += -fno-sanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
93# Ignore benign warnings for now.
94LOCAL_CLANG_CFLAGS += -Wno-error=unused-private-field
95LOCAL_MODULE_TAGS := optional
96LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
97LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
98include $(BUILD_SHARED_LIBRARY)
99
100
101###
102# libsoftkeymaster provides a software-based keymaster HAL implementation.
103# This is used by keystore as a fallback for when the hardware keymaster does
104# not support the request.
105###
106include $(CLEAR_VARS)
107LOCAL_MODULE := libsoftkeymasterdevice
108LOCAL_SRC_FILES := \
109	ec_keymaster0_key.cpp \
110	ec_keymaster1_key.cpp \
111	ecdsa_keymaster1_operation.cpp \
112	keymaster0_engine.cpp \
113	keymaster1_engine.cpp \
114	keymaster_configuration.cpp \
115	rsa_keymaster0_key.cpp \
116	rsa_keymaster1_key.cpp \
117	rsa_keymaster1_operation.cpp \
118	soft_keymaster_context.cpp \
119	soft_keymaster_device.cpp \
120	soft_keymaster_logger.cpp
121LOCAL_C_INCLUDES := \
122	system/security/keystore \
123	$(LOCAL_PATH)/include
124LOCAL_CFLAGS = -Wall -Werror -Wunused
125LOCAL_CLANG := true
126LOCAL_CLANG_CFLAGS += -Wno-error=unused-const-variable -Wno-error=unused-private-field
127# TODO(krasin): reenable coverage flags, when the new Clang toolchain is released.
128# Currently, if enabled, these flags will cause an internal error in Clang.
129LOCAL_CLANG_CFLAGS += -fno-sanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
130LOCAL_SHARED_LIBRARIES := libkeymaster_messages libkeymaster1 liblog libcrypto libcutils
131LOCAL_MODULE_TAGS := optional
132LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
133LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
134include $(BUILD_SHARED_LIBRARY)
135
136###
137# libkeymasterfiles is an empty library that exports all of the files in keymaster as includes.
138###
139include $(CLEAR_VARS)
140LOCAL_MODULE := libkeymasterfiles
141LOCAL_EXPORT_C_INCLUDE_DIRS := \
142	$(LOCAL_PATH) \
143	$(LOCAL_PATH)/include
144LOCAL_MODULE_TAGS := optional
145LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
146include $(BUILD_STATIC_LIBRARY)
147
148# Unit tests for libkeymaster
149include $(CLEAR_VARS)
150LOCAL_MODULE := keymaster_tests
151LOCAL_SRC_FILES := \
152	android_keymaster_messages_test.cpp \
153	android_keymaster_test.cpp \
154	android_keymaster_test_utils.cpp \
155	attestation_record_test.cpp \
156	authorization_set_test.cpp \
157	hkdf_test.cpp \
158	hmac_test.cpp \
159	kdf1_test.cpp \
160	kdf2_test.cpp \
161	kdf_test.cpp \
162	key_blob_test.cpp \
163	keymaster_enforcement_test.cpp
164
165LOCAL_C_INCLUDES := \
166	$(LOCAL_PATH)/include
167LOCAL_CFLAGS = -Wall -Werror -Wunused -DKEYMASTER_NAME_TAGS
168LOCAL_CLANG := true
169LOCAL_CLANG_CFLAGS += -Wno-error=unused-const-variable -Wno-error=unused-private-field
170# TODO(krasin): reenable coverage flags, when the new Clang toolchain is released.
171# Currently, if enabled, these flags will cause an internal error in Clang.
172LOCAL_CLANG_CFLAGS += -fno-sanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
173LOCAL_MODULE_TAGS := tests
174LOCAL_SHARED_LIBRARIES := \
175	libsoftkeymasterdevice \
176	libkeymaster_messages \
177	libkeymaster1 \
178	libcrypto \
179	libsoftkeymaster
180LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
181include $(BUILD_NATIVE_TEST)
182