Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 1 | package { |
| 2 | default_applicable_licenses: ["external_open_dice_license"], |
| 3 | } |
| 4 | |
| 5 | license { |
| 6 | name: "external_open_dice_license", |
| 7 | visibility: [":__subpackages__"], |
| 8 | license_kinds: ["SPDX-license-identifier-Apache-2.0"], |
| 9 | license_text: ["LICENSE"], |
| 10 | } |
| 11 | |
| 12 | cc_library_headers { |
| 13 | name: "libopen_dice_headers", |
| 14 | host_supported: true, |
Janis Danisevskis | 785b0b4 | 2021-11-09 14:41:24 -0800 | [diff] [blame] | 15 | vendor_available: true, |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 16 | export_include_dirs: ["include"], |
| 17 | } |
| 18 | |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 19 | cc_library_headers { |
| 20 | name: "libopen_dice_boringssl_ed25519_headers", |
| 21 | host_supported: true, |
Janis Danisevskis | 785b0b4 | 2021-11-09 14:41:24 -0800 | [diff] [blame] | 22 | vendor_available: true, |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 23 | export_include_dirs: ["include/dice/config/boringssl_ed25519"], |
| 24 | } |
| 25 | |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 26 | cc_library_static { |
| 27 | name: "libopen_dice_cbor", |
| 28 | host_supported: true, |
Janis Danisevskis | 785b0b4 | 2021-11-09 14:41:24 -0800 | [diff] [blame] | 29 | vendor_available: true, |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 30 | srcs: [ |
Hasini Gunasinghe | 0620de4 | 2022-04-06 05:01:36 +0000 | [diff] [blame] | 31 | "src/boringssl_hash_kdf_ops.c", |
| 32 | "src/boringssl_ed25519_ops.c", |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 33 | "src/cbor_cert_op.c", |
| 34 | "src/cbor_writer.c", |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 35 | "src/clear_memory.c", |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 36 | "src/dice.c", |
| 37 | "src/utils.c", |
| 38 | ], |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 39 | header_libs: [ |
| 40 | "libopen_dice_boringssl_ed25519_headers", |
| 41 | "libopen_dice_headers", |
| 42 | ], |
| 43 | export_header_lib_headers: [ |
| 44 | "libopen_dice_boringssl_ed25519_headers", |
| 45 | "libopen_dice_headers", |
| 46 | ], |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 47 | shared_libs: ["libcrypto"], |
| 48 | } |
| 49 | |
Andrew Scull | ecd29a6 | 2021-11-04 17:27:44 +0000 | [diff] [blame] | 50 | cc_library_static { |
| 51 | name: "libopen_dice_bcc", |
| 52 | host_supported: true, |
Janis Danisevskis | 785b0b4 | 2021-11-09 14:41:24 -0800 | [diff] [blame] | 53 | vendor_available: true, |
Andrew Scull | ecd29a6 | 2021-11-04 17:27:44 +0000 | [diff] [blame] | 54 | srcs: [ |
| 55 | "src/cbor_reader.c", |
| 56 | "src/android/bcc.c", |
| 57 | ], |
| 58 | static_libs: ["libopen_dice_cbor"], |
| 59 | export_static_lib_headers: ["libopen_dice_cbor"], |
| 60 | shared_libs: ["libcrypto"], |
| 61 | } |
| 62 | |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 63 | cc_test { |
| 64 | name: "libopen_dice_test", |
| 65 | host_supported: true, |
| 66 | cflags: ["-DDICE_USE_GTEST"], |
| 67 | srcs: [ |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 68 | "src/clear_memory.c", |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 69 | "src/dice_test.cc", |
| 70 | "src/dice.c", |
| 71 | "src/utils.c", |
| 72 | ], |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 73 | header_libs: [ |
| 74 | "libopen_dice_boringssl_ed25519_headers", |
| 75 | "libopen_dice_headers", |
| 76 | ], |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 77 | shared_libs: ["libcrypto"], |
| 78 | } |
| 79 | |
| 80 | cc_test { |
| 81 | name: "libopen_dice_cbor_writer_test", |
| 82 | host_supported: true, |
| 83 | cflags: ["-DDICE_USE_GTEST"], |
| 84 | srcs: ["src/cbor_writer_test.cc"], |
| 85 | static_libs: ["libopen_dice_cbor"], |
| 86 | } |
| 87 | |
Andrew Scull | ecd29a6 | 2021-11-04 17:27:44 +0000 | [diff] [blame] | 88 | cc_test { |
| 89 | name: "libopen_dice_cbor_reader_test", |
| 90 | host_supported: true, |
| 91 | cflags: ["-DDICE_USE_GTEST"], |
| 92 | srcs: ["src/cbor_reader_test.cc"], |
| 93 | static_libs: ["libopen_dice_bcc"], |
| 94 | } |
| 95 | |
| 96 | cc_test { |
| 97 | name: "libopen_dice_bcc_test", |
| 98 | host_supported: true, |
| 99 | cflags: ["-DDICE_USE_GTEST"], |
| 100 | srcs: ["src/android/bcc_test.cc"], |
| 101 | static_libs: [ |
| 102 | "libopen_dice_bcc", |
| 103 | "libopen_dice_cbor", |
| 104 | ], |
| 105 | shared_libs: ["libcrypto"], |
| 106 | } |
| 107 | |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 108 | // TODO: cbor_cert_op_test after resolving COSE dependency |
| 109 | |
| 110 | cc_fuzz { |
| 111 | name: "libopen_dice_cbor_writer_fuzzer", |
| 112 | host_supported: true, |
| 113 | srcs: ["src/cbor_writer_fuzzer.cc"], |
| 114 | static_libs: ["libopen_dice_cbor"], |
| 115 | } |
| 116 | |
| 117 | cc_fuzz { |
Andrew Scull | ecd29a6 | 2021-11-04 17:27:44 +0000 | [diff] [blame] | 118 | name: "libopen_dice_cbor_reader_fuzzer", |
| 119 | host_supported: true, |
| 120 | srcs: ["src/cbor_reader_fuzzer.cc"], |
| 121 | static_libs: ["libopen_dice_bcc"], |
| 122 | } |
| 123 | |
| 124 | cc_fuzz { |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 125 | name: "libopen_dice_cbor_fuzzer", |
| 126 | host_supported: true, |
Andrew Scull | f0b0690 | 2021-08-10 21:17:01 +0000 | [diff] [blame] | 127 | srcs: ["src/fuzzer.cc"], |
Andrew Scull | 9573bec | 2021-07-15 19:05:19 +0000 | [diff] [blame] | 128 | static_libs: ["libopen_dice_cbor"], |
| 129 | shared_libs: ["libcrypto"], |
| 130 | } |
Andrew Scull | ecd29a6 | 2021-11-04 17:27:44 +0000 | [diff] [blame] | 131 | |
| 132 | cc_fuzz { |
| 133 | name: "libopen_dice_bcc_fuzzer", |
| 134 | host_supported: true, |
| 135 | srcs: ["src/android/bcc_fuzzer.cc"], |
| 136 | static_libs: [ |
| 137 | "libopen_dice_bcc", |
| 138 | "libopen_dice_cbor", |
| 139 | ], |
| 140 | shared_libs: ["libcrypto"], |
| 141 | } |
Janis Danisevskis | 3d32ed5 | 2021-10-11 14:20:30 -0700 | [diff] [blame] | 142 | |
| 143 | rust_bindgen { |
| 144 | name: "libopen_dice_cbor_bindgen", |
| 145 | wrapper_src: "rust/dice.h", |
| 146 | crate_name: "open_dice_cbor_bindgen", |
| 147 | source_stem: "bindings", |
| 148 | header_libs: [ |
| 149 | "libopen_dice_boringssl_ed25519_headers", |
| 150 | "libopen_dice_headers", |
| 151 | ], |
| 152 | |
| 153 | // Generate bindings only for the symbols that are actually exported (see exported.map.txt). |
| 154 | // This makes the generated bindings much more concise and improves compilation |
| 155 | // time. |
| 156 | bindgen_flags: [ |
Janis Danisevskis | 5669e7b | 2021-12-13 21:03:05 -0800 | [diff] [blame] | 157 | "--size_t-is-usize", |
| 158 | |
Janis Danisevskis | 3d32ed5 | 2021-10-11 14:20:30 -0700 | [diff] [blame] | 159 | "--allowlist-function=DiceDeriveCdiPrivateKeySeed", |
| 160 | "--allowlist-function=DiceDeriveCdiCertificateId", |
| 161 | "--allowlist-function=DiceMainFlow", |
| 162 | "--allowlist-function=DiceHash", |
| 163 | "--allowlist-function=DiceKdf", |
| 164 | "--allowlist-function=DiceKeypairFromSeed", |
| 165 | "--allowlist-function=DiceSign", |
| 166 | "--allowlist-function=DiceVerify", |
| 167 | "--allowlist-function=DiceGenerateCertificate", |
| 168 | |
| 169 | // We also need some constants in addition to the functions. |
| 170 | "--allowlist-var=DICE_CDI_SIZE", |
| 171 | "--allowlist-var=DICE_HASH_SIZE", |
| 172 | "--allowlist-var=DICE_HIDDEN_SIZE", |
| 173 | "--allowlist-var=DICE_INLINE_CONFIG_SIZE", |
| 174 | "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE", |
| 175 | "--allowlist-var=DICE_ID_SIZE", |
| 176 | "--allowlist-var=DICE_PUBLIC_KEY_SIZE", |
| 177 | "--allowlist-var=DICE_PRIVATE_KEY_SIZE", |
| 178 | "--allowlist-var=DICE_SIGNATURE_SIZE", |
| 179 | ], |
| 180 | |
| 181 | // This is mainly to run layout tests for generated bindings on the host. |
| 182 | host_supported: true, |
Janis Danisevskis | 785b0b4 | 2021-11-09 14:41:24 -0800 | [diff] [blame] | 183 | vendor_available: true, |
Janis Danisevskis | 3d32ed5 | 2021-10-11 14:20:30 -0700 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | rust_bindgen { |
| 187 | name: "libopen_dice_bcc_bindgen", |
| 188 | wrapper_src: "rust/android/bcc.h", |
| 189 | crate_name: "open_dice_bcc_bindgen", |
| 190 | source_stem: "bindings", |
| 191 | header_libs: [ |
| 192 | "libopen_dice_headers", |
| 193 | ], |
| 194 | |
| 195 | // Generate bindings only for the symbols that are actually exported (see exported.map.txt). |
| 196 | // This makes the generated bindings much more concise and improves compilation |
| 197 | // time. |
| 198 | bindgen_flags: [ |
Janis Danisevskis | 5669e7b | 2021-12-13 21:03:05 -0800 | [diff] [blame] | 199 | "--size_t-is-usize", |
| 200 | |
Janis Danisevskis | 3d32ed5 | 2021-10-11 14:20:30 -0700 | [diff] [blame] | 201 | "--allowlist-function=BccFormatConfigDescriptor", |
| 202 | "--allowlist-function=BccMainFlow", |
| 203 | "--allowlist-function=BccHandoverMainFlow", |
| 204 | |
| 205 | // We also need some constants in addition to the functions. |
| 206 | "--allowlist-var=BCC_INPUT_COMPONENT_NAME", |
| 207 | "--allowlist-var=BCC_INPUT_COMPONENT_VERSION", |
| 208 | "--allowlist-var=BCC_INPUT_RESETTABLE", |
Janis Danisevskis | 5669e7b | 2021-12-13 21:03:05 -0800 | [diff] [blame] | 209 | |
| 210 | // Prevent DiceInputValues from being generated a second time and |
| 211 | // import it instead from open_dice_cbor_bindgen. |
| 212 | "--blocklist-type=DiceInputValues_", |
| 213 | "--blocklist-type=DiceInputValues", |
Hasini Gunasinghe | 0620de4 | 2022-04-06 05:01:36 +0000 | [diff] [blame] | 214 | "--raw-line", |
| 215 | "pub use open_dice_cbor_bindgen::DiceInputValues;", |
Janis Danisevskis | 5669e7b | 2021-12-13 21:03:05 -0800 | [diff] [blame] | 216 | ], |
| 217 | |
| 218 | rustlibs: [ |
| 219 | "libopen_dice_cbor_bindgen", |
Janis Danisevskis | 3d32ed5 | 2021-10-11 14:20:30 -0700 | [diff] [blame] | 220 | ], |
| 221 | |
| 222 | // This is mainly to run layout tests for generated bindings on the host. |
| 223 | host_supported: true, |
Janis Danisevskis | 785b0b4 | 2021-11-09 14:41:24 -0800 | [diff] [blame] | 224 | vendor_available: true, |
Janis Danisevskis | 3d32ed5 | 2021-10-11 14:20:30 -0700 | [diff] [blame] | 225 | } |
Janis Danisevskis | ecade46 | 2021-11-12 10:09:22 -0800 | [diff] [blame] | 226 | |
| 227 | rust_test { |
| 228 | name: "libopen_dice_cbor_bindgen_test", |
| 229 | srcs: [ |
| 230 | ":libopen_dice_cbor_bindgen", |
| 231 | ], |
| 232 | crate_name: "open_dice_cbor_bindgen_test", |
| 233 | test_suites: ["general-tests"], |
| 234 | auto_gen_config: true, |
| 235 | clippy_lints: "none", |
| 236 | lints: "none", |
| 237 | } |
| 238 | |
| 239 | rust_test { |
| 240 | name: "libopen_dice_bcc_bindgen_test", |
| 241 | srcs: [ |
| 242 | ":libopen_dice_bcc_bindgen", |
| 243 | ], |
| 244 | crate_name: "open_dice_bcc_bindgen_test", |
Janis Danisevskis | 5669e7b | 2021-12-13 21:03:05 -0800 | [diff] [blame] | 245 | |
| 246 | rustlibs: [ |
| 247 | "libopen_dice_cbor_bindgen", |
| 248 | ], |
| 249 | |
Janis Danisevskis | ecade46 | 2021-11-12 10:09:22 -0800 | [diff] [blame] | 250 | test_suites: ["general-tests"], |
| 251 | auto_gen_config: true, |
| 252 | clippy_lints: "none", |
| 253 | lints: "none", |
| 254 | } |