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 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | cc_library { |
| 41 | name: "libkeystore2_crypto", |
| 42 | srcs: [ |
| 43 | "crypto.cpp", |
| 44 | "certificate_utils.cpp", |
| 45 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 46 | export_include_dirs: ["include"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 47 | shared_libs: [ |
| 48 | "libcrypto", |
| 49 | "liblog", |
| 50 | ], |
| 51 | } |
| 52 | |
| 53 | rust_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, |
Joel Galenson | 0591458 | 2021-01-08 09:30:41 -0800 | [diff] [blame] | 59 | shared_libs: ["libcrypto"], |
| 60 | bindgen_flags: [ |
| 61 | "--size_t-is-usize", |
Joel Galenson | 915d3ea | 2021-04-19 09:02:41 -0700 | [diff] [blame] | 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", |
Joel Galenson | 0591458 | 2021-01-08 09:30:41 -0800 | [diff] [blame] | 83 | ], |
| 84 | cflags: ["-DBORINGSSL_NO_CXX"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | rust_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", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 95 | "liblog_rust", |
| 96 | "libnix", |
| 97 | "libthiserror", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 98 | ], |
| 99 | static_libs: [ |
| 100 | "libkeystore2_crypto", |
| 101 | ], |
| 102 | shared_libs: [ |
| 103 | "libc++", |
| 104 | "libcrypto", |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 105 | "liblog", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 106 | ], |
| 107 | } |
| 108 | |
| 109 | cc_test { |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 110 | name: "keystore2_crypto_test", |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 111 | cflags: [ |
| 112 | "-Wall", |
| 113 | "-Werror", |
| 114 | "-Wextra", |
| 115 | ], |
| 116 | srcs: [ |
| 117 | "tests/certificate_utils_test.cpp", |
| 118 | "tests/gtest_main.cpp", |
| 119 | ], |
Janis Danisevskis | 9d90b81 | 2020-11-25 21:02:11 -0800 | [diff] [blame] | 120 | test_suites: ["general-tests"], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 121 | static_libs: [ |
| 122 | "libkeystore2_crypto", |
| 123 | ], |
| 124 | shared_libs: [ |
| 125 | "libcrypto", |
| 126 | ], |
Joel Galenson | 46d6fd0 | 2020-11-19 17:58:33 -0800 | [diff] [blame] | 127 | } |