blob: 76c02c589dca8bc8f3f902e66a1b207ce86a81bf [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",
Joel Galenson915d3ea2021-04-19 09:02:41 -070065 "--allowlist-function", "randomBytes",
66 "--allowlist-function", "AES_gcm_encrypt",
67 "--allowlist-function", "AES_gcm_decrypt",
68 "--allowlist-function", "CreateKeyId",
69 "--allowlist-function", "generateKeyFromPassword",
70 "--allowlist-function", "HKDFExtract",
71 "--allowlist-function", "HKDFExpand",
72 "--allowlist-function", "ECDHComputeKey",
73 "--allowlist-function", "ECKEYGenerateKey",
74 "--allowlist-function", "ECKEYMarshalPrivateKey",
75 "--allowlist-function", "ECKEYParsePrivateKey",
76 "--allowlist-function", "EC_KEY_get0_public_key",
77 "--allowlist-function", "ECPOINTPoint2Oct",
78 "--allowlist-function", "ECPOINTOct2Point",
79 "--allowlist-function", "EC_KEY_free",
80 "--allowlist-function", "EC_POINT_free",
81 "--allowlist-function", "extractSubjectFromCertificate",
82 "--allowlist-type", "EC_KEY",
83 "--allowlist-type", "EC_POINT",
84 "--allowlist-var", "EC_MAX_BYTES",
85 "--allowlist-var", "EVP_MAX_MD_SIZE",
Joel Galenson05914582021-01-08 09:30:41 -080086 ],
87 cflags: ["-DBORINGSSL_NO_CXX"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080088}
89
90rust_test {
91 name: "keystore2_crypto_test_rust",
92 crate_name: "keystore2_crypto_test_rust",
93 srcs: ["lib.rs"],
94 test_suites: ["general-tests"],
95 auto_gen_config: true,
96 rustlibs: [
97 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080098 "liblog_rust",
99 "libnix",
100 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800101 ],
102 static_libs: [
103 "libkeystore2_crypto",
104 ],
105 shared_libs: [
106 "libc++",
107 "libcrypto",
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800108 "liblog",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800109 ],
110}
111
112cc_test {
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800113 name: "keystore2_crypto_test",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800114 cflags: [
115 "-Wall",
116 "-Werror",
117 "-Wextra",
118 ],
119 srcs: [
120 "tests/certificate_utils_test.cpp",
121 "tests/gtest_main.cpp",
122 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800123 test_suites: ["general-tests"],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800124 static_libs: [
125 "libkeystore2_crypto",
126 ],
127 shared_libs: [
128 "libcrypto",
129 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800130}
Joel Galenson733d1d02021-08-23 13:47:37 -0700131
132rust_test {
133 name: "libkeystore2_crypto_bindgen_test",
134 srcs: [":libkeystore2_crypto_bindgen"],
135 crate_name: "keystore2_crypto_bindgen_test",
136 test_suites: ["general-tests"],
137 auto_gen_config: true,
138 clippy_lints: "none",
139 lints: "none",
140}