1*e1997b9aSAndroid Build Coastguard Worker// Copyright 2020, The Android Open Source Project 2*e1997b9aSAndroid Build Coastguard Worker// 3*e1997b9aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*e1997b9aSAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*e1997b9aSAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*e1997b9aSAndroid Build Coastguard Worker// 7*e1997b9aSAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*e1997b9aSAndroid Build Coastguard Worker// 9*e1997b9aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*e1997b9aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*e1997b9aSAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*e1997b9aSAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*e1997b9aSAndroid Build Coastguard Worker// limitations under the License. 14*e1997b9aSAndroid Build Coastguard Worker 15*e1997b9aSAndroid Build Coastguard Workerpackage { 16*e1997b9aSAndroid Build Coastguard Worker // See: http://go/android-license-faq 17*e1997b9aSAndroid Build Coastguard Worker // A large-scale-change added 'default_applicable_licenses' to import 18*e1997b9aSAndroid Build Coastguard Worker // all of the 'license_kinds' from "system_security_license" 19*e1997b9aSAndroid Build Coastguard Worker // to get the below license kinds: 20*e1997b9aSAndroid Build Coastguard Worker // SPDX-license-identifier-Apache-2.0 21*e1997b9aSAndroid Build Coastguard Worker default_applicable_licenses: ["system_security_license"], 22*e1997b9aSAndroid Build Coastguard Worker} 23*e1997b9aSAndroid Build Coastguard Worker 24*e1997b9aSAndroid Build Coastguard Workerrust_library { 25*e1997b9aSAndroid Build Coastguard Worker name: "libkeystore2_crypto_rust", 26*e1997b9aSAndroid Build Coastguard Worker crate_name: "keystore2_crypto", 27*e1997b9aSAndroid Build Coastguard Worker srcs: ["lib.rs"], 28*e1997b9aSAndroid Build Coastguard Worker rustlibs: [ 29*e1997b9aSAndroid Build Coastguard Worker "libkeystore2_crypto_bindgen", 30*e1997b9aSAndroid Build Coastguard Worker "liblog_rust", 31*e1997b9aSAndroid Build Coastguard Worker "libnix", 32*e1997b9aSAndroid Build Coastguard Worker "libthiserror", 33*e1997b9aSAndroid Build Coastguard Worker ], 34*e1997b9aSAndroid Build Coastguard Worker shared_libs: [ 35*e1997b9aSAndroid Build Coastguard Worker "libcrypto", 36*e1997b9aSAndroid Build Coastguard Worker "libkeystore2_crypto", 37*e1997b9aSAndroid Build Coastguard Worker ], 38*e1997b9aSAndroid Build Coastguard Worker vendor_available: true, 39*e1997b9aSAndroid Build Coastguard Worker apex_available: [ 40*e1997b9aSAndroid Build Coastguard Worker "//apex_available:platform", 41*e1997b9aSAndroid Build Coastguard Worker "com.android.virt", 42*e1997b9aSAndroid Build Coastguard Worker ], 43*e1997b9aSAndroid Build Coastguard Worker} 44*e1997b9aSAndroid Build Coastguard Worker 45*e1997b9aSAndroid Build Coastguard Workercc_library { 46*e1997b9aSAndroid Build Coastguard Worker name: "libkeystore2_crypto", 47*e1997b9aSAndroid Build Coastguard Worker srcs: [ 48*e1997b9aSAndroid Build Coastguard Worker "certificate_utils.cpp", 49*e1997b9aSAndroid Build Coastguard Worker "crypto.cpp", 50*e1997b9aSAndroid Build Coastguard Worker ], 51*e1997b9aSAndroid Build Coastguard Worker export_include_dirs: ["include"], 52*e1997b9aSAndroid Build Coastguard Worker shared_libs: [ 53*e1997b9aSAndroid Build Coastguard Worker "libcrypto", 54*e1997b9aSAndroid Build Coastguard Worker "liblog", 55*e1997b9aSAndroid Build Coastguard Worker ], 56*e1997b9aSAndroid Build Coastguard Worker vendor_available: true, 57*e1997b9aSAndroid Build Coastguard Worker apex_available: [ 58*e1997b9aSAndroid Build Coastguard Worker "//apex_available:platform", 59*e1997b9aSAndroid Build Coastguard Worker "com.android.virt", 60*e1997b9aSAndroid Build Coastguard Worker ], 61*e1997b9aSAndroid Build Coastguard Worker} 62*e1997b9aSAndroid Build Coastguard Worker 63*e1997b9aSAndroid Build Coastguard Workerrust_bindgen { 64*e1997b9aSAndroid Build Coastguard Worker name: "libkeystore2_crypto_bindgen", 65*e1997b9aSAndroid Build Coastguard Worker wrapper_src: "crypto.hpp", 66*e1997b9aSAndroid Build Coastguard Worker crate_name: "keystore2_crypto_bindgen", 67*e1997b9aSAndroid Build Coastguard Worker source_stem: "bindings", 68*e1997b9aSAndroid Build Coastguard Worker host_supported: true, 69*e1997b9aSAndroid Build Coastguard Worker vendor_available: true, 70*e1997b9aSAndroid Build Coastguard Worker shared_libs: ["libcrypto"], 71*e1997b9aSAndroid Build Coastguard Worker bindgen_flags: [ 72*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=AES_gcm_decrypt", 73*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=AES_gcm_encrypt", 74*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=CreateKeyId", 75*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=ECDHComputeKey", 76*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=ECKEYGenerateKey", 77*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=ECKEYMarshalPrivateKey", 78*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=ECKEYParsePrivateKey", 79*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=ECPOINTOct2Point", 80*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=ECPOINTPoint2Oct", 81*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=EC_KEY_free", 82*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=EC_KEY_get0_public_key", 83*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=EC_POINT_free", 84*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=HKDFExpand", 85*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=HKDFExtract", 86*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=PBKDF2", 87*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=extractSubjectFromCertificate", 88*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=hmacSha256", 89*e1997b9aSAndroid Build Coastguard Worker "--allowlist-function=randomBytes", 90*e1997b9aSAndroid Build Coastguard Worker "--allowlist-type=EC_KEY", 91*e1997b9aSAndroid Build Coastguard Worker "--allowlist-type=EC_POINT", 92*e1997b9aSAndroid Build Coastguard Worker "--allowlist-var=EC_MAX_BYTES", 93*e1997b9aSAndroid Build Coastguard Worker "--allowlist-var=EVP_MAX_MD_SIZE", 94*e1997b9aSAndroid Build Coastguard Worker ], 95*e1997b9aSAndroid Build Coastguard Worker cflags: ["-DBORINGSSL_NO_CXX"], 96*e1997b9aSAndroid Build Coastguard Worker apex_available: [ 97*e1997b9aSAndroid Build Coastguard Worker "//apex_available:platform", 98*e1997b9aSAndroid Build Coastguard Worker "com.android.virt", 99*e1997b9aSAndroid Build Coastguard Worker ], 100*e1997b9aSAndroid Build Coastguard Worker} 101*e1997b9aSAndroid Build Coastguard Worker 102*e1997b9aSAndroid Build Coastguard Workerrust_test { 103*e1997b9aSAndroid Build Coastguard Worker name: "keystore2_crypto_test_rust", 104*e1997b9aSAndroid Build Coastguard Worker crate_name: "keystore2_crypto_test_rust", 105*e1997b9aSAndroid Build Coastguard Worker srcs: ["lib.rs"], 106*e1997b9aSAndroid Build Coastguard Worker test_suites: ["general-tests"], 107*e1997b9aSAndroid Build Coastguard Worker auto_gen_config: true, 108*e1997b9aSAndroid Build Coastguard Worker rustlibs: [ 109*e1997b9aSAndroid Build Coastguard Worker "libkeystore2_crypto_bindgen", 110*e1997b9aSAndroid Build Coastguard Worker "liblog_rust", 111*e1997b9aSAndroid Build Coastguard Worker "libnix", 112*e1997b9aSAndroid Build Coastguard Worker "libthiserror", 113*e1997b9aSAndroid Build Coastguard Worker ], 114*e1997b9aSAndroid Build Coastguard Worker static_libs: [ 115*e1997b9aSAndroid Build Coastguard Worker "libkeystore2_crypto", 116*e1997b9aSAndroid Build Coastguard Worker ], 117*e1997b9aSAndroid Build Coastguard Worker shared_libs: [ 118*e1997b9aSAndroid Build Coastguard Worker "libc++", 119*e1997b9aSAndroid Build Coastguard Worker "libcrypto", 120*e1997b9aSAndroid Build Coastguard Worker "liblog", 121*e1997b9aSAndroid Build Coastguard Worker ], 122*e1997b9aSAndroid Build Coastguard Worker} 123*e1997b9aSAndroid Build Coastguard Worker 124*e1997b9aSAndroid Build Coastguard Workercc_test { 125*e1997b9aSAndroid Build Coastguard Worker name: "keystore2_crypto_test", 126*e1997b9aSAndroid Build Coastguard Worker cflags: [ 127*e1997b9aSAndroid Build Coastguard Worker "-Wall", 128*e1997b9aSAndroid Build Coastguard Worker "-Werror", 129*e1997b9aSAndroid Build Coastguard Worker "-Wextra", 130*e1997b9aSAndroid Build Coastguard Worker ], 131*e1997b9aSAndroid Build Coastguard Worker srcs: [ 132*e1997b9aSAndroid Build Coastguard Worker "tests/certificate_utils_test.cpp", 133*e1997b9aSAndroid Build Coastguard Worker "tests/gtest_main.cpp", 134*e1997b9aSAndroid Build Coastguard Worker ], 135*e1997b9aSAndroid Build Coastguard Worker test_suites: ["general-tests"], 136*e1997b9aSAndroid Build Coastguard Worker static_libs: [ 137*e1997b9aSAndroid Build Coastguard Worker "libkeystore2_crypto", 138*e1997b9aSAndroid Build Coastguard Worker ], 139*e1997b9aSAndroid Build Coastguard Worker shared_libs: [ 140*e1997b9aSAndroid Build Coastguard Worker "libcrypto", 141*e1997b9aSAndroid Build Coastguard Worker ], 142*e1997b9aSAndroid Build Coastguard Worker} 143*e1997b9aSAndroid Build Coastguard Worker 144*e1997b9aSAndroid Build Coastguard Workerrust_test { 145*e1997b9aSAndroid Build Coastguard Worker name: "libkeystore2_crypto_bindgen_test", 146*e1997b9aSAndroid Build Coastguard Worker srcs: [":libkeystore2_crypto_bindgen"], 147*e1997b9aSAndroid Build Coastguard Worker crate_name: "keystore2_crypto_bindgen_test", 148*e1997b9aSAndroid Build Coastguard Worker test_suites: ["general-tests"], 149*e1997b9aSAndroid Build Coastguard Worker auto_gen_config: true, 150*e1997b9aSAndroid Build Coastguard Worker clippy_lints: "none", 151*e1997b9aSAndroid Build Coastguard Worker lints: "none", 152*e1997b9aSAndroid Build Coastguard Worker apex_available: [ 153*e1997b9aSAndroid Build Coastguard Worker "//apex_available:platform", 154*e1997b9aSAndroid Build Coastguard Worker "com.android.virt", 155*e1997b9aSAndroid Build Coastguard Worker ], 156*e1997b9aSAndroid Build Coastguard Worker} 157