1#  Copyright (c) 2020, The OpenThread Authors.
2#  All rights reserved.
3#
4#  Redistribution and use in source and binary forms, with or without
5#  modification, are permitted provided that the following conditions are met:
6#  1. Redistributions of source code must retain the above copyright
7#     notice, this list of conditions and the following disclaimer.
8#  2. Redistributions in binary form must reproduce the above copyright
9#     notice, this list of conditions and the following disclaimer in the
10#     documentation and/or other materials provided with the distribution.
11#  3. Neither the name of the copyright holder nor the
12#     names of its contributors may be used to endorse or promote products
13#     derived from this software without specific prior written permission.
14#
15#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25#  POSSIBILITY OF SUCH DAMAGE.
26#
27
28declare_args() {
29  # Configuration file for MbedTLS.
30  mbedtls_config_file = "mbedtls-config.h"
31
32  # Extra dependencies for MbedTLS
33  mbedtls_deps = [ "../../src/core:libopenthread_core_config" ]
34}
35
36config("mbedtls_config") {
37  include_dirs = [
38    ".",
39    "repo/include",
40    "repo/library",
41  ]
42
43  defines = [ "MBEDTLS_CONFIG_FILE=\"${mbedtls_config_file}\"" ]
44  cflags = [
45    "-Wno-conversion",
46  ]
47}
48
49static_library("mbedtls") {
50  sources = [
51    "repo/include/mbedtls/aes.h",
52    "repo/include/mbedtls/aria.h",
53    "repo/include/mbedtls/asn1.h",
54    "repo/include/mbedtls/asn1write.h",
55    "repo/include/mbedtls/base64.h",
56    "repo/include/mbedtls/bignum.h",
57    "repo/include/mbedtls/block_cipher.h",
58    "repo/include/mbedtls/build_info.h",
59    "repo/include/mbedtls/camellia.h",
60    "repo/include/mbedtls/ccm.h",
61    "repo/include/mbedtls/chacha20.h",
62    "repo/include/mbedtls/chachapoly.h",
63    "repo/include/mbedtls/check_config.h",
64    "repo/include/mbedtls/cipher.h",
65    "repo/include/mbedtls/cmac.h",
66    "repo/include/mbedtls/compat-2.x.h",
67    "repo/include/mbedtls/config_adjust_legacy_crypto.h",
68    "repo/include/mbedtls/config_adjust_legacy_from_psa.h",
69    "repo/include/mbedtls/config_adjust_psa_from_legacy.h",
70    "repo/include/mbedtls/config_adjust_psa_superset_legacy.h",
71    "repo/include/mbedtls/config_adjust_ssl.h",
72    "repo/include/mbedtls/config_adjust_x509.h",
73    "repo/include/mbedtls/config_psa.h",
74    "repo/include/mbedtls/constant_time.h",
75    "repo/include/mbedtls/ctr_drbg.h",
76    "repo/include/mbedtls/debug.h",
77    "repo/include/mbedtls/des.h",
78    "repo/include/mbedtls/dhm.h",
79    "repo/include/mbedtls/ecdh.h",
80    "repo/include/mbedtls/ecdsa.h",
81    "repo/include/mbedtls/ecjpake.h",
82    "repo/include/mbedtls/ecp.h",
83    "repo/include/mbedtls/entropy.h",
84    "repo/include/mbedtls/error.h",
85    "repo/include/mbedtls/gcm.h",
86    "repo/include/mbedtls/hkdf.h",
87    "repo/include/mbedtls/hmac_drbg.h",
88    "repo/include/mbedtls/lms.h",
89    "repo/include/mbedtls/mbedtls_config.h",
90    "repo/include/mbedtls/md5.h",
91    "repo/include/mbedtls/md.h",
92    "repo/include/mbedtls/memory_buffer_alloc.h",
93    "repo/include/mbedtls/net_sockets.h",
94    "repo/include/mbedtls/nist_kw.h",
95    "repo/include/mbedtls/oid.h",
96    "repo/include/mbedtls/pem.h",
97    "repo/include/mbedtls/pkcs12.h",
98    "repo/include/mbedtls/pkcs5.h",
99    "repo/include/mbedtls/pkcs7.h",
100    "repo/include/mbedtls/pk.h",
101    "repo/include/mbedtls/platform.h",
102    "repo/include/mbedtls/platform_time.h",
103    "repo/include/mbedtls/platform_util.h",
104    "repo/include/mbedtls/poly1305.h",
105    "repo/include/mbedtls/private_access.h",
106    "repo/include/mbedtls/psa_util.h",
107    "repo/include/mbedtls/ripemd160.h",
108    "repo/include/mbedtls/rsa.h",
109    "repo/include/mbedtls/sha1.h",
110    "repo/include/mbedtls/sha256.h",
111    "repo/include/mbedtls/sha3.h",
112    "repo/include/mbedtls/sha512.h",
113    "repo/include/mbedtls/ssl_cache.h",
114    "repo/include/mbedtls/ssl_ciphersuites.h",
115    "repo/include/mbedtls/ssl_cookie.h",
116    "repo/include/mbedtls/ssl.h",
117    "repo/include/mbedtls/ssl_ticket.h",
118    "repo/include/mbedtls/threading.h",
119    "repo/include/mbedtls/timing.h",
120    "repo/include/mbedtls/version.h",
121    "repo/include/mbedtls/x509_crl.h",
122    "repo/include/mbedtls/x509_crt.h",
123    "repo/include/mbedtls/x509_csr.h",
124    "repo/include/mbedtls/x509.h",
125    "repo/include/psa/build_info.h",
126    "repo/include/psa/crypto_adjust_auto_enabled.h",
127    "repo/include/psa/crypto_adjust_config_key_pair_types.h",
128    "repo/include/psa/crypto_adjust_config_synonyms.h",
129    "repo/include/psa/crypto_builtin_composites.h",
130    "repo/include/psa/crypto_builtin_key_derivation.h",
131    "repo/include/psa/crypto_builtin_primitives.h",
132    "repo/include/psa/crypto_compat.h",
133    "repo/include/psa/crypto_config.h",
134    "repo/include/psa/crypto_driver_common.h",
135    "repo/include/psa/crypto_driver_contexts_composites.h",
136    "repo/include/psa/crypto_driver_contexts_key_derivation.h",
137    "repo/include/psa/crypto_driver_contexts_primitives.h",
138    "repo/include/psa/crypto_extra.h",
139    "repo/include/psa/crypto.h",
140    "repo/include/psa/crypto_legacy.h",
141    "repo/include/psa/crypto_platform.h",
142    "repo/include/psa/crypto_se_driver.h",
143    "repo/include/psa/crypto_sizes.h",
144    "repo/include/psa/crypto_struct.h",
145    "repo/include/psa/crypto_types.h",
146    "repo/include/psa/crypto_values.h",
147    "repo/library/aes.c",
148    "repo/library/aesce.c",
149    "repo/library/aesce.h",
150    "repo/library/aesni.c",
151    "repo/library/aesni.h",
152    "repo/library/alignment.h",
153    "repo/library/aria.c",
154    "repo/library/asn1parse.c",
155    "repo/library/asn1write.c",
156    "repo/library/base64.c",
157    "repo/library/base64_internal.h",
158    "repo/library/bignum.c",
159    "repo/library/bignum_core.c",
160    "repo/library/bignum_core.h",
161    "repo/library/bignum_mod.c",
162    "repo/library/bignum_mod.h",
163    "repo/library/bignum_mod_raw.c",
164    "repo/library/bignum_mod_raw.h",
165    "repo/library/bignum_mod_raw_invasive.h",
166    "repo/library/block_cipher.c",
167    "repo/library/block_cipher_internal.h",
168    "repo/library/bn_mul.h",
169    "repo/library/camellia.c",
170    "repo/library/ccm.c",
171    "repo/library/chacha20.c",
172    "repo/library/chachapoly.c",
173    "repo/library/check_crypto_config.h",
174    "repo/library/cipher.c",
175    "repo/library/cipher_wrap.c",
176    "repo/library/cipher_wrap.h",
177    "repo/library/cmac.c",
178    "repo/library/common.h",
179    "repo/library/constant_time.c",
180    "repo/library/constant_time_impl.h",
181    "repo/library/constant_time_internal.h",
182    "repo/library/ctr_drbg.c",
183    "repo/library/ctr.h",
184    "repo/library/debug.c",
185    "repo/library/debug_internal.h",
186    "repo/library/des.c",
187    "repo/library/dhm.c",
188    "repo/library/ecdh.c",
189    "repo/library/ecdsa.c",
190    "repo/library/ecjpake.c",
191    "repo/library/ecp.c",
192    "repo/library/ecp_curves.c",
193    "repo/library/ecp_curves_new.c",
194    "repo/library/ecp_internal_alt.h",
195    "repo/library/ecp_invasive.h",
196    "repo/library/entropy.c",
197    "repo/library/entropy_poll.c",
198    "repo/library/entropy_poll.h",
199    "repo/library/error.c",
200    "repo/library/gcm.c",
201    "repo/library/hkdf.c",
202    "repo/library/hmac_drbg.c",
203    "repo/library/lmots.c",
204    "repo/library/lmots.h",
205    "repo/library/lms.c",
206    "repo/library/md5.c",
207    "repo/library/md.c",
208    "repo/library/md_psa.h",
209    "repo/library/md_wrap.h",
210    "repo/library/memory_buffer_alloc.c",
211    "repo/library/mps_common.h",
212    "repo/library/mps_error.h",
213    "repo/library/mps_reader.c",
214    "repo/library/mps_reader.h",
215    "repo/library/mps_trace.c",
216    "repo/library/mps_trace.h",
217    "repo/library/net_sockets.c",
218    "repo/library/nist_kw.c",
219    "repo/library/oid.c",
220    "repo/library/padlock.c",
221    "repo/library/padlock.h",
222    "repo/library/pem.c",
223    "repo/library/pk.c",
224    "repo/library/pkcs12.c",
225    "repo/library/pkcs5.c",
226    "repo/library/pkcs7.c",
227    "repo/library/pk_ecc.c",
228    "repo/library/pk_internal.h",
229    "repo/library/pkparse.c",
230    "repo/library/pk_wrap.c",
231    "repo/library/pk_wrap.h",
232    "repo/library/pkwrite.c",
233    "repo/library/pkwrite.h",
234    "repo/library/platform.c",
235    "repo/library/platform_util.c",
236    "repo/library/poly1305.c",
237    "repo/library/psa_crypto_aead.c",
238    "repo/library/psa_crypto_aead.h",
239    "repo/library/psa_crypto.c",
240    "repo/library/psa_crypto_cipher.c",
241    "repo/library/psa_crypto_cipher.h",
242    "repo/library/psa_crypto_client.c",
243    "repo/library/psa_crypto_core_common.h",
244    "repo/library/psa_crypto_core.h",
245    "repo/library/psa_crypto_driver_wrappers.h",
246    "repo/library/psa_crypto_driver_wrappers_no_static.c",
247    "repo/library/psa_crypto_driver_wrappers_no_static.h",
248    "repo/library/psa_crypto_ecp.c",
249    "repo/library/psa_crypto_ecp.h",
250    "repo/library/psa_crypto_ffdh.c",
251    "repo/library/psa_crypto_ffdh.h",
252    "repo/library/psa_crypto_hash.c",
253    "repo/library/psa_crypto_hash.h",
254    "repo/library/psa_crypto_invasive.h",
255    "repo/library/psa_crypto_its.h",
256    "repo/library/psa_crypto_mac.c",
257    "repo/library/psa_crypto_mac.h",
258    "repo/library/psa_crypto_pake.c",
259    "repo/library/psa_crypto_pake.h",
260    "repo/library/psa_crypto_random_impl.h",
261    "repo/library/psa_crypto_rsa.c",
262    "repo/library/psa_crypto_rsa.h",
263    "repo/library/psa_crypto_se.c",
264    "repo/library/psa_crypto_se.h",
265    "repo/library/psa_crypto_slot_management.c",
266    "repo/library/psa_crypto_slot_management.h",
267    "repo/library/psa_crypto_storage.c",
268    "repo/library/psa_crypto_storage.h",
269    "repo/library/psa_its_file.c",
270    "repo/library/psa_util.c",
271    "repo/library/psa_util_internal.h",
272    "repo/library/ripemd160.c",
273    "repo/library/rsa_alt_helpers.c",
274    "repo/library/rsa_alt_helpers.h",
275    "repo/library/rsa.c",
276    "repo/library/rsa_internal.h",
277    "repo/library/sha1.c",
278    "repo/library/sha256.c",
279    "repo/library/sha3.c",
280    "repo/library/sha512.c",
281    "repo/library/ssl_cache.c",
282    "repo/library/ssl_ciphersuites.c",
283    "repo/library/ssl_ciphersuites_internal.h",
284    "repo/library/ssl_client.c",
285    "repo/library/ssl_client.h",
286    "repo/library/ssl_cookie.c",
287    "repo/library/ssl_debug_helpers_generated.c",
288    "repo/library/ssl_debug_helpers.h",
289    "repo/library/ssl_misc.h",
290    "repo/library/ssl_msg.c",
291    "repo/library/ssl_ticket.c",
292    "repo/library/ssl_tls12_client.c",
293    "repo/library/ssl_tls12_server.c",
294    "repo/library/ssl_tls13_client.c",
295    "repo/library/ssl_tls13_generic.c",
296    "repo/library/ssl_tls13_invasive.h",
297    "repo/library/ssl_tls13_keys.c",
298    "repo/library/ssl_tls13_keys.h",
299    "repo/library/ssl_tls13_server.c",
300    "repo/library/ssl_tls.c",
301    "repo/library/threading.c",
302    "repo/library/timing.c",
303    "repo/library/version.c",
304    "repo/library/version_features.c",
305    "repo/library/x509.c",
306    "repo/library/x509_create.c",
307    "repo/library/x509_crl.c",
308    "repo/library/x509_crt.c",
309    "repo/library/x509_csr.c",
310    "repo/library/x509_internal.h",
311    "repo/library/x509write.c",
312    "repo/library/x509write_crt.c",
313    "repo/library/x509write_csr.c"
314  ]
315
316  public_deps = mbedtls_deps
317
318  public_configs = [ ":mbedtls_config" ]
319}
320