Hanno Becker | 0c3bebf | 2020-06-02 06:32:43 +0100 | [diff] [blame] | 1 | TLS 1.3 Experimental Developments |
Hanno Becker | 9338f9f | 2020-05-31 07:39:50 +0100 | [diff] [blame] | 2 | ================================= |
| 3 | |
| 4 | Overview |
| 5 | -------- |
| 6 | |
| 7 | Mbed TLS doesn't support the TLS 1.3 protocol yet, but a prototype is in development. |
| 8 | Stable parts of this prototype that can be independently tested are being successively |
| 9 | upstreamed under the guard of the following macro: |
| 10 | |
| 11 | ``` |
| 12 | MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
| 13 | ``` |
| 14 | |
| 15 | This macro will likely be renamed to `MBEDTLS_SSL_PROTO_TLS1_3` once a minimal viable |
| 16 | implementation of the TLS 1.3 protocol is available. |
| 17 | |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 18 | See the [documentation of `MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL`](../../include/mbedtls/mbedtls_config.h) |
Hanno Becker | 9338f9f | 2020-05-31 07:39:50 +0100 | [diff] [blame] | 19 | for more information. |
| 20 | |
| 21 | Status |
| 22 | ------ |
| 23 | |
| 24 | The following lists which parts of the TLS 1.3 prototype have already been upstreamed |
| 25 | together with their level of testing: |
| 26 | |
| 27 | * TLS 1.3 record protection mechanisms |
| 28 | |
| 29 | The record protection routines `mbedtls_ssl_{encrypt|decrypt}_buf()` have been extended |
| 30 | to support the modified TLS 1.3 record protection mechanism, including modified computation |
| 31 | of AAD, IV, and the introduction of a flexible padding. |
| 32 | |
| 33 | Those record protection routines have unit tests in `test_suite_ssl` alongside the |
| 34 | tests for the other record protection routines. |
| 35 | |
| 36 | TODO: Add some test vectors from RFC 8448. |
Hanno Becker | 5a83d29 | 2020-06-02 06:33:00 +0100 | [diff] [blame] | 37 | |
| 38 | - The HKDF key derivation function on which the TLS 1.3 key schedule is based, |
| 39 | is already present as an independent module controlled by `MBEDTLS_HKDF_C` |
| 40 | independently of the development of the TLS 1.3 prototype. |
Hanno Becker | b11c309 | 2020-08-10 17:00:19 +0100 | [diff] [blame] | 41 | |
| 42 | - The TLS 1.3-specific HKDF-based key derivation functions (see RFC 8446): |
| 43 | * HKDF-Expand-Label |
| 44 | * Derive-Secret |
| 45 | - Secret evolution |
| 46 | * The traffic {Key,IV} generation from secret |
| 47 | Those functions are implemented in `library/ssl_tls13_keys.c` and |
| 48 | tested in `test_suite_ssl` using test vectors from RFC 8448 and |
| 49 | https://tls13.ulfheim.net/. |
Hanno Becker | 7594c68 | 2021-03-05 05:17:11 +0000 | [diff] [blame] | 50 | |
| 51 | - New TLS Message Processing Stack (MPS) |
| 52 | |
| 53 | The TLS 1.3 prototype is developed alongside a rewrite of the TLS messaging layer, |
| 54 | encompassing low-level details such as record parsing, handshake reassembly, and |
| 55 | DTLS retransmission state machine. |
| 56 | |
| 57 | MPS has the following components: |
| 58 | - Layer 1 (Datagram handling) |
| 59 | - Layer 2 (Record handling) |
| 60 | - Layer 3 (Message handling) |
| 61 | - Layer 4 (Retransmission State Machine) |
| 62 | - Reader (Abstracted pointer arithmetic and reassembly logic for incoming data) |
| 63 | - Writer (Abstracted pointer arithmetic and fragmentation logic for outgoing data) |
| 64 | |
| 65 | Of those components, the following have been upstreamed |
| 66 | as part of `MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL`: |
| 67 | |
| 68 | - Reader ([`library/mps_reader.h`](../../library/mps_reader.h)) |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 69 | |
| 70 | |
| 71 | MVP definition |
| 72 | -------------- |
| 73 | |
| 74 | The TLS 1.3 MVP implements only the client side of the protocol. |
| 75 | The TLS 1.3 MVP does not support the handling of server HelloRetryRequest and |
| 76 | CertificateRequest messages. If it receives one of those messages, it aborts |
Ronald Cron | 004df8a | 2021-09-27 12:12:00 +0200 | [diff] [blame] | 77 | the handshake with an handshake_failure closure alert and the |
| 78 | `mbedtls_ssl_handshake()` returns in error with the |
| 79 | `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE` error code. |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 80 | |
| 81 | - Supported cipher suites: depends on the library configuration. Potentially |
| 82 | all of them: |
| 83 | TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, |
| 84 | TLS_AES_128_CCM_SHA256 and TLS_AES_128_CCM_8_SHA256. |
| 85 | |
| 86 | - Supported ClientHello extensions: |
| 87 | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 88 | | Extension | MVP | Prototype (1) | |
| 89 | | ---------------------------- | ------- | ------------- | |
Ronald Cron | 85e5108 | 2021-09-27 12:13:16 +0200 | [diff] [blame] | 90 | | server_name | YES | YES | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 91 | | max_fragment_length | no | YES | |
| 92 | | status_request | no | no | |
| 93 | | supported_groups | YES | YES | |
| 94 | | signature_algorithms | YES | YES | |
| 95 | | use_srtp | no | no | |
| 96 | | heartbeat | no | no | |
| 97 | | apln | no | YES | |
| 98 | | signed_certificate_timestamp | no | no | |
| 99 | | client_certificate_type | no | no | |
| 100 | | server_certificate_type | no | no | |
| 101 | | padding | no | no | |
Ronald Cron | 3160d70 | 2021-09-27 13:27:21 +0200 | [diff] [blame] | 102 | | key_share | YES (2) | YES | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 103 | | pre_shared_key | no | YES | |
| 104 | | psk_key_exchange_modes | no | YES | |
| 105 | | early_data | no | YES | |
| 106 | | cookie | no | YES | |
Ronald Cron | 3160d70 | 2021-09-27 13:27:21 +0200 | [diff] [blame] | 107 | | supported_versions | YES (3) | YES | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 108 | | certificate_authorities | no | no | |
| 109 | | post_handshake_auth | no | no | |
| 110 | | signature_algorithms_cert | no | no | |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 111 | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 112 | (1) This is just for comparison. |
| 113 | |
Ronald Cron | 3160d70 | 2021-09-27 13:27:21 +0200 | [diff] [blame] | 114 | (2) The MVP sends one shared secret corresponding to the configured preferred |
| 115 | group. The preferred group is the group of the first curve in the list of |
| 116 | allowed curves as defined by the configuration. By default, it is the |
| 117 | mandatory group as defined by section 9.1 of the specification, |
| 118 | `secp256r1`. The list of allowed curves can be set through the |
| 119 | `mbedtls_ssl_conf_curves()` API. |
| 120 | |
| 121 | (3) The MVP proposes only TLS 1.3 and does not support version negociation. |
| 122 | Out-of-protocol fallback is supported though if the Mbed TLS library |
| 123 | has been built to support both TLS 1.3 and TLS 1.2: just set the |
| 124 | maximum of the minor version of the SSL configuration to |
| 125 | MBEDTLS_SSL_MINOR_VERSION_3 (`mbedtls_ssl_conf_min_version()` API) and |
| 126 | re-initiate a server handshake. |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 127 | |
| 128 | - Supported groups: depends on the library configuration. |
Ronald Cron | c3b510f | 2021-09-27 13:36:33 +0200 | [diff] [blame] | 129 | Minimally (as defined in section 9.1 of the TLS 1.3 specification): |
| 130 | secp256r1 and x25519. |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 131 | |
Ronald Cron | c3b510f | 2021-09-27 13:36:33 +0200 | [diff] [blame] | 132 | Furthermore, depending on the library configuration, potentially: |
| 133 | secp384r1 and secp521r1. |
| 134 | |
| 135 | Finite field groups (DHE) are not supported. |
| 136 | |
| 137 | - Supported signature algorithms(both for certificates and CertificateVerify): |
| 138 | Minimally (as defined in section 9.1 of the TLS 1.3 specification): |
| 139 | rsa_pkcs1_sha256, rsa_pss_rsae_sha256 and ecdsa_secp256r1_sha256 |
| 140 | |
| 141 | Furthermore, depending on the library configuration, potentially: |
| 142 | ecdsa_secp384r1_sha384 and ecdsa_secp521r1_sha512 |
| 143 | |
| 144 | - Supported versions: only TLS 1.3, version negotiation is not supported. |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 145 | |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 146 | - Support of Mbed TLS SSL/TLS related (not DTLS) features: |
| 147 | |
| 148 | The TLS 1.3 MVP is compatible with all TLS 1.2 configuration options in the |
| 149 | sense that when enabling the TLS 1.3 MVP in the library there is no need to |
| 150 | modify the configuration for TLS 1.2. Mbed TLS SSL/TLS related features are |
| 151 | not supported or not applicable to the TLS 1.3 MVP: |
| 152 | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 153 | | Mbed TLS configuration option | Support | |
| 154 | | ---------------------------------------- | ------- | |
| 155 | | MBEDTLS_SSL_ALL_ALERT_MESSAGES | no | |
| 156 | | MBEDTLS_SSL_ASYNC_PRIVATE | no | |
| 157 | | MBEDTLS_SSL_CONTEXT_SERIALIZATION | no | |
| 158 | | MBEDTLS_SSL_DEBUG_ALL | no | |
| 159 | | MBEDTLS_SSL_ENCRYPT_THEN_MAC | n/a | |
| 160 | | MBEDTLS_SSL_EXTENDED_MASTER_SECRET | n/a | |
| 161 | | MBEDTLS_SSL_KEEP_PEER_CERTIFICATE | no | |
| 162 | | MBEDTLS_SSL_RENEGOTIATION | n/a | |
| 163 | | MBEDTLS_SSL_MAX_FRAGMENT_LENGTH | no | |
| 164 | | | | |
| 165 | | MBEDTLS_SSL_SESSION_TICKETS | no | |
| 166 | | MBEDTLS_SSL_EXPORT_KEYS | no (1) | |
| 167 | | MBEDTLS_SSL_SERVER_NAME_INDICATION | no | |
| 168 | | MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH | no | |
| 169 | | | | |
| 170 | | MBEDTLS_ECP_RESTARTABLE | no | |
| 171 | | MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED | no | |
| 172 | | | | |
| 173 | | MBEDTLS_KEY_EXCHANGE_PSK_ENABLED | n/a (2) | |
| 174 | | MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED | n/a | |
| 175 | | MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED | n/a | |
| 176 | | MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED | n/a | |
| 177 | | MBEDTLS_KEY_EXCHANGE_RSA_ENABLED | n/a | |
| 178 | | MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED | n/a | |
| 179 | | MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED | n/a | |
| 180 | | MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED | n/a | |
| 181 | | MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED | n/a | |
| 182 | | MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED | n/a | |
| 183 | | MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED | n/a | |
| 184 | | | | |
| 185 | | MBEDTLS_USE_PSA_CRYPTO | no | |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 186 | |
Ronald Cron | 023987f | 2021-09-27 11:59:25 +0200 | [diff] [blame] | 187 | (1) Some support has already been upstreamed but it is incomplete. |
Ronald Cron | 1fa5088 | 2021-09-27 12:06:52 +0200 | [diff] [blame] | 188 | (2) Key exchange configuration options for TLS 1.3 will likely to be |
| 189 | organized around the notion of key exchange mode along the line |
| 190 | of the MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_NONE/PSK/PSK_EPHEMERAL/EPHEMERAL |
| 191 | runtime configuration macros. |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 192 | |
Ronald Cron | 660c723 | 2021-09-27 13:40:53 +0200 | [diff] [blame] | 193 | - Quality considerations |
| 194 | - Standard Mbed TLS review bar |
| 195 | - Interoperability testing with OpenSSL and GnuTLS. Test with all the |
| 196 | cipher suites supported by OpenSSL/GnuTLS server with and without |
| 197 | certificate base authentication. |
| 198 | - Negative testing against OpenSSL/GnuTLS servers with which the |
| 199 | handshake fails due to imcompatibility with the capabilities of the |
| 200 | MVP: TLS 1.2 or 1.1 server, server sending an HelloRetryRequest message in |
| 201 | response to the MVP ClientHello, server sending a CertificateRequest |
| 202 | message ... |
| 203 | |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 204 | Coding rules checklist for TLS 1.3 |
| 205 | ---------------------------------- |
| 206 | |
| 207 | The following coding rules are aimed to be a checklist for TLS 1.3 upstreaming |
| 208 | work to reduce review rounds and the number of comments in each round. They |
| 209 | come along (do NOT replace) the project coding rules |
| 210 | (https://tls.mbed.org/kb/development/mbedtls-coding-standards). They have been |
| 211 | established and discussed following the review of #4882 that was the |
| 212 | PR upstreaming the first part of TLS 1.3 ClientHello writing code. |
| 213 | |
| 214 | TLS 1.3 specific coding rules: |
| 215 | |
| 216 | - TLS 1.3 specific C modules, headers, static functions names are prefixed |
| 217 | with `ssl_tls1_3_`. The same applies to structures and types that are |
| 218 | internal to C modules. |
| 219 | |
| 220 | - TLS 1.3 specific exported functions, macros, structures and types are |
| 221 | prefixed with `mbedtls_ssl_tls1_3_`. |
| 222 | |
| 223 | - The names of macros and variables related to a field or structure in the |
| 224 | TLS 1.3 specification should contain as far as possible the field name as |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 225 | it is in the specification. If the field name is "too long" and we prefer |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 226 | to introduce some kind of abbreviation of it, use the same abbreviation |
| 227 | everywhere in the code. |
| 228 | |
| 229 | Example 1: #define CLIENT_HELLO_RANDOM_LEN 32, macro for the length of the |
| 230 | `random` field of the ClientHello message. |
| 231 | |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 232 | Example 2 (consistent abbreviation): `mbedtls_ssl_tls1_3_write_sig_alg_ext()` |
| 233 | and `MBEDTLS_TLS_EXT_SIG_ALG`, `sig_alg` standing for |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 234 | `signature_algorithms`. |
| 235 | |
| 236 | - Regarding vectors that are represented by a length followed by their value |
| 237 | in the data exchanged between servers and clients: |
| 238 | |
| 239 | - Use `<vector name>_len` for the name of a variable used to compute the |
| 240 | length in bytes of the vector, where <vector name> is the name of the |
| 241 | vector as defined in the TLS 1.3 specification. |
| 242 | |
| 243 | - Use `<vector_name>_len_ptr` for the name of a variable intended to hold |
| 244 | the address of the first byte of the vector length. |
| 245 | |
| 246 | - Use `<vector_name>_ptr` for the name of a variable intended to hold the |
| 247 | address of the first byte of the vector value. |
| 248 | |
| 249 | - Use `<vector_name>_end_ptr` for the name of a variable intended to hold |
| 250 | the address of the first byte past the vector value. |
| 251 | |
| 252 | Those two last idioms should lower the risk of mis-using one of the address |
| 253 | in place of the other one which could potentially lead to some nasty |
| 254 | issues. |
| 255 | |
| 256 | Example: `cipher_suites` vector of ClientHello in |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 257 | `ssl_tls1_3_write_client_hello_cipher_suites()` |
| 258 | ``` |
| 259 | size_t cipher_suites_len; |
| 260 | unsigned char *cipher_suites_len_ptr; |
| 261 | unsigned char *cipher_suites_ptr; |
| 262 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 263 | |
| 264 | - Use of MBEDTLS_BYTE_xyz, MBEDTLS_PUT/GET_xyz, MBEDTLS_SSL_CHK_BUF_PTR |
| 265 | MBEDTLS_SSL_CHK_BUF_READ_PTR macros where applicable. |
| 266 | |
| 267 | These macros were introduced after the prototype was written thus are |
| 268 | likely not to be used in prototype where we now would use them in |
| 269 | development. |
| 270 | |
| 271 | The two first types, MBEDTLS_BYTE_xyz and MBEDTLS_PUT/GET_xyz, improve |
| 272 | the readability of the code and reduce the risk of writing or reading |
| 273 | bytes in the wrong order: we should probably have only MBEDTLS_GET/PUT_*_BE |
| 274 | (BE stands for Big-Endian) macros in the TLS 1.3 code. |
| 275 | |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 276 | The two last types, `MBEDTLS_SSL_CHK_BUF_PTR` and |
| 277 | `MBEDTLS_SSL_CHK_BUF_READ_PTR`, improve the readability of the code and |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 278 | reduce the risk of error in the non-completely-trivial arithmetic to |
| 279 | check that we do not write or read past the end of a data buffer. The |
| 280 | usage of those macros combined with the following rule mitigate the risk |
| 281 | to read/write past the end of a data buffer. |
| 282 | |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 283 | Examples: |
| 284 | ``` |
| 285 | hs_hdr[1] = MBEDTLS_BYTE_2( total_hs_len ); |
| 286 | MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); |
| 287 | MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); |
| 288 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 289 | |
| 290 | - To mitigate what happened here |
| 291 | (https://github.com/ARMmbed/mbedtls/pull/4882#discussion_r701704527) from |
| 292 | happening again, use always a local variable named `p` for the reading |
| 293 | pointer in functions parsing TLS 1.3 data, and for the writing pointer in |
| 294 | functions writing data into an output buffer. The name `p` has been |
| 295 | chosen as it was already widely used in TLS code. |
| 296 | |
| 297 | - When an TLS 1.3 structure is written or read by a function or as part of |
| 298 | a function, provide as documentation the definition of the structure as |
| 299 | it is in the TLS 1.3 specification. |
| 300 | |
| 301 | General coding rules: |
| 302 | |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 303 | - We prefer grouping "related statement lines" by not adding blank lines |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 304 | between them. |
| 305 | |
| 306 | Example 1: |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 307 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 308 | ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &output_len ); |
| 309 | if( ret != 0 ) |
| 310 | return( ret ); |
| 311 | buf += output_len; |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 312 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 313 | |
| 314 | Example 2: |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 315 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 316 | MBEDTLS_SSL_CHK_BUF_PTR( cipher_suites_iter, end, 2 ); |
| 317 | MBEDTLS_PUT_UINT16_BE( cipher_suite, cipher_suites_iter, 0 ); |
| 318 | cipher_suites_iter += 2; |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 319 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 320 | |
| 321 | - Use macros for constants that are used in different functions, different |
| 322 | places in the code. When a constant is used only locally in a function |
| 323 | (like the length in bytes of the vector lengths in functions reading and |
| 324 | writing TLS handshake message) there is no need to define a macro for it. |
| 325 | |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 326 | Example: `#define CLIENT_HELLO_RANDOM_LEN 32` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 327 | |
| 328 | - When declaring a pointer the dereferencing operator should be prepended to |
| 329 | the pointer name not appended to the pointer type: |
| 330 | |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 331 | Example: `mbedtls_ssl_context *ssl;` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 332 | |
| 333 | - Maximum line length is 80 characters. |
| 334 | |
| 335 | Exceptions: |
| 336 | |
| 337 | - string literals can extend beyond 80 characters as we do not want to |
| 338 | split them to ease their search in the code base. |
| 339 | |
| 340 | - A line can be more than 80 characters by a few characters if just looking |
| 341 | at the 80 first characters is enough to fully understand the line. For |
| 342 | example it is generally fine if some closure characters like ";" or ")" |
| 343 | are beyond the 80 characters limit. |
| 344 | |
| 345 | - When in successive lines, functions and macros parameters should be aligned |
| 346 | vertically. |
| 347 | |
| 348 | Example: |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 349 | ``` |
Ronald Cron | 3785c90 | 2021-09-20 09:05:36 +0200 | [diff] [blame] | 350 | int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, |
| 351 | unsigned hs_type, |
| 352 | unsigned char **buf, |
| 353 | size_t *buf_len ); |
Ronald Cron | 72064b3 | 2021-09-27 13:54:28 +0200 | [diff] [blame^] | 354 | ``` |