blob: c3f6f3c8719f08b81499faab1f277e1a7da6e002 [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,
Joel Galenson46d6fd02020-11-19 17:58:33 -080039}
40
41cc_library {
42 name: "libkeystore2_crypto",
43 srcs: [
44 "crypto.cpp",
45 "certificate_utils.cpp",
46 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -080047 export_include_dirs: ["include"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080048 shared_libs: [
49 "libcrypto",
50 "liblog",
51 ],
Janis Danisevskisaaba4af2021-11-18 14:25:07 -080052 vendor_available: true,
Joel Galenson46d6fd02020-11-19 17:58:33 -080053}
54
55rust_bindgen {
56 name: "libkeystore2_crypto_bindgen",
57 wrapper_src: "crypto.hpp",
58 crate_name: "keystore2_crypto_bindgen",
59 source_stem: "bindings",
60 host_supported: true,
Janis Danisevskisaaba4af2021-11-18 14:25:07 -080061 vendor_available: true,
Joel Galenson05914582021-01-08 09:30:41 -080062 shared_libs: ["libcrypto"],
63 bindgen_flags: [
64 "--size_t-is-usize",
David Drysdalec97eb9e2022-01-26 13:03:48 -080065 "--allowlist-function", "hmacSha256",
Joel Galenson915d3ea2021-04-19 09:02:41 -070066 "--allowlist-function", "randomBytes",
67 "--allowlist-function", "AES_gcm_encrypt",
68 "--allowlist-function", "AES_gcm_decrypt",
69 "--allowlist-function", "CreateKeyId",
70 "--allowlist-function", "generateKeyFromPassword",
71 "--allowlist-function", "HKDFExtract",
72 "--allowlist-function", "HKDFExpand",
73 "--allowlist-function", "ECDHComputeKey",
74 "--allowlist-function", "ECKEYGenerateKey",
75 "--allowlist-function", "ECKEYMarshalPrivateKey",
76 "--allowlist-function", "ECKEYParsePrivateKey",
77 "--allowlist-function", "EC_KEY_get0_public_key",
78 "--allowlist-function", "ECPOINTPoint2Oct",
79 "--allowlist-function", "ECPOINTOct2Point",
80 "--allowlist-function", "EC_KEY_free",
81 "--allowlist-function", "EC_POINT_free",
82 "--allowlist-function", "extractSubjectFromCertificate",
83 "--allowlist-type", "EC_KEY",
84 "--allowlist-type", "EC_POINT",
85 "--allowlist-var", "EC_MAX_BYTES",
86 "--allowlist-var", "EVP_MAX_MD_SIZE",
Joel Galenson05914582021-01-08 09:30:41 -080087 ],
88 cflags: ["-DBORINGSSL_NO_CXX"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080089}
90
91rust_test {
92 name: "keystore2_crypto_test_rust",
93 crate_name: "keystore2_crypto_test_rust",
94 srcs: ["lib.rs"],
95 test_suites: ["general-tests"],
96 auto_gen_config: true,
97 rustlibs: [
98 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080099 "liblog_rust",
100 "libnix",
101 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800102 ],
103 static_libs: [
104 "libkeystore2_crypto",
105 ],
106 shared_libs: [
107 "libc++",
108 "libcrypto",
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800109 "liblog",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800110 ],
111}
112
113cc_test {
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800114 name: "keystore2_crypto_test",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800115 cflags: [
116 "-Wall",
117 "-Werror",
118 "-Wextra",
119 ],
120 srcs: [
121 "tests/certificate_utils_test.cpp",
122 "tests/gtest_main.cpp",
123 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800124 test_suites: ["general-tests"],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800125 static_libs: [
126 "libkeystore2_crypto",
127 ],
128 shared_libs: [
129 "libcrypto",
130 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800131}
Joel Galenson733d1d02021-08-23 13:47:37 -0700132
133rust_test {
134 name: "libkeystore2_crypto_bindgen_test",
135 srcs: [":libkeystore2_crypto_bindgen"],
136 crate_name: "keystore2_crypto_bindgen_test",
137 test_suites: ["general-tests"],
138 auto_gen_config: true,
139 clippy_lints: "none",
140 lints: "none",
141}