iPXE
tlsfmt.h
Go to the documentation of this file.
1#ifndef _IPXE_TLSFMT_H
2#define _IPXE_TLSFMT_H
3
4/** @file
5 *
6 * TLS data formats
7 *
8 * TLS uses an ad hoc mixture of fixed-length and variable-length
9 * fields. Variable-length fields are preceded by a length field that
10 * may be one, two, or three bytes depending on the maximum length
11 * defined by the structure.
12 *
13 * To avoid open-coding a very large number of bounds checks, we
14 * define an abstraction for decomposing the component parts of a TLS
15 * data structure into a sequence of field data pointers and lengths
16 * (for variable-length fields), along with an efficient binary
17 * encoding that can describe the mapping between the decomposition
18 * and the raw data structure.
19 *
20 * A fixed-length field is described using a simple pointer to the
21 * appropriate fixed-length data type. A variable-length field is
22 * described using a cursor structure that comprises a void pointer
23 * followed by a length. TLS extensions are always variable-length
24 * and so are represented in the same way as variable-length fields.
25 *
26 * For example, the start of a ServerHello could be described using:
27 *
28 * struct tls_server_hello {
29 * uint16_t *version;
30 * struct tls_random *random;
31 * struct tls_cursor session_id;
32 * uint16_t *suite;
33 * uint8_t *compression;
34 * struct {
35 * struct tls_cursor all;
36 * struct tls_cursor renegotiation;
37 * struct tls_cursor extended_master_secret;
38 * } ext;
39 * };
40 *
41 * Note that the fixed-length fields are all typed pointers, whereas
42 * the variable-length session ID uses a TLS cursor (i.e. a void
43 * pointer and a length). Since pointer values and length values are
44 * necessarily the same size, we can meaningfully treat this
45 * descriptor structure as an array `ptrlen[]` of pointer/length
46 * values.
47 *
48 * We create a binary encoding to allow us to define the mapping
49 * between this descriptor structure and the raw TLS data structure
50 * using a static byte array constructed at build time. The same
51 * binary encoding may be used both for parsing and for building a TLS
52 * data structure.
53 *
54 * Starting at index `N=1` within the byte array `map[]`:
55 *
56 * - Interpret `map[0]` as the length of the `map[]` array. A zero
57 * array length is invalid and is treated as a fatal error.
58 *
59 * - Upon reaching the end of the mapping (i.e. `N==map[0]`),
60 * stop processing.
61 *
62 * - Interpret `map[N]` as the eight bits `llllllvv`, where:
63 *
64 * - `V = vv` is the minimal TLS version that includes this field
65 * (encoded as a delta from the lowest version currently
66 * supported by the codebase).
67 *
68 * - `L = llllll` is one plus the length of the corresponding
69 * fixed-length data structure. An empty fixed-length data
70 * structure is pointless, and so we choose a zero fixed length
71 * (i.e. `L==1`) to represent a variable-length data structure.
72 * A negative fixed length (i.e. `L==0`) is invalid and is
73 * treated as a fatal error.
74 *
75 * - For a fixed-length data structure (with `L>1`):
76 *
77 * - When parsing: store the pointer to the start of the
78 * fixed-length data as `ptrlen[N-1]`.
79 *
80 * - When building: append a copy of the data from `ptrlen[N-1]`
81 * with length `L-1`.
82 *
83 * - For a variable-length data structure (with `L==1`), interpret
84 * `map[N+1]` as the eight bits `xxxxxxnn`, where:
85 *
86 * - `N = nn` is the length of the length header that precedes the
87 * variable-length data structure. A zero-byte length header is
88 * invalid, and so we choose `N==0` to represent a field that
89 * covers all remaining data.
90 *
91 * - `X = xxxxxx` is one plus the number of TLS extension types
92 * that immediately follow `map[N+1]` and that represent
93 * extensions of interest that may be present within this field.
94 * A negative number of extensions (i.e. `X==0`) is impossible
95 * and so we choose this to represent a field that is not used
96 * to contain extensions.
97 *
98 * - When parsing: store the pointer to the start of the
99 * variable-length data as `ptrlen[N-1]`, and store the decoded
100 * length of the variable-length data as `ptrlen[N]`.
101 *
102 * - When building: append a copy of the data from `ptrlen[N-1]`
103 * (with the correct `N`-byte length header). Take the length
104 * of the variable-length data to be `X ? 0 : ptrlen[N]`
105 * (i.e. always build fields that contain extensions as being
106 * empty).
107 *
108 * - For each `1<=k<=(X-1)` in a variable-length data structure that
109 * is used to contain extensions (i.e. that has `X>0`), interpret
110 * `T = map[N+2k]:map[N+2k+1]` as the inverse of a TLS extension
111 * type (in network-endian order):
112 *
113 * - If `T==0`, then terminate processing with a fatal error.
114 *
115 * - When parsing: for each matching extension type `~T` that is
116 * found, store the pointer to the start of the extension data
117 * as `ptrlen[N+2k-1]`, and store the decoded length of the
118 * variable-length extension data as `ptrlen[N+2k]`.
119 *
120 * - When building: if `ptrlen[N+2k-1]` is set, then append a copy
121 * of the data from `ptrlen[N+2k-1]` with length `ptrlen[N+2k]`
122 * as an extension with type `~T` (with the correct extension
123 * header, and updating the length of the containing field
124 * accordingly).
125 *
126 * - Increment `N` to the next uninterpreted byte, and loop.
127 *
128 * Any parsing failure (e.g. insufficient remaining space to contain
129 * the fixed-length or variable-length structure) will be treated as a
130 * fatal error. Missing extensions of interest will not be treated as
131 * errors, and the corresponding `ptrlen` entries will be zeroed to
132 * indicate that the extension was not found. Duplicate extensions of
133 * interest will be treated as a fatal error. (Any extensions that
134 * are not of interest will be ignored, even if duplicated.)
135 *
136 * The encoding allows for fixed-length fields of up to 62 bytes.
137 * Longer fixed-length fields must be expressed as a sequence of
138 * smaller fixed-length fields.
139 *
140 * All fields must be represented using data structures that are
141 * packed and that allow for arbitrary byte alignment.
142 *
143 * A variable-length field that covers all remaining data (i.e. with
144 * `N==0`) may be used for incremental parsing, as required for the
145 * variable number of entries in structures such as a TLS extension
146 * list. If no such variable-length field exists, then any leftover
147 * data will be treated as a fatal parsing error.
148 *
149 * Up to four consecutive versions of TLS may be supported by the
150 * encoding. Experience shows that at most three versions of TLS will
151 * be supported by the codebase at any one time, and so this is likely
152 * to be sufficient in practice.
153 *
154 * The encoding is designed to allow for efficient population of the
155 * byte array using preprocessor macros (with compile-time checks to
156 * ensure that the byte array matches the descriptor structure). A
157 * missing populator macro will leave an erroneous zero byte within
158 * the byte array, and the encoding has been designed so that stray
159 * zero bytes will fail safe: `map[0]==0` is treated as a fatal error,
160 * `L==0` or `T==0` are treated as fatal errors, and `N==0` would
161 * capture all remaining data (and so cause parsing to fail on the
162 * subsequent byte).
163 *
164 */
165
166FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
167FILE_SECBOOT ( PERMITTED );
168
169#include <stdint.h>
170#include <stddef.h>
171#include <ipxe/asn1.h>
172
173/** TLS version 1.1 */
174#define TLS_VERSION_TLS_1_1 0x0302
175
176/** TLS version 1.2 */
177#define TLS_VERSION_TLS_1_2 0x0303
178
179/** TLS version 1.3 */
180#define TLS_VERSION_TLS_1_3 0x0304
181
182/** Lowest configurable supported version */
183#define TLS_VERSION_BASE TLS_VERSION_TLS_1_1
184
185/** A TLS variable-length data cursor */
187 /** Data */
188 void *data;
189 /** Length of data */
190 size_t len;
191};
192
193/** A pointer/length value */
195 /** Data pointer */
196 void *data;
197 /** Length */
198 size_t len;
199};
200
201/**
202 * Number of pointer/length values in a descriptor structure
203 *
204 * @v desc Descriptor structure name
205 * @ret count Number of pointer/length values
206 */
207#define TLS_DESCR_COUNT( desc ) \
208 ( /* Calculate count */ \
209 ( sizeof ( struct desc ) / sizeof ( union tls_ptr_len ) ) + \
210 /* Check alignment */ \
211 ( 0 * sizeof ( int[ -( sizeof ( struct desc ) % \
212 sizeof ( union tls_ptr_len ) ) ] ) ) )
213
214/**
215 * Binary encoding of a descriptor structure mapping
216 *
217 * @v desc Descriptor structure name
218 * @ret map Binary encoding of the descriptor structure mapping
219 */
220#define TLS_DESCR_MAPPING( desc ) \
221 const uint8_t desc ## _map [ 1 /* Mapping size byte */ + \
222 TLS_DESCR_COUNT ( desc ) ]
223
224/**
225 * Describe size of a descriptor mapping
226 *
227 * @v desc Descriptor stucture name
228 */
229#define TLS_MAPSZ( desc ) \
230 [0] = ( 1 /* Mapping size byte */ + TLS_DESCR_COUNT ( desc ) )
231
232/**
233 * Index of descriptor field
234 *
235 * @v desc Descriptor structure name
236 * @v field Field name within descriptor structure
237 * @ret index Index within byte array or ptr/len array
238 */
239#define TLS_INDEX( desc, field ) \
240 ( /* Skip mapping size byte */ \
241 1 + \
242 /* Index within ptr/len array */ \
243 ( offsetof ( struct desc, field ) / \
244 sizeof ( union tls_ptr_len ) ) + \
245 /* Check alignment */ \
246 ( 0 * sizeof ( int[ -( offsetof ( struct desc, field ) % \
247 sizeof ( union tls_ptr_len ) ) ] ) ) )
248
249/**
250 * Number of extensions of interest within an extension descriptor
251 *
252 * @v desc Descriptor structure name
253 * @v field Field name within descriptor structure
254 * @ret extns Number of extensions of interest within this field
255 */
256#define TLS_EXTNS( desc, field ) \
257 ( ( sizeof ( ( ( struct desc * ) NULL )->field ) - \
258 sizeof ( ( ( struct desc * ) NULL )->field.all ) ) \
259 / sizeof ( struct tls_cursor ) )
260
261/**
262 * Describe a fixed-length field
263 *
264 * @v desc Descriptor structure name
265 * @v version Minimum TLS version that includes this field
266 * @v field Field name within descriptor structure
267 */
268#define TLS_FIXED( desc, version, field ) \
269 /* Encoded `llllllvv` */ \
270 [ TLS_INDEX ( desc, field ) ] = \
271 ( ( (version) - TLS_VERSION_BASE ) + \
272 ( ( sizeof ( *( ( ( struct desc * ) NULL )->field ) ) \
273 + 1 ) << 2 ) )
274
275/**
276 * Describe a variable-length field
277 *
278 * @v desc Descriptor structure name
279 * @v version Minimum TLS version that includes this field
280 * @v field Field name within descriptor structure
281 * @v bits Number of bits used to encode field length
282 * @v extns Number of extensions of interest plus one (if any)
283 */
284#define TLS_VARIABLE( desc, version, field, bits, extns ) \
285 /* Encoded `000001vv` */ \
286 [ TLS_INDEX ( desc, field ) ] = \
287 ( ( (version) - TLS_VERSION_BASE ) + ( 1 << 2 ) ), \
288 /* Encoded `xxxxxxnn` */ \
289 [ TLS_INDEX ( desc, field ) + 1 ] = \
290 ( ( ( (bits) + 7 ) / 8 ) + ( (extns) << 2 ) )
291
292/**
293 * Describe a variable-length field that captures all remaining data
294 *
295 * @v desc Descriptor structure name
296 * @v version Minimum TLS version that includes this field
297 * @v field Field name within descriptor structure
298 */
299#define TLS_EXTRA( desc, version, field ) \
300 TLS_VARIABLE ( desc, version, field, 0, 0 )
301
302/**
303 * Describe a variable-length field with an 8-bit length
304 *
305 * @v desc Descriptor structure name
306 * @v version Minimum TLS version that includes this field
307 * @v field Field name within descriptor structure
308 */
309#define TLS_VAR08( desc, version, field ) \
310 TLS_VARIABLE ( desc, (version), field, 8, 0 )
311
312/**
313 * Describe a variable-length field with a 16-bit length
314 *
315 * @v desc Descriptor structure name
316 * @v version Minimum TLS version that includes this field
317 * @v field Field name within descriptor structure
318 */
319#define TLS_VAR16( desc, version, field ) \
320 TLS_VARIABLE ( desc, (version), field, 16, 0 )
321
322/**
323 * Describe a variable-length field with a 24-bit length
324 *
325 * @v desc Descriptor structure name
326 * @v version Minimum TLS version that includes this field
327 * @v field Field name within descriptor structure
328 */
329#define TLS_VAR24( desc, version, field ) \
330 TLS_VARIABLE ( desc, (version), field, 24, 0 )
331
332/**
333 * Describe a variable-length field containing extensions
334 *
335 * @v desc Descriptor structure name
336 * @v version Minimum TLS version that includes this field
337 * @v field Field name within descriptor structure
338 */
339#define TLS_EXT16( desc, version, field ) \
340 TLS_VARIABLE ( desc, (version), field.all, 16, \
341 ( TLS_EXTNS ( desc, field ) + 1 ) )
342
343/**
344 * Describe a variable-length field containing an extension of interest
345 *
346 * @v desc Descriptor structure name
347 * @v extension Extension type
348 * @v field Field name within descriptor structure
349 */
350#define TLS_EXTND( desc, extension, field ) \
351 [ TLS_INDEX ( desc, field ) ] = \
352 ( ( (extension) >> 8 ) ^ 0xff ), \
353 [ TLS_INDEX ( desc, field ) + 1 ] = \
354 ( ( (extension) & 0xff ) ^ 0xff )
355
356/**
357 * Interpret minimum version from an `llllllvv` byte
358 *
359 * @v byte Mapping byte
360 * @ret min Minimum TLS version that includes this field
361 */
362#define TLS_MAP_MIN( byte ) ( TLS_VERSION_BASE + ( (byte) & 0x03 ) )
363
364/**
365 * Interpret fixed length from an `llllllvv` byte
366 *
367 * @v byte Mapping byte
368 * @ret fixed Fixed length
369 */
370#define TLS_MAP_FIXED( byte ) ( ( (byte) >> 2 ) - 1 )
371
372/**
373 * Interpret number of length bytes from an `xxxxxxnn` byte
374 *
375 * @v byte Mapping byte
376 * @ret len_len Number of length bytes
377 */
378#define TLS_MAP_LEN_LEN( byte ) ( (byte) & 0x03 )
379
380/** Maximum number of length bytes */
381#define TLS_MAP_LEN_LEN_MAX 3
382
383/**
384 * Interpret number of extensions from an `xxxxxxnn` byte
385 *
386 * @v byte Mapping byte
387 * @ret extensions Number of extensions
388 */
389#define TLS_MAP_EXTENSIONS( byte ) ( ( (byte) >> 2 ) - 1 )
390
391/** Certificate descriptor */
393 /** Certificate request context */
395 /** Certificate list */
397};
398
399/** CertificateEntry descriptor */
401 /** Certificate data */
403 /** Extensions of interest */
404 struct {
405 /** All extensions */
408 /** Next certificate */
410};
411
412/** DigitallySigned descriptor */
414 /** Signature and hash algorithm */
415 uint16_t __attribute__ (( aligned ( 1 ) )) *sig_hash;
416 /** Signature */
418};
419
420/** Extension descriptor */
422 /** Extension type */
423 uint16_t __attribute__ (( aligned ( 1 ) )) *type;
424 /** Extension data */
426 /** Next extension */
428};
429
430/** HelloRequest descriptor */
432
433/** KeyShareEntry descriptor */
435 /** Named group */
436 uint16_t __attribute__ (( aligned ( 1 ) )) *group;
437 /** Public key */
439 /** Next key share */
441};
442
443/** NewSessionTicket descriptor */
445 /** Lifetime hint */
446 uint32_t __attribute__ (( aligned ( 1 ) )) *lifetime;
447 /** Age obfuscation */
448 uint32_t __attribute__ (( aligned ( 1 ) )) *age;
449 /** Nonce */
451 /** Ticket */
453 /** Extensions of interest */
454 struct {
455 /** All extensions */
458};
459
460/** RenegotiationInfo descriptor */
462 /** Verification data from previous Finished */
464};
465
466/** ServerHello descriptor */
468 /** First fixed-length portion */
469 struct {
470 /** Selected version */
472 /** Server random bytes */
474 } __attribute__ (( packed )) *a;
475 /** Session ID */
477 /** Second fixed-length portion */
478 struct {
479 /** Selected cipher suite */
481 /** Selected compression method */
483 } __attribute__ (( packed )) *b;
484 /** Extensions of interest */
485 struct {
486 /** All extensions */
488 /** Renegotiation information extension */
490 /** Extended master secret extension */
492 /** Supported version */
494 /** Key share */
497};
498
499/** ServerHelloDone descriptor */
501
502/** ServerKeyExchange descriptor (for DHE) */
504 /** Prime modulus */
506 /** Generator */
508 /** Public key */
510 /** Signature */
512};
513
514/** ServerKeyExchange descriptor (for ECDHE) */
516 /** Curve parameters */
517 struct {
518 /** Curve type */
520 /** Named group */
522 } __attribute__ (( packed )) *curve;
523 /** Curve point */
525 /** Signature */
527};
528
529/** SupportedVersions descriptor (in ServerHello) */
531 /** Selected version */
532 uint16_t __attribute__ (( aligned ( 1 ) )) *selected;
533};
534
535/** SupportedVersions descriptor (in ClientHello) */
537 /** Supported versions */
539};
540
541/**
542 * Get ASN.1 cursor from TLS cursor
543 *
544 * @v cursor TLS cursor
545 * @ret asn1 ASN.1 object cursor
546 */
547static inline __attribute__ (( always_inline )) const struct asn1_cursor *
548tls_asn1 ( const struct tls_cursor *cursor ) {
549 union {
550 const struct tls_cursor tls;
551 const struct asn1_cursor asn1;
552 } *u = container_of ( cursor, typeof ( *u ), tls );
553
554 /* Sanity check */
555 build_assert ( ( ( const void * ) &u->tls.data ) == &u->asn1.data );
556 build_assert ( &u->tls.len == &u->asn1.len );
557
558 return &u->asn1;
559}
560
561extern int tls_parse_map ( const uint8_t *map, unsigned int version,
562 const struct tls_cursor *cursor,
563 union tls_ptr_len *desc );
564extern int tls_parse_opt_map ( const uint8_t *map, unsigned int version,
565 const struct tls_cursor *cursor,
566 union tls_ptr_len *desc );
567extern int tls_build_map ( const uint8_t *map, unsigned int version,
568 union tls_ptr_len *desc,
569 struct tls_cursor *cursor );
570
571/**
572 * Calculate length of TLS data structure
573 *
574 * @v type Descriptor structure name
575 * @v version Protocol version
576 * @v desc Data structure descriptor to fill in
577 * @v cursor Cursor to contain TLS data structure
578 * @ret rc Return status code
579 */
580static inline __attribute__ (( always_inline )) int
581tls_size_map ( const uint8_t *map, unsigned int version,
582 union tls_ptr_len *desc, struct tls_cursor *cursor ) {
583
584 cursor->data = NULL;
585 return tls_build_map ( map, version, desc, cursor );
586}
587
588/**
589 * Parse TLS data structure
590 *
591 * @v type Descriptor structure name
592 * @v version Protocol version
593 * @v cursor Cursor containing TLS data structure
594 * @v desc Data structure descriptor to fill in
595 * @ret rc Return status code
596 */
597#define tls_parse( type, version, cursor, desc ) \
598 tls_parse_map ( type ## _map, (version), (cursor), \
599 ( ( union tls_ptr_len * ) \
600 ( (desc) == ( ( struct type * ) NULL ) ? \
601 (desc) : (desc) ) ) )
602
603/**
604 * Parse optional TLS data structure
605 *
606 * @v type Descriptor structure name
607 * @v version Protocol version
608 * @v cursor Cursor containing TLS data structure
609 * @v desc Data structure descriptor to fill in
610 * @ret rc Return status code
611 */
612#define tls_parse_opt( type, version, cursor, desc ) \
613 tls_parse_opt_map ( type ## _map, (version), (cursor), \
614 ( ( union tls_ptr_len * ) \
615 ( (desc) == ( ( struct type * ) NULL ) ? \
616 (desc) : (desc) ) ) )
617
618/**
619 * Build TLS data structure
620 *
621 * @v type Descriptor structure name
622 * @v version Protocol version
623 * @v desc Data structure descriptor to fill in
624 * @v cursor Cursor to contain TLS data structure
625 * @ret rc Return status code
626 */
627#define tls_build( type, version, desc, cursor ) \
628 tls_build_map ( type ## _map, (version), \
629 ( ( union tls_ptr_len * ) \
630 ( (desc) == ( ( struct type * ) NULL ) ? \
631 (desc) : (desc) ) ), (cursor) )
632
633/**
634 * Calculate length of TLS data structure
635 *
636 * @v type Descriptor structure name
637 * @v version Protocol version
638 * @v desc Data structure descriptor to fill in
639 * @v cursor Cursor to contain TLS data structure
640 * @ret rc Return status code
641 */
642#define tls_size( type, version, desc, cursor ) \
643 tls_size_map ( type ## _map, (version), \
644 ( ( union tls_ptr_len * ) \
645 ( (desc) == ( ( struct type * ) NULL ) ? \
646 (desc) : (desc) ) ), (cursor) )
647
662
663#endif /* _IPXE_TLSFMT_H */
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
ASN.1 encoding.
#define build_assert(condition)
Assert a condition at build time (after dead code elimination).
Definition assert.h:88
u32 version
Driver version.
Definition ath9k_hw.c:1985
union @104331263140136355135267063077374276003064103115 u
uint16_t ext
Extended status.
Definition ena.h:9
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
#define __attribute__(x)
Definition compiler.h:10
static __always_inline int struct dma_mapping * map
Definition dma.h:184
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
An ASN.1 object cursor.
Definition asn1.h:21
CertificateEntry descriptor.
Definition tlsfmt.h:400
struct tls_cursor next
Next certificate.
Definition tlsfmt.h:409
struct tls_cursor all
All extensions.
Definition tlsfmt.h:406
struct tls_cursor cert
Certificate data.
Definition tlsfmt.h:402
Certificate descriptor.
Definition tlsfmt.h:392
struct tls_cursor list
Certificate list.
Definition tlsfmt.h:396
struct tls_cursor context
Certificate request context.
Definition tlsfmt.h:394
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:413
uint16_t * sig_hash
Signature and hash algorithm.
Definition tlsfmt.h:415
struct tls_cursor sig
Signature.
Definition tlsfmt.h:417
Extension descriptor.
Definition tlsfmt.h:421
struct tls_cursor data
Extension data.
Definition tlsfmt.h:425
struct tls_cursor next
Next extension.
Definition tlsfmt.h:427
uint16_t * type
Extension type.
Definition tlsfmt.h:423
HelloRequest descriptor.
Definition tlsfmt.h:431
KeyShareEntry descriptor.
Definition tlsfmt.h:434
struct tls_cursor next
Next key share.
Definition tlsfmt.h:440
uint16_t * group
Named group.
Definition tlsfmt.h:436
struct tls_cursor public
Public key.
Definition tlsfmt.h:438
NewSessionTicket descriptor.
Definition tlsfmt.h:444
struct tls_cursor all
All extensions.
Definition tlsfmt.h:456
uint32_t * age
Age obfuscation.
Definition tlsfmt.h:448
struct tls_cursor ticket
Ticket.
Definition tlsfmt.h:452
struct tls_cursor nonce
Nonce.
Definition tlsfmt.h:450
uint32_t * lifetime
Lifetime hint.
Definition tlsfmt.h:446
RenegotiationInfo descriptor.
Definition tlsfmt.h:461
struct tls_cursor verify
Verification data from previous Finished.
Definition tlsfmt.h:463
ServerHelloDone descriptor.
Definition tlsfmt.h:500
ServerHello descriptor.
Definition tlsfmt.h:467
struct tls_cursor key
Key share.
Definition tlsfmt.h:495
struct tls_cursor all
All extensions.
Definition tlsfmt.h:487
uint16_t cipher_suite
Selected cipher suite.
Definition tlsfmt.h:480
struct tls_server_hello::@125012126022344142326053215051117066274341043305 * b
Second fixed-length portion.
struct tls_cursor session_id
Session ID.
Definition tlsfmt.h:476
struct tls_cursor ems
Extended master secret extension.
Definition tlsfmt.h:491
uint8_t random[32]
Server random bytes.
Definition tlsfmt.h:473
uint16_t version
Selected version.
Definition tlsfmt.h:471
struct tls_cursor reneg
Renegotiation information extension.
Definition tlsfmt.h:489
struct tls_server_hello::@315336275176055335347330363223260265225077223170 * a
First fixed-length portion.
uint8_t compression_method
Selected compression method.
Definition tlsfmt.h:482
struct tls_cursor supver
Supported version.
Definition tlsfmt.h:493
ServerKeyExchange descriptor (for DHE).
Definition tlsfmt.h:503
struct tls_cursor dsig
Signature.
Definition tlsfmt.h:511
struct tls_cursor dh_ys
Public key.
Definition tlsfmt.h:509
struct tls_cursor dh_g
Generator.
Definition tlsfmt.h:507
struct tls_cursor dh_p
Prime modulus.
Definition tlsfmt.h:505
ServerKeyExchange descriptor (for ECDHE).
Definition tlsfmt.h:515
uint8_t type
Curve type.
Definition tlsfmt.h:519
uint16_t group
Named group.
Definition tlsfmt.h:521
struct tls_server_key_exchange_ecdhe::@161027372353017270343224204013300325065157134244 * curve
Curve parameters.
struct tls_cursor dsig
Signature.
Definition tlsfmt.h:526
struct tls_cursor point
Curve point.
Definition tlsfmt.h:524
SupportedVersions descriptor (in ServerHello).
Definition tlsfmt.h:530
uint16_t * selected
Selected version.
Definition tlsfmt.h:532
SupportedVersions descriptor (in ClientHello).
Definition tlsfmt.h:536
struct tls_cursor versions
Supported versions.
Definition tlsfmt.h:538
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:444
static const struct asn1_cursor * tls_asn1(const struct tls_cursor *cursor)
Get ASN.1 cursor from TLS cursor.
Definition tlsfmt.h:548
#define TLS_DESCR_MAPPING(desc)
Binary encoding of a descriptor structure mapping.
Definition tlsfmt.h:220
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:319
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:148
static 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.h:581
A pointer/length value.
Definition tlsfmt.h:194
size_t len
Length.
Definition tlsfmt.h:198
void * data
Data pointer.
Definition tlsfmt.h:196