• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_visibility: [":__subpackages__"],
3    default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
6rust_defaults {
7    name: "libdiced_open_dice_defaults",
8    crate_name: "diced_open_dice",
9    defaults: ["avf_build_flags_rust"],
10    srcs: ["src/lib.rs"],
11}
12
13rust_library_rlib {
14    name: "libdiced_open_dice_nostd",
15    defaults: ["libdiced_open_dice_defaults"],
16    rustlibs: [
17        "libcoset_nostd",
18        "libopen_dice_android_bindgen_nostd",
19        "libopen_dice_cbor_bindgen_nostd",
20        "libzeroize_nostd",
21    ],
22    features: [
23        "multialg",
24    ],
25    whole_static_libs: [
26        "libcrypto_baremetal",
27    ],
28    visibility: [
29        "//packages/modules/Virtualization:__subpackages__",
30    ],
31}
32
33rust_library {
34    name: "libdiced_open_dice",
35    defaults: ["libdiced_open_dice_defaults"],
36    host_supported: true,
37    vendor_available: true,
38    rustlibs: [
39        "libcoset",
40        "libopen_dice_android_bindgen",
41        "libopen_dice_cbor_bindgen",
42        "libserde",
43        "libzeroize",
44    ],
45    features: [
46        "serde_derive",
47        "std",
48    ],
49    proc_macros: ["libserde_derive"],
50    shared_libs: [
51        "libcrypto",
52    ],
53    visibility: [
54        "//hardware/interfaces/security/secretkeeper/aidl/vts",
55        "//packages/modules/Virtualization:__subpackages__",
56        "//system/authgraph/tests:__subpackages__",
57        "//system/secretkeeper/client:__subpackages__",
58        "//system/software_defined_vehicle:__subpackages__",
59    ],
60    apex_available: [
61        "//apex_available:platform",
62        "com.android.virt",
63    ],
64    min_sdk_version: "35",
65}
66
67rust_library {
68    name: "libdiced_open_dice_multialg",
69    defaults: ["libdiced_open_dice_defaults"],
70    host_supported: true,
71    vendor_available: true,
72    rustlibs: [
73        "libcoset",
74        "libopen_dice_android_bindgen_multialg",
75        "libopen_dice_cbor_bindgen_multialg",
76        "libzeroize",
77    ],
78    features: [
79        "std",
80        "multialg",
81    ],
82    shared_libs: [
83        "libcrypto",
84    ],
85    visibility: [
86        "//system/software_defined_vehicle:__subpackages__",
87    ],
88    apex_available: [
89        "//apex_available:platform",
90        "com.android.virt",
91    ],
92    min_sdk_version: "35",
93}
94
95rust_defaults {
96    name: "libdiced_open_dice_test_defaults",
97    crate_name: "diced_open_dice_test",
98    srcs: ["tests/api_test.rs"],
99    test_suites: ["general-tests"],
100}
101
102rust_test {
103    name: "libdiced_open_dice.integration_test",
104    defaults: ["libdiced_open_dice_test_defaults"],
105    rustlibs: [
106        "libdiced_open_dice",
107        "libcoset",
108    ],
109}
110
111rust_test {
112    name: "libdiced_open_dice_multialg.integration_test",
113    defaults: ["libdiced_open_dice_test_defaults"],
114    rustlibs: [
115        "libdiced_open_dice_multialg",
116        "libcoset",
117    ],
118    features: [
119        "multialg",
120    ],
121}
122
123rust_test {
124    name: "libdiced_open_dice_nostd.integration_test",
125    defaults: ["libdiced_open_dice_test_defaults"],
126    rustlibs: [
127        "libdiced_open_dice_nostd",
128        "libcoset_nostd",
129    ],
130}
131
132rust_defaults {
133    name: "libopen_dice_bindgen_nostd.rust_defaults",
134    bindgen_flags: [
135        "--use-core",
136        "--ctypes-prefix=core::ffi",
137        "--raw-line=#![no_std]",
138    ],
139    dylib: {
140        enabled: false,
141    },
142    no_stdlibs: true,
143    prefer_rlib: true,
144    stdlibs: [
145        "libcore.rust_sysroot",
146        "libcompiler_builtins.rust_sysroot",
147    ],
148    target: {
149        musl: {
150            enabled: false,
151        },
152        glibc: {
153            enabled: false,
154        },
155        darwin: {
156            enabled: false,
157        },
158    },
159}
160
161rust_defaults {
162    name: "libopen_dice.rust_defaults",
163    host_supported: true,
164    vendor_available: true,
165    apex_available: [
166        "//apex_available:platform",
167        "com.android.compos",
168        "com.android.virt",
169    ],
170}
171
172rust_defaults {
173    name: "libopen_dice_cbor_bindgen.rust_defaults",
174    wrapper_src: "bindgen/dice/dice.h",
175    crate_name: "open_dice_cbor_bindgen",
176    source_stem: "bindings",
177    bindgen_flags: [
178        "--rustified-enum DiceConfigType",
179        "--rustified-enum DiceMode",
180        "--rustified-enum DiceResult",
181        "--rustified-enum DicePrincipal",
182
183        // By generating only essential functions, we can make bindings concise and
184        // optimize compilation time.
185        "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
186        "--allowlist-function=DiceDeriveCdiCertificateId",
187        "--allowlist-function=DiceMainFlow",
188        "--allowlist-function=DiceHash",
189        "--allowlist-function=DiceKdf",
190        "--allowlist-function=DiceKeypairFromSeed",
191        "--allowlist-function=DiceSign",
192        "--allowlist-function=DiceCoseSignAndEncodeSign1",
193        "--allowlist-function=DiceVerify",
194        "--allowlist-function=DiceGenerateCertificate",
195
196        // We also need some constants in addition to the functions.
197        "--allowlist-var=DICE_CDI_SIZE",
198        "--allowlist-var=DICE_HASH_SIZE",
199        "--allowlist-var=DICE_HIDDEN_SIZE",
200        "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
201        "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
202        "--allowlist-var=DICE_ID_SIZE",
203        "--allowlist-var=DICE_PRIVATE_KEY_BUFFER_SIZE",
204    ],
205}
206
207rust_bindgen {
208    name: "libopen_dice_cbor_bindgen",
209    defaults: [
210        "libopen_dice.rust_defaults",
211        "libopen_dice_cbor_bindgen.rust_defaults",
212    ],
213    whole_static_libs: ["libopen_dice_cbor"],
214    shared_libs: ["libcrypto"],
215    min_sdk_version: "35",
216}
217
218rust_bindgen {
219    name: "libopen_dice_cbor_bindgen_multialg",
220    defaults: [
221        "libopen_dice.rust_defaults",
222        "libopen_dice_cbor_bindgen.rust_defaults",
223    ],
224    bindgen_flags: [
225        "--rustified-enum DiceKeyAlgorithm",
226        "--allowlist-type=DiceContext",
227    ],
228    whole_static_libs: ["libopen_dice_cbor_multialg"],
229    shared_libs: ["libcrypto"],
230    min_sdk_version: "35",
231}
232
233rust_bindgen {
234    name: "libopen_dice_cbor_bindgen_nostd",
235    defaults: [
236        "libopen_dice_cbor_bindgen.rust_defaults",
237        "libopen_dice_bindgen_nostd.rust_defaults",
238    ],
239    bindgen_flags: [
240        "--rustified-enum DiceKeyAlgorithm",
241        "--allowlist-type=DiceContext",
242    ],
243    whole_static_libs: ["libopen_dice_cbor_baremetal_multialg"],
244}
245
246rust_defaults {
247    name: "libopen_dice_android_bindgen.rust_defaults",
248    wrapper_src: "bindgen/android/android.h",
249    crate_name: "open_dice_android_bindgen",
250    source_stem: "bindings",
251    bindgen_flags: [
252        // By generating only essential functions, we can make bindings concise and
253        // optimize compilation time.
254        "--allowlist-function=DiceAndroidFormatConfigDescriptor",
255        "--allowlist-function=DiceAndroidMainFlow",
256        "--allowlist-function=DiceAndroidHandoverMainFlow",
257        "--allowlist-function=DiceAndroidHandoverParse",
258
259        // We also need some constants in addition to the functions.
260        "--allowlist-var=DICE_ANDROID_CONFIG_.*",
261
262        // Prevent DiceInputValues from being generated a second time and
263        // import it instead from open_dice_cbor_bindgen.
264        "--blocklist-type=DiceInputValues_",
265        "--blocklist-type=DiceInputValues",
266        "--raw-line",
267        "pub use open_dice_cbor_bindgen::DiceInputValues;",
268
269        // Prevent DiceResult from being generated a second time and
270        // import it instead from open_dice_cbor_bindgen.
271        "--blocklist-type=DiceResult",
272        "--raw-line",
273        "pub use open_dice_cbor_bindgen::DiceResult;",
274    ],
275
276}
277
278rust_bindgen {
279    name: "libopen_dice_android_bindgen",
280    defaults: [
281        "libopen_dice.rust_defaults",
282        "libopen_dice_android_bindgen.rust_defaults",
283    ],
284    rustlibs: [
285        "libopen_dice_cbor_bindgen",
286    ],
287    whole_static_libs: ["libopen_dice_android"],
288    min_sdk_version: "35",
289}
290
291rust_bindgen {
292    name: "libopen_dice_android_bindgen_multialg",
293    defaults: [
294        "libopen_dice.rust_defaults",
295        "libopen_dice_android_bindgen.rust_defaults",
296    ],
297    rustlibs: [
298        "libopen_dice_cbor_bindgen_multialg",
299    ],
300    whole_static_libs: ["libopen_dice_android_multialg"],
301    min_sdk_version: "35",
302}
303
304rust_bindgen {
305    name: "libopen_dice_android_bindgen_nostd",
306    defaults: [
307        "libopen_dice_android_bindgen.rust_defaults",
308        "libopen_dice_bindgen_nostd.rust_defaults",
309    ],
310    rustlibs: [
311        "libopen_dice_cbor_bindgen_nostd",
312    ],
313    whole_static_libs: ["libopen_dice_android_baremetal_multialg"],
314}
315
316rust_test {
317    name: "libopen_dice_cbor_bindgen_test",
318    srcs: [
319        ":libopen_dice_cbor_bindgen",
320    ],
321    crate_name: "open_dice_cbor_bindgen_test",
322    test_suites: ["general-tests"],
323    auto_gen_config: true,
324    clippy_lints: "none",
325    lints: "none",
326}
327
328rust_test {
329    name: "libopen_dice_android_bindgen_test",
330    srcs: [
331        ":libopen_dice_android_bindgen",
332    ],
333    crate_name: "open_dice_android_bindgen_test",
334    rustlibs: [
335        "libopen_dice_cbor_bindgen",
336    ],
337    test_suites: ["general-tests"],
338    auto_gen_config: true,
339    clippy_lints: "none",
340    lints: "none",
341}
342
343dirgroup {
344    name: "trusty_dirgroup_packages_modules_virtualization_libs_open_dice",
345    visibility: ["//trusty/vendor/google/aosp/scripts"],
346    dirs: ["."],
347}
348