iPXE
tlsfmt_test.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 );
25
26/** @file
27 *
28 * TLS data format tests
29 *
30 */
31
32/* Forcibly enable assertions */
33#undef NDEBUG
34
35#include <string.h>
36#include <byteswap.h>
37#include <ipxe/tls.h>
38#include <ipxe/tlsfmt.h>
39#include <ipxe/test.h>
40
41/** Known valid TLSv1.3 ServerHello (from RFC 8448) */
43 0x03, 0x03, 0xa6, 0xaf, 0x06, 0xa4, 0x12, 0x18, 0x60, 0xdc, 0x5e,
44 0x6e, 0x60, 0x24, 0x9c, 0xd3, 0x4c, 0x95, 0x93, 0x0c, 0x8a, 0xc5,
45 0xcb, 0x14, 0x34, 0xda, 0xc1, 0x55, 0x77, 0x2e, 0xd3, 0xe2, 0x69,
46 0x28, 0x00, 0x13, 0x01, 0x00, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x24,
47 0x00, 0x1d, 0x00, 0x20, 0xc9, 0x82, 0x88, 0x76, 0x11, 0x20, 0x95,
48 0xfe, 0x66, 0x76, 0x2b, 0xdb, 0xf7, 0xc6, 0x72, 0xe1, 0x56, 0xd6,
49 0xcc, 0x25, 0x3b, 0x83, 0x3d, 0xf1, 0xdd, 0x69, 0xb1, 0xb0, 0x4e,
50 0x75, 0x1f, 0x0f, 0x00, 0x2b, 0x00, 0x02, 0x03, 0x04
51};
52
53/** TLSv1.3 ServerHello random bytes */
55 0xa6, 0xaf, 0x06, 0xa4, 0x12, 0x18, 0x60, 0xdc, 0x5e, 0x6e, 0x60,
56 0x24, 0x9c, 0xd3, 0x4c, 0x95, 0x93, 0x0c, 0x8a, 0xc5, 0xcb, 0x14,
57 0x34, 0xda, 0xc1, 0x55, 0x77, 0x2e, 0xd3, 0xe2, 0x69, 0x28
58};
59
60/** TLSv1.3 ServerHello public key */
62 0xc9, 0x82, 0x88, 0x76, 0x11, 0x20, 0x95, 0xfe, 0x66, 0x76, 0x2b,
63 0xdb, 0xf7, 0xc6, 0x72, 0xe1, 0x56, 0xd6, 0xcc, 0x25, 0x3b, 0x83,
64 0x3d, 0xf1, 0xdd, 0x69, 0xb1, 0xb0, 0x4e, 0x75, 0x1f, 0x0f
65};
66
67/** Known valid TLSv1.3 Certificate (from RFC 8448) */
69 0x00, 0x00, 0x01, 0xb5, 0x00, 0x01, 0xb0, 0x30, 0x82, 0x01, 0xac,
70 0x30, 0x82, 0x01, 0x15, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01,
71 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
72 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a,
73 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x72, 0x73, 0x61, 0x30,
74 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x37, 0x33, 0x30, 0x30, 0x31,
75 0x32, 0x33, 0x35, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x36, 0x30, 0x37,
76 0x33, 0x30, 0x30, 0x31, 0x32, 0x33, 0x35, 0x39, 0x5a, 0x30, 0x0e,
77 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03,
78 0x72, 0x73, 0x61, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a,
79 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03,
80 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xb4,
81 0xbb, 0x49, 0x8f, 0x82, 0x79, 0x30, 0x3d, 0x98, 0x08, 0x36, 0x39,
82 0x9b, 0x36, 0xc6, 0x98, 0x8c, 0x0c, 0x68, 0xde, 0x55, 0xe1, 0xbd,
83 0xb8, 0x26, 0xd3, 0x90, 0x1a, 0x24, 0x61, 0xea, 0xfd, 0x2d, 0xe4,
84 0x9a, 0x91, 0xd0, 0x15, 0xab, 0xbc, 0x9a, 0x95, 0x13, 0x7a, 0xce,
85 0x6c, 0x1a, 0xf1, 0x9e, 0xaa, 0x6a, 0xf9, 0x8c, 0x7c, 0xed, 0x43,
86 0x12, 0x09, 0x98, 0xe1, 0x87, 0xa8, 0x0e, 0xe0, 0xcc, 0xb0, 0x52,
87 0x4b, 0x1b, 0x01, 0x8c, 0x3e, 0x0b, 0x63, 0x26, 0x4d, 0x44, 0x9a,
88 0x6d, 0x38, 0xe2, 0x2a, 0x5f, 0xda, 0x43, 0x08, 0x46, 0x74, 0x80,
89 0x30, 0x53, 0x0e, 0xf0, 0x46, 0x1c, 0x8c, 0xa9, 0xd9, 0xef, 0xbf,
90 0xae, 0x8e, 0xa6, 0xd1, 0xd0, 0x3e, 0x2b, 0xd1, 0x93, 0xef, 0xf0,
91 0xab, 0x9a, 0x80, 0x02, 0xc4, 0x74, 0x28, 0xa6, 0xd3, 0x5a, 0x8d,
92 0x88, 0xd7, 0x9f, 0x7f, 0x1e, 0x3f, 0x02, 0x03, 0x01, 0x00, 0x01,
93 0xa3, 0x1a, 0x30, 0x18, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13,
94 0x04, 0x02, 0x30, 0x00, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f,
95 0x04, 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30, 0x0d, 0x06, 0x09, 0x2a,
96 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03,
97 0x81, 0x81, 0x00, 0x85, 0xaa, 0xd2, 0xa0, 0xe5, 0xb9, 0x27, 0x6b,
98 0x90, 0x8c, 0x65, 0xf7, 0x3a, 0x72, 0x67, 0x17, 0x06, 0x18, 0xa5,
99 0x4c, 0x5f, 0x8a, 0x7b, 0x33, 0x7d, 0x2d, 0xf7, 0xa5, 0x94, 0x36,
100 0x54, 0x17, 0xf2, 0xea, 0xe8, 0xf8, 0xa5, 0x8c, 0x8f, 0x81, 0x72,
101 0xf9, 0x31, 0x9c, 0xf3, 0x6b, 0x7f, 0xd6, 0xc5, 0x5b, 0x80, 0xf2,
102 0x1a, 0x03, 0x01, 0x51, 0x56, 0x72, 0x60, 0x96, 0xfd, 0x33, 0x5e,
103 0x5e, 0x67, 0xf2, 0xdb, 0xf1, 0x02, 0x70, 0x2e, 0x60, 0x8c, 0xca,
104 0xe6, 0xbe, 0xc1, 0xfc, 0x63, 0xa4, 0x2a, 0x99, 0xbe, 0x5c, 0x3e,
105 0xb7, 0x10, 0x7c, 0x3c, 0x54, 0xe9, 0xb9, 0xeb, 0x2b, 0xd5, 0x20,
106 0x3b, 0x1c, 0x3b, 0x84, 0xe0, 0xa8, 0xb2, 0xf7, 0x59, 0x40, 0x9b,
107 0xa3, 0xea, 0xc9, 0xd9, 0x1d, 0x40, 0x2d, 0xcc, 0x0c, 0xc8, 0xf8,
108 0x96, 0x12, 0x29, 0xac, 0x91, 0x87, 0xb4, 0x2b, 0x4d, 0xe1, 0x00,
109 0x00
110};
111
112/** TLSv1.2 Certificate (derived from RFC 8448) */
114 0x00, 0x01, 0xb3, 0x00, 0x01, 0xb0, 0x30, 0x82, 0x01, 0xac, 0x30,
115 0x82, 0x01, 0x15, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02,
116 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
117 0x01, 0x0b, 0x05, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06,
118 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x72, 0x73, 0x61, 0x30, 0x1e,
119 0x17, 0x0d, 0x31, 0x36, 0x30, 0x37, 0x33, 0x30, 0x30, 0x31, 0x32,
120 0x33, 0x35, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x36, 0x30, 0x37, 0x33,
121 0x30, 0x30, 0x31, 0x32, 0x33, 0x35, 0x39, 0x5a, 0x30, 0x0e, 0x31,
122 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x72,
123 0x73, 0x61, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
124 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81,
125 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xb4, 0xbb,
126 0x49, 0x8f, 0x82, 0x79, 0x30, 0x3d, 0x98, 0x08, 0x36, 0x39, 0x9b,
127 0x36, 0xc6, 0x98, 0x8c, 0x0c, 0x68, 0xde, 0x55, 0xe1, 0xbd, 0xb8,
128 0x26, 0xd3, 0x90, 0x1a, 0x24, 0x61, 0xea, 0xfd, 0x2d, 0xe4, 0x9a,
129 0x91, 0xd0, 0x15, 0xab, 0xbc, 0x9a, 0x95, 0x13, 0x7a, 0xce, 0x6c,
130 0x1a, 0xf1, 0x9e, 0xaa, 0x6a, 0xf9, 0x8c, 0x7c, 0xed, 0x43, 0x12,
131 0x09, 0x98, 0xe1, 0x87, 0xa8, 0x0e, 0xe0, 0xcc, 0xb0, 0x52, 0x4b,
132 0x1b, 0x01, 0x8c, 0x3e, 0x0b, 0x63, 0x26, 0x4d, 0x44, 0x9a, 0x6d,
133 0x38, 0xe2, 0x2a, 0x5f, 0xda, 0x43, 0x08, 0x46, 0x74, 0x80, 0x30,
134 0x53, 0x0e, 0xf0, 0x46, 0x1c, 0x8c, 0xa9, 0xd9, 0xef, 0xbf, 0xae,
135 0x8e, 0xa6, 0xd1, 0xd0, 0x3e, 0x2b, 0xd1, 0x93, 0xef, 0xf0, 0xab,
136 0x9a, 0x80, 0x02, 0xc4, 0x74, 0x28, 0xa6, 0xd3, 0x5a, 0x8d, 0x88,
137 0xd7, 0x9f, 0x7f, 0x1e, 0x3f, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3,
138 0x1a, 0x30, 0x18, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04,
139 0x02, 0x30, 0x00, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04,
140 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
141 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x81,
142 0x81, 0x00, 0x85, 0xaa, 0xd2, 0xa0, 0xe5, 0xb9, 0x27, 0x6b, 0x90,
143 0x8c, 0x65, 0xf7, 0x3a, 0x72, 0x67, 0x17, 0x06, 0x18, 0xa5, 0x4c,
144 0x5f, 0x8a, 0x7b, 0x33, 0x7d, 0x2d, 0xf7, 0xa5, 0x94, 0x36, 0x54,
145 0x17, 0xf2, 0xea, 0xe8, 0xf8, 0xa5, 0x8c, 0x8f, 0x81, 0x72, 0xf9,
146 0x31, 0x9c, 0xf3, 0x6b, 0x7f, 0xd6, 0xc5, 0x5b, 0x80, 0xf2, 0x1a,
147 0x03, 0x01, 0x51, 0x56, 0x72, 0x60, 0x96, 0xfd, 0x33, 0x5e, 0x5e,
148 0x67, 0xf2, 0xdb, 0xf1, 0x02, 0x70, 0x2e, 0x60, 0x8c, 0xca, 0xe6,
149 0xbe, 0xc1, 0xfc, 0x63, 0xa4, 0x2a, 0x99, 0xbe, 0x5c, 0x3e, 0xb7,
150 0x10, 0x7c, 0x3c, 0x54, 0xe9, 0xb9, 0xeb, 0x2b, 0xd5, 0x20, 0x3b,
151 0x1c, 0x3b, 0x84, 0xe0, 0xa8, 0xb2, 0xf7, 0x59, 0x40, 0x9b, 0xa3,
152 0xea, 0xc9, 0xd9, 0x1d, 0x40, 0x2d, 0xcc, 0x0c, 0xc8, 0xf8, 0x96,
153 0x12, 0x29, 0xac, 0x91, 0x87, 0xb4, 0x2b, 0x4d, 0xe1
154};
155
156/** TLSv1.1 ServerHello with no extensions */
158 0x03, 0x02, 0x1d, 0xd2, 0xbc, 0xd6, 0xce, 0xb4, 0x4b, 0x7c, 0x86,
159 0xd1, 0xac, 0x69, 0xef, 0x72, 0xf0, 0x97, 0xf7, 0xba, 0x9a, 0x84,
160 0x8d, 0x7c, 0x43, 0xf0, 0x9b, 0xea, 0x2a, 0xc0, 0x2b, 0xe6, 0xc2,
161 0xca, 0x00, 0x00, 0x2f, 0x00
162};
163
164/** TLSv1.2 ServerKeyExchange with explicit signature hash algorithm */
166 0x03, 0x00, 0x1d, 0x20, 0x79, 0xc4, 0x99, 0x60, 0xa2, 0x38, 0xa5,
167 0x11, 0xe1, 0xd1, 0x88, 0x30, 0x17, 0xb0, 0xbe, 0xef, 0xd3, 0x93,
168 0x71, 0x1e, 0xc4, 0x76, 0x70, 0x5a, 0xd5, 0x24, 0x94, 0xdb, 0x6a,
169 0xfa, 0x1c, 0x74, 0x02, 0x01, 0x01, 0x00, 0x4a, 0x8e, 0x81, 0x8b,
170 0x7f, 0x7c, 0xe0, 0x0f, 0x71, 0xe6, 0xcf, 0x24, 0xce, 0x99, 0xb4,
171 0x18, 0xf1, 0xb0, 0x68, 0x8b, 0xbf, 0x18, 0xe9, 0xed, 0xf5, 0xb4,
172 0x61, 0x4a, 0x89, 0x57, 0xa2, 0x30, 0xe8, 0x67, 0xdd, 0x70, 0x85,
173 0x60, 0xc8, 0x16, 0x4e, 0x6b, 0x0e, 0x7f, 0x8d, 0xa3, 0x5b, 0xd8,
174 0xbc, 0x2b, 0xc7, 0x81, 0xf2, 0x5f, 0xda, 0xed, 0x25, 0x60, 0x7b,
175 0x01, 0x8d, 0xaf, 0xad, 0x6b, 0x7e, 0x89, 0x2e, 0x4b, 0x14, 0xa0,
176 0x17, 0xa9, 0x53, 0xd9, 0x1f, 0xd2, 0x82, 0x88, 0x9c, 0xd9, 0x2e,
177 0x6e, 0x30, 0x78, 0x07, 0xf1, 0x9f, 0x53, 0x1f, 0xc8, 0xec, 0x2d,
178 0xf2, 0xf7, 0xdc, 0x19, 0x2b, 0x36, 0xbc, 0xf6, 0xec, 0x73, 0x9a,
179 0x43, 0xf1, 0x44, 0xa2, 0x9d, 0x80, 0xd5, 0xee, 0x18, 0xf5, 0x76,
180 0xcd, 0x81, 0xfd, 0x66, 0xb0, 0xf0, 0xa5, 0x23, 0x35, 0x42, 0x4b,
181 0xc2, 0x36, 0xbc, 0x9f, 0x55, 0x33, 0x0f, 0x64, 0x97, 0xda, 0x67,
182 0x25, 0xcb, 0x2c, 0xae, 0x78, 0xab, 0xd0, 0xa2, 0xd4, 0xf8, 0xde,
183 0x88, 0x44, 0x5a, 0x6a, 0x46, 0x1d, 0x69, 0x98, 0x2f, 0x2e, 0xe7,
184 0xd2, 0xde, 0x87, 0x0b, 0x25, 0xe3, 0x2c, 0xc1, 0x8f, 0xb6, 0xec,
185 0xf1, 0xb3, 0xba, 0xdc, 0xd7, 0x17, 0xf8, 0xbc, 0x40, 0x8f, 0xa5,
186 0x76, 0x3a, 0x40, 0xe6, 0x4c, 0x6d, 0x84, 0x76, 0x88, 0xf8, 0x37,
187 0xf4, 0x53, 0x14, 0xf6, 0x9c, 0x59, 0x39, 0x5f, 0x9b, 0x02, 0xea,
188 0x22, 0xbf, 0xa3, 0xb2, 0xde, 0x06, 0xc5, 0xba, 0x01, 0xd8, 0x15,
189 0xdc, 0x02, 0x8c, 0xdb, 0xa5, 0x56, 0x85, 0xa7, 0xbd, 0x8b, 0x9a,
190 0xdf, 0x8e, 0xbd, 0x7b, 0xac, 0xe4, 0xf3, 0x5a, 0xc4, 0x52, 0xd6,
191 0xba, 0x32, 0xca, 0xdc, 0x9f, 0x71, 0x0e, 0x00, 0xc9, 0xb0, 0x9a,
192 0x6e, 0xc6, 0xe3, 0x20, 0xb2, 0x9b, 0xe5, 0x02, 0x07, 0x2e
193};
194
195/** TLSv1.1 ServerKeyExchange with implicit signature hash algorithm */
197 0x03, 0x00, 0x1d, 0x20, 0x79, 0xc4, 0x99, 0x60, 0xa2, 0x38, 0xa5,
198 0x11, 0xe1, 0xd1, 0x88, 0x30, 0x17, 0xb0, 0xbe, 0xef, 0xd3, 0x93,
199 0x71, 0x1e, 0xc4, 0x76, 0x70, 0x5a, 0xd5, 0x24, 0x94, 0xdb, 0x6a,
200 0xfa, 0x1c, 0x74, 0x01, 0x00, 0x4a, 0x8e, 0x81, 0x8b, 0x7f, 0x7c,
201 0xe0, 0x0f, 0x71, 0xe6, 0xcf, 0x24, 0xce, 0x99, 0xb4, 0x18, 0xf1,
202 0xb0, 0x68, 0x8b, 0xbf, 0x18, 0xe9, 0xed, 0xf5, 0xb4, 0x61, 0x4a,
203 0x89, 0x57, 0xa2, 0x30, 0xe8, 0x67, 0xdd, 0x70, 0x85, 0x60, 0xc8,
204 0x16, 0x4e, 0x6b, 0x0e, 0x7f, 0x8d, 0xa3, 0x5b, 0xd8, 0xbc, 0x2b,
205 0xc7, 0x81, 0xf2, 0x5f, 0xda, 0xed, 0x25, 0x60, 0x7b, 0x01, 0x8d,
206 0xaf, 0xad, 0x6b, 0x7e, 0x89, 0x2e, 0x4b, 0x14, 0xa0, 0x17, 0xa9,
207 0x53, 0xd9, 0x1f, 0xd2, 0x82, 0x88, 0x9c, 0xd9, 0x2e, 0x6e, 0x30,
208 0x78, 0x07, 0xf1, 0x9f, 0x53, 0x1f, 0xc8, 0xec, 0x2d, 0xf2, 0xf7,
209 0xdc, 0x19, 0x2b, 0x36, 0xbc, 0xf6, 0xec, 0x73, 0x9a, 0x43, 0xf1,
210 0x44, 0xa2, 0x9d, 0x80, 0xd5, 0xee, 0x18, 0xf5, 0x76, 0xcd, 0x81,
211 0xfd, 0x66, 0xb0, 0xf0, 0xa5, 0x23, 0x35, 0x42, 0x4b, 0xc2, 0x36,
212 0xbc, 0x9f, 0x55, 0x33, 0x0f, 0x64, 0x97, 0xda, 0x67, 0x25, 0xcb,
213 0x2c, 0xae, 0x78, 0xab, 0xd0, 0xa2, 0xd4, 0xf8, 0xde, 0x88, 0x44,
214 0x5a, 0x6a, 0x46, 0x1d, 0x69, 0x98, 0x2f, 0x2e, 0xe7, 0xd2, 0xde,
215 0x87, 0x0b, 0x25, 0xe3, 0x2c, 0xc1, 0x8f, 0xb6, 0xec, 0xf1, 0xb3,
216 0xba, 0xdc, 0xd7, 0x17, 0xf8, 0xbc, 0x40, 0x8f, 0xa5, 0x76, 0x3a,
217 0x40, 0xe6, 0x4c, 0x6d, 0x84, 0x76, 0x88, 0xf8, 0x37, 0xf4, 0x53,
218 0x14, 0xf6, 0x9c, 0x59, 0x39, 0x5f, 0x9b, 0x02, 0xea, 0x22, 0xbf,
219 0xa3, 0xb2, 0xde, 0x06, 0xc5, 0xba, 0x01, 0xd8, 0x15, 0xdc, 0x02,
220 0x8c, 0xdb, 0xa5, 0x56, 0x85, 0xa7, 0xbd, 0x8b, 0x9a, 0xdf, 0x8e,
221 0xbd, 0x7b, 0xac, 0xe4, 0xf3, 0x5a, 0xc4, 0x52, 0xd6, 0xba, 0x32,
222 0xca, 0xdc, 0x9f, 0x71, 0x0e, 0x00, 0xc9, 0xb0, 0x9a, 0x6e, 0xc6,
223 0xe3, 0x20, 0xb2, 0x9b, 0xe5, 0x02, 0x07, 0x2e
224};
225
226/** ServerKeyExchange public curve point */
228 0x79, 0xc4, 0x99, 0x60, 0xa2, 0x38, 0xa5, 0x11, 0xe1, 0xd1, 0x88,
229 0x30, 0x17, 0xb0, 0xbe, 0xef, 0xd3, 0x93, 0x71, 0x1e, 0xc4, 0x76,
230 0x70, 0x5a, 0xd5, 0x24, 0x94, 0xdb, 0x6a, 0xfa, 0x1c, 0x74
231};
232
233/** ServerKeyExchange signature */
235 0x4a, 0x8e, 0x81, 0x8b, 0x7f, 0x7c, 0xe0, 0x0f, 0x71, 0xe6, 0xcf,
236 0x24, 0xce, 0x99, 0xb4, 0x18, 0xf1, 0xb0, 0x68, 0x8b, 0xbf, 0x18,
237 0xe9, 0xed, 0xf5, 0xb4, 0x61, 0x4a, 0x89, 0x57, 0xa2, 0x30, 0xe8,
238 0x67, 0xdd, 0x70, 0x85, 0x60, 0xc8, 0x16, 0x4e, 0x6b, 0x0e, 0x7f,
239 0x8d, 0xa3, 0x5b, 0xd8, 0xbc, 0x2b, 0xc7, 0x81, 0xf2, 0x5f, 0xda,
240 0xed, 0x25, 0x60, 0x7b, 0x01, 0x8d, 0xaf, 0xad, 0x6b, 0x7e, 0x89,
241 0x2e, 0x4b, 0x14, 0xa0, 0x17, 0xa9, 0x53, 0xd9, 0x1f, 0xd2, 0x82,
242 0x88, 0x9c, 0xd9, 0x2e, 0x6e, 0x30, 0x78, 0x07, 0xf1, 0x9f, 0x53,
243 0x1f, 0xc8, 0xec, 0x2d, 0xf2, 0xf7, 0xdc, 0x19, 0x2b, 0x36, 0xbc,
244 0xf6, 0xec, 0x73, 0x9a, 0x43, 0xf1, 0x44, 0xa2, 0x9d, 0x80, 0xd5,
245 0xee, 0x18, 0xf5, 0x76, 0xcd, 0x81, 0xfd, 0x66, 0xb0, 0xf0, 0xa5,
246 0x23, 0x35, 0x42, 0x4b, 0xc2, 0x36, 0xbc, 0x9f, 0x55, 0x33, 0x0f,
247 0x64, 0x97, 0xda, 0x67, 0x25, 0xcb, 0x2c, 0xae, 0x78, 0xab, 0xd0,
248 0xa2, 0xd4, 0xf8, 0xde, 0x88, 0x44, 0x5a, 0x6a, 0x46, 0x1d, 0x69,
249 0x98, 0x2f, 0x2e, 0xe7, 0xd2, 0xde, 0x87, 0x0b, 0x25, 0xe3, 0x2c,
250 0xc1, 0x8f, 0xb6, 0xec, 0xf1, 0xb3, 0xba, 0xdc, 0xd7, 0x17, 0xf8,
251 0xbc, 0x40, 0x8f, 0xa5, 0x76, 0x3a, 0x40, 0xe6, 0x4c, 0x6d, 0x84,
252 0x76, 0x88, 0xf8, 0x37, 0xf4, 0x53, 0x14, 0xf6, 0x9c, 0x59, 0x39,
253 0x5f, 0x9b, 0x02, 0xea, 0x22, 0xbf, 0xa3, 0xb2, 0xde, 0x06, 0xc5,
254 0xba, 0x01, 0xd8, 0x15, 0xdc, 0x02, 0x8c, 0xdb, 0xa5, 0x56, 0x85,
255 0xa7, 0xbd, 0x8b, 0x9a, 0xdf, 0x8e, 0xbd, 0x7b, 0xac, 0xe4, 0xf3,
256 0x5a, 0xc4, 0x52, 0xd6, 0xba, 0x32, 0xca, 0xdc, 0x9f, 0x71, 0x0e,
257 0x00, 0xc9, 0xb0, 0x9a, 0x6e, 0xc6, 0xe3, 0x20, 0xb2, 0x9b, 0xe5,
258 0x02, 0x07, 0x2e
259};
260
261/** Space for test data */
272
273/**
274 * Perform TLS data format self-test
275 *
276 */
277static void tlsfmt_test_exec ( void ) {
278 union tlsfmt_test_data u;
279 struct tls_cursor cursor;
280 struct tls_server_hello server_hello;
281 struct tls_server_hello server_hello_ref;
282 struct tls_supported_version supported_version;
283 struct tls_key_share_entry key_share_entry;
284 struct tls_certificate certificate;
285 struct tls_certificate_entry certificate_entry;
286 struct tls_server_key_exchange_ecdhe server_key_exchange_ecdhe;
287 struct tls_digitally_signed digitally_signed;
288 struct x509_certificate *tls13_cert;
289 struct x509_certificate *tls12_cert;
290 unsigned int offset;
291 uint16_t __attribute__ (( aligned ( 1 ) )) *tmp16;
293
294 /* Well-formed TLSv1.3 ServerHello */
295 memset ( u.tls13_server_hello, 0xaa, sizeof ( u.tls13_server_hello ) );
296 memcpy ( u.tls13_server_hello, tls13_server_hello,
297 sizeof ( tls13_server_hello ) );
298 cursor.data = u.tls13_server_hello;
299 cursor.len = sizeof ( tls13_server_hello );
301 &server_hello ) == 0 );
302 ok ( server_hello.a->version == htons ( TLS_VERSION_TLS_1_2 ) );
303 ok ( server_hello.session_id.data != NULL );
304 ok ( server_hello.session_id.len == 0 );
305 ok ( server_hello.b->cipher_suite ==
307 ok ( server_hello.ext.reneg.data == NULL );
308 ok ( server_hello.ext.ems.data == NULL );
309 ok ( server_hello.ext.supver.data != NULL );
310 ok ( server_hello.ext.key.data != NULL );
312 &server_hello.ext.supver, &supported_version ) == 0 );
313 ok ( *supported_version.selected == htons ( TLS_VERSION_TLS_1_3 ) );
315 &server_hello.ext.key, &key_share_entry ) == 0 );
316 ok ( *key_share_entry.group == htons ( TLS_NAMED_GROUP_X25519 ) );
317 ok ( key_share_entry.public.data != NULL );
318 ok ( key_share_entry.public.len ==
319 sizeof ( tls13_server_hello_public ) );
320 ok ( key_share_entry.next.data != NULL );
321 ok ( key_share_entry.next.len == 0 );
322
323 /* Truncated fixed-length data */
324 cursor.data = server_hello.ext.supver.data;
325 cursor.len = server_hello.ext.supver.len;
327 &cursor, &supported_version ) == 0 );
328 cursor.len -= 1;
330 &cursor, &supported_version ) != 0 );
331
332 /* Truncated variable-length length */
333 cursor.data = server_hello.ext.key.data;
334 cursor.len = server_hello.ext.key.len;
336 &key_share_entry ) == 0 );
337 cursor.len = ( sizeof ( *key_share_entry.group ) + 1 );
339 &key_share_entry ) != 0 );
340
341 /* Truncated variable-length data */
342 cursor.data = u.tls13_server_hello;
343 cursor.len = sizeof ( tls13_server_hello );
345 &server_hello ) == 0 );
346 cursor.len -= 1;
348 &server_hello ) != 0 );
349
350 /* Excess data */
351 cursor.data = u.tls13_server_hello;
352 cursor.len = sizeof ( tls13_server_hello );
354 &server_hello ) == 0 );
355 cursor.len += 1;
357 &server_hello ) != 0 );
358
359 /* Duplicate extension type */
360 cursor.data = u.tls13_server_hello;
361 cursor.len = sizeof ( tls13_server_hello );
363 &server_hello ) == 0 );
364 offset = ( server_hello.ext.key.data - cursor.data - 4 );
365 tmp16 = ( ( void * ) &u.tls13_server_hello[offset] );
366 ok ( *tmp16 == htons ( TLS_KEY_SHARE ) );
367 *tmp16 = htons ( TLS_RENEGOTIATION_INFO );
369 &server_hello ) == 0 );
370 *tmp16 = htons ( TLS_SUPPORTED_VERSIONS );
372 &server_hello ) != 0 );
373 *tmp16 = htons ( TLS_KEY_SHARE );
375 &server_hello ) == 0 );
376
377 /* Malformed extension length */
378 cursor.data = u.tls13_server_hello;
379 cursor.len = sizeof ( tls13_server_hello );
381 &server_hello ) == 0 );
382 offset = ( server_hello.ext.key.data - cursor.data - 2 );
383 tmp16 = ( ( void * ) &u.tls13_server_hello[offset] );
384 ok ( *tmp16 == htons ( 36 ) );
385 *tmp16 = htons ( sizeof ( tls13_server_hello ) );
387 &server_hello ) != 0 );
388 *tmp16 = htons ( 36 );
390 &server_hello ) == 0 );
391
392 /* Well-formed TLSv1.3 Certificate */
393 memcpy ( u.tls13_certificate, tls13_certificate,
394 sizeof ( tls13_certificate ) );
395 cursor.data = u.tls13_certificate;
396 cursor.len = sizeof ( tls13_certificate );
398 &certificate ) == 0 );
400 &certificate.list, &certificate_entry ) == 0 );
401 ok ( x509_certificate ( certificate_entry.cert.data,
402 certificate_entry.cert.len,
403 &tls13_cert ) == 0 );
404 ok ( certificate_entry.next.data != NULL );
405 ok ( certificate_entry.next.len == 0 );
406 ok ( asn1_compare ( tls_asn1 ( &certificate_entry.cert ),
407 &tls13_cert->raw ) == 0 );
408
409 /* Fields not present in older TLS versions */
411 &certificate ) == 0 );
413 &certificate ) != 0 );
414
415 /* Well-formed TLSv1.2 Certificate */
416 memcpy ( u.tls12_certificate, tls12_certificate,
417 sizeof ( tls12_certificate ) );
418 cursor.data = u.tls12_certificate;
419 cursor.len = sizeof ( tls12_certificate );
421 &certificate ) == 0 );
423 &certificate.list, &certificate_entry ) == 0 );
424 ok ( x509_certificate ( certificate_entry.cert.data,
425 certificate_entry.cert.len,
426 &tls12_cert ) == 0 );
427 ok ( certificate_entry.next.data != NULL );
428 ok ( certificate_entry.next.len == 0 );
429 ok ( asn1_compare ( tls_asn1 ( &certificate_entry.cert ),
430 &tls12_cert->raw ) == 0 );
431 ok ( tls12_cert == tls13_cert );
432
433 /* Fields not present in newer TLS versions */
435 &certificate ) == 0 );
437 &certificate ) != 0 );
438
439 /* Well-formed TLSv1.1 ServerHello with no extensions */
440 memcpy ( u.tls11_server_hello, tls11_server_hello,
441 sizeof ( tls11_server_hello ) );
442 cursor.data = u.tls11_server_hello;
443 cursor.len = sizeof ( tls11_server_hello );
445 &server_hello ) == 0 );
447 &server_hello ) == 0 );
449 &server_hello ) != 0 );
450
451 /* Well-formed TLSv1.2 ServerKeyExchange with explicit algorithm */
452 memcpy ( u.tls12_server_key_exchange_ecdhe,
455 cursor.data = u.tls12_server_key_exchange_ecdhe;
456 cursor.len = sizeof ( tls12_server_key_exchange_ecdhe );
458 &cursor, &server_key_exchange_ecdhe ) == 0 );
459 ok ( server_key_exchange_ecdhe.curve->type == TLS_NAMED_CURVE_TYPE );
460 ok ( server_key_exchange_ecdhe.curve->group ==
463 &cursor, &server_key_exchange_ecdhe ) == 0 );
465 &server_key_exchange_ecdhe.dsig,
466 &digitally_signed ) == 0 );
467 ok ( digitally_signed.sig_hash != NULL );
468 ok ( *digitally_signed.sig_hash == htons ( TLS_RSA_SHA1_ALGORITHM ) );
470 &server_key_exchange_ecdhe.dsig,
471 &digitally_signed ) != 0 );
472
473 /* Well-formed TLSv1.1 ServerKeyExchange with implicit algorithm */
474 memcpy ( u.tls11_server_key_exchange_ecdhe,
477 cursor.data = u.tls11_server_key_exchange_ecdhe;
478 cursor.len = sizeof ( tls11_server_key_exchange_ecdhe );
480 &cursor, &server_key_exchange_ecdhe ) == 0 );
481 ok ( server_key_exchange_ecdhe.curve->type == TLS_NAMED_CURVE_TYPE );
482 ok ( server_key_exchange_ecdhe.curve->group ==
485 &cursor, &server_key_exchange_ecdhe ) == 0 );
487 &server_key_exchange_ecdhe.dsig,
488 &digitally_signed ) == 0 );
489 ok ( digitally_signed.sig_hash == NULL );
491 &server_key_exchange_ecdhe.dsig,
492 &digitally_signed ) != 0 );
493
494 /* Build TLSv1.3 ServerHello */
495 memset ( &supported_version, 0, sizeof ( supported_version ) );
496 memset ( &key_share_entry, 0, sizeof ( key_share_entry ) );
497 memset ( &server_hello, 0, sizeof ( server_hello ) );
499 key_share_entry.group = &group;
500 key_share_entry.public.data = tls13_server_hello_public;
501 key_share_entry.public.len = sizeof ( tls13_server_hello_public );
503 &supported_version, &server_hello.ext.supver ) == 0 );
505 &key_share_entry, &server_hello.ext.key ) == 0 );
507 &server_hello, &cursor ) == 0 );
508 ok ( cursor.len == sizeof ( tls13_server_hello ) );
509 cursor.data = u.tls13_server_hello;
511 &server_hello, &cursor ) == 0 );
512 server_hello.a->version = htons ( TLS_VERSION_TLS_1_2 );
513 memcpy ( server_hello.a->random, tls13_server_hello_random,
514 sizeof ( server_hello.a->random ) );
515 server_hello.b->cipher_suite = htons ( TLS_AES_128_GCM_SHA256 );
517 &key_share_entry, &server_hello.ext.key ) == 0 );
519 &supported_version, &server_hello.ext.supver ) == 0 );
520 *supported_version.selected = htons ( TLS_VERSION_TLS_1_3 );
521 DBGC ( &cursor, "TLSFMT built TLSv1.3 ServerHello:\n" );
522 DBGC_HDA ( &cursor, 0, cursor.data, cursor.len );
523 DBGC ( &cursor, "TLSFMT reference TLSv1.3 ServerHello:\n" );
524 DBGC_HDA ( &cursor, 0, tls13_server_hello,
525 sizeof ( tls13_server_hello ) );
526 cursor.data = tls13_server_hello;
527 cursor.len = sizeof ( tls13_server_hello );
529 &cursor, &server_hello_ref ) == 0 );
530 ok ( server_hello.ext.supver.len == server_hello_ref.ext.supver.len );
531 ok ( server_hello.ext.key.len == server_hello_ref.ext.key.len );
532 ok ( memcmp ( u.tls13_server_hello, tls13_server_hello,
533 ( server_hello.ext.all.data -
534 ( ( void * ) u.tls13_server_hello ) ) ) == 0 );
535 ok ( memcmp ( server_hello.ext.supver.data,
536 server_hello_ref.ext.supver.data,
537 server_hello_ref.ext.supver.len ) == 0 );
538 ok ( memcmp ( server_hello.ext.key.data,
539 server_hello_ref.ext.key.data,
540 server_hello_ref.ext.key.len ) == 0 );
541
542 /* Build TLSv1.2 ServerKeyExchange */
543 memset ( &digitally_signed, 0, sizeof ( digitally_signed ) );
544 memset ( &server_key_exchange_ecdhe, 0,
545 sizeof ( server_key_exchange_ecdhe ) );
546 server_key_exchange_ecdhe.point.data = server_key_exchange_point;
547 server_key_exchange_ecdhe.point.len =
548 sizeof ( server_key_exchange_point );
549 digitally_signed.sig.data = server_key_exchange_sig;
550 digitally_signed.sig.len = sizeof ( server_key_exchange_sig );
552 &digitally_signed,
553 &server_key_exchange_ecdhe.dsig ) == 0 );
555 &server_key_exchange_ecdhe, &cursor ) == 0 );
556 ok ( cursor.len == sizeof ( tls12_server_key_exchange_ecdhe ) );
557 cursor.data = u.tls12_server_key_exchange_ecdhe;
559 &server_key_exchange_ecdhe, &cursor ) == 0 );
561 &digitally_signed,
562 &server_key_exchange_ecdhe.dsig ) == 0 );
563 server_key_exchange_ecdhe.curve->type = TLS_NAMED_CURVE_TYPE;
564 server_key_exchange_ecdhe.curve->group =
566 ok ( digitally_signed.sig_hash != NULL );
567 *digitally_signed.sig_hash = htons ( TLS_RSA_SHA1_ALGORITHM );
568 DBGC ( &cursor, "TLSFMT built TLSv1.2 ServerKeyExchange:\n" );
569 DBGC_HDA ( &cursor, 0, cursor.data, cursor.len );
570 DBGC ( &cursor, "TLSFMT reference TLSv1.2 ServerKeyExchange:\n" );
573 ok ( memcmp ( u.tls12_server_key_exchange_ecdhe,
575 sizeof ( tls12_server_key_exchange_ecdhe ) ) == 0 );
576
577 /* Build TLSv1.1 ServerKeyExchange */
578 memset ( &digitally_signed, 0, sizeof ( digitally_signed ) );
579 memset ( &server_key_exchange_ecdhe, 0,
580 sizeof ( server_key_exchange_ecdhe ) );
581 server_key_exchange_ecdhe.point.data = server_key_exchange_point;
582 server_key_exchange_ecdhe.point.len =
583 sizeof ( server_key_exchange_point );
584 digitally_signed.sig.data = server_key_exchange_sig;
585 digitally_signed.sig.len = sizeof ( server_key_exchange_sig );
587 &digitally_signed,
588 &server_key_exchange_ecdhe.dsig ) == 0 );
590 &server_key_exchange_ecdhe, &cursor ) == 0 );
591 ok ( cursor.len == sizeof ( tls11_server_key_exchange_ecdhe ) );
592 cursor.data = u.tls11_server_key_exchange_ecdhe;
594 &server_key_exchange_ecdhe, &cursor ) == 0 );
596 &digitally_signed,
597 &server_key_exchange_ecdhe.dsig ) == 0 );
598 server_key_exchange_ecdhe.curve->type = TLS_NAMED_CURVE_TYPE;
599 server_key_exchange_ecdhe.curve->group =
601 ok ( digitally_signed.sig_hash == NULL );
602 DBGC ( &cursor, "TLSFMT built TLSv1.1 ServerKeyExchange:\n" );
603 DBGC_HDA ( &cursor, 0, cursor.data, cursor.len );
604 DBGC ( &cursor, "TLSFMT reference TLSv1.1 ServerKeyExchange:\n" );
607 ok ( memcmp ( u.tls11_server_key_exchange_ecdhe,
609 sizeof ( tls11_server_key_exchange_ecdhe ) ) == 0 );
610
611 /* Drop certificate references */
612 x509_put ( tls12_cert );
613 x509_put ( tls13_cert );
614}
615
616/** TLS data format self-test */
617struct self_test tlsfmt_test __self_test = {
618 .name = "tlsfmt",
619 .exec = tlsfmt_test_exec,
620};
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
unsigned short uint16_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:10
int asn1_compare(const struct asn1_cursor *cursor1, const struct asn1_cursor *cursor2)
Compare two ASN.1 objects.
Definition asn1.c:566
uint16_t offset
Offset to command line.
Definition bzimage.h:3
union @104331263140136355135267063077374276003064103115 u
uint16_t group
Type of event.
Definition ena.h:1
#define DBGC(...)
Definition compiler.h:530
#define DBGC_HDA(...)
Definition compiler.h:531
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define htons(value)
Definition byteswap.h:136
#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
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
A self-test set.
Definition test.h:15
CertificateEntry descriptor.
Definition tlsfmt.h:400
struct tls_cursor next
Next certificate.
Definition tlsfmt.h:409
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
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
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
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_server_hello::@103274354304025060212205334334227305117174114135 ext
Extensions of interest.
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.
struct tls_cursor supver
Supported version.
Definition tlsfmt.h:493
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
An X.509 certificate.
Definition x509.h:216
struct asn1_cursor raw
Raw certificate.
Definition x509.h:231
Self-test infrastructure.
#define ok(success)
Definition test.h:46
#define __self_test
Declare a self-test.
Definition test.h:32
Transport Layer Security Protocol.
#define TLS_RENEGOTIATION_INFO
Definition tls.h:192
#define TLS_KEY_SHARE
Definition tls.h:189
#define TLS_SUPPORTED_VERSIONS
Definition tls.h:186
#define TLS_AES_128_GCM_SHA256
Definition tls.h:124
#define TLS_RSA_SHA1_ALGORITHM
Definition tls.h:140
#define TLS_NAMED_GROUP_X25519
Definition tls.h:171
#define TLS_NAMED_CURVE_TYPE
TLS named curve type.
Definition tls.h:296
TLS data formats.
#define tls_build(type, version, desc, cursor)
Build TLS data structure.
Definition tlsfmt.h:627
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_VERSION_TLS_1_2
TLS version 1.2.
Definition tlsfmt.h:177
#define tls_parse(type, version, cursor, desc)
Parse TLS data structure.
Definition tlsfmt.h:597
#define TLS_VERSION_TLS_1_3
TLS version 1.3.
Definition tlsfmt.h:180
#define TLS_VERSION_TLS_1_1
TLS version 1.1.
Definition tlsfmt.h:174
#define tls_size(type, version, desc, cursor)
Calculate length of TLS data structure.
Definition tlsfmt.h:642
static uint8_t server_key_exchange_point[]
ServerKeyExchange public curve point.
static uint8_t tls11_server_hello[]
TLSv1.1 ServerHello with no extensions.
static void tlsfmt_test_exec(void)
Perform TLS data format self-test.
static uint8_t tls11_server_key_exchange_ecdhe[]
TLSv1.1 ServerKeyExchange with implicit signature hash algorithm.
static uint8_t tls13_server_hello_public[]
TLSv1.3 ServerHello public key.
Definition tlsfmt_test.c:61
static uint8_t server_key_exchange_sig[]
ServerKeyExchange signature.
static uint8_t tls13_server_hello_random[]
TLSv1.3 ServerHello random bytes.
Definition tlsfmt_test.c:54
static uint8_t tls13_server_hello[]
Known valid TLSv1.3 ServerHello (from RFC 8448).
Definition tlsfmt_test.c:42
static uint8_t tls12_server_key_exchange_ecdhe[]
TLSv1.2 ServerKeyExchange with explicit signature hash algorithm.
static uint8_t tls12_certificate[]
TLSv1.2 Certificate (derived from RFC 8448).
static uint8_t tls13_certificate[]
Known valid TLSv1.3 Certificate (from RFC 8448).
Definition tlsfmt_test.c:68
Space for test data.
uint8_t tls12_certificate[sizeof(tls12_certificate)]
uint8_t tls13_server_hello[sizeof(tls13_server_hello)+1]
uint8_t tls11_server_hello[sizeof(tls11_server_hello)]
uint8_t tls13_certificate[sizeof(tls13_certificate)]
uint8_t tls12_server_key_exchange_ecdhe[sizeof(tls12_server_key_exchange_ecdhe)]
uint8_t tls11_server_key_exchange_ecdhe[sizeof(tls11_server_key_exchange_ecdhe)]
static void x509_put(struct x509_certificate *cert)
Drop reference to X.509 certificate.
Definition x509.h:278