tls13_server_misc.c
Go to the documentation of this file.
1 /**
2  * @file tls13_server_misc.c
3  * @brief Helper functions for TLS 1.3 server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSL Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.2
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL TLS_TRACE_LEVEL
33 
34 //Dependencies
35 #include "tls/tls.h"
36 #include "tls/tls_server_misc.h"
38 #include "tls/tls_ffdhe.h"
39 #include "tls/tls_misc.h"
40 #include "tls13/tls13_server.h"
44 #include "debug.h"
45 
46 //Check TLS library configuration
47 #if (TLS_SUPPORT == ENABLED && TLS_SERVER_SUPPORT == ENABLED && \
48  TLS_MAX_VERSION >= TLS_VERSION_1_3)
49 
50 
51 /**
52  * @brief Cipher suite and key exchange method negotiation
53  * @param[in] context Pointer to the TLS context
54  * @param[in] clientHello Pointer to the ClientHello message
55  * @param[in] clientHelloLen Length of the ClientHello message
56  * @param[in] cipherSuites List of cipher suites offered by the client
57  * @param[in] extensions ClientHello extensions offered by the client
58  * @return Error code
59  **/
60 
61 error_t tls13NegotiateCipherSuite(TlsContext *context, const void *clientHello,
62  size_t clientHelloLen, const TlsCipherSuites *cipherSuites,
64 {
65  error_t error;
66 
67  //In TLS 1.3, the cipher suite concept has been changed. The key exchange
68  //mechanism is negotiated separately from the cipher suite
69  context->keyExchMethod = TLS_KEY_EXCH_NONE;
70 
71  //The PreSharedKey extension is used to negotiate the identity of the
72  //pre-shared key to be used with a given handshake in association with
73  //PSK key establishment
74  error = tls13ParseClientPreSharedKeyExtension(context, clientHello,
75  clientHelloLen, extensions->identityList, extensions->binderList);
76  //Any error to report?
77  if(error)
78  return error;
79 
80  //Externally established PSKs should influence cipher suite selection
81  if(context->selectedIdentity >= 0)
82  {
83  //Select a cipher suite indicating a hash associated with the PSK
84  error = tlsNegotiateCipherSuite(context, context->cipherSuite.prfHashAlgo,
85  cipherSuites, extensions);
86 
87  //The server must ensure that it selects a compatible PSK and cipher suite
88  if(!error)
89  {
90  //Perform PSK handshake
91  context->keyExchMethod = TLS13_KEY_EXCH_PSK;
92  }
93  else
94  {
95  //Perform a non-PSK handshake if possible
96  context->keyExchMethod = TLS_KEY_EXCH_NONE;
97  context->selectedIdentity = -1;
98  }
99  }
100 
101  //Check key exchange method
102  if(context->keyExchMethod == TLS_KEY_EXCH_NONE)
103  {
104  //Perform cipher suite negotiation
105  error = tlsNegotiateCipherSuite(context, NULL, cipherSuites, extensions);
106  //If no acceptable choices are presented, terminate the handshake
107  if(error)
108  return ERROR_HANDSHAKE_FAILED;
109  }
110 
111  //If the handshake includes a HelloRetryRequest, the initial ClientHello
112  //and HelloRetryRequest are included in the transcript along with the new
113  //ClientHello
114  if(context->state == TLS_STATE_CLIENT_HELLO)
115  {
116  //Initialize handshake message hashing
117  error = tlsInitTranscriptHash(context);
118  //Any error to report?
119  if(error)
120  return error;
121  }
122 
123 #if (DTLS_SUPPORT == ENABLED)
124  //DTLS protocol?
125  if(context->transportProtocol == TLS_TRANSPORT_PROTOCOL_DATAGRAM)
126  {
127  //When the second ClientHello is received, the server can verify that
128  //the cookie is valid (refer to RFC 9147, section 5.1)
129  error = dtls13ParseClientCookieExtension(context, extensions->cookie);
130  //Any error to report?
131  if(error)
132  return error;
133  }
134 #endif
135 
136  //If the client opts to send 0-RTT data, it must supply an EarlyData
137  //extension in its ClientHello
138  error = tls13ParseClientEarlyDataExtension(context,
139  extensions->earlyDataIndication);
140  //Any error to report?
141  if(error)
142  return error;
143 
144  //The KeyShare extension contains the client's cryptographic parameters
145  error = tls13ParseClientKeyShareExtension(context, extensions->keyShareList,
146  extensions->supportedGroupList);
147  //Any error to report?
148  if(error)
149  return error;
150 
151  //Incorrect (EC)DHE share?
152  if(extensions->keyShareList != NULL && context->namedGroup == TLS_GROUP_NONE)
153  {
154  //Select an appropriate ECDHE or FFDHE group
155  error = tls13SelectGroup(context, extensions->supportedGroupList);
156  //Any error to report?
157  if(error)
158  return error;
159 
160  //The server corrects the mismatch with a HelloRetryRequest
161  context->wrongKeyShare = TRUE;
162  }
163  else
164  {
165  //Check key exchange method
166  if(context->keyExchMethod == TLS13_KEY_EXCH_DHE ||
167  context->keyExchMethod == TLS13_KEY_EXCH_ECDHE ||
168  context->keyExchMethod == TLS13_KEY_EXCH_MLKEM ||
169  context->keyExchMethod == TLS13_KEY_EXCH_HYBRID)
170  {
171  //Check whether the client supports session resumption with a PSK
172  error = tls13ParsePskKeModesExtension(context,
173  extensions->pskKeModeList);
174  //Any error to report?
175  if(error)
176  return error;
177  }
178  else if(context->keyExchMethod == TLS13_KEY_EXCH_PSK ||
179  context->keyExchMethod == TLS13_KEY_EXCH_PSK_DHE ||
180  context->keyExchMethod == TLS13_KEY_EXCH_PSK_ECDHE ||
181  context->keyExchMethod == TLS13_KEY_EXCH_PSK_MLKEM ||
182  context->keyExchMethod == TLS13_KEY_EXCH_PSK_HYBRID)
183  {
184  //Servers must not select a key exchange mode that is not listed by
185  //the client in the PskKeyExchangeModes extension
186  error = tls13ParsePskKeModesExtension(context,
187  extensions->pskKeModeList);
188  //Any error to report?
189  if(error)
190  return error;
191 
192  //Prior to accepting PSK key establishment, the server must validate
193  //the corresponding binder value
194  error = tls13VerifyPskBinder(context, clientHello, clientHelloLen,
195  extensions->identityList, extensions->binderList,
196  context->selectedIdentity);
197  //If this value does not validate, the server must abort the handshake
198  if(error)
199  return error;
200  }
201  else
202  {
203  //If no common cryptographic parameters can be negotiated, the server
204  //must abort the handshake with an appropriate alert
205  return ERROR_HANDSHAKE_FAILED;
206  }
207  }
208 
209  //Successful processing
210  return NO_ERROR;
211 }
212 
213 
214 /**
215  * @brief Select the group to be used when performing (EC)DHE key exchange
216  * @param[in] context Pointer to the TLS context
217  * @param[in] groupList List of named groups supported by the client
218  * @return Error code
219  **/
220 
222  const TlsSupportedGroupList *groupList)
223 {
224  error_t error;
225 
226  //Initialize status code
227  error = ERROR_ILLEGAL_PARAMETER;
228 
229  //Reset the named group to its default value
230  context->namedGroup = TLS_GROUP_NONE;
231 
232 #if (TLS13_DHE_KE_SUPPORT == ENABLED || TLS13_PSK_DHE_KE_SUPPORT == ENABLED || \
233  TLS13_ECDHE_KE_SUPPORT == ENABLED || TLS13_PSK_ECDHE_KE_SUPPORT == ENABLED || \
234  TLS13_MLKEM_KE_SUPPORT == ENABLED || TLS13_PSK_MLKEM_KE_SUPPORT == ENABLED || \
235  TLS13_HYBRID_KE_SUPPORT == ENABLED || TLS13_PSK_HYBRID_KE_SUPPORT == ENABLED)
236  //Valid SupportedGroups extension?
237  if(groupList != NULL)
238  {
239  uint_t i;
240  uint_t n;
241  uint16_t namedGroup;
242 
243  //Any preferred ECDHE or FFDHE groups?
244  if(context->numSupportedGroups > 0)
245  {
246  //Loop through the list of allowed groups (most preferred first)
247  for(i = 0; i < context->numSupportedGroups && error; i++)
248  {
249  //Get current named group
250  namedGroup = context->supportedGroups[i];
251 
252  //The named group to be used when performing (EC)DHE key exchange
253  //must be one of those present in the SupportedGroups extension
254  if(tls13IsGroupOffered(namedGroup, groupList))
255  {
256  //Check whether the ECDHE or FFDHE group is supported
257  if(tls13IsGroupObsolete(context, namedGroup))
258  {
259  //Obsolete curves are used in previous versions of TLS and
260  //must not be negotiated by TLS 1.3 implementations
261  }
262  else if(tls13IsGroupSupported(context, namedGroup))
263  {
264  //Save the named group
265  context->namedGroup = namedGroup;
266  //The group is supported
267  error = NO_ERROR;
268  }
269  else
270  {
271  //The group is not supported
272  error = ERROR_HANDSHAKE_FAILED;
273  }
274  }
275  }
276  }
277  else
278  {
279  //Get the number of named groups present in the list
280  n = ntohs(groupList->length) / sizeof(uint16_t);
281 
282  //The named group to be used when performing (EC)DHE key exchange must
283  //be one of those present in the SupportedGroups extension
284  for(i = 0; i < n && error; i++)
285  {
286  //Convert the named group to host byte order
287  namedGroup = ntohs(groupList->value[i]);
288 
289  //Check whether the ECDHE or FFDHE group is supported
290  if(tls13IsGroupObsolete(context, namedGroup))
291  {
292  //Obsolete curves are used in previous versions of TLS and must
293  //not be negotiated by TLS 1.3 implementations
294  }
295  else if(tls13IsGroupSupported(context, namedGroup))
296  {
297  //Save the named group
298  context->namedGroup = namedGroup;
299  //The group is supported
300  error = NO_ERROR;
301  }
302  else
303  {
304  //The group is not supported
305  error = ERROR_HANDSHAKE_FAILED;
306  }
307  }
308  }
309  }
310 #endif
311 
312  //Return status code
313  return error;
314 }
315 
316 
317 /**
318  * @brief Check whether a group is offered in the SupportedGroups extension
319  * @param[in] namedGroup Named group
320  * @param[in] groupList List of named groups supported by the client
321  * @return TRUE if the group is offered in the SupportedGroups extension,
322  * else FALSE
323  **/
324 
325 bool_t tls13IsGroupOffered(uint16_t namedGroup,
326  const TlsSupportedGroupList *groupList)
327 {
328  uint_t i;
329  uint_t n;
330  bool_t found;
331 
332  //Initialize flag
333  found = FALSE;
334 
335  //Valid SupportedGroups extension?
336  if(groupList != NULL)
337  {
338  //Get the number of named groups present in the list
339  n = ntohs(groupList->length) / sizeof(uint16_t);
340 
341  //Loop through the list of named groups the client supports
342  for(i = 0; i < n && !found; i++)
343  {
344  //Matching group?
345  if(ntohs(groupList->value[i]) == namedGroup)
346  {
347  found = TRUE;
348  }
349  }
350  }
351 
352  //Return TRUE if the group is offered in the SupportedGroups extension
353  return found;
354 }
355 
356 
357 /**
358  * @brief Check whether a given group is obsolete
359  * @param[in] context Pointer to the TLS context
360  * @param[in] namedGroup Named group
361  * @return TRUE is the group is obsolete, else FALSE
362  **/
363 
364 bool_t tls13IsGroupObsolete(TlsContext *context, uint16_t namedGroup)
365 {
366  bool_t obsolete;
367 
368  //Values within obsolete ranges are used in previous versions of TLS and
369  //must not be offered or negotiated by TLS 1.3 implementations (refer to
370  //RFC 8446, appendix B.3.1.4)
371  if(namedGroup >= TLS_GROUP_SECT163K1 &&
372  namedGroup <= TLS_GROUP_SECP256K1)
373  {
374  obsolete = TRUE;
375  }
376  else if(namedGroup >= TLS_GROUP_BRAINPOOLP256R1 &&
377  namedGroup <= TLS_GROUP_BRAINPOOLP512R1)
378  {
379  obsolete = TRUE;
380  }
381  else if(namedGroup >= TLS_GROUP_EXPLICIT_PRIME_CURVE &&
382  namedGroup <= TLS_GROUP_EXPLICIT_CHAR2_CURVE)
383  {
384  obsolete = TRUE;
385  }
386  else
387  {
388  obsolete = FALSE;
389  }
390 
391  //Return TRUE is the group is obsolete
392  return obsolete;
393 }
394 
395 
396 /**
397  * @brief Hash HelloRetryRequest in the transcript
398  * @param[in] context Pointer to the TLS context
399  * @param[in] namedGroup Named group
400  * @return Error code
401  **/
402 
404  TlsNamedGroup namedGroup)
405 {
406  error_t error;
407  size_t length;
409  const HashAlgo *hash;
410 
411  //Invalid hash context?
412  if(context->transcriptHashContext == NULL)
413  return ERROR_FAILURE;
414 
415  //The hash function used by HKDF is the cipher suite hash algorithm
416  hash = context->cipherSuite.prfHashAlgo;
417  //Make sure the hash algorithm is valid
418  if(hash == NULL)
419  return ERROR_FAILURE;
420 
421  //Point to the buffer where to format the handshake message
422  message = (TlsHandshake *) context->txBuffer;
423 
424  //For reasons of backward compatibility with middleboxes the
425  //HelloRetryRequest message uses the same format as the ServerHello
426  message->msgType = TLS_TYPE_SERVER_HELLO;
427 
428  //Use the same extensions as the original HelloRetryRequest message
429  context->wrongKeyShare = (namedGroup != TLS_GROUP_NONE) ? TRUE : FALSE;
430  context->wrongCookie = TRUE;
431 
432  //Format HelloRetryRequest message
433  error = tls13FormatHelloRetryRequest(context,
435  //Any error to report?
436  if(error)
437  return error;
438 
439  //Number of bytes in the message
440  STORE24BE(length, message->length);
441 
442  //Update the hash value with the contents of the message
443  hash->update(context->transcriptHashContext, message,
444  length + sizeof(TlsHandshake));
445 
446  //Clear flags
447  context->wrongKeyShare = FALSE;
448  context->wrongCookie = FALSE;
449 
450  //Successful processing
451  return NO_ERROR;
452 }
453 
454 
455 /**
456  * @brief Verify PSK binder value
457  * @param[in] context Pointer to the TLS context
458  * @param[in] clientHello Pointer to the ClientHello message
459  * @param[in] clientHelloLen Length of the ClientHello message
460  * @param[in] identityList List of the identities that the client is willing
461  * to negotiate with the server
462  * @param[in] binderList List of HMAC values, one for each PSK offered in the
463  * PreSharedKey extension
464  * @param[in] selectedIdentity Selected PSK identity
465  * @return Error code
466  **/
467 
468 error_t tls13VerifyPskBinder(TlsContext *context, const void *clientHello,
469  size_t clientHelloLen, const Tls13PskIdentityList *identityList,
470  const Tls13PskBinderList *binderList, int_t selectedIdentity)
471 {
472 #if (TLS13_PSK_KE_SUPPORT == ENABLED || TLS13_PSK_DHE_KE_SUPPORT == ENABLED || \
473  TLS13_PSK_ECDHE_KE_SUPPORT == ENABLED || TLS13_PSK_HYBRID_KE_SUPPORT == ENABLED)
474  error_t error;
475  int_t i;
476  size_t n;
477  const uint8_t *p;
478  const Tls13PskIdentity *identity;
479  const Tls13PskBinder *binder;
480  uint8_t calculatedBinder[TLS_MAX_HKDF_DIGEST_SIZE];
481 
482  //Initialize variables
483  identity = NULL;
484  binder = NULL;
485 
486  //Make sure the PreSharedKey extension is valid
487  if(identityList == NULL || binderList == NULL)
488  return ERROR_FAILURE;
489 
490  //Make sure the selected identity is valid
491  if(selectedIdentity < 0)
492  return ERROR_FAILURE;
493 
494  //Point to the list of the identities that the client is willing to
495  //negotiate with the server
496  p = identityList->value;
497  n = ntohs(identityList->length);
498 
499  //Loop through the list of PSK identities
500  for(i = 0; i <= selectedIdentity && n > 0; i++)
501  {
502  //Point to the current PskIdentity entry
503  identity = (Tls13PskIdentity *) p;
504 
505  //Malformed PreSharedKey extension?
506  if(n < sizeof(TlsPskIdentity))
507  return ERROR_DECODING_FAILED;
508  if(n < (sizeof(TlsPskIdentity) + ntohs(identity->length)))
509  return ERROR_DECODING_FAILED;
510 
511  //Point to the obfuscated_ticket_age field
512  p += sizeof(TlsPskIdentity) + ntohs(identity->length);
513  n -= sizeof(TlsPskIdentity) + ntohs(identity->length);
514 
515  //The obfuscated_ticket_age field is a 32-bit unsigned integer
516  if(n < sizeof(uint32_t))
517  return ERROR_DECODING_FAILED;
518 
519  //Point to the next PskIdentity entry
520  p += sizeof(uint32_t);
521  n -= sizeof(uint32_t);
522  }
523 
524  //Make sure the selected identity is within the range supplied by the client
525  if(selectedIdentity >= i)
526  return ERROR_FAILURE;
527 
528  //Point to the list of HMAC values, one for each PSK offered in the
529  //PreSharedKey extension
530  p = binderList->value;
531  n = ntohs(binderList->length);
532 
533  //Loop through the list of PSK binders
534  for(i = 0; i <= selectedIdentity && n > 0; i++)
535  {
536  //Point to the PskBinderEntry
537  binder = (Tls13PskBinder *) p;
538 
539  //Malformed PreSharedKey extension?
540  if(n < sizeof(Tls13PskBinder))
541  return ERROR_DECODING_FAILED;
542  if(n < (sizeof(Tls13PskBinder) + binder->length))
543  return ERROR_DECODING_FAILED;
544 
545  //Point to the next PskBinderEntry
546  p += sizeof(Tls13PskBinder) + binder->length;
547  n -= sizeof(Tls13PskBinder) + binder->length;
548  }
549 
550  //Make sure the selected identity is within the range supplied by the client
551  if(selectedIdentity >= i)
552  return ERROR_FAILURE;
553 
554  //Check the length of the PSK binder
555  if(binder->length > TLS_MAX_HKDF_DIGEST_SIZE)
557 
558  //The PSK binder is computed as an HMAC over a transcript hash containing
559  //a partial ClientHello up to the binders list itself
560  n = (uint8_t *) binderList - (uint8_t *) clientHello;
561 
562  //Compute PSK binder value
563  error = tls13ComputePskBinder(context, clientHello, clientHelloLen,
564  n, identity, calculatedBinder, binder->length);
565  //Any error to report?
566  if(error)
568 
569  //Debug message
570  TRACE_DEBUG("PSK binder:\r\n");
571  TRACE_DEBUG_ARRAY(" ", binder->value, binder->length);
572  TRACE_DEBUG("Calculated PSK binder:\r\n");
573  TRACE_DEBUG_ARRAY(" ", calculatedBinder, binder->length);
574 
575  //Prior to accepting PSK key establishment, the server must validate the
576  //corresponding binder value
577  if(osMemcmp(calculatedBinder, binder->value, binder->length))
578  {
579  //If this value does not validate, the server must abort the handshake
581  }
582 
583  //Successful verification
584  return NO_ERROR;
585 #else
586  //Not implemented
587  return ERROR_NOT_IMPLEMENTED;
588 #endif
589 }
590 
591 
592 /**
593  * @brief Process early data
594  * @param[in] context Pointer to the TLS context
595  * @param[in] data Pointer to the early data
596  * @param[in] length Length of the early data, in bytes
597  * @return Error code
598  **/
599 
600 error_t tls13ProcessEarlyData(TlsContext *context, const uint8_t *data,
601  size_t length)
602 {
603  //Check TLS version
604  if(context->version != TLS_VERSION_1_3)
606 
607  //Check operation mode
608  if(context->entity != TLS_CONNECTION_END_SERVER)
609  return ERROR_FAILURE;
610 
611  //Check current state
612  if(context->state != TLS_STATE_CLIENT_HELLO_2)
614 
615  //If the client opts to send 0-RTT data, it must supply an EarlyData
616  //extension in its ClientHello (refer to RFC 8446, section 4.2.10)
617  if(!context->earlyDataExtReceived)
619 
620  //Amount of 0-RTT data received by the server
621  context->earlyDataLen += length;
622 
623  //Discard records which fail deprotection (up to the configured
624  //max_early_data_size)
625  if(context->earlyDataLen > context->maxEarlyDataSize)
626  return ERROR_BAD_RECORD_MAC;
627 
628  //Debug message
629  TRACE_INFO("Discarding early data (%" PRIuSIZE " bytes)...\r\n", length);
630 
631  //The server may opt to reject early data
632  return NO_ERROR;
633 }
634 
635 #endif
@ TLS13_KEY_EXCH_PSK
Definition: tls.h:1224
TLS helper functions.
uint8_t extensions[]
Definition: ntp_common.h:213
Tls13PskBinderList
Definition: tls13_misc.h:275
int bool_t
Definition: compiler_port.h:63
error_t tls13ParsePskKeModesExtension(TlsContext *context, const Tls13PskKeModeList *pskKeModeList)
Parse PskKeyExchangeModes extension.
Handshake message processing (TLS 1.3 server)
@ TLS13_KEY_EXCH_MLKEM
Definition: tls.h:1222
@ TLS13_KEY_EXCH_PSK_DHE
Definition: tls.h:1225
signed int int_t
Definition: compiler_port.h:56
@ ERROR_NOT_IMPLEMENTED
Definition: error.h:66
@ ERROR_ILLEGAL_PARAMETER
Definition: error.h:244
@ ERROR_DECRYPTION_FAILED
Definition: error.h:243
@ ERROR_UNEXPECTED_MESSAGE
Definition: error.h:195
uint8_t p
Definition: ndp.h:300
uint8_t message[]
Definition: chap.h:154
@ TLS_GROUP_SECP256K1
Definition: tls.h:1490
#define TRUE
Definition: os_port.h:50
@ TLS_GROUP_EXPLICIT_CHAR2_CURVE
Definition: tls.h:1524
uint8_t data[]
Definition: ethernet.h:224
error_t dtls13ParseClientCookieExtension(TlsContext *context, const Tls13Cookie *cookie)
Parse Cookie extension.
@ TLS_TRANSPORT_PROTOCOL_DATAGRAM
Definition: tls.h:1017
HashAlgoUpdate update
Definition: crypto.h:1162
TlsPskIdentity
Definition: tls.h:1838
@ TLS13_KEY_EXCH_PSK_MLKEM
Definition: tls.h:1227
error_t tls13VerifyPskBinder(TlsContext *context, const void *clientHello, size_t clientHelloLen, const Tls13PskIdentityList *identityList, const Tls13PskBinderList *binderList, int_t selectedIdentity)
Verify PSK binder value.
error_t tls13DigestHelloRetryRequest(TlsContext *context, TlsNamedGroup namedGroup)
Hash HelloRetryRequest in the transcript.
error_t tls13SelectGroup(TlsContext *context, const TlsSupportedGroupList *groupList)
Select the group to be used when performing (EC)DHE key exchange.
#define osMemcmp(p1, p2, length)
Definition: os_port.h:156
@ ERROR_HANDSHAKE_FAILED
Definition: error.h:234
@ TLS13_KEY_EXCH_ECDHE
Definition: tls.h:1221
@ ERROR_BAD_RECORD_MAC
Definition: error.h:232
error_t tls13NegotiateCipherSuite(TlsContext *context, const void *clientHello, size_t clientHelloLen, const TlsCipherSuites *cipherSuites, TlsHelloExtensions *extensions)
Cipher suite and key exchange method negotiation.
@ TLS_GROUP_BRAINPOOLP256R1
Definition: tls.h:1494
@ TLS13_KEY_EXCH_PSK_HYBRID
Definition: tls.h:1228
@ TLS_STATE_CLIENT_HELLO
Definition: tls.h:1559
TlsCipherSuites
Definition: tls.h:1638
TlsHandshake
Definition: tls.h:1897
#define FALSE
Definition: os_port.h:46
#define TlsContext
Definition: tls.h:36
error_t
Error codes.
Definition: error.h:43
bool_t tls13IsGroupSupported(TlsContext *context, uint16_t namedGroup)
Check whether a given named group is supported.
Definition: tls13_misc.c:947
@ TLS_CONNECTION_END_SERVER
Definition: tls.h:1030
@ TLS_GROUP_NONE
Definition: tls.h:1468
Tls13HelloRetryRequest
Definition: tls13_misc.h:311
Formatting and parsing of extensions (TLS 1.3 server)
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
@ TLS_GROUP_EXPLICIT_PRIME_CURVE
Definition: tls.h:1523
@ TLS13_KEY_EXCH_DHE
Definition: tls.h:1220
@ TLS_GROUP_SECT163K1
Definition: tls.h:1469
#define TLS_VERSION_1_3
Definition: tls.h:98
@ TLS_TYPE_SERVER_HELLO
Definition: tls.h:1103
error_t tlsNegotiateCipherSuite(TlsContext *context, const HashAlgo *hashAlgo, const TlsCipherSuites *cipherSuites, TlsHelloExtensions *extensions)
Cipher suite negotiation.
bool_t tls13IsGroupObsolete(TlsContext *context, uint16_t namedGroup)
Check whether a given group is obsolete.
error_t tls13ParseClientEarlyDataExtension(TlsContext *context, const TlsExtension *earlyDataIndication)
Parse EarlyData extension.
Tls13PskBinder
Definition: tls13_misc.h:264
#define TRACE_INFO(...)
Definition: debug.h:105
uint8_t length
Definition: tcp.h:375
@ TLS_GROUP_BRAINPOOLP512R1
Definition: tls.h:1496
Helper functions for TLS 1.3 server.
Hello extensions.
Definition: tls.h:2278
Transcript hash calculation.
#define ntohs(value)
Definition: cpu_endian.h:421
#define TRACE_DEBUG(...)
Definition: debug.h:119
@ TLS_KEY_EXCH_NONE
Definition: tls.h:1201
@ TLS13_KEY_EXCH_PSK_ECDHE
Definition: tls.h:1226
@ TLS_STATE_CLIENT_HELLO_2
Definition: tls.h:1560
#define TRACE_DEBUG_ARRAY(p, a, n)
Definition: debug.h:120
error_t tls13ComputePskBinder(TlsContext *context, const void *clientHello, size_t clientHelloLen, size_t truncatedClientHelloLen, const Tls13PskIdentity *identity, uint8_t *binder, size_t binderLen)
Compute PSK binder value.
Definition: tls13_misc.c:86
uint8_t n
error_t tls13ParseClientKeyShareExtension(TlsContext *context, const Tls13KeyShareList *keyShareList, const TlsSupportedGroupList *groupList)
Parse KeyShare extension.
@ TLS13_KEY_EXCH_HYBRID
Definition: tls.h:1223
error_t tlsInitTranscriptHash(TlsContext *context)
Initialize handshake message hashing.
Formatting and parsing of extensions (DTLS 1.3 server)
#define TLS_MAX_HKDF_DIGEST_SIZE
Definition: tls.h:965
TLS (Transport Layer Security)
#define STORE24BE(a, p)
Definition: cpu_endian.h:273
Common interface for hash algorithms.
Definition: crypto.h:1151
bool_t tls13IsGroupOffered(uint16_t namedGroup, const TlsSupportedGroupList *groupList)
Check whether a group is offered in the SupportedGroups extension.
FFDHE key exchange.
Helper functions for TLS server.
Tls13PskIdentity
Definition: tls13_misc.h:242
TlsNamedGroup
Named groups.
Definition: tls.h:1467
@ ERROR_DECODING_FAILED
Definition: error.h:242
Tls13PskIdentityList
Definition: tls13_misc.h:253
#define PRIuSIZE
unsigned int uint_t
Definition: compiler_port.h:57
TlsSupportedGroupList
Definition: tls.h:1794
error_t tls13ProcessEarlyData(TlsContext *context, const uint8_t *data, size_t length)
Process early data.
@ NO_ERROR
Success.
Definition: error.h:44
error_t tls13ParseClientPreSharedKeyExtension(TlsContext *context, const TlsClientHello *clientHello, size_t clientHelloLen, const Tls13PskIdentityList *identityList, const Tls13PskBinderList *binderList)
Parse PreSharedKey extension.
Debugging facilities.
error_t tls13FormatHelloRetryRequest(TlsContext *context, Tls13HelloRetryRequest *message, size_t *length)
Format HelloRetryRequest message.
Definition: tls13_server.c:274