• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_applicable_licenses: ["external_open_dice_license"],
3}
4
5license {
6    name: "external_open_dice_license",
7    visibility: [":__subpackages__"],
8    license_kinds: ["SPDX-license-identifier-Apache-2.0"],
9    license_text: ["LICENSE"],
10}
11
12cc_library_headers {
13    name: "libopen_dice_headers",
14    host_supported: true,
15    vendor_available: true,
16    export_include_dirs: ["include"],
17}
18
19cc_library_headers {
20    name: "libopen_dice_boringssl_ed25519_headers",
21    host_supported: true,
22    vendor_available: true,
23    export_include_dirs: ["include/dice/config/boringssl_ed25519"],
24}
25
26cc_library_static {
27    name: "libopen_dice_cbor",
28    host_supported: true,
29    vendor_available: true,
30    srcs: [
31        "src/boringssl_hash_kdf_ops.c",
32        "src/boringssl_ed25519_ops.c",
33        "src/cbor_cert_op.c",
34        "src/cbor_writer.c",
35        "src/clear_memory.c",
36        "src/dice.c",
37        "src/utils.c",
38    ],
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    ],
47    shared_libs: ["libcrypto"],
48}
49
50cc_library_static {
51    name: "libopen_dice_bcc",
52    host_supported: true,
53    vendor_available: true,
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
63cc_test {
64    name: "libopen_dice_test",
65    host_supported: true,
66    cflags: ["-DDICE_USE_GTEST"],
67    srcs: [
68        "src/clear_memory.c",
69        "src/dice_test.cc",
70        "src/dice.c",
71        "src/utils.c",
72    ],
73    header_libs: [
74        "libopen_dice_boringssl_ed25519_headers",
75        "libopen_dice_headers",
76    ],
77    shared_libs: ["libcrypto"],
78}
79
80cc_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
88cc_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
96cc_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
108// TODO: cbor_cert_op_test after resolving COSE dependency
109
110cc_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
117cc_fuzz {
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
124cc_fuzz {
125    name: "libopen_dice_cbor_fuzzer",
126    host_supported: true,
127    srcs: ["src/fuzzer.cc"],
128    static_libs: ["libopen_dice_cbor"],
129    shared_libs: ["libcrypto"],
130}
131
132cc_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}
142
143rust_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: [
157        "--size_t-is-usize",
158
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,
183    vendor_available: true,
184}
185
186rust_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: [
199        "--size_t-is-usize",
200
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",
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",
214        "--raw-line",
215        "pub use open_dice_cbor_bindgen::DiceInputValues;",
216    ],
217
218    rustlibs: [
219        "libopen_dice_cbor_bindgen",
220    ],
221
222    // This is mainly to run layout tests for generated bindings on the host.
223    host_supported: true,
224    vendor_available: true,
225}
226
227rust_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
239rust_test {
240    name: "libopen_dice_bcc_bindgen_test",
241    srcs: [
242        ":libopen_dice_bcc_bindgen",
243    ],
244    crate_name: "open_dice_bcc_bindgen_test",
245
246    rustlibs: [
247        "libopen_dice_cbor_bindgen",
248    ],
249
250    test_suites: ["general-tests"],
251    auto_gen_config: true,
252    clippy_lints: "none",
253    lints: "none",
254}
255