Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 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 | |
Bob Badour | 4c7858c | 2021-02-12 15:40:29 -0800 | [diff] [blame] | 15 | package { |
| 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 Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 24 | rust_library { |
| 25 | name: "libkeystore2_crypto_rust", |
| 26 | crate_name: "keystore2_crypto", |
| 27 | srcs: ["lib.rs"], |
| 28 | rustlibs: [ |
| 29 | "libkeystore2_crypto_bindgen", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 30 | "liblog_rust", |
| 31 | "libnix", |
| 32 | "libthiserror", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 33 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 34 | shared_libs: [ |
| 35 | "libkeystore2_crypto", |
| 36 | "libcrypto", |
| 37 | ], |
Janis Danisevskis | aaba4af | 2021-11-18 14:25:07 -0800 | [diff] [blame] | 38 | vendor_available: true, |
Andrew Scull | f4a6e28 | 2022-07-12 15:27:00 +0000 | [diff] [blame] | 39 | apex_available: [ |
| 40 | "//apex_available:platform", |
| 41 | "com.android.virt", |
| 42 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | cc_library { |
| 46 | name: "libkeystore2_crypto", |
| 47 | srcs: [ |
| 48 | "crypto.cpp", |
| 49 | "certificate_utils.cpp", |
| 50 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 51 | export_include_dirs: ["include"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 52 | shared_libs: [ |
| 53 | "libcrypto", |
| 54 | "liblog", |
| 55 | ], |
Janis Danisevskis | aaba4af | 2021-11-18 14:25:07 -0800 | [diff] [blame] | 56 | vendor_available: true, |
Andrew Scull | f4a6e28 | 2022-07-12 15:27:00 +0000 | [diff] [blame] | 57 | apex_available: [ |
| 58 | "//apex_available:platform", |
| 59 | "com.android.virt", |
| 60 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | rust_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, |
Janis Danisevskis | aaba4af | 2021-11-18 14:25:07 -0800 | [diff] [blame] | 69 | vendor_available: true, |
Joel Galenson | 0591458 | 2021-01-08 09:30:41 -0800 | [diff] [blame] | 70 | shared_libs: ["libcrypto"], |
| 71 | bindgen_flags: [ |
David Drysdale | c97eb9e | 2022-01-26 13:03:48 -0800 | [diff] [blame] | 72 | "--allowlist-function", "hmacSha256", |
Joel Galenson | 915d3ea | 2021-04-19 09:02:41 -0700 | [diff] [blame] | 73 | "--allowlist-function", "randomBytes", |
| 74 | "--allowlist-function", "AES_gcm_encrypt", |
| 75 | "--allowlist-function", "AES_gcm_decrypt", |
| 76 | "--allowlist-function", "CreateKeyId", |
| 77 | "--allowlist-function", "generateKeyFromPassword", |
| 78 | "--allowlist-function", "HKDFExtract", |
| 79 | "--allowlist-function", "HKDFExpand", |
| 80 | "--allowlist-function", "ECDHComputeKey", |
| 81 | "--allowlist-function", "ECKEYGenerateKey", |
| 82 | "--allowlist-function", "ECKEYMarshalPrivateKey", |
| 83 | "--allowlist-function", "ECKEYParsePrivateKey", |
| 84 | "--allowlist-function", "EC_KEY_get0_public_key", |
| 85 | "--allowlist-function", "ECPOINTPoint2Oct", |
| 86 | "--allowlist-function", "ECPOINTOct2Point", |
| 87 | "--allowlist-function", "EC_KEY_free", |
| 88 | "--allowlist-function", "EC_POINT_free", |
| 89 | "--allowlist-function", "extractSubjectFromCertificate", |
| 90 | "--allowlist-type", "EC_KEY", |
| 91 | "--allowlist-type", "EC_POINT", |
| 92 | "--allowlist-var", "EC_MAX_BYTES", |
| 93 | "--allowlist-var", "EVP_MAX_MD_SIZE", |
Joel Galenson | 0591458 | 2021-01-08 09:30:41 -0800 | [diff] [blame] | 94 | ], |
| 95 | cflags: ["-DBORINGSSL_NO_CXX"], |
Andrew Scull | f4a6e28 | 2022-07-12 15:27:00 +0000 | [diff] [blame] | 96 | apex_available: [ |
| 97 | "//apex_available:platform", |
| 98 | "com.android.virt", |
| 99 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | rust_test { |
| 103 | name: "keystore2_crypto_test_rust", |
| 104 | crate_name: "keystore2_crypto_test_rust", |
| 105 | srcs: ["lib.rs"], |
| 106 | test_suites: ["general-tests"], |
| 107 | auto_gen_config: true, |
| 108 | rustlibs: [ |
| 109 | "libkeystore2_crypto_bindgen", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 110 | "liblog_rust", |
| 111 | "libnix", |
| 112 | "libthiserror", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 113 | ], |
| 114 | static_libs: [ |
| 115 | "libkeystore2_crypto", |
| 116 | ], |
| 117 | shared_libs: [ |
| 118 | "libc++", |
| 119 | "libcrypto", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 120 | "liblog", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 121 | ], |
| 122 | } |
| 123 | |
| 124 | cc_test { |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 125 | name: "keystore2_crypto_test", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 126 | cflags: [ |
| 127 | "-Wall", |
| 128 | "-Werror", |
| 129 | "-Wextra", |
| 130 | ], |
| 131 | srcs: [ |
| 132 | "tests/certificate_utils_test.cpp", |
| 133 | "tests/gtest_main.cpp", |
| 134 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 135 | test_suites: ["general-tests"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 136 | static_libs: [ |
| 137 | "libkeystore2_crypto", |
| 138 | ], |
| 139 | shared_libs: [ |
| 140 | "libcrypto", |
| 141 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 142 | } |
Joel Galenson | 733d1d0 | 2021-08-23 13:47:37 -0700 | [diff] [blame] | 143 | |
| 144 | rust_test { |
| 145 | name: "libkeystore2_crypto_bindgen_test", |
| 146 | srcs: [":libkeystore2_crypto_bindgen"], |
| 147 | crate_name: "keystore2_crypto_bindgen_test", |
| 148 | test_suites: ["general-tests"], |
| 149 | auto_gen_config: true, |
| 150 | clippy_lints: "none", |
| 151 | lints: "none", |
Andrew Scull | f4a6e28 | 2022-07-12 15:27:00 +0000 | [diff] [blame] | 152 | apex_available: [ |
| 153 | "//apex_available:platform", |
| 154 | "com.android.virt", |
| 155 | ], |
Joel Galenson | 733d1d0 | 2021-08-23 13:47:37 -0700 | [diff] [blame] | 156 | } |