blob: 9ecd823db112aee8f4e856fdb24d130f1496daec [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
15rust_library {
16 name: "libkeystore2_crypto_rust",
17 crate_name: "keystore2_crypto",
18 srcs: ["lib.rs"],
19 rustlibs: [
20 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080021 "liblog_rust",
22 "libnix",
23 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -080024 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -080025 shared_libs: [
26 "libkeystore2_crypto",
27 "libcrypto",
28 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -080029}
30
31cc_library {
32 name: "libkeystore2_crypto",
33 srcs: [
34 "crypto.cpp",
35 "certificate_utils.cpp",
36 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -080037 export_include_dirs: ["include"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080038 shared_libs: [
39 "libcrypto",
40 "liblog",
41 ],
42}
43
44rust_bindgen {
45 name: "libkeystore2_crypto_bindgen",
46 wrapper_src: "crypto.hpp",
47 crate_name: "keystore2_crypto_bindgen",
48 source_stem: "bindings",
49 host_supported: true,
Joel Galenson05914582021-01-08 09:30:41 -080050 shared_libs: ["libcrypto"],
51 bindgen_flags: [
52 "--size_t-is-usize",
53 "--whitelist-function", "randomBytes",
54 "--whitelist-function", "AES_gcm_encrypt",
55 "--whitelist-function", "AES_gcm_decrypt",
56 "--whitelist-function", "CreateKeyId",
57 "--whitelist-function", "generateKeyFromPassword",
58 "--whitelist-function", "HKDFExtract",
59 "--whitelist-function", "HKDFExpand",
60 "--whitelist-function", "ECDHComputeKey",
61 "--whitelist-function", "ECKEYGenerateKey",
62 "--whitelist-function", "ECKEYDeriveFromSecret",
63 "--whitelist-function", "EC_KEY_get0_public_key",
64 "--whitelist-function", "ECPOINTPoint2Oct",
65 "--whitelist-function", "ECPOINTOct2Point",
66 "--whitelist-function", "EC_KEY_free",
67 "--whitelist-function", "EC_POINT_free",
68 "--whitelist-type", "EC_KEY",
69 "--whitelist-type", "EC_POINT",
70 "--whitelist-var", "EC_MAX_BYTES",
71 "--whitelist-var", "EVP_MAX_MD_SIZE",
72 ],
73 cflags: ["-DBORINGSSL_NO_CXX"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080074}
75
76rust_test {
77 name: "keystore2_crypto_test_rust",
78 crate_name: "keystore2_crypto_test_rust",
79 srcs: ["lib.rs"],
80 test_suites: ["general-tests"],
81 auto_gen_config: true,
82 rustlibs: [
83 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080084 "liblog_rust",
85 "libnix",
86 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -080087 ],
88 static_libs: [
89 "libkeystore2_crypto",
90 ],
91 shared_libs: [
92 "libc++",
93 "libcrypto",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080094 "liblog",
Joel Galenson46d6fd02020-11-19 17:58:33 -080095 ],
96}
97
98cc_test {
Janis Danisevskis9d90b812020-11-25 21:02:11 -080099 name: "keystore2_crypto_test",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800100 cflags: [
101 "-Wall",
102 "-Werror",
103 "-Wextra",
104 ],
105 srcs: [
106 "tests/certificate_utils_test.cpp",
107 "tests/gtest_main.cpp",
108 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800109 test_suites: ["general-tests"],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800110 static_libs: [
111 "libkeystore2_crypto",
112 ],
113 shared_libs: [
114 "libcrypto",
115 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800116}