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