blob: 35fc5a90039eb04787489fd3bdd48e9c2066ca03 [file] [log] [blame]
Joel Galenson46d6fd02020-11-19 17:58:33 -08001// Copyright 2020, 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
Bob Badour4c7858c2021-02-12 15:40:29 -080015package {
16 // See: http://go/android-license-faq
17 // A large-scale-change added 'default_applicable_licenses' to import
18 // all of the 'license_kinds' from "system_security_license"
19 // to get the below license kinds:
20 // SPDX-license-identifier-Apache-2.0
21 default_applicable_licenses: ["system_security_license"],
22}
23
Joel Galenson46d6fd02020-11-19 17:58:33 -080024rust_library {
25 name: "libkeystore2_crypto_rust",
26 crate_name: "keystore2_crypto",
27 srcs: ["lib.rs"],
28 rustlibs: [
29 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080030 "liblog_rust",
31 "libnix",
32 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -080033 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -080034 shared_libs: [
35 "libkeystore2_crypto",
36 "libcrypto",
37 ],
Janis Danisevskisaaba4af2021-11-18 14:25:07 -080038 vendor_available: true,
Andrew Scullf4a6e282022-07-12 15:27:00 +000039 apex_available: [
40 "//apex_available:platform",
41 "com.android.virt",
42 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -080043}
44
45cc_library {
46 name: "libkeystore2_crypto",
47 srcs: [
48 "crypto.cpp",
49 "certificate_utils.cpp",
50 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -080051 export_include_dirs: ["include"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080052 shared_libs: [
53 "libcrypto",
54 "liblog",
55 ],
Janis Danisevskisaaba4af2021-11-18 14:25:07 -080056 vendor_available: true,
Andrew Scullf4a6e282022-07-12 15:27:00 +000057 apex_available: [
58 "//apex_available:platform",
59 "com.android.virt",
60 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -080061}
62
63rust_bindgen {
64 name: "libkeystore2_crypto_bindgen",
65 wrapper_src: "crypto.hpp",
66 crate_name: "keystore2_crypto_bindgen",
67 source_stem: "bindings",
68 host_supported: true,
Janis Danisevskisaaba4af2021-11-18 14:25:07 -080069 vendor_available: true,
Joel Galenson05914582021-01-08 09:30:41 -080070 shared_libs: ["libcrypto"],
71 bindgen_flags: [
David Drysdalec97eb9e2022-01-26 13:03:48 -080072 "--allowlist-function", "hmacSha256",
Joel Galenson915d3ea2021-04-19 09:02:41 -070073 "--allowlist-function", "randomBytes",
74 "--allowlist-function", "AES_gcm_encrypt",
75 "--allowlist-function", "AES_gcm_decrypt",
76 "--allowlist-function", "CreateKeyId",
77 "--allowlist-function", "generateKeyFromPassword",
78 "--allowlist-function", "HKDFExtract",
79 "--allowlist-function", "HKDFExpand",
80 "--allowlist-function", "ECDHComputeKey",
81 "--allowlist-function", "ECKEYGenerateKey",
82 "--allowlist-function", "ECKEYMarshalPrivateKey",
83 "--allowlist-function", "ECKEYParsePrivateKey",
84 "--allowlist-function", "EC_KEY_get0_public_key",
85 "--allowlist-function", "ECPOINTPoint2Oct",
86 "--allowlist-function", "ECPOINTOct2Point",
87 "--allowlist-function", "EC_KEY_free",
88 "--allowlist-function", "EC_POINT_free",
89 "--allowlist-function", "extractSubjectFromCertificate",
90 "--allowlist-type", "EC_KEY",
91 "--allowlist-type", "EC_POINT",
92 "--allowlist-var", "EC_MAX_BYTES",
93 "--allowlist-var", "EVP_MAX_MD_SIZE",
Joel Galenson05914582021-01-08 09:30:41 -080094 ],
95 cflags: ["-DBORINGSSL_NO_CXX"],
Andrew Scullf4a6e282022-07-12 15:27:00 +000096 apex_available: [
97 "//apex_available:platform",
98 "com.android.virt",
99 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800100}
101
102rust_test {
103 name: "keystore2_crypto_test_rust",
104 crate_name: "keystore2_crypto_test_rust",
105 srcs: ["lib.rs"],
106 test_suites: ["general-tests"],
107 auto_gen_config: true,
108 rustlibs: [
109 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800110 "liblog_rust",
111 "libnix",
112 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800113 ],
114 static_libs: [
115 "libkeystore2_crypto",
116 ],
117 shared_libs: [
118 "libc++",
119 "libcrypto",
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800120 "liblog",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800121 ],
122}
123
124cc_test {
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800125 name: "keystore2_crypto_test",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800126 cflags: [
127 "-Wall",
128 "-Werror",
129 "-Wextra",
130 ],
131 srcs: [
132 "tests/certificate_utils_test.cpp",
133 "tests/gtest_main.cpp",
134 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800135 test_suites: ["general-tests"],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800136 static_libs: [
137 "libkeystore2_crypto",
138 ],
139 shared_libs: [
140 "libcrypto",
141 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800142}
Joel Galenson733d1d02021-08-23 13:47:37 -0700143
144rust_test {
145 name: "libkeystore2_crypto_bindgen_test",
146 srcs: [":libkeystore2_crypto_bindgen"],
147 crate_name: "keystore2_crypto_bindgen_test",
148 test_suites: ["general-tests"],
149 auto_gen_config: true,
150 clippy_lints: "none",
151 lints: "none",
Andrew Scullf4a6e282022-07-12 15:27:00 +0000152 apex_available: [
153 "//apex_available:platform",
154 "com.android.virt",
155 ],
Joel Galenson733d1d02021-08-23 13:47:37 -0700156}