blob: 7673400dbe2f45a4608dde1e43ac000940fd6eb7 [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 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -080038}
39
40cc_library {
41 name: "libkeystore2_crypto",
42 srcs: [
43 "crypto.cpp",
44 "certificate_utils.cpp",
45 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -080046 export_include_dirs: ["include"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080047 shared_libs: [
48 "libcrypto",
49 "liblog",
50 ],
51}
52
53rust_bindgen {
54 name: "libkeystore2_crypto_bindgen",
55 wrapper_src: "crypto.hpp",
56 crate_name: "keystore2_crypto_bindgen",
57 source_stem: "bindings",
58 host_supported: true,
Joel Galenson05914582021-01-08 09:30:41 -080059 shared_libs: ["libcrypto"],
60 bindgen_flags: [
61 "--size_t-is-usize",
62 "--whitelist-function", "randomBytes",
63 "--whitelist-function", "AES_gcm_encrypt",
64 "--whitelist-function", "AES_gcm_decrypt",
65 "--whitelist-function", "CreateKeyId",
66 "--whitelist-function", "generateKeyFromPassword",
67 "--whitelist-function", "HKDFExtract",
68 "--whitelist-function", "HKDFExpand",
69 "--whitelist-function", "ECDHComputeKey",
70 "--whitelist-function", "ECKEYGenerateKey",
71 "--whitelist-function", "ECKEYDeriveFromSecret",
72 "--whitelist-function", "EC_KEY_get0_public_key",
73 "--whitelist-function", "ECPOINTPoint2Oct",
74 "--whitelist-function", "ECPOINTOct2Point",
75 "--whitelist-function", "EC_KEY_free",
76 "--whitelist-function", "EC_POINT_free",
77 "--whitelist-type", "EC_KEY",
78 "--whitelist-type", "EC_POINT",
79 "--whitelist-var", "EC_MAX_BYTES",
80 "--whitelist-var", "EVP_MAX_MD_SIZE",
81 ],
82 cflags: ["-DBORINGSSL_NO_CXX"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080083}
84
85rust_test {
86 name: "keystore2_crypto_test_rust",
87 crate_name: "keystore2_crypto_test_rust",
88 srcs: ["lib.rs"],
89 test_suites: ["general-tests"],
90 auto_gen_config: true,
91 rustlibs: [
92 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080093 "liblog_rust",
94 "libnix",
95 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -080096 ],
97 static_libs: [
98 "libkeystore2_crypto",
99 ],
100 shared_libs: [
101 "libc++",
102 "libcrypto",
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800103 "liblog",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800104 ],
105}
106
107cc_test {
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800108 name: "keystore2_crypto_test",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800109 cflags: [
110 "-Wall",
111 "-Werror",
112 "-Wextra",
113 ],
114 srcs: [
115 "tests/certificate_utils_test.cpp",
116 "tests/gtest_main.cpp",
117 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800118 test_suites: ["general-tests"],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800119 static_libs: [
120 "libkeystore2_crypto",
121 ],
122 shared_libs: [
123 "libcrypto",
124 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800125}