• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16import("$dir_pw_bloat/bloat.gni")
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_unit_test/test.gni")
19
20group("default") {
21  deps = [
22    ":fuzzers(//toolchains:host_fuzz)",
23    ":optimized_libs(//toolchains:host_optimized)",
24    ":tests.run(//toolchains:host_debug)",
25  ]
26}
27
28pw_source_set("cbor_writer") {
29  public = [
30    "include/dice/cbor_writer.h",
31  ]
32  sources = [ "src/cbor_writer.c" ]
33}
34
35pw_source_set("cbor_reader") {
36  public = [
37    "include/dice/cbor_reader.h",
38  ]
39  sources = [ "src/cbor_reader.c" ]
40}
41
42config("standalone_ops_config") {
43  include_dirs = [ "//include/dice/config/standalone" ]
44}
45
46pw_static_library("dice_standalone") {
47  public = [
48    "include/dice/dice.h",
49    "include/dice/utils.h",
50  ]
51  sources = [
52    "src/clear_memory.c",
53    "src/dice.c"
54  ]
55  all_dependent_configs = [ ":standalone_ops_config" ]
56}
57
58config("boringssl_ed25519_ops_config") {
59  include_dirs = [ "//include/dice/config/boringssl_ed25519" ]
60}
61
62pw_static_library("dice_with_boringssl_ops") {
63  public = [
64    "include/dice/dice.h",
65    "include/dice/utils.h",
66  ]
67  sources = [
68    "src/boringssl_cert_op.c",
69    "src/boringssl_hash_kdf_ops.c",
70    "src/boringssl_ed25519_ops.c",
71    "src/clear_memory.c",
72    "src/dice.c",
73    "src/utils.c",
74  ]
75  deps = [
76    "//third_party/boringssl:crypto",
77  ]
78  all_dependent_configs = [ ":boringssl_ed25519_ops_config" ]
79}
80
81config("mbedtls_ops_config") {
82  include_dirs = [ "//include//dice/config/mbedtls_ecdsa_p256" ]
83}
84
85pw_static_library("dice_with_mbedtls_ops") {
86  public = [
87    "include/dice/dice.h",
88    "include/dice/utils.h",
89  ]
90  sources = [
91    "src/clear_memory.c",
92    "src/dice.c",
93    "src/mbedtls_ops.c",
94    "src/utils.c",
95  ]
96  deps = [
97    "//third_party/mbedtls:mbedcrypto",
98  ]
99  all_dependent_configs = [ ":mbedtls_ops_config" ]
100}
101
102pw_static_library("dice_with_cbor_cert") {
103  public = [
104    "include/dice/dice.h",
105    "include/dice/utils.h",
106  ]
107  sources = [
108    "src/boringssl_hash_kdf_ops.c",
109    "src/boringssl_ed25519_ops.c",
110    "src/cbor_cert_op.c",
111    "src/clear_memory.c",
112    "src/dice.c",
113    "src/utils.c",
114  ]
115  deps = [
116    ":cbor_writer",
117    "//third_party/boringssl:crypto",
118  ]
119  all_dependent_configs = [ ":boringssl_ed25519_ops_config" ]
120}
121
122pw_static_library("dice_with_cbor_template_cert") {
123  public = [
124    "include/dice/dice.h",
125    "include/dice/utils.h",
126  ]
127  sources = [
128    "src/boringssl_hash_kdf_ops.c",
129    "src/boringssl_ed25519_ops.c",
130    "src/clear_memory.c",
131    "src/dice.c",
132    "src/template_cbor_cert_op.c",
133    "src/utils.c",
134  ]
135  deps = [
136    "//third_party/boringssl:crypto",
137  ]
138  all_dependent_configs = [ ":boringssl_ed25519_ops_config" ]
139}
140
141pw_static_library("dice_with_x509_template_cert") {
142  public = [
143    "include/dice/dice.h",
144    "include/dice/utils.h",
145  ]
146  sources = [
147    "src/boringssl_hash_kdf_ops.c",
148    "src/boringssl_ed25519_ops.c",
149    "src/clear_memory.c",
150    "src/dice.c",
151    "src/template_cert_op.c",
152    "src/utils.c",
153  ]
154  deps = [
155    "//third_party/boringssl:crypto",
156  ]
157  all_dependent_configs = [ ":boringssl_ed25519_ops_config" ]
158}
159
160pw_source_set("fuzzer") {
161  sources = [ "src/fuzzer.cc" ]
162}
163
164pw_test("cbor_writer_test") {
165  sources = [ "src/cbor_writer_test.cc" ]
166  deps = [
167    ":cbor_writer",
168  ]
169}
170
171pw_test("cbor_reader_test") {
172  sources = [ "src/cbor_reader_test.cc" ]
173  deps = [
174    ":cbor_reader",
175  ]
176}
177
178pw_executable("cbor_writer_fuzzer") {
179  sources = [ "src/cbor_writer_fuzzer.cc" ]
180  deps = [
181    ":cbor_writer",
182  ]
183}
184
185pw_executable("cbor_reader_fuzzer") {
186  sources = [ "src/cbor_reader_fuzzer.cc" ]
187  deps = [
188    ":cbor_reader",
189  ]
190}
191
192pw_test("dice_test") {
193  sources = [ "src/dice_test.cc" ]
194  deps = [
195    ":dice_standalone",
196    "//third_party/boringssl:crypto",
197  ]
198}
199
200pw_test("boringssl_ops_test") {
201  sources = [
202    "src/boringssl_ops_test.cc",
203    "src/test_utils.cc",
204  ]
205  deps = [
206    ":dice_with_boringssl_ops",
207    "//third_party/boringssl:crypto",
208    "//third_party/cose-c:cose-c",
209    "$dir_pw_string:pw_string",
210  ]
211}
212
213pw_executable("boringssl_ops_fuzzer") {
214  deps = [
215    ":dice_with_boringssl_ops",
216    ":fuzzer",
217  ]
218}
219
220pw_test("template_cert_op_test") {
221  sources = [
222    "src/template_cert_op_test.cc",
223    "src/test_utils.cc",
224  ]
225  deps = [
226    ":dice_with_x509_template_cert",
227    "//third_party/boringssl:crypto",
228    "//third_party/cose-c:cose-c",
229    "$dir_pw_string:pw_string",
230  ]
231}
232
233pw_executable("template_cert_op_fuzzer") {
234  deps = [
235    ":dice_with_x509_template_cert",
236    ":fuzzer",
237  ]
238}
239
240pw_test("cbor_cert_op_test") {
241  sources = [
242    "src/cbor_cert_op_test.cc",
243    "src/test_utils.cc",
244  ]
245  deps = [
246    ":dice_with_cbor_cert",
247    "//third_party/boringssl:crypto",
248    "//third_party/cose-c:cose-c",
249    "$dir_pw_string:pw_string",
250  ]
251}
252
253pw_executable("cbor_cert_op_fuzzer") {
254  deps = [
255    ":dice_with_cbor_cert",
256    ":fuzzer",
257  ]
258}
259
260pw_test("template_cbor_cert_op_test") {
261  sources = [
262    "src/template_cbor_cert_op_test.cc",
263    "src/test_utils.cc",
264  ]
265  deps = [
266    ":dice_with_cbor_template_cert",
267    "//third_party/boringssl:crypto",
268    "//third_party/cose-c:cose-c",
269    "$dir_pw_string:pw_string",
270  ]
271}
272
273pw_executable("template_cbor_cert_op_fuzzer") {
274  deps = [
275    ":dice_with_cbor_template_cert",
276    ":fuzzer",
277  ]
278}
279
280pw_test("mbedtls_ops_test") {
281  sources = [
282    "src/mbedtls_ops_test.cc",
283    "src/test_utils.cc",
284  ]
285  deps = [
286    ":dice_with_mbedtls_ops",
287    "//third_party/boringssl:crypto",
288    "//third_party/cose-c:cose-c",
289    "$dir_pw_string:pw_string",
290  ]
291}
292
293pw_executable("mbedtls_ops_fuzzer") {
294  deps = [
295    ":dice_with_mbedtls_ops",
296    ":fuzzer",
297  ]
298}
299
300pw_test_group("tests") {
301  tests = [
302    ":boringssl_ops_test",
303    ":cbor_cert_op_test",
304    ":cbor_reader_test",
305    ":cbor_writer_test",
306    ":dice_test",
307    ":mbedtls_ops_test",
308    ":template_cbor_cert_op_test",
309    ":template_cert_op_test",
310    "//src/android:bcc_test",
311  ]
312}
313
314group("fuzzers") {
315  deps = [
316    ":boringssl_ops_fuzzer",
317    ":cbor_cert_op_fuzzer",
318    ":cbor_reader_fuzzer",
319    ":cbor_writer_fuzzer",
320    ":mbedtls_ops_fuzzer",
321    ":template_cbor_cert_op_fuzzer",
322    ":template_cert_op_fuzzer",
323    "//src/android:bcc_fuzzer",
324  ]
325}
326
327pw_static_library("empty_lib") {
328}
329
330pw_executable("empty_main") {
331  sources = [ "src/empty_main.c" ]
332}
333
334pw_executable("dice_standalone_main") {
335  sources = [ "src/dice_standalone_main.c" ]
336  deps = [ ":dice_standalone" ]
337}
338
339pw_source_set("dice_main") {
340  sources = [ "src/dice_main.c" ]
341}
342
343pw_executable("dice_with_boringssl_ops_main") {
344  deps = [
345    ":dice_main",
346    ":dice_with_boringssl_ops",
347  ]
348}
349
350pw_executable("dice_with_mbedtls_ops_main") {
351  deps = [
352    ":dice_main",
353    ":dice_with_mbedtls_ops",
354  ]
355}
356
357pw_executable("dice_with_cbor_cert_main") {
358  deps = [
359    ":dice_main",
360    ":dice_with_cbor_cert",
361  ]
362}
363
364pw_executable("dice_with_cbor_template_cert_main") {
365  deps = [
366    ":dice_main",
367    ":dice_with_cbor_template_cert",
368  ]
369}
370
371pw_executable("dice_with_x509_template_cert_main") {
372  deps = [
373    ":dice_main",
374    ":dice_with_x509_template_cert",
375  ]
376}
377
378pw_size_report("executable_size_report") {
379  title = "Executable sizes (includes thirdparty deps)"
380  base = ":empty_main"
381  binaries = [
382    {
383      target = ":dice_standalone_main"
384      label = "DiceMainFlow only (No Ops)"
385    },
386    {
387      target = ":dice_with_boringssl_ops_main"
388      label = "Boringssl Ops"
389      base = ":dice_standalone_main"
390    },
391    {
392      target = ":dice_with_mbedtls_ops_main"
393      label = "MbedTLS Ops"
394      base = ":dice_standalone_main"
395    },
396    {
397      target = ":dice_with_cbor_cert_main"
398      label = "Boringssl with CBOR Cert"
399      base = ":dice_with_boringssl_ops_main"
400    },
401    {
402      target = ":dice_with_cbor_template_cert_main"
403      label = "Boringssl with CBOR Template Cert"
404      base = ":dice_with_boringssl_ops_main"
405    },
406    {
407      target = ":dice_with_x509_template_cert_main"
408      label = "Boringssl with X.509 Template Cert"
409      base = ":dice_with_boringssl_ops_main"
410    },
411  ]
412}
413
414pw_size_report("library_size_report") {
415  title = "Library sizes (excludes thirdparty deps)"
416  base = ":empty_lib"
417  binaries = [
418    {
419      target = ":dice_standalone"
420      label = "DICE Standalone (No Ops)"
421    },
422    {
423      target = ":dice_with_boringssl_ops"
424      label = "Boringssl Ops"
425      base = ":dice_standalone"
426    },
427    {
428      target = ":dice_with_mbedtls_ops"
429      label = "MbedTLS Ops"
430      base = ":dice_standalone"
431    },
432    {
433      target = ":dice_with_cbor_cert"
434      label = "CBOR Cert"
435      base = ":dice_standalone"
436    },
437    {
438      target = ":dice_with_cbor_template_cert"
439      label = "CBOR Template Cert"
440      base = ":dice_standalone"
441    },
442    {
443      target = ":dice_with_x509_template_cert"
444      label = "X.509 Template Cert"
445      base = ":dice_standalone"
446    },
447  ]
448}
449
450group("optimized_libs") {
451  deps = [
452    ":dice_standalone",
453    ":dice_with_boringssl_ops",
454    ":dice_with_cbor_cert",
455    ":dice_with_cbor_template_cert",
456    ":dice_with_mbedtls_ops",
457    ":dice_with_x509_template_cert",
458    ":executable_size_report",
459    ":library_size_report",
460    "//src/android:bcc",
461  ]
462}
463