Ulf Magnusson | bd6e044 | 2019-11-01 13:45:29 +0100 | [diff] [blame] | 1 | # Cryptography primitive options for mbed TLS |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 2 | |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 3 | # Copyright (c) 2016 Intel Corporation |
Ulf Magnusson | bd6e044 | 2019-11-01 13:45:29 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: Apache-2.0 |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 5 | |
| 6 | menuconfig MBEDTLS |
Ulf Magnusson | 8cf8db3 | 2018-08-14 16:19:20 +0200 | [diff] [blame] | 7 | bool "mbedTLS Support" |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 8 | help |
| 9 | This option enables the mbedTLS cryptography library. |
| 10 | |
Sebastian Bøe | 61cf3b0 | 2017-12-11 12:36:26 +0100 | [diff] [blame] | 11 | if MBEDTLS |
| 12 | |
| 13 | choice |
| 14 | prompt "Select implementation" |
| 15 | default MBEDTLS_BUILTIN |
| 16 | |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 17 | config MBEDTLS_BUILTIN |
Paul Sokolovsky | 29493fd | 2020-03-03 15:19:51 +0200 | [diff] [blame] | 18 | bool "Use Zephyr in-tree mbedTLS version" |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 19 | help |
Paul Sokolovsky | 29493fd | 2020-03-03 15:19:51 +0200 | [diff] [blame] | 20 | 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 Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 23 | |
Sebastian Bøe | 61cf3b0 | 2017-12-11 12:36:26 +0100 | [diff] [blame] | 24 | config MBEDTLS_LIBRARY |
Paul Sokolovsky | 29493fd | 2020-03-03 15:19:51 +0200 | [diff] [blame] | 25 | bool "Use external mbedTLS library" |
Sebastian Bøe | 61cf3b0 | 2017-12-11 12:36:26 +0100 | [diff] [blame] | 26 | help |
Paul Sokolovsky | 29493fd | 2020-03-03 15:19:51 +0200 | [diff] [blame] | 27 | Use external, out-of-tree prebuilt mbedTLS library. For advanced |
| 28 | users only. |
Sebastian Bøe | 61cf3b0 | 2017-12-11 12:36:26 +0100 | [diff] [blame] | 29 | |
| 30 | endchoice |
| 31 | |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 32 | config MBEDTLS_CFG_FILE |
| 33 | string "mbed TLS configuration file" |
| 34 | depends on MBEDTLS_BUILTIN |
Robert Lubos | f1421b9 | 2018-07-10 14:00:29 +0200 | [diff] [blame] | 35 | default "config-tls-generic.h" |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 36 | help |
Paul Sokolovsky | 29493fd | 2020-03-03 15:19:51 +0200 | [diff] [blame] | 37 | Use a specific mbedTLS configuration file. The default config file |
Robert Lubos | f1421b9 | 2018-07-10 14:00:29 +0200 | [diff] [blame] | 38 | 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 Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 43 | |
Anas Nashif | 6e27d6d | 2019-05-09 08:43:30 -0400 | [diff] [blame] | 44 | rsource "Kconfig.tls-generic" |
Robert Lubos | a60af5c | 2018-07-10 10:13:08 +0200 | [diff] [blame] | 45 | |
Paul Sokolovsky | 7558ce8 | 2018-03-01 00:00:29 +0200 | [diff] [blame] | 46 | config 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 Rissanen | 65b9656 | 2017-06-22 15:38:37 +0300 | [diff] [blame] | 61 | config MBEDTLS_DEBUG |
Michael Scott | afd5442 | 2017-10-01 13:37:41 -0700 | [diff] [blame] | 62 | bool "mbed TLS debug activation" |
Jukka Rissanen | 65b9656 | 2017-06-22 15:38:37 +0300 | [diff] [blame] | 63 | depends on MBEDTLS_BUILTIN |
Jukka Rissanen | 65b9656 | 2017-06-22 15:38:37 +0300 | [diff] [blame] | 64 | help |
Paul Sokolovsky | ec207f4 | 2018-02-21 17:37:07 +0200 | [diff] [blame] | 65 | 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 Nashif | 429c2a4 | 2017-12-13 10:08:21 -0500 | [diff] [blame] | 70 | mbedtls_ssl_conf_dbg(&mbedtls.conf, my_debug, NULL); |
Paul Sokolovsky | ec207f4 | 2018-02-21 17:37:07 +0200 | [diff] [blame] | 71 | mbedtls_debug_set_threshold(level); |
Anas Nashif | 429c2a4 | 2017-12-13 10:08:21 -0500 | [diff] [blame] | 72 | functions in your application, and create the my_debug() function to |
| 73 | actually print something useful. |
Jukka Rissanen | 65b9656 | 2017-06-22 15:38:37 +0300 | [diff] [blame] | 74 | |
Paul Sokolovsky | ec207f4 | 2018-02-21 17:37:07 +0200 | [diff] [blame] | 75 | config 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 Niestroj | 480a682 | 2020-11-05 14:46:47 +0100 | [diff] [blame] | 89 | config 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 Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 97 | config MBEDTLS_TEST |
| 98 | bool "Compile internal self test functions" |
| 99 | depends on MBEDTLS_BUILTIN |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 100 | help |
Anas Nashif | 429c2a4 | 2017-12-13 10:08:21 -0500 | [diff] [blame] | 101 | Enable self test function for the crypto algorithms |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 102 | |
Sergio Rodriguez | 312def2 | 2016-07-20 15:03:12 -0700 | [diff] [blame] | 103 | config MBEDTLS_INSTALL_PATH |
| 104 | string "mbedTLS install path" |
| 105 | depends on MBEDTLS_LIBRARY |
| 106 | help |
Anas Nashif | 429c2a4 | 2017-12-13 10:08:21 -0500 | [diff] [blame] | 107 | 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 Rissanen | a9c0a3f | 2017-06-22 16:23:39 +0300 | [diff] [blame] | 110 | |
| 111 | config MBEDTLS_ENABLE_HEAP |
| 112 | bool "Enable global heap for mbed TLS" |
Jukka Rissanen | a9c0a3f | 2017-06-22 16:23:39 +0300 | [diff] [blame] | 113 | help |
Anas Nashif | 429c2a4 | 2017-12-13 10:08:21 -0500 | [diff] [blame] | 114 | 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 Rissanen | a9c0a3f | 2017-06-22 16:23:39 +0300 | [diff] [blame] | 119 | |
| 120 | config MBEDTLS_HEAP_SIZE |
| 121 | int "Heap size for mbed TLS" |
Marek Porwisz | 81e0a05 | 2020-06-19 13:22:32 +0200 | [diff] [blame] | 122 | default 10240 if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER |
Ramakrishna Pallala | 26c1bd5 | 2017-11-03 16:38:29 -0400 | [diff] [blame] | 123 | default 512 |
Jukka Rissanen | a9c0a3f | 2017-06-22 16:23:39 +0300 | [diff] [blame] | 124 | depends on MBEDTLS_ENABLE_HEAP |
| 125 | help |
Anas Nashif | 429c2a4 | 2017-12-13 10:08:21 -0500 | [diff] [blame] | 126 | 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 Sokolovsky | 7558ce8 | 2018-03-01 00:00:29 +0200 | [diff] [blame] | 131 | 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øe | 6f642a1 | 2017-12-27 16:10:15 +0100 | [diff] [blame] | 135 | |
| 136 | config APP_LINK_WITH_MBEDTLS |
| 137 | bool "Link 'app' with MBEDTLS" |
| 138 | default y |
Sebastian Bøe | 6f642a1 | 2017-12-27 16:10:15 +0100 | [diff] [blame] | 139 | 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øe | 61cf3b0 | 2017-12-11 12:36:26 +0100 | [diff] [blame] | 143 | |
Ulf Magnusson | 9bf05a5 | 2019-03-10 04:58:20 +0100 | [diff] [blame] | 144 | endif # MBEDTLS |