• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
15package {
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
24rust_library {
25    name: "libkeystore2_crypto_rust",
26    crate_name: "keystore2_crypto",
27    srcs: ["lib.rs"],
28    rustlibs: [
29        "libkeystore2_crypto_bindgen",
30        "liblog_rust",
31        "libnix",
32        "libthiserror",
33    ],
34    shared_libs: [
35        "libkeystore2_crypto",
36        "libcrypto",
37    ],
38}
39
40cc_library {
41    name: "libkeystore2_crypto",
42    srcs: [
43        "crypto.cpp",
44        "certificate_utils.cpp",
45    ],
46    export_include_dirs: ["include"],
47    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,
59    shared_libs: ["libcrypto"],
60    bindgen_flags: [
61        "--size_t-is-usize",
62        "--allowlist-function", "randomBytes",
63        "--allowlist-function", "AES_gcm_encrypt",
64        "--allowlist-function", "AES_gcm_decrypt",
65        "--allowlist-function", "CreateKeyId",
66        "--allowlist-function", "generateKeyFromPassword",
67        "--allowlist-function", "HKDFExtract",
68        "--allowlist-function", "HKDFExpand",
69        "--allowlist-function", "ECDHComputeKey",
70        "--allowlist-function", "ECKEYGenerateKey",
71        "--allowlist-function", "ECKEYMarshalPrivateKey",
72        "--allowlist-function", "ECKEYParsePrivateKey",
73        "--allowlist-function", "EC_KEY_get0_public_key",
74        "--allowlist-function", "ECPOINTPoint2Oct",
75        "--allowlist-function", "ECPOINTOct2Point",
76        "--allowlist-function", "EC_KEY_free",
77        "--allowlist-function", "EC_POINT_free",
78        "--allowlist-function", "extractSubjectFromCertificate",
79        "--allowlist-type", "EC_KEY",
80        "--allowlist-type", "EC_POINT",
81        "--allowlist-var", "EC_MAX_BYTES",
82        "--allowlist-var", "EVP_MAX_MD_SIZE",
83    ],
84    cflags: ["-DBORINGSSL_NO_CXX"],
85}
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",
95        "liblog_rust",
96        "libnix",
97        "libthiserror",
98    ],
99    static_libs: [
100        "libkeystore2_crypto",
101    ],
102    shared_libs: [
103        "libc++",
104        "libcrypto",
105        "liblog",
106    ],
107}
108
109cc_test {
110    name: "keystore2_crypto_test",
111    cflags: [
112        "-Wall",
113        "-Werror",
114        "-Wextra",
115    ],
116    srcs: [
117        "tests/certificate_utils_test.cpp",
118        "tests/gtest_main.cpp",
119    ],
120    test_suites: ["general-tests"],
121    static_libs: [
122        "libkeystore2_crypto",
123    ],
124    shared_libs: [
125        "libcrypto",
126    ],
127}
128