iPXE
tlsfmt.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25FILE_SECBOOT ( PERMITTED );
26
27/** @file
28 *
29 * TLS data formats
30 *
31 */
32
33#include <string.h>
34#include <errno.h>
35#include <byteswap.h>
36#include <ipxe/tls.h>
37#include <ipxe/tlsfmt.h>
38
39/**
40 * Get data structure descriptor mapping name (for debugging)
41 *
42 * @v map Data structure descriptor mapping
43 * @ret name Data structure name
44 */
45static const char * tls_map_name ( const uint8_t *map ) {
46
47 if ( map == tls_certificate_map ) {
48 return "Certificate";
49 } else if ( map == tls_certificate_entry_map ) {
50 return "CertificateEntry";
51 } else if ( map == tls_client_hello_map ) {
52 return "ClientHello";
53 } else if ( ( map == tls_client_key_exchange_dhe_map ) ||
54 ( map == tls_client_key_exchange_ecdhe_map ) ||
55 ( map == tls_client_key_exchange_pubkey_map ) ) {
56 return "ClientKeyExchange";
57 } else if ( map == tls_digitally_signed_map ) {
58 return "DigitallySigned";
59 } else if ( map == tls_extension_map ) {
60 return "Extension";
61 } else if ( map == tls_hello_request_map ) {
62 return "HelloRequest";
63 } else if ( map == tls_key_share_client_hello_map ) {
64 return "KeyShareClientHello";
65 } else if ( map == tls_key_share_entry_map ) {
66 return "KeyShareEntry";
67 } else if ( map == tls_key_share_hello_retry_request_map ) {
68 return "KeyShareHelloRetryRequest";
69 } else if ( map == tls_key_share_server_hello_map ) {
70 return "KeyShareServerHello";
71 } else if ( map == tls_max_fragment_length_map ) {
72 return "MaxFragmentLength";
73 } else if ( map == tls_named_group_list_map ) {
74 return "NamedGroupList";
75 } else if ( map == tls_new_session_ticket_map ) {
76 return "NewSessionTicket";
77 } else if ( map == tls_psk_key_exchange_modes_map ) {
78 return "PskKeyExchangeModes";
79 } else if ( map == tls_renegotiation_info_map ) {
80 return "RenegotiationInfo";
81 } else if ( map == tls_server_hello_map ) {
82 return "ServerHello";
83 } else if ( map == tls_server_hello_done_map ) {
84 return "ServerHelloDone";
85 } else if ( ( map == tls_server_key_exchange_dhe_map ) ||
86 ( map == tls_server_key_exchange_ecdhe_map ) ) {
87 return "ServerKeyExchange";
88 } else if ( map == tls_server_name_map ) {
89 return "ServerName";
90 } else if ( map == tls_server_name_list_map ) {
91 return "ServerNameList";
92 } else if ( map == tls_signature_scheme_list_map ) {
93 return "SignatureSchemeList";
94 } else if ( ( map == tls_supported_versions_map ) ||
95 ( map == tls_supported_version_map ) ) {
96 return "SupportedVersions";
97 } else {
98 return "<UNKNOWN>";
99 }
100}
101
102/**
103 * Parse TLS extensions within a data structure
104 *
105 * @v map Data structure descriptor mapping
106 * @v index Current index within mapping
107 * @v fields Extensions data fields
108 * @v count Number of extensions
109 * @ret rc Return status code
110 */
111static int tls_parse_extensions ( const uint8_t *map, unsigned int index,
112 struct tls_cursor *fields,
113 unsigned int count ) {
114 const uint16_t __attribute__ (( aligned ( 1 ) )) *invtypes;
115 const struct tls_cursor *cursor = &fields[0];
116 struct tls_extension extension;
117 unsigned int i;
119 int rc;
120
121 /* Extension types are encoded as inverted */
122 invtypes = ( ( const void * ) &map[index] );
123 for ( i = 1 ; i <= count ; i++ ) {
124 if ( ! invtypes[i] ) {
125 DBGC ( map, "TLSFMT %s #%d mapping missing extension "
126 "%d\n", tls_map_name ( map ), index, i );
127 return -EINVAL;
128 }
129 }
130
131 /* Parse extensions */
132 for ( ; cursor->len ; cursor = &extension.next ) {
133
134 /* Parse next extension */
136 cursor, &extension ) ) != 0 )
137 return rc;
138
139 /* Scan for matching extensions */
140 for ( i = 1 ; i <= count ; i++ ) {
141 type = ~invtypes[i];
142 if ( type != *(extension.type) )
143 continue;
144 if ( fields[i].data ) {
145 DBGC ( map, "TLSFMT %s #%d has duplicate "
146 "extension %#04x\n",
148 ntohs ( type ) );
149 return -EPROTO;
150 }
151 fields[i].data = extension.data.data;
152 fields[i].len = extension.data.len;
153 DBGC2 ( map, "TLSFMT %s #%d extension %#04x len "
154 "%zd\n", tls_map_name ( map ), index,
155 ntohs ( type ), fields[i].len );
156 DBGC2_HDA ( map, 0, fields[i].data, fields[i].len );
157 }
158 }
159
160 return 0;
161}
162
163/**
164 * Parse TLS data structure
165 *
166 * @v map Data structure descriptor mapping
167 * @v version Protocol version
168 * @v cursor Cursor containing TLS data structure
169 * @v desc Data structure descriptor to fill in
170 * @ret rc Return status code
171 */
172int tls_parse_map ( const uint8_t *map, unsigned int version,
173 const struct tls_cursor *cursor,
174 union tls_ptr_len *desc ) {
175 struct tls_cursor *field;
176 void *data;
177 size_t remaining;
178 unsigned int count;
179 unsigned int index;
180 unsigned int next;
181 unsigned int byte;
182 unsigned int minimum;
183 unsigned int len_len;
184 unsigned int len;
185 int fixed;
186 int exts;
187 int rc;
188
189 /* Read initial cursor (may overlap output data structure) */
190 data = cursor->data;
191 remaining = cursor->len;
192 DBGC2 ( map, "TLSFMT %s parsing len %zd\n",
193 tls_map_name ( map ), remaining );
194 DBGC2_HDA ( map, 0, data, remaining );
195
196 /* Get mapping length */
197 count = map[0];
198 if ( ! count ) {
199 DBGC ( map, "TLSFMT %s mapping has no count\n",
200 tls_map_name ( map ) );
201 return -EINVAL;
202 }
203
204 /* Clear data structure descriptor */
205 memset ( desc, 0, ( ( count - 1 ) * sizeof ( desc[0] ) ) );
206
207 /* Parse data via mapping */
208 for ( index = 1 ; ( next = index ) < count ; index = next ) {
209
210 /* Prepare to store field description */
211 field = container_of ( &desc[ index - 1 ].data,
212 struct tls_cursor, data );
213
214 /* Interpret byte as `llllllvv` */
215 byte = map[next++];
216 minimum = TLS_MAP_MIN ( byte );
217 fixed = TLS_MAP_FIXED ( byte );
218 if ( fixed < 0 ) {
219 DBGC ( map, "TLSFMT %s #%d mapping missing\n",
220 tls_map_name ( map ), index );
221 return -EINVAL;
222 }
223 assert ( next <= count );
224
225 /* Handle fixed-length fields */
226 if ( fixed ) {
227 if ( version < minimum ) {
228 DBGC2 ( map, "TLSFMT %s #%d not in version "
229 "%d.%d\n", tls_map_name ( map ),
230 index, ( version >> 8 ),
231 ( version & 0xff ) );
232 continue;
233 }
234 if ( ( ( size_t ) fixed ) > remaining ) {
235 DBGC ( map, "TLSFMT %s #%d too short for "
236 "fixed length %d:\n",
237 tls_map_name ( map ), index, fixed );
238 DBGC_HDA ( map, 0, data, remaining );
239 return -EPROTO;
240 }
241 field->data = data;
242 DBGC2 ( map, "TLSFMT %s #%d len %d\n",
243 tls_map_name ( map ), index, fixed );
244 DBGC2_HDA ( map, 0, field->data, fixed );
245 data += fixed;
246 remaining -= fixed;
247 continue;
248 }
249
250 /* Interpret next byte as `xxxxxxnn` */
251 if ( next >= count ) {
252 DBGC ( map, "TLSFMT %s #%d mapping overrun\n",
253 tls_map_name ( map ), index );
254 return -EINVAL;
255 }
256 byte = map[next++];
257 len_len = TLS_MAP_LEN_LEN ( byte );
258 exts = TLS_MAP_EXTENSIONS ( byte );
259 if ( exts >= 0 )
260 next += ( exts * 2 );
261 if ( next > count ) {
262 DBGC ( map, "TLSFMT %s #%d mapping extensions "
263 "overrun\n", tls_map_name ( map ), index );
264 return -EINVAL;
265 }
266 if ( version < minimum ) {
267 DBGC2 ( map, "TLSFMT %s #%d not in version %d.%d\n",
268 tls_map_name ( map ), index, ( version >> 8 ),
269 ( version & 0xff ) );
270 continue;
271 }
272
273 /* Allow for optional extensions fields */
274 if ( ( exts >= 0 ) && ( ! remaining ) &&
276 DBGC2 ( map, "TLSFMT %s #%d optional in version "
277 "%d.%d\n", tls_map_name ( map ), index,
278 ( version >> 8 ), ( version & 0xff ) );
279 continue;
280 }
281
282 /* Handle variable-length fields */
283 if ( remaining < len_len ) {
284 DBGC ( map, "TLSFMT %s #%d too short for %d-byte "
285 "variable length:\n", tls_map_name ( map ),
286 index, len_len );
287 DBGC_HDA ( map, 0, data, remaining );
288 return -EPROTO;
289 }
290 if ( len_len ) {
291 for ( len = 0 ; len_len ; len_len-- ) {
292 len <<= 8;
293 len |= *( ( const uint8_t * ) data++ );
294 remaining--;
295 }
296 } else {
297 len = remaining;
298 }
299 if ( remaining < len ) {
300 DBGC ( map, "TLSFMT %s #%d too short for variable "
301 "length %d:\n",
302 tls_map_name ( map ), index, len );
303 DBGC_HDA ( map, 0, data, remaining );
304 return -EPROTO;
305 }
306 field->data = data;
307 field->len = len;
308 DBGC2 ( map, "TLSFMT %s #%d len %zd\n",
309 tls_map_name ( map ), index, field->len );
310 DBGC2_HDA ( map, 0, field->data, field->len );
311 data += len;
312 remaining -= len;
313 if ( exts < 0 )
314 continue;
315
316 /* Handle fields containing extensions */
317 if ( ( rc = tls_parse_extensions ( map, index, field,
318 exts ) ) != 0 ) {
319 return rc;
320 }
321 }
322
323 /* Check that all data was consumed */
324 if ( remaining ) {
325 DBGC ( map, "TLSFMT %s has excess data:\n",
326 tls_map_name ( map ) );
327 DBGC_HDA ( map, 0, data, remaining );
328 return -EPROTO;
329 }
330
331 return 0;
332}
333
334/**
335 * Parse optional TLS data structure
336 *
337 * @v map Data structure descriptor mapping
338 * @v version Protocol version
339 * @v cursor Cursor containing TLS data structure
340 * @v desc Data structure descriptor to fill in
341 * @ret rc Return status code
342 */
343int tls_parse_opt_map ( const uint8_t *map, unsigned int version,
344 const struct tls_cursor *cursor,
345 union tls_ptr_len *desc ) {
346 unsigned int count;
347 int rc;
348
349 /* Get mapping length */
350 count = map[0];
351 if ( ! count ) {
352 DBGC ( map, "TLSFMT %s mapping has no count\n",
353 tls_map_name ( map ) );
354 return -EINVAL;
355 }
356
357 /* Clear data structure descriptor */
358 memset ( desc, 0, ( ( count - 1 ) * sizeof ( desc[0] ) ) );
359
360 /* Do nothing if optional data structure is not present */
361 if ( ! cursor->data )
362 return 0;
363
364 /* Parse data structure */
365 if ( ( rc = tls_parse_map ( map, version, cursor, desc ) ) != 0 )
366 return rc;
367
368 return 0;
369}
370
371/**
372 * Build TLS extensions within a data structure
373 *
374 * @v map Data structure descriptor mapping
375 * @v index Current index within mapping
376 * @v fields Extensions data fields
377 * @v count Number of extensions
378 * @ret rc Return status code
379 */
380static int tls_build_extensions ( const uint8_t *map, unsigned int index,
381 struct tls_cursor *fields,
382 unsigned int count ) {
383 const uint16_t __attribute__ (( aligned ( 1 ) )) *invtypes;
384 struct tls_cursor *cursor = &fields[0];
385 struct tls_cursor *subcursor;
386 struct tls_extension extension;
387 unsigned int i;
389 int rc;
390
391 /* Prepare per-extension subcursor */
392 subcursor = &extension.next;
393 subcursor->data = cursor->data;
394 cursor->len = 0;
395
396 /* Extension types are encoded as inverted */
397 invtypes = ( ( const void * ) &map[index] );
398 for ( i = 1 ; i <= count ; i++ ) {
399 if ( ! invtypes[i] ) {
400 DBGC ( map, "TLSFMT %s #%d mapping missing extension "
401 "%d\n", tls_map_name ( map ), index, i );
402 return -EINVAL;
403 }
404 }
405
406 /* Build extensions */
407 for ( i = 1 ; i <= count ; i++ ) {
408
409 /* Skip extensions that will not be included */
410 if ( ! ( fields[i].data || fields[i].len ) )
411 continue;
412
413 /* Build extension */
414 type = ~invtypes[i];
415 extension.type = &type;
416 extension.data = fields[i];
417 extension.next.len = 0;
419 &extension, subcursor ) ) != 0 ) {
420 return rc;
421 }
422 fields[i].len = extension.data.len;
423 DBGC2 ( map, "TLSFMT %s #%d extension %#04x len %zd\n",
424 tls_map_name ( map ), index, ntohs ( type ),
425 fields[i].len );
426 cursor->len += subcursor->len;
427 if ( cursor->data ) {
428 fields[i].data = extension.data.data;
429 DBGC2_HDA ( map, 0, fields[i].data, fields[i].len );
430 }
431 }
432
433 return 0;
434}
435
436/**
437 * Build TLS data structure
438 *
439 * @v map Data structure descriptor mapping
440 * @v version Protocol version
441 * @v desc Data structure descriptor
442 * @v cursor Cursor to contain TLS data structure
443 * @ret rc Return status code
444 *
445 * Build a TLS data structure at the cursor. The cursor's original
446 * length will be ignored and will be set to the overall length of the
447 * built data structure. The caller must ensure that sufficient space
448 * already exists (e.g. by calling tls_size() first to determine the
449 * required length).
450 *
451 * The overall length will be calculated based on the variable lengths
452 * within the descriptor. The output content will be be copied from
453 * any non-NULL pointers within the descriptor (with any missing
454 * content initialised to zero).
455 *
456 * Pointers within the descriptor will be updated to point to the
457 * appropriate location within the built data structure.
458 *
459 * The caller must therefore fill in any variable lengths within the
460 * descriptor beforehand, but may freely choose to either fill in
461 * pointers within the descriptor beforehand or to write through the
462 * updated pointers afterwards.
463 *
464 * A cursor with a NULL data pointer may be used to calculate the
465 * required length without copying in any data or updating any
466 * pointers within the descriptor.
467 */
468int tls_build_map ( const uint8_t *map, unsigned int version,
469 union tls_ptr_len *desc, struct tls_cursor *cursor ) {
470 struct tls_cursor *field;
471 void *data;
472 size_t len;
473 size_t max;
474 unsigned int count;
475 unsigned int index;
476 unsigned int next;
477 unsigned int byte;
478 unsigned int minimum;
479 unsigned int len_len;
480 int fixed;
481 int exts;
482 int rc;
483
484 /* Read initial cursor (may overlap output data structure) */
485 data = cursor->data;
486 len = 0;
487
488 /* Get mapping length */
489 count = map[0];
490 if ( ! count ) {
491 DBGC ( map, "TLSFMT %s mapping has no count\n",
492 tls_map_name ( map ) );
493 return -EINVAL;
494 }
495
496 /* Accumulate total length via mapping */
497 for ( index = 1 ; ( next = index ) < count ; index = next ) {
498
499 /* Prepare to read field description */
500 field = container_of ( &desc[ index - 1 ].data,
501 struct tls_cursor, data );
502
503 /* Interpret byte as `llllllvv` */
504 byte = map[next++];
505 minimum = TLS_MAP_MIN ( byte );
506 fixed = TLS_MAP_FIXED ( byte );
507 if ( fixed < 0 ) {
508 DBGC ( map, "TLSFMT %s #%d mapping missing\n",
509 tls_map_name ( map ), index );
510 return -EINVAL;
511 }
512 assert ( next <= count );
513
514 /* Handle fixed-length fields */
515 if ( fixed ) {
516 if ( version < minimum ) {
517 DBGC2 ( map, "TLSFMT %s #%d not in version "
518 "%d.%d\n", tls_map_name ( map ),
519 index, ( version >> 8 ),
520 ( version & 0xff ) );
521 continue;
522 }
523 DBGC2 ( map, "TLSFMT %s #%d len %d\n",
524 tls_map_name ( map ), index, fixed );
525 len += fixed;
526 if ( data ) {
527 if ( field->data ) {
528 memcpy ( data, field->data, fixed );
529 } else {
530 memset ( data, 0, fixed );
531 }
532 field->data = data;
533 data += fixed;
534 DBGC2_HDA ( map, 0, field->data, fixed );
535 }
536 continue;
537 }
538
539 /* Interpret next byte as `xxxxxxnn` */
540 if ( next >= count ) {
541 DBGC ( map, "TLSFMT %s #%d mapping overrun\n",
542 tls_map_name ( map ), index );
543 return -EINVAL;
544 }
545 byte = map[next++];
546 len_len = TLS_MAP_LEN_LEN ( byte );
547 exts = TLS_MAP_EXTENSIONS ( byte );
548 if ( exts >= 0 )
549 next += ( exts * 2 );
550 if ( next > count ) {
551 DBGC ( map, "TLSFMT %s #%d mapping extensions "
552 "overrun\n", tls_map_name ( map ), index );
553 return -EINVAL;
554 }
555 if ( version < minimum ) {
556 DBGC2 ( map, "TLSFMT %s #%d not in version %d.%d\n",
557 tls_map_name ( map ), index, ( version >> 8 ),
558 ( version & 0xff ) );
559 continue;
560 }
561
562 /* Handle variable-length fields */
563 max = ( len_len ? ( ( 1 << ( 8 * len_len ) ) - 1 ) :
564 ( ( 1 << ( 8 * TLS_MAP_LEN_LEN_MAX ) ) - 1 ) );
565 if ( exts >= 0 ) {
566 field->data = ( data ? ( data + len_len ) : NULL );
567 if ( ( rc = tls_build_extensions ( map, index, field,
568 exts ) ) != 0 ) {
569 return rc;
570 }
571 }
572 if ( field->len > max ) {
573 DBGC ( map, "TLSFMT %s #%d len %zd too long\n",
574 tls_map_name ( map ), index, field->len );
575 return -ERANGE;
576 }
577
578 /* Allow for optional extensions fields */
579 if ( ( exts >= 0 ) && ( ! field->len ) &&
581 DBGC2 ( map, "TLSFMT %s #%d optional in version "
582 "%d.%d\n", tls_map_name ( map ), index,
583 ( version >> 8 ), ( version & 0xff ) );
584 continue;
585 }
586
587 /* Build field */
588 DBGC2 ( map, "TLSFMT %s #%d len %zd\n",
589 tls_map_name ( map ), index, field->len );
590 len += ( len_len + field->len );
591 if ( data ) {
592 while ( len_len-- ) {
593 *( ( uint8_t * ) data++ ) =
594 ( field->len >> ( 8 * len_len ) );
595 }
596 if ( exts < 0 ) {
597 if ( field->data ) {
598 memcpy ( data, field->data,
599 field->len );
600 } else {
601 memset ( data, 0, field->len );
602 }
603 }
604 field->data = data;
605 data += field->len;
606 DBGC2_HDA ( map, 0, field->data, field->len );
607 }
608 }
609
610 /* Update cursor (may overlap output data structure) */
611 cursor->len = len;
612 DBGC2 ( map, "TLSFMT %s built len %zd\n",
613 tls_map_name ( map ), cursor->len );
614 if ( data )
615 DBGC2_HDA ( map, 0, ( data - cursor->len ), cursor->len );
616
617 return 0;
618}
619
620/**
621 * Calculate length of TLS data structure
622 *
623 * @v type Descriptor structure name
624 * @v version Protocol version
625 * @v desc Data structure descriptor to fill in
626 * @v cursor Cursor to contain TLS data structure
627 * @ret rc Return status code
628 *
629 * The cursor size will be set to the overall length required to
630 * contain the TLS data structure, and the cursor data pointer will be
631 * set to NULL.
632 *
633 * If this function returns successfully, then a subsequent call to
634 * tls_build() with the exact same inputs is guaranteed to succeed and
635 * need not be checked for an error return status. The data structure
636 * descriptor must not be modified in any way that would affect its
637 * length before calling tls_build(): the easiest way to ensure this
638 * is to not modify the data structure descriptor at all.
639 *
640 * If this function fails, then the cursor length will be set to a
641 * value that is too large to be represented by a 24-bit length field.
642 * If the cursor itself lies within a containing data structure
643 * descriptor (e.g. if tls_size() is being used to calculate the size
644 * of an extension within a ClientHello descriptor), then this
645 * guarantees that a subsequent call to tls_size() on the containing
646 * descriptor will also fail. The caller therefore need only check
647 * the return status code from the call to tls_size() for the
648 * outermost descriptor.
649 *
650 * Note that this optimisation applies only when the result cursor
651 * lies within a containing data structure descriptor and so is
652 * guaranteed to be consumed by a subsequent call to calculate the
653 * length of that containing TLS data structure. If a caller is using
654 * the result from tls_size() in any other way (e.g. to add up the
655 * lengths of a sequence of CertificateEntry structures), then the
656 * caller must check the return status code in the normal way.
657 */
658int tls_size_map ( const uint8_t *map, unsigned int version,
659 union tls_ptr_len *desc, struct tls_cursor *cursor ) {
660 int rc;
661
662 /* Calculate length */
663 cursor->data = NULL;
664 if ( ( rc = tls_build_map ( map, version, desc, cursor ) ) != 0 ) {
665 /* Set an uncontainable length on error */
666 cursor->len = -1UL;
667 return rc;
668 }
669
670 return 0;
671}
672
673/** Certificate descriptor mapping */
679
680/** CertificateEntry descriptor mapping */
687
688/** ClientHello descriptor mapping */
709
710/** ClientKeyExchange descriptor mapping (for DHE) */
715
716/** ClientKeyExchange descriptor mapping (for ECDHE) */
721
722/** ClientKeyExchange descriptor mapping (for key transport) */
727
728/** DigitallySigned descriptor mapping */
734
735/** Extension descriptor mapping */
742
743/** HelloRequest descriptor mapping */
747
748/** KeyShareClientHello descriptor mapping */
753
754/** KeyShareEntry descriptor mapping */
761
762/** KeyShareHelloRetryRequest descriptor mapping */
768
769/** KeyShareServerHello descriptor mapping */
775
776/** MaxFragmentLength descriptor mapping */
781
782/** NamedGroupList descriptor mapping */
787
788/** NewSessionTicket descriptor mapping */
797
798/** PskKeyExchangeModes descriptor mapping */
803
804/** RenegotiationInfo descriptor mapping */
809
810/** ServerHello descriptor mapping */
823
824/** ServerHello descriptor mapping */
828
829/** ServerKeyExchange descriptor mapping (for DHE) */
837
838/** ServerKeyExchange descriptor mapping (for ECDHE) */
845
846/** ServerName descriptor mapping */
852
853/** ServerNameList descriptor mapping */
858
859/** SignatureSchemeList descriptor mapping */
864
865/** SupportedVersions descriptor mapping (in ServerHello) */
870
871/** SupportedVersions descriptor mapping (in ClientHello) */
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
u8 sig
Definition CIB_PRM.h:15
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned short uint16_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:10
long index
Definition bigint.h:30
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:61
u32 version
Driver version.
Definition ath9k_hw.c:1985
const char * name
Definition ath9k_hw.c:1986
#define max(x, y)
Definition ath.h:41
uint32_t next
Next descriptor address.
Definition dwmac.h:11
ring len
Length.
Definition dwmac.h:226
struct eltorito_descriptor_fixed fixed
Fixed portion.
Definition eltorito.h:1
uint16_t ext
Extended status.
Definition ena.h:9
uint32_t type
Operating system type.
Definition ena.h:1
uint8_t data[48]
Additional event data.
Definition ena.h:11
uint16_t group
Type of event.
Definition ena.h:1
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
Error codes.
#define DBGC2(...)
Definition compiler.h:547
#define DBGC2_HDA(...)
Definition compiler.h:548
#define DBGC(...)
Definition compiler.h:530
#define DBGC_HDA(...)
Definition compiler.h:531
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define EINVAL
Invalid argument.
Definition errno.h:472
#define EPROTO
Protocol error.
Definition errno.h:668
#define ERANGE
Result too large.
Definition errno.h:683
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
#define ntohs(value)
Definition byteswap.h:137
#define __attribute__(x)
Definition compiler.h:10
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
static __always_inline int struct dma_mapping * map
Definition dma.h:184
unsigned char byte
Definition smc9000.h:38
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
uint16_t age
Message age.
Definition stp.h:23
CertificateEntry descriptor.
Definition tlsfmt.h:400
Certificate descriptor.
Definition tlsfmt.h:392
ClientHello descriptor.
Definition tlsfmt.h:413
ClientKeyExchange descriptor (for DHE).
Definition tlsfmt.h:459
ClientKeyExchange descriptor (for ECDHE).
Definition tlsfmt.h:465
ClientKeyExchange descriptor (for key transport).
Definition tlsfmt.h:471
A TLS variable-length data cursor.
Definition tlsfmt.h:186
void * data
Data.
Definition tlsfmt.h:188
size_t len
Length of data.
Definition tlsfmt.h:190
DigitallySigned descriptor.
Definition tlsfmt.h:491
Extension descriptor.
Definition tlsfmt.h:499
struct tls_cursor data
Extension data.
Definition tlsfmt.h:503
struct tls_cursor next
Next extension.
Definition tlsfmt.h:505
uint16_t * type
Extension type.
Definition tlsfmt.h:501
HelloRequest descriptor.
Definition tlsfmt.h:509
KeyShareClientHello descriptor.
Definition tlsfmt.h:512
KeyShareEntry descriptor.
Definition tlsfmt.h:518
KeyShareHelloRetryRequest descriptor.
Definition tlsfmt.h:528
KeyShareServerHello descriptor.
Definition tlsfmt.h:534
MaxFragmentLength descriptor.
Definition tlsfmt.h:554
NamedGroupList descriptor.
Definition tlsfmt.h:560
NewSessionTicket descriptor.
Definition tlsfmt.h:566
PskKeyExchangeModes descriptor.
Definition tlsfmt.h:583
RenegotiationInfo descriptor.
Definition tlsfmt.h:589
ServerHelloDone descriptor.
Definition tlsfmt.h:630
ServerHello descriptor.
Definition tlsfmt.h:595
ServerKeyExchange descriptor (for DHE).
Definition tlsfmt.h:633
ServerKeyExchange descriptor (for ECDHE).
Definition tlsfmt.h:645
ServerNameList descriptor.
Definition tlsfmt.h:668
ServerName descriptor.
Definition tlsfmt.h:660
SignatureSchemeList descriptor.
Definition tlsfmt.h:674
SupportedVersions descriptor (in ServerHello).
Definition tlsfmt.h:680
SupportedVersions descriptor (in ClientHello).
Definition tlsfmt.h:686
Transport Layer Security Protocol.
#define TLS_RECORD_SIZE_LIMIT
Definition tls.h:183
#define TLS_PSK_MODES
Definition tls.h:195
#define TLS_COOKIE
Definition tls.h:192
#define TLS_EXTENDED_MASTER_SECRET
Definition tls.h:180
#define TLS_RENEGOTIATION_INFO
Definition tls.h:201
#define TLS_KEY_SHARE
Definition tls.h:198
#define TLS_SERVER_NAME
Definition tls.h:157
#define TLS_SUPPORTED_VERSIONS
Definition tls.h:189
#define TLS_MAX_FRAGMENT_LENGTH
Definition tls.h:161
#define TLS_NAMED_GROUP
Definition tls.h:168
#define TLS_SESSION_TICKET
Definition tls.h:186
#define TLS_SIGNATURE_ALGORITHMS
Definition tls.h:177
int tls_build_map(const uint8_t *map, unsigned int version, union tls_ptr_len *desc, struct tls_cursor *cursor)
Build TLS data structure.
Definition tlsfmt.c:468
static int tls_parse_extensions(const uint8_t *map, unsigned int index, struct tls_cursor *fields, unsigned int count)
Parse TLS extensions within a data structure.
Definition tlsfmt.c:111
int tls_size_map(const uint8_t *map, unsigned int version, union tls_ptr_len *desc, struct tls_cursor *cursor)
Calculate length of TLS data structure.
Definition tlsfmt.c:658
static const char * tls_map_name(const uint8_t *map)
Get data structure descriptor mapping name (for debugging).
Definition tlsfmt.c:45
int tls_parse_opt_map(const uint8_t *map, unsigned int version, const struct tls_cursor *cursor, union tls_ptr_len *desc)
Parse optional TLS data structure.
Definition tlsfmt.c:343
int tls_parse_map(const uint8_t *map, unsigned int version, const struct tls_cursor *cursor, union tls_ptr_len *desc)
Parse TLS data structure.
Definition tlsfmt.c:172
static int tls_build_extensions(const uint8_t *map, unsigned int index, struct tls_cursor *fields, unsigned int count)
Build TLS extensions within a data structure.
Definition tlsfmt.c:380
TLS data formats.
#define TLS_EXT16(desc, version, field)
Describe a variable-length field containing extensions.
Definition tlsfmt.h:339
#define tls_build(type, version, desc, cursor)
Build TLS data structure.
Definition tlsfmt.h:763
#define TLS_FIXED(desc, version, field)
Describe a fixed-length field.
Definition tlsfmt.h:268
#define TLS_VERSION_TLS_1_2
TLS version 1.2.
Definition tlsfmt.h:177
#define TLS_MAP_FIXED(byte)
Interpret fixed length from an llllllvv byte.
Definition tlsfmt.h:370
#define tls_parse(type, version, cursor, desc)
Parse TLS data structure.
Definition tlsfmt.h:733
#define TLS_VERSION_TLS_1_3
TLS version 1.3.
Definition tlsfmt.h:180
#define TLS_VAR08(desc, version, field)
Describe a variable-length field with an 8-bit length.
Definition tlsfmt.h:309
#define TLS_VAR24(desc, version, field)
Describe a variable-length field with a 24-bit length.
Definition tlsfmt.h:329
#define TLS_MAP_EXTENSIONS(byte)
Interpret number of extensions from an xxxxxxnn byte.
Definition tlsfmt.h:389
#define TLS_DESCR_MAPPING(desc)
Binary encoding of a descriptor structure mapping.
Definition tlsfmt.h:220
#define TLS_VAR16(desc, version, field)
Describe a variable-length field with a 16-bit length.
Definition tlsfmt.h:319
#define TLS_VERSION_BASE
Lowest configurable supported version.
Definition tlsfmt.h:183
#define TLS_MAPSZ(desc)
Describe size of a descriptor mapping.
Definition tlsfmt.h:229
#define TLS_EXTND(desc, extension, field)
Describe a variable-length field containing an extension of interest.
Definition tlsfmt.h:350
#define TLS_MAP_MIN(byte)
Interpret minimum version from an llllllvv byte.
Definition tlsfmt.h:362
#define TLS_MAP_LEN_LEN(byte)
Interpret number of length bytes from an xxxxxxnn byte.
Definition tlsfmt.h:378
#define TLS_EXTRA(desc, version, field)
Describe a variable-length field that captures all remaining data.
Definition tlsfmt.h:299
#define TLS_MAP_LEN_LEN_MAX
Maximum number of length bytes.
Definition tlsfmt.h:381
A pointer/length value.
Definition tlsfmt.h:194
u32 lifetime
For Lifetime-type KDEs, the lifetime in seconds.
Definition wpa.h:27
u8 nonce[32]
Nonce value.
Definition wpa.h:25