blob: 8d37003144f98ebc8c25079d309995225194202b [file] [log] [blame]
Ulf Magnussonbd6e0442019-11-01 13:45:29 +01001# Cryptography primitive options for mbed TLS
Sergio Rodriguez312def22016-07-20 15:03:12 -07002
Sergio Rodriguez312def22016-07-20 15:03:12 -07003# Copyright (c) 2016 Intel Corporation
Ulf Magnussonbd6e0442019-11-01 13:45:29 +01004# SPDX-License-Identifier: Apache-2.0
Sergio Rodriguez312def22016-07-20 15:03:12 -07005
6menuconfig MBEDTLS
Ulf Magnusson8cf8db32018-08-14 16:19:20 +02007 bool "mbedTLS Support"
Sergio Rodriguez312def22016-07-20 15:03:12 -07008 help
9 This option enables the mbedTLS cryptography library.
10
Sebastian Bøe61cf3b02017-12-11 12:36:26 +010011if MBEDTLS
12
13choice
14 prompt "Select implementation"
15 default MBEDTLS_BUILTIN
16
Sergio Rodriguez312def22016-07-20 15:03:12 -070017config MBEDTLS_BUILTIN
Paul Sokolovsky29493fd2020-03-03 15:19:51 +020018 bool "Use Zephyr in-tree mbedTLS version"
Sergio Rodriguez312def22016-07-20 15:03:12 -070019 help
Paul Sokolovsky29493fd2020-03-03 15:19:51 +020020 Link with mbedTLS sources included with Zephyr distribution.
21 Included mbedTLS version is well integrated with and supported
22 by Zephyr, and the recommended choice for most users.
Sergio Rodriguez312def22016-07-20 15:03:12 -070023
Sebastian Bøe61cf3b02017-12-11 12:36:26 +010024config MBEDTLS_LIBRARY
Paul Sokolovsky29493fd2020-03-03 15:19:51 +020025 bool "Use external mbedTLS library"
Sebastian Bøe61cf3b02017-12-11 12:36:26 +010026 help
Paul Sokolovsky29493fd2020-03-03 15:19:51 +020027 Use external, out-of-tree prebuilt mbedTLS library. For advanced
28 users only.
Sebastian Bøe61cf3b02017-12-11 12:36:26 +010029
30endchoice
31
Sergio Rodriguez312def22016-07-20 15:03:12 -070032config MBEDTLS_CFG_FILE
33 string "mbed TLS configuration file"
34 depends on MBEDTLS_BUILTIN
Robert Lubosf1421b92018-07-10 14:00:29 +020035 default "config-tls-generic.h"
Sergio Rodriguez312def22016-07-20 15:03:12 -070036 help
Paul Sokolovsky29493fd2020-03-03 15:19:51 +020037 Use a specific mbedTLS configuration file. The default config file
Robert Lubosf1421b92018-07-10 14:00:29 +020038 file can be tweaked with Kconfig. The default configuration is
39 suitable to communicate with majority of HTTPS servers on the Internet,
40 but has relatively many features enabled. To optimize resources for
41 special TLS usage, use available Kconfig options, or select an
42 alternative config.
Sergio Rodriguez312def22016-07-20 15:03:12 -070043
Anas Nashif6e27d6d2019-05-09 08:43:30 -040044rsource "Kconfig.tls-generic"
Robert Lubosa60af5c2018-07-10 10:13:08 +020045
Paul Sokolovsky7558ce82018-03-01 00:00:29 +020046config MBEDTLS_SSL_MAX_CONTENT_LEN
47 int "Max payload size for TLS protocol message"
48 default 1500
49 depends on MBEDTLS_BUILTIN
50 help
51 The TLS standards mandate max payload size of 16384 bytes. So, for
52 maximum operability and for general-purpose usage, that value must
53 be used. For specific usages, that value can be largely decreased.
54 E.g. for DTLS, payload size is limited by UDP datagram size, and
55 even for HTTPS REST API, the payload can be limited to max size of
56 (REST request, REST response, server certificate(s)).
57 mbedTLS uses this value separate for input and output buffers, so
58 twice this value will be allocated (on mbedTLS own heap, so the
59 value of MBEDTLS_HEAP_SIZE should accommodate that).
60
Jukka Rissanen65b96562017-06-22 15:38:37 +030061config MBEDTLS_DEBUG
Michael Scottafd54422017-10-01 13:37:41 -070062 bool "mbed TLS debug activation"
Jukka Rissanen65b96562017-06-22 15:38:37 +030063 depends on MBEDTLS_BUILTIN
Jukka Rissanen65b96562017-06-22 15:38:37 +030064 help
Paul Sokolovskyec207f42018-02-21 17:37:07 +020065 Enable debugging activation for mbed TLS configuration. If you use
66 mbedTLS/Zephyr integration (e.g. net_app), this will activate debug
67 logging (of the level configured by MBEDTLS_DEBUG_LEVEL).
68 If you use mbedTLS directly instead, you will need to perform
69 additional configuration yourself: call
Anas Nashif429c2a42017-12-13 10:08:21 -050070 mbedtls_ssl_conf_dbg(&mbedtls.conf, my_debug, NULL);
Paul Sokolovskyec207f42018-02-21 17:37:07 +020071 mbedtls_debug_set_threshold(level);
Anas Nashif429c2a42017-12-13 10:08:21 -050072 functions in your application, and create the my_debug() function to
73 actually print something useful.
Jukka Rissanen65b96562017-06-22 15:38:37 +030074
Paul Sokolovskyec207f42018-02-21 17:37:07 +020075config MBEDTLS_DEBUG_LEVEL
76 int "mbed TLS default debug level"
77 depends on MBEDTLS_DEBUG
78 default 0
79 range 0 4
80 help
81 Default mbed TLS debug logging level for Zephyr integration code
82 (from ext/lib/crypto/mbedtls/include/mbedtls/debug.h):
83 0 No debug
84 1 Error
85 2 State change
86 3 Information
87 4 Verbose
88
Marcin Niestroj480a6822020-11-05 14:46:47 +010089config MBEDTLS_MEMORY_DEBUG
90 bool "mbed TLS memory debug activation"
91 depends on MBEDTLS_BUILTIN
92 help
93 Enable debugging of buffer allocator memory issues. Automatically
94 prints (to stderr) all (fatal) messages on memory allocation
95 issues. Enables function for 'debug output' of allocated memory.
96
Sergio Rodriguez312def22016-07-20 15:03:12 -070097config MBEDTLS_TEST
98 bool "Compile internal self test functions"
99 depends on MBEDTLS_BUILTIN
Sergio Rodriguez312def22016-07-20 15:03:12 -0700100 help
Anas Nashif429c2a42017-12-13 10:08:21 -0500101 Enable self test function for the crypto algorithms
Sergio Rodriguez312def22016-07-20 15:03:12 -0700102
Sergio Rodriguez312def22016-07-20 15:03:12 -0700103config MBEDTLS_INSTALL_PATH
104 string "mbedTLS install path"
105 depends on MBEDTLS_LIBRARY
106 help
Anas Nashif429c2a42017-12-13 10:08:21 -0500107 This option holds the path where the mbedTLS libraries and headers are
108 installed. Make sure this option is properly set when MBEDTLS_LIBRARY
109 is enabled otherwise the build will fail.
Jukka Rissanena9c0a3f2017-06-22 16:23:39 +0300110
111config MBEDTLS_ENABLE_HEAP
112 bool "Enable global heap for mbed TLS"
Jukka Rissanena9c0a3f2017-06-22 16:23:39 +0300113 help
Anas Nashif429c2a42017-12-13 10:08:21 -0500114 This option enables the mbedtls to use the heap. This setting must
115 be global so that various applications and libraries in Zephyr do not
116 try to do this themselves as there can be only one heap defined
117 in mbedtls. If this is enabled, then the Zephyr will, during the device
118 startup, initialize the heap automatically.
Jukka Rissanena9c0a3f2017-06-22 16:23:39 +0300119
120config MBEDTLS_HEAP_SIZE
121 int "Heap size for mbed TLS"
Marek Porwisz81e0a052020-06-19 13:22:32 +0200122 default 10240 if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
Ramakrishna Pallala26c1bd52017-11-03 16:38:29 -0400123 default 512
Jukka Rissanena9c0a3f2017-06-22 16:23:39 +0300124 depends on MBEDTLS_ENABLE_HEAP
125 help
Anas Nashif429c2a42017-12-13 10:08:21 -0500126 The mbedtls routines will use this heap if enabled.
127 See ext/lib/crypto/mbedtls/include/mbedtls/config.h and
128 MBEDTLS_MEMORY_BUFFER_ALLOC_C option for details. That option is not
129 enabled by default.
130 Default value for the heap size is not set as it depends on the
Paul Sokolovsky7558ce82018-03-01 00:00:29 +0200131 application. For streaming communication with arbitrary (HTTPS)
132 servers on the Internet, 32KB + overheads (up to another 20KB) may
133 be needed. For some dedicated and specific usage of mbedtls API, the
134 1000 bytes might be ok.
Sebastian Bøe6f642a12017-12-27 16:10:15 +0100135
136config APP_LINK_WITH_MBEDTLS
137 bool "Link 'app' with MBEDTLS"
138 default y
Sebastian Bøe6f642a12017-12-27 16:10:15 +0100139 help
140 Add MBEDTLS header files to the 'app' include path. It may be
141 disabled if the include paths for MBEDTLS are causing aliasing
142 issues for 'app'.
Sebastian Bøe61cf3b02017-12-11 12:36:26 +0100143
Ulf Magnusson9bf05a52019-03-10 04:58:20 +0100144endif # MBEDTLS