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 | |
| 15 | rust_library { |
| 16 | name: "libkeystore2_crypto_rust", |
| 17 | crate_name: "keystore2_crypto", |
| 18 | srcs: ["lib.rs"], |
| 19 | rustlibs: [ |
| 20 | "libkeystore2_crypto_bindgen", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 21 | "liblog_rust", |
| 22 | "libnix", |
| 23 | "libthiserror", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 24 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 25 | shared_libs: [ |
| 26 | "libkeystore2_crypto", |
| 27 | "libcrypto", |
| 28 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | cc_library { |
| 32 | name: "libkeystore2_crypto", |
| 33 | srcs: [ |
| 34 | "crypto.cpp", |
| 35 | "certificate_utils.cpp", |
| 36 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 37 | export_include_dirs: ["include"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 38 | shared_libs: [ |
| 39 | "libcrypto", |
| 40 | "liblog", |
| 41 | ], |
| 42 | } |
| 43 | |
| 44 | rust_bindgen { |
| 45 | name: "libkeystore2_crypto_bindgen", |
| 46 | wrapper_src: "crypto.hpp", |
| 47 | crate_name: "keystore2_crypto_bindgen", |
| 48 | source_stem: "bindings", |
| 49 | host_supported: true, |
Joel Galenson | 0591458 | 2021-01-08 09:30:41 -0800 | [diff] [blame] | 50 | shared_libs: ["libcrypto"], |
| 51 | bindgen_flags: [ |
| 52 | "--size_t-is-usize", |
| 53 | "--whitelist-function", "randomBytes", |
| 54 | "--whitelist-function", "AES_gcm_encrypt", |
| 55 | "--whitelist-function", "AES_gcm_decrypt", |
| 56 | "--whitelist-function", "CreateKeyId", |
| 57 | "--whitelist-function", "generateKeyFromPassword", |
| 58 | "--whitelist-function", "HKDFExtract", |
| 59 | "--whitelist-function", "HKDFExpand", |
| 60 | "--whitelist-function", "ECDHComputeKey", |
| 61 | "--whitelist-function", "ECKEYGenerateKey", |
| 62 | "--whitelist-function", "ECKEYDeriveFromSecret", |
| 63 | "--whitelist-function", "EC_KEY_get0_public_key", |
| 64 | "--whitelist-function", "ECPOINTPoint2Oct", |
| 65 | "--whitelist-function", "ECPOINTOct2Point", |
| 66 | "--whitelist-function", "EC_KEY_free", |
| 67 | "--whitelist-function", "EC_POINT_free", |
| 68 | "--whitelist-type", "EC_KEY", |
| 69 | "--whitelist-type", "EC_POINT", |
| 70 | "--whitelist-var", "EC_MAX_BYTES", |
| 71 | "--whitelist-var", "EVP_MAX_MD_SIZE", |
| 72 | ], |
| 73 | cflags: ["-DBORINGSSL_NO_CXX"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | rust_test { |
| 77 | name: "keystore2_crypto_test_rust", |
| 78 | crate_name: "keystore2_crypto_test_rust", |
| 79 | srcs: ["lib.rs"], |
| 80 | test_suites: ["general-tests"], |
| 81 | auto_gen_config: true, |
| 82 | rustlibs: [ |
| 83 | "libkeystore2_crypto_bindgen", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 84 | "liblog_rust", |
| 85 | "libnix", |
| 86 | "libthiserror", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 87 | ], |
| 88 | static_libs: [ |
| 89 | "libkeystore2_crypto", |
| 90 | ], |
| 91 | shared_libs: [ |
| 92 | "libc++", |
| 93 | "libcrypto", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 94 | "liblog", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 95 | ], |
| 96 | } |
| 97 | |
| 98 | cc_test { |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 99 | name: "keystore2_crypto_test", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 100 | cflags: [ |
| 101 | "-Wall", |
| 102 | "-Werror", |
| 103 | "-Wextra", |
| 104 | ], |
| 105 | srcs: [ |
| 106 | "tests/certificate_utils_test.cpp", |
| 107 | "tests/gtest_main.cpp", |
| 108 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 109 | test_suites: ["general-tests"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 110 | static_libs: [ |
| 111 | "libkeystore2_crypto", |
| 112 | ], |
| 113 | shared_libs: [ |
| 114 | "libcrypto", |
| 115 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 116 | } |