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 vendor_available: true, 39 apex_available: [ 40 "//apex_available:platform", 41 "com.android.virt", 42 ], 43} 44 45cc_library { 46 name: "libkeystore2_crypto", 47 srcs: [ 48 "crypto.cpp", 49 "certificate_utils.cpp", 50 ], 51 export_include_dirs: ["include"], 52 shared_libs: [ 53 "libcrypto", 54 "liblog", 55 ], 56 vendor_available: true, 57 apex_available: [ 58 "//apex_available:platform", 59 "com.android.virt", 60 ], 61} 62 63rust_bindgen { 64 name: "libkeystore2_crypto_bindgen", 65 wrapper_src: "crypto.hpp", 66 crate_name: "keystore2_crypto_bindgen", 67 source_stem: "bindings", 68 host_supported: true, 69 vendor_available: true, 70 shared_libs: ["libcrypto"], 71 bindgen_flags: [ 72 "--size_t-is-usize", 73 "--allowlist-function", "hmacSha256", 74 "--allowlist-function", "randomBytes", 75 "--allowlist-function", "AES_gcm_encrypt", 76 "--allowlist-function", "AES_gcm_decrypt", 77 "--allowlist-function", "CreateKeyId", 78 "--allowlist-function", "generateKeyFromPassword", 79 "--allowlist-function", "HKDFExtract", 80 "--allowlist-function", "HKDFExpand", 81 "--allowlist-function", "ECDHComputeKey", 82 "--allowlist-function", "ECKEYGenerateKey", 83 "--allowlist-function", "ECKEYMarshalPrivateKey", 84 "--allowlist-function", "ECKEYParsePrivateKey", 85 "--allowlist-function", "EC_KEY_get0_public_key", 86 "--allowlist-function", "ECPOINTPoint2Oct", 87 "--allowlist-function", "ECPOINTOct2Point", 88 "--allowlist-function", "EC_KEY_free", 89 "--allowlist-function", "EC_POINT_free", 90 "--allowlist-function", "extractSubjectFromCertificate", 91 "--allowlist-type", "EC_KEY", 92 "--allowlist-type", "EC_POINT", 93 "--allowlist-var", "EC_MAX_BYTES", 94 "--allowlist-var", "EVP_MAX_MD_SIZE", 95 ], 96 cflags: ["-DBORINGSSL_NO_CXX"], 97 apex_available: [ 98 "//apex_available:platform", 99 "com.android.virt", 100 ], 101} 102 103rust_test { 104 name: "keystore2_crypto_test_rust", 105 crate_name: "keystore2_crypto_test_rust", 106 srcs: ["lib.rs"], 107 test_suites: ["general-tests"], 108 auto_gen_config: true, 109 rustlibs: [ 110 "libkeystore2_crypto_bindgen", 111 "liblog_rust", 112 "libnix", 113 "libthiserror", 114 ], 115 static_libs: [ 116 "libkeystore2_crypto", 117 ], 118 shared_libs: [ 119 "libc++", 120 "libcrypto", 121 "liblog", 122 ], 123} 124 125cc_test { 126 name: "keystore2_crypto_test", 127 cflags: [ 128 "-Wall", 129 "-Werror", 130 "-Wextra", 131 ], 132 srcs: [ 133 "tests/certificate_utils_test.cpp", 134 "tests/gtest_main.cpp", 135 ], 136 test_suites: ["general-tests"], 137 static_libs: [ 138 "libkeystore2_crypto", 139 ], 140 shared_libs: [ 141 "libcrypto", 142 ], 143} 144 145rust_test { 146 name: "libkeystore2_crypto_bindgen_test", 147 srcs: [":libkeystore2_crypto_bindgen"], 148 crate_name: "keystore2_crypto_bindgen_test", 149 test_suites: ["general-tests"], 150 auto_gen_config: true, 151 clippy_lints: "none", 152 lints: "none", 153 apex_available: [ 154 "//apex_available:platform", 155 "com.android.virt", 156 ], 157} 158