blob: 21c9b745f3899eff3f368e330b5bad6fd7f69b19 [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",
Paul Crowley7bb5edd2021-03-20 20:26:43 -070071 "--whitelist-function", "ECKEYMarshalPrivateKey",
72 "--whitelist-function", "ECKEYParsePrivateKey",
Joel Galenson05914582021-01-08 09:30:41 -080073 "--whitelist-function", "EC_KEY_get0_public_key",
74 "--whitelist-function", "ECPOINTPoint2Oct",
75 "--whitelist-function", "ECPOINTOct2Point",
76 "--whitelist-function", "EC_KEY_free",
77 "--whitelist-function", "EC_POINT_free",
Shawn Willden8fde4c22021-02-14 13:58:22 -070078 "--whitelist-function", "extractSubjectFromCertificate",
Joel Galenson05914582021-01-08 09:30:41 -080079 "--whitelist-type", "EC_KEY",
80 "--whitelist-type", "EC_POINT",
81 "--whitelist-var", "EC_MAX_BYTES",
82 "--whitelist-var", "EVP_MAX_MD_SIZE",
83 ],
84 cflags: ["-DBORINGSSL_NO_CXX"],
Joel Galenson46d6fd02020-11-19 17:58:33 -080085}
86
87rust_test {
88 name: "keystore2_crypto_test_rust",
89 crate_name: "keystore2_crypto_test_rust",
90 srcs: ["lib.rs"],
91 test_suites: ["general-tests"],
92 auto_gen_config: true,
93 rustlibs: [
94 "libkeystore2_crypto_bindgen",
Janis Danisevskis9d90b812020-11-25 21:02:11 -080095 "liblog_rust",
96 "libnix",
97 "libthiserror",
Joel Galenson46d6fd02020-11-19 17:58:33 -080098 ],
99 static_libs: [
100 "libkeystore2_crypto",
101 ],
102 shared_libs: [
103 "libc++",
104 "libcrypto",
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800105 "liblog",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800106 ],
107}
108
109cc_test {
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800110 name: "keystore2_crypto_test",
Joel Galenson46d6fd02020-11-19 17:58:33 -0800111 cflags: [
112 "-Wall",
113 "-Werror",
114 "-Wextra",
115 ],
116 srcs: [
117 "tests/certificate_utils_test.cpp",
118 "tests/gtest_main.cpp",
119 ],
Janis Danisevskis9d90b812020-11-25 21:02:11 -0800120 test_suites: ["general-tests"],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800121 static_libs: [
122 "libkeystore2_crypto",
123 ],
124 shared_libs: [
125 "libcrypto",
126 ],
Joel Galenson46d6fd02020-11-19 17:58:33 -0800127}