• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  X.509 test certificates
3  *
4  *  Copyright The Mbed TLS Contributors
5  *  SPDX-License-Identifier: Apache-2.0
6  *
7  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
8  *  not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *
11  *  http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  */
19 
20 #include "common.h"
21 
22 #include <test/certs.h>
23 
24 #include "mbedtls/build_info.h"
25 
26 #include "mbedtls/pk.h"
27 
28 #include "test_certs.h"
29 
30 /*
31  *
32  * Test certificates and keys as C variables
33  *
34  */
35 
36 /*
37  * CA
38  */
39 
40 const char mbedtls_test_ca_crt_ec_pem[]           = TEST_CA_CRT_EC_PEM;
41 const char mbedtls_test_ca_key_ec_pem[]           = TEST_CA_KEY_EC_PEM;
42 const char mbedtls_test_ca_pwd_ec_pem[]           = TEST_CA_PWD_EC_PEM;
43 const char mbedtls_test_ca_key_rsa_pem[]          = TEST_CA_KEY_RSA_PEM;
44 const char mbedtls_test_ca_pwd_rsa_pem[]          = TEST_CA_PWD_RSA_PEM;
45 const char mbedtls_test_ca_crt_rsa_sha1_pem[]     = TEST_CA_CRT_RSA_SHA1_PEM;
46 const char mbedtls_test_ca_crt_rsa_sha256_pem[]   = TEST_CA_CRT_RSA_SHA256_PEM;
47 
48 const unsigned char mbedtls_test_ca_crt_ec_der[]   = TEST_CA_CRT_EC_DER;
49 const unsigned char mbedtls_test_ca_key_ec_der[]   = TEST_CA_KEY_EC_DER;
50 const unsigned char mbedtls_test_ca_key_rsa_der[]  = TEST_CA_KEY_RSA_DER;
51 const unsigned char mbedtls_test_ca_crt_rsa_sha1_der[]   =
52     TEST_CA_CRT_RSA_SHA1_DER;
53 const unsigned char mbedtls_test_ca_crt_rsa_sha256_der[] =
54     TEST_CA_CRT_RSA_SHA256_DER;
55 
56 const size_t mbedtls_test_ca_crt_ec_pem_len =
57     sizeof(mbedtls_test_ca_crt_ec_pem);
58 const size_t mbedtls_test_ca_key_ec_pem_len =
59     sizeof(mbedtls_test_ca_key_ec_pem);
60 const size_t mbedtls_test_ca_pwd_ec_pem_len =
61     sizeof(mbedtls_test_ca_pwd_ec_pem) - 1;
62 const size_t mbedtls_test_ca_key_rsa_pem_len =
63     sizeof(mbedtls_test_ca_key_rsa_pem);
64 const size_t mbedtls_test_ca_pwd_rsa_pem_len =
65     sizeof(mbedtls_test_ca_pwd_rsa_pem) - 1;
66 const size_t mbedtls_test_ca_crt_rsa_sha1_pem_len =
67     sizeof(mbedtls_test_ca_crt_rsa_sha1_pem);
68 const size_t mbedtls_test_ca_crt_rsa_sha256_pem_len =
69     sizeof(mbedtls_test_ca_crt_rsa_sha256_pem);
70 
71 const size_t mbedtls_test_ca_crt_ec_der_len =
72     sizeof(mbedtls_test_ca_crt_ec_der);
73 const size_t mbedtls_test_ca_key_ec_der_len =
74     sizeof(mbedtls_test_ca_key_ec_der);
75 const size_t mbedtls_test_ca_pwd_ec_der_len = 0;
76 const size_t mbedtls_test_ca_key_rsa_der_len =
77     sizeof(mbedtls_test_ca_key_rsa_der);
78 const size_t mbedtls_test_ca_pwd_rsa_der_len = 0;
79 const size_t mbedtls_test_ca_crt_rsa_sha1_der_len =
80     sizeof(mbedtls_test_ca_crt_rsa_sha1_der);
81 const size_t mbedtls_test_ca_crt_rsa_sha256_der_len =
82     sizeof(mbedtls_test_ca_crt_rsa_sha256_der);
83 
84 /*
85  * Server
86  */
87 
88 const char mbedtls_test_srv_crt_ec_pem[]           = TEST_SRV_CRT_EC_PEM;
89 const char mbedtls_test_srv_key_ec_pem[]           = TEST_SRV_KEY_EC_PEM;
90 const char mbedtls_test_srv_pwd_ec_pem[]           = "";
91 const char mbedtls_test_srv_key_rsa_pem[]          = TEST_SRV_KEY_RSA_PEM;
92 const char mbedtls_test_srv_pwd_rsa_pem[]          = "";
93 const char mbedtls_test_srv_crt_rsa_sha1_pem[]     = TEST_SRV_CRT_RSA_SHA1_PEM;
94 const char mbedtls_test_srv_crt_rsa_sha256_pem[]   = TEST_SRV_CRT_RSA_SHA256_PEM;
95 
96 const unsigned char mbedtls_test_srv_crt_ec_der[]   = TEST_SRV_CRT_EC_DER;
97 const unsigned char mbedtls_test_srv_key_ec_der[]   = TEST_SRV_KEY_EC_DER;
98 const unsigned char mbedtls_test_srv_key_rsa_der[]  = TEST_SRV_KEY_RSA_DER;
99 const unsigned char mbedtls_test_srv_crt_rsa_sha1_der[]   =
100     TEST_SRV_CRT_RSA_SHA1_DER;
101 const unsigned char mbedtls_test_srv_crt_rsa_sha256_der[] =
102     TEST_SRV_CRT_RSA_SHA256_DER;
103 
104 const size_t mbedtls_test_srv_crt_ec_pem_len =
105     sizeof(mbedtls_test_srv_crt_ec_pem);
106 const size_t mbedtls_test_srv_key_ec_pem_len =
107     sizeof(mbedtls_test_srv_key_ec_pem);
108 const size_t mbedtls_test_srv_pwd_ec_pem_len =
109     sizeof(mbedtls_test_srv_pwd_ec_pem) - 1;
110 const size_t mbedtls_test_srv_key_rsa_pem_len =
111     sizeof(mbedtls_test_srv_key_rsa_pem);
112 const size_t mbedtls_test_srv_pwd_rsa_pem_len =
113     sizeof(mbedtls_test_srv_pwd_rsa_pem) - 1;
114 const size_t mbedtls_test_srv_crt_rsa_sha1_pem_len =
115     sizeof(mbedtls_test_srv_crt_rsa_sha1_pem);
116 const size_t mbedtls_test_srv_crt_rsa_sha256_pem_len =
117     sizeof(mbedtls_test_srv_crt_rsa_sha256_pem);
118 
119 const size_t mbedtls_test_srv_crt_ec_der_len =
120     sizeof(mbedtls_test_srv_crt_ec_der);
121 const size_t mbedtls_test_srv_key_ec_der_len =
122     sizeof(mbedtls_test_srv_key_ec_der);
123 const size_t mbedtls_test_srv_pwd_ec_der_len = 0;
124 const size_t mbedtls_test_srv_key_rsa_der_len =
125     sizeof(mbedtls_test_srv_key_rsa_der);
126 const size_t mbedtls_test_srv_pwd_rsa_der_len = 0;
127 const size_t mbedtls_test_srv_crt_rsa_sha1_der_len =
128     sizeof(mbedtls_test_srv_crt_rsa_sha1_der);
129 const size_t mbedtls_test_srv_crt_rsa_sha256_der_len =
130     sizeof(mbedtls_test_srv_crt_rsa_sha256_der);
131 
132 /*
133  * Client
134  */
135 
136 const char mbedtls_test_cli_crt_ec_pem[]   = TEST_CLI_CRT_EC_PEM;
137 const char mbedtls_test_cli_key_ec_pem[]   = TEST_CLI_KEY_EC_PEM;
138 const char mbedtls_test_cli_pwd_ec_pem[]   = "";
139 const char mbedtls_test_cli_key_rsa_pem[]  = TEST_CLI_KEY_RSA_PEM;
140 const char mbedtls_test_cli_pwd_rsa_pem[]  = "";
141 const char mbedtls_test_cli_crt_rsa_pem[]  = TEST_CLI_CRT_RSA_PEM;
142 
143 const unsigned char mbedtls_test_cli_crt_ec_der[]   = TEST_CLI_CRT_EC_DER;
144 const unsigned char mbedtls_test_cli_key_ec_der[]   = TEST_CLI_KEY_EC_DER;
145 const unsigned char mbedtls_test_cli_key_rsa_der[]  = TEST_CLI_KEY_RSA_DER;
146 const unsigned char mbedtls_test_cli_crt_rsa_der[]  = TEST_CLI_CRT_RSA_DER;
147 
148 const size_t mbedtls_test_cli_crt_ec_pem_len =
149     sizeof(mbedtls_test_cli_crt_ec_pem);
150 const size_t mbedtls_test_cli_key_ec_pem_len =
151     sizeof(mbedtls_test_cli_key_ec_pem);
152 const size_t mbedtls_test_cli_pwd_ec_pem_len =
153     sizeof(mbedtls_test_cli_pwd_ec_pem) - 1;
154 const size_t mbedtls_test_cli_key_rsa_pem_len =
155     sizeof(mbedtls_test_cli_key_rsa_pem);
156 const size_t mbedtls_test_cli_pwd_rsa_pem_len =
157     sizeof(mbedtls_test_cli_pwd_rsa_pem) - 1;
158 const size_t mbedtls_test_cli_crt_rsa_pem_len =
159     sizeof(mbedtls_test_cli_crt_rsa_pem);
160 
161 const size_t mbedtls_test_cli_crt_ec_der_len =
162     sizeof(mbedtls_test_cli_crt_ec_der);
163 const size_t mbedtls_test_cli_key_ec_der_len =
164     sizeof(mbedtls_test_cli_key_ec_der);
165 const size_t mbedtls_test_cli_key_rsa_der_len =
166     sizeof(mbedtls_test_cli_key_rsa_der);
167 const size_t mbedtls_test_cli_crt_rsa_der_len =
168     sizeof(mbedtls_test_cli_crt_rsa_der);
169 
170 /*
171  *
172  * Definitions of test CRTs without specification of all parameters, choosing
173  * them automatically according to the config. For example, mbedtls_test_ca_crt
174  * is one of mbedtls_test_ca_crt_{rsa|ec}_{sha1|sha256}_{pem|der}.
175  *
176  */
177 
178 /*
179  * Dispatch between PEM and DER according to config
180  */
181 
182 #if defined(MBEDTLS_PEM_PARSE_C)
183 
184 /* PEM encoded test CA certificates and keys */
185 
186 #define TEST_CA_KEY_RSA        TEST_CA_KEY_RSA_PEM
187 #define TEST_CA_PWD_RSA        TEST_CA_PWD_RSA_PEM
188 #define TEST_CA_CRT_RSA_SHA256 TEST_CA_CRT_RSA_SHA256_PEM
189 #define TEST_CA_CRT_RSA_SHA1   TEST_CA_CRT_RSA_SHA1_PEM
190 #define TEST_CA_KEY_EC         TEST_CA_KEY_EC_PEM
191 #define TEST_CA_PWD_EC         TEST_CA_PWD_EC_PEM
192 #define TEST_CA_CRT_EC         TEST_CA_CRT_EC_PEM
193 
194 /* PEM encoded test server certificates and keys */
195 
196 #define TEST_SRV_KEY_RSA        TEST_SRV_KEY_RSA_PEM
197 #define TEST_SRV_PWD_RSA        ""
198 #define TEST_SRV_CRT_RSA_SHA256 TEST_SRV_CRT_RSA_SHA256_PEM
199 #define TEST_SRV_CRT_RSA_SHA1   TEST_SRV_CRT_RSA_SHA1_PEM
200 #define TEST_SRV_KEY_EC         TEST_SRV_KEY_EC_PEM
201 #define TEST_SRV_PWD_EC         ""
202 #define TEST_SRV_CRT_EC         TEST_SRV_CRT_EC_PEM
203 
204 /* PEM encoded test client certificates and keys */
205 
206 #define TEST_CLI_KEY_RSA  TEST_CLI_KEY_RSA_PEM
207 #define TEST_CLI_PWD_RSA  ""
208 #define TEST_CLI_CRT_RSA  TEST_CLI_CRT_RSA_PEM
209 #define TEST_CLI_KEY_EC   TEST_CLI_KEY_EC_PEM
210 #define TEST_CLI_PWD_EC   ""
211 #define TEST_CLI_CRT_EC   TEST_CLI_CRT_EC_PEM
212 
213 #else /* MBEDTLS_PEM_PARSE_C */
214 
215 /* DER encoded test CA certificates and keys */
216 
217 #define TEST_CA_KEY_RSA        TEST_CA_KEY_RSA_DER
218 #define TEST_CA_PWD_RSA        ""
219 #define TEST_CA_CRT_RSA_SHA256 TEST_CA_CRT_RSA_SHA256_DER
220 #define TEST_CA_CRT_RSA_SHA1   TEST_CA_CRT_RSA_SHA1_DER
221 #define TEST_CA_KEY_EC         TEST_CA_KEY_EC_DER
222 #define TEST_CA_PWD_EC         ""
223 #define TEST_CA_CRT_EC         TEST_CA_CRT_EC_DER
224 
225 /* DER encoded test server certificates and keys */
226 
227 #define TEST_SRV_KEY_RSA        TEST_SRV_KEY_RSA_DER
228 #define TEST_SRV_PWD_RSA        ""
229 #define TEST_SRV_CRT_RSA_SHA256 TEST_SRV_CRT_RSA_SHA256_DER
230 #define TEST_SRV_CRT_RSA_SHA1   TEST_SRV_CRT_RSA_SHA1_DER
231 #define TEST_SRV_KEY_EC         TEST_SRV_KEY_EC_DER
232 #define TEST_SRV_PWD_EC         ""
233 #define TEST_SRV_CRT_EC         TEST_SRV_CRT_EC_DER
234 
235 /* DER encoded test client certificates and keys */
236 
237 #define TEST_CLI_KEY_RSA  TEST_CLI_KEY_RSA_DER
238 #define TEST_CLI_PWD_RSA  ""
239 #define TEST_CLI_CRT_RSA  TEST_CLI_CRT_RSA_DER
240 #define TEST_CLI_KEY_EC   TEST_CLI_KEY_EC_DER
241 #define TEST_CLI_PWD_EC   ""
242 #define TEST_CLI_CRT_EC   TEST_CLI_CRT_EC_DER
243 
244 #endif /* MBEDTLS_PEM_PARSE_C */
245 
246 const char mbedtls_test_ca_key_rsa[]         = TEST_CA_KEY_RSA;
247 const char mbedtls_test_ca_pwd_rsa[]         = TEST_CA_PWD_RSA;
248 const char mbedtls_test_ca_crt_rsa_sha256[]  = TEST_CA_CRT_RSA_SHA256;
249 const char mbedtls_test_ca_crt_rsa_sha1[]    = TEST_CA_CRT_RSA_SHA1;
250 const char mbedtls_test_ca_key_ec[]          = TEST_CA_KEY_EC;
251 const char mbedtls_test_ca_pwd_ec[]          = TEST_CA_PWD_EC;
252 const char mbedtls_test_ca_crt_ec[]          = TEST_CA_CRT_EC;
253 
254 const char mbedtls_test_srv_key_rsa[]        = TEST_SRV_KEY_RSA;
255 const char mbedtls_test_srv_pwd_rsa[]        = TEST_SRV_PWD_RSA;
256 const char mbedtls_test_srv_crt_rsa_sha256[] = TEST_SRV_CRT_RSA_SHA256;
257 const char mbedtls_test_srv_crt_rsa_sha1[]   = TEST_SRV_CRT_RSA_SHA1;
258 const char mbedtls_test_srv_key_ec[]         = TEST_SRV_KEY_EC;
259 const char mbedtls_test_srv_pwd_ec[]         = TEST_SRV_PWD_EC;
260 const char mbedtls_test_srv_crt_ec[]         = TEST_SRV_CRT_EC;
261 
262 const char mbedtls_test_cli_key_rsa[]        = TEST_CLI_KEY_RSA;
263 const char mbedtls_test_cli_pwd_rsa[]        = TEST_CLI_PWD_RSA;
264 const char mbedtls_test_cli_crt_rsa[]        = TEST_CLI_CRT_RSA;
265 const char mbedtls_test_cli_key_ec[]         = TEST_CLI_KEY_EC;
266 const char mbedtls_test_cli_pwd_ec[]         = TEST_CLI_PWD_EC;
267 const char mbedtls_test_cli_crt_ec[]         = TEST_CLI_CRT_EC;
268 
269 const size_t mbedtls_test_ca_key_rsa_len =
270     sizeof(mbedtls_test_ca_key_rsa);
271 const size_t mbedtls_test_ca_pwd_rsa_len =
272     sizeof(mbedtls_test_ca_pwd_rsa) - 1;
273 const size_t mbedtls_test_ca_crt_rsa_sha256_len =
274     sizeof(mbedtls_test_ca_crt_rsa_sha256);
275 const size_t mbedtls_test_ca_crt_rsa_sha1_len =
276     sizeof(mbedtls_test_ca_crt_rsa_sha1);
277 const size_t mbedtls_test_ca_key_ec_len =
278     sizeof(mbedtls_test_ca_key_ec);
279 const size_t mbedtls_test_ca_pwd_ec_len =
280     sizeof(mbedtls_test_ca_pwd_ec) - 1;
281 const size_t mbedtls_test_ca_crt_ec_len =
282     sizeof(mbedtls_test_ca_crt_ec);
283 
284 const size_t mbedtls_test_srv_key_rsa_len =
285     sizeof(mbedtls_test_srv_key_rsa);
286 const size_t mbedtls_test_srv_pwd_rsa_len =
287     sizeof(mbedtls_test_srv_pwd_rsa) -1;
288 const size_t mbedtls_test_srv_crt_rsa_sha256_len =
289     sizeof(mbedtls_test_srv_crt_rsa_sha256);
290 const size_t mbedtls_test_srv_crt_rsa_sha1_len =
291     sizeof(mbedtls_test_srv_crt_rsa_sha1);
292 const size_t mbedtls_test_srv_key_ec_len =
293     sizeof(mbedtls_test_srv_key_ec);
294 const size_t mbedtls_test_srv_pwd_ec_len =
295     sizeof(mbedtls_test_srv_pwd_ec) - 1;
296 const size_t mbedtls_test_srv_crt_ec_len =
297     sizeof(mbedtls_test_srv_crt_ec);
298 
299 const size_t mbedtls_test_cli_key_rsa_len =
300     sizeof(mbedtls_test_cli_key_rsa);
301 const size_t mbedtls_test_cli_pwd_rsa_len =
302     sizeof(mbedtls_test_cli_pwd_rsa) - 1;
303 const size_t mbedtls_test_cli_crt_rsa_len =
304     sizeof(mbedtls_test_cli_crt_rsa);
305 const size_t mbedtls_test_cli_key_ec_len =
306     sizeof(mbedtls_test_cli_key_ec);
307 const size_t mbedtls_test_cli_pwd_ec_len =
308     sizeof(mbedtls_test_cli_pwd_ec) - 1;
309 const size_t mbedtls_test_cli_crt_ec_len =
310     sizeof(mbedtls_test_cli_crt_ec);
311 
312 /*
313  * Dispatch between SHA-1 and SHA-256
314  */
315 
316 #if defined(MBEDTLS_MD_CAN_SHA256)
317 #define TEST_CA_CRT_RSA  TEST_CA_CRT_RSA_SHA256
318 #define TEST_SRV_CRT_RSA TEST_SRV_CRT_RSA_SHA256
319 #else
320 #define TEST_CA_CRT_RSA  TEST_CA_CRT_RSA_SHA1
321 #define TEST_SRV_CRT_RSA TEST_SRV_CRT_RSA_SHA1
322 #endif /* MBEDTLS_MD_CAN_SHA256 */
323 
324 const char mbedtls_test_ca_crt_rsa[]  = TEST_CA_CRT_RSA;
325 const char mbedtls_test_srv_crt_rsa[] = TEST_SRV_CRT_RSA;
326 
327 const size_t mbedtls_test_ca_crt_rsa_len =
328     sizeof(mbedtls_test_ca_crt_rsa);
329 const size_t mbedtls_test_srv_crt_rsa_len =
330     sizeof(mbedtls_test_srv_crt_rsa);
331 
332 /*
333  * Dispatch between RSA and EC
334  */
335 
336 #if defined(MBEDTLS_RSA_C)
337 
338 #define TEST_CA_KEY TEST_CA_KEY_RSA
339 #define TEST_CA_PWD TEST_CA_PWD_RSA
340 #define TEST_CA_CRT TEST_CA_CRT_RSA
341 
342 #define TEST_SRV_KEY TEST_SRV_KEY_RSA
343 #define TEST_SRV_PWD TEST_SRV_PWD_RSA
344 #define TEST_SRV_CRT TEST_SRV_CRT_RSA
345 
346 #define TEST_CLI_KEY TEST_CLI_KEY_RSA
347 #define TEST_CLI_PWD TEST_CLI_PWD_RSA
348 #define TEST_CLI_CRT TEST_CLI_CRT_RSA
349 
350 #else /* no RSA, so assume ECDSA */
351 
352 #define TEST_CA_KEY TEST_CA_KEY_EC
353 #define TEST_CA_PWD TEST_CA_PWD_EC
354 #define TEST_CA_CRT TEST_CA_CRT_EC
355 
356 #define TEST_SRV_KEY TEST_SRV_KEY_EC
357 #define TEST_SRV_PWD TEST_SRV_PWD_EC
358 #define TEST_SRV_CRT TEST_SRV_CRT_EC
359 
360 #define TEST_CLI_KEY TEST_CLI_KEY_EC
361 #define TEST_CLI_PWD TEST_CLI_PWD_EC
362 #define TEST_CLI_CRT TEST_CLI_CRT_EC
363 #endif /* MBEDTLS_RSA_C */
364 
365 /* API stability forces us to declare
366  *   mbedtls_test_{ca|srv|cli}_{key|pwd|crt}
367  * as pointers. */
368 static const char test_ca_key[] = TEST_CA_KEY;
369 static const char test_ca_pwd[] = TEST_CA_PWD;
370 static const char test_ca_crt[] = TEST_CA_CRT;
371 
372 static const char test_srv_key[] = TEST_SRV_KEY;
373 static const char test_srv_pwd[] = TEST_SRV_PWD;
374 static const char test_srv_crt[] = TEST_SRV_CRT;
375 
376 static const char test_cli_key[] = TEST_CLI_KEY;
377 static const char test_cli_pwd[] = TEST_CLI_PWD;
378 static const char test_cli_crt[] = TEST_CLI_CRT;
379 
380 const char *mbedtls_test_ca_key = test_ca_key;
381 const char *mbedtls_test_ca_pwd = test_ca_pwd;
382 const char *mbedtls_test_ca_crt = test_ca_crt;
383 
384 const char *mbedtls_test_srv_key = test_srv_key;
385 const char *mbedtls_test_srv_pwd = test_srv_pwd;
386 const char *mbedtls_test_srv_crt = test_srv_crt;
387 
388 const char *mbedtls_test_cli_key = test_cli_key;
389 const char *mbedtls_test_cli_pwd = test_cli_pwd;
390 const char *mbedtls_test_cli_crt = test_cli_crt;
391 
392 const size_t mbedtls_test_ca_key_len =
393     sizeof(test_ca_key);
394 const size_t mbedtls_test_ca_pwd_len =
395     sizeof(test_ca_pwd) - 1;
396 const size_t mbedtls_test_ca_crt_len =
397     sizeof(test_ca_crt);
398 
399 const size_t mbedtls_test_srv_key_len =
400     sizeof(test_srv_key);
401 const size_t mbedtls_test_srv_pwd_len =
402     sizeof(test_srv_pwd) - 1;
403 const size_t mbedtls_test_srv_crt_len =
404     sizeof(test_srv_crt);
405 
406 const size_t mbedtls_test_cli_key_len =
407     sizeof(test_cli_key);
408 const size_t mbedtls_test_cli_pwd_len =
409     sizeof(test_cli_pwd) - 1;
410 const size_t mbedtls_test_cli_crt_len =
411     sizeof(test_cli_crt);
412 
413 /*
414  *
415  * Lists of certificates
416  *
417  */
418 
419 /* List of CAs in PEM or DER, depending on config */
420 const char *mbedtls_test_cas[] = {
421 #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA1)
422     mbedtls_test_ca_crt_rsa_sha1,
423 #endif
424 #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA256)
425     mbedtls_test_ca_crt_rsa_sha256,
426 #endif
427 #if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
428     mbedtls_test_ca_crt_ec,
429 #endif
430     NULL
431 };
432 const size_t mbedtls_test_cas_len[] = {
433 #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA1)
434     sizeof(mbedtls_test_ca_crt_rsa_sha1),
435 #endif
436 #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA256)
437     sizeof(mbedtls_test_ca_crt_rsa_sha256),
438 #endif
439 #if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
440     sizeof(mbedtls_test_ca_crt_ec),
441 #endif
442     0
443 };
444 
445 /* List of all available CA certificates in DER format */
446 const unsigned char *mbedtls_test_cas_der[] = {
447 #if defined(MBEDTLS_RSA_C)
448 #if defined(MBEDTLS_MD_CAN_SHA256)
449     mbedtls_test_ca_crt_rsa_sha256_der,
450 #endif /* MBEDTLS_MD_CAN_SHA256 */
451 #if defined(MBEDTLS_MD_CAN_SHA1)
452     mbedtls_test_ca_crt_rsa_sha1_der,
453 #endif /* MBEDTLS_MD_CAN_SHA1 */
454 #endif /* MBEDTLS_RSA_C */
455 #if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
456     mbedtls_test_ca_crt_ec_der,
457 #endif /* MBEDTLS_PK_CAN_ECDSA_SOME */
458     NULL
459 };
460 
461 const size_t mbedtls_test_cas_der_len[] = {
462 #if defined(MBEDTLS_RSA_C)
463 #if defined(MBEDTLS_MD_CAN_SHA256)
464     sizeof(mbedtls_test_ca_crt_rsa_sha256_der),
465 #endif /* MBEDTLS_MD_CAN_SHA256 */
466 #if defined(MBEDTLS_MD_CAN_SHA1)
467     sizeof(mbedtls_test_ca_crt_rsa_sha1_der),
468 #endif /* MBEDTLS_MD_CAN_SHA1 */
469 #endif /* MBEDTLS_RSA_C */
470 #if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
471     sizeof(mbedtls_test_ca_crt_ec_der),
472 #endif /* MBEDTLS_PK_CAN_ECDSA_SOME */
473     0
474 };
475 
476 /* Concatenation of all available CA certificates in PEM format */
477 #if defined(MBEDTLS_PEM_PARSE_C)
478 const char mbedtls_test_cas_pem[] =
479 #if defined(MBEDTLS_RSA_C)
480 #if defined(MBEDTLS_MD_CAN_SHA256)
481     TEST_CA_CRT_RSA_SHA256_PEM
482 #endif /* MBEDTLS_MD_CAN_SHA256 */
483 #if defined(MBEDTLS_MD_CAN_SHA1)
484     TEST_CA_CRT_RSA_SHA1_PEM
485 #endif /* MBEDTLS_MD_CAN_SHA1 */
486 #endif /* MBEDTLS_RSA_C */
487 #if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
488     TEST_CA_CRT_EC_PEM
489 #endif /* MBEDTLS_PK_CAN_ECDSA_SOME */
490     "";
491 const size_t mbedtls_test_cas_pem_len = sizeof(mbedtls_test_cas_pem);
492 #endif /* MBEDTLS_PEM_PARSE_C */
493