2009-01-03 22:22:43 +01:00
|
|
|
/*
|
|
|
|
* X.509 test certificates
|
|
|
|
*
|
2020-08-07 13:07:28 +02:00
|
|
|
* Copyright The Mbed TLS Contributors
|
2023-11-02 20:47:20 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
|
|
|
|
2020-06-03 01:43:33 +02:00
|
|
|
#include "common.h"
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2021-02-08 15:34:42 +01:00
|
|
|
#include <test/certs.h>
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2022-08-17 22:09:31 +02:00
|
|
|
#include "mbedtls/build_info.h"
|
|
|
|
|
2023-02-13 11:09:40 +01:00
|
|
|
#include "mbedtls/pk.h"
|
2023-02-08 14:46:15 +01:00
|
|
|
|
2023-05-23 10:10:09 +02:00
|
|
|
#include "test_certs.h"
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Test certificates and keys as C variables
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CA
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char mbedtls_test_ca_crt_ec_pem[] = TEST_CA_CRT_EC_PEM;
|
|
|
|
const char mbedtls_test_ca_key_ec_pem[] = TEST_CA_KEY_EC_PEM;
|
|
|
|
const char mbedtls_test_ca_pwd_ec_pem[] = TEST_CA_PWD_EC_PEM;
|
|
|
|
const char mbedtls_test_ca_key_rsa_pem[] = TEST_CA_KEY_RSA_PEM;
|
|
|
|
const char mbedtls_test_ca_pwd_rsa_pem[] = TEST_CA_PWD_RSA_PEM;
|
|
|
|
const char mbedtls_test_ca_crt_rsa_sha1_pem[] = TEST_CA_CRT_RSA_SHA1_PEM;
|
|
|
|
const char mbedtls_test_ca_crt_rsa_sha256_pem[] = TEST_CA_CRT_RSA_SHA256_PEM;
|
|
|
|
|
|
|
|
const unsigned char mbedtls_test_ca_crt_ec_der[] = TEST_CA_CRT_EC_DER;
|
|
|
|
const unsigned char mbedtls_test_ca_key_ec_der[] = TEST_CA_KEY_EC_DER;
|
|
|
|
const unsigned char mbedtls_test_ca_key_rsa_der[] = TEST_CA_KEY_RSA_DER;
|
|
|
|
const unsigned char mbedtls_test_ca_crt_rsa_sha1_der[] =
|
|
|
|
TEST_CA_CRT_RSA_SHA1_DER;
|
|
|
|
const unsigned char mbedtls_test_ca_crt_rsa_sha256_der[] =
|
|
|
|
TEST_CA_CRT_RSA_SHA256_DER;
|
|
|
|
|
|
|
|
const size_t mbedtls_test_ca_crt_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_ec_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_key_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_key_ec_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_pwd_ec_pem) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_key_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_key_rsa_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_pwd_rsa_pem) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_rsa_sha1_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha1_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_rsa_sha256_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha256_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_ca_crt_ec_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_ec_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_key_ec_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_key_ec_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_ec_der_len = 0;
|
|
|
|
const size_t mbedtls_test_ca_key_rsa_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_key_rsa_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_rsa_der_len = 0;
|
|
|
|
const size_t mbedtls_test_ca_crt_rsa_sha1_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha1_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_rsa_sha256_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha256_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Server
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char mbedtls_test_srv_crt_ec_pem[] = TEST_SRV_CRT_EC_PEM;
|
|
|
|
const char mbedtls_test_srv_key_ec_pem[] = TEST_SRV_KEY_EC_PEM;
|
|
|
|
const char mbedtls_test_srv_pwd_ec_pem[] = "";
|
|
|
|
const char mbedtls_test_srv_key_rsa_pem[] = TEST_SRV_KEY_RSA_PEM;
|
|
|
|
const char mbedtls_test_srv_pwd_rsa_pem[] = "";
|
|
|
|
const char mbedtls_test_srv_crt_rsa_sha1_pem[] = TEST_SRV_CRT_RSA_SHA1_PEM;
|
|
|
|
const char mbedtls_test_srv_crt_rsa_sha256_pem[] = TEST_SRV_CRT_RSA_SHA256_PEM;
|
|
|
|
|
|
|
|
const unsigned char mbedtls_test_srv_crt_ec_der[] = TEST_SRV_CRT_EC_DER;
|
|
|
|
const unsigned char mbedtls_test_srv_key_ec_der[] = TEST_SRV_KEY_EC_DER;
|
|
|
|
const unsigned char mbedtls_test_srv_key_rsa_der[] = TEST_SRV_KEY_RSA_DER;
|
|
|
|
const unsigned char mbedtls_test_srv_crt_rsa_sha1_der[] =
|
|
|
|
TEST_SRV_CRT_RSA_SHA1_DER;
|
|
|
|
const unsigned char mbedtls_test_srv_crt_rsa_sha256_der[] =
|
|
|
|
TEST_SRV_CRT_RSA_SHA256_DER;
|
|
|
|
|
|
|
|
const size_t mbedtls_test_srv_crt_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_ec_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_key_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_key_ec_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_pwd_ec_pem) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_key_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_key_rsa_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_pwd_rsa_pem) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_rsa_sha1_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa_sha1_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_rsa_sha256_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa_sha256_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_srv_crt_ec_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_ec_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_key_ec_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_key_ec_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_ec_der_len = 0;
|
|
|
|
const size_t mbedtls_test_srv_key_rsa_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_key_rsa_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_rsa_der_len = 0;
|
|
|
|
const size_t mbedtls_test_srv_crt_rsa_sha1_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa_sha1_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_rsa_sha256_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa_sha256_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Client
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char mbedtls_test_cli_crt_ec_pem[] = TEST_CLI_CRT_EC_PEM;
|
|
|
|
const char mbedtls_test_cli_key_ec_pem[] = TEST_CLI_KEY_EC_PEM;
|
|
|
|
const char mbedtls_test_cli_pwd_ec_pem[] = "";
|
|
|
|
const char mbedtls_test_cli_key_rsa_pem[] = TEST_CLI_KEY_RSA_PEM;
|
|
|
|
const char mbedtls_test_cli_pwd_rsa_pem[] = "";
|
|
|
|
const char mbedtls_test_cli_crt_rsa_pem[] = TEST_CLI_CRT_RSA_PEM;
|
|
|
|
|
|
|
|
const unsigned char mbedtls_test_cli_crt_ec_der[] = TEST_CLI_CRT_EC_DER;
|
|
|
|
const unsigned char mbedtls_test_cli_key_ec_der[] = TEST_CLI_KEY_EC_DER;
|
|
|
|
const unsigned char mbedtls_test_cli_key_rsa_der[] = TEST_CLI_KEY_RSA_DER;
|
|
|
|
const unsigned char mbedtls_test_cli_crt_rsa_der[] = TEST_CLI_CRT_RSA_DER;
|
|
|
|
|
|
|
|
const size_t mbedtls_test_cli_crt_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_crt_ec_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_key_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_key_ec_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_pwd_ec_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_pwd_ec_pem) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_key_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_key_rsa_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_pwd_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_pwd_rsa_pem) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_crt_rsa_pem_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_crt_rsa_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_cli_crt_ec_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_crt_ec_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_key_ec_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_key_ec_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_key_rsa_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_key_rsa_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_crt_rsa_der_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_crt_rsa_der);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Definitions of test CRTs without specification of all parameters, choosing
|
|
|
|
* them automatically according to the config. For example, mbedtls_test_ca_crt
|
|
|
|
* is one of mbedtls_test_ca_crt_{rsa|ec}_{sha1|sha256}_{pem|der}.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dispatch between PEM and DER according to config
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(MBEDTLS_PEM_PARSE_C)
|
|
|
|
|
|
|
|
/* PEM encoded test CA certificates and keys */
|
|
|
|
|
|
|
|
#define TEST_CA_KEY_RSA TEST_CA_KEY_RSA_PEM
|
|
|
|
#define TEST_CA_PWD_RSA TEST_CA_PWD_RSA_PEM
|
|
|
|
#define TEST_CA_CRT_RSA_SHA256 TEST_CA_CRT_RSA_SHA256_PEM
|
|
|
|
#define TEST_CA_CRT_RSA_SHA1 TEST_CA_CRT_RSA_SHA1_PEM
|
|
|
|
#define TEST_CA_KEY_EC TEST_CA_KEY_EC_PEM
|
|
|
|
#define TEST_CA_PWD_EC TEST_CA_PWD_EC_PEM
|
|
|
|
#define TEST_CA_CRT_EC TEST_CA_CRT_EC_PEM
|
|
|
|
|
|
|
|
/* PEM encoded test server certificates and keys */
|
|
|
|
|
|
|
|
#define TEST_SRV_KEY_RSA TEST_SRV_KEY_RSA_PEM
|
|
|
|
#define TEST_SRV_PWD_RSA ""
|
|
|
|
#define TEST_SRV_CRT_RSA_SHA256 TEST_SRV_CRT_RSA_SHA256_PEM
|
|
|
|
#define TEST_SRV_CRT_RSA_SHA1 TEST_SRV_CRT_RSA_SHA1_PEM
|
|
|
|
#define TEST_SRV_KEY_EC TEST_SRV_KEY_EC_PEM
|
|
|
|
#define TEST_SRV_PWD_EC ""
|
|
|
|
#define TEST_SRV_CRT_EC TEST_SRV_CRT_EC_PEM
|
|
|
|
|
|
|
|
/* PEM encoded test client certificates and keys */
|
|
|
|
|
|
|
|
#define TEST_CLI_KEY_RSA TEST_CLI_KEY_RSA_PEM
|
|
|
|
#define TEST_CLI_PWD_RSA ""
|
|
|
|
#define TEST_CLI_CRT_RSA TEST_CLI_CRT_RSA_PEM
|
|
|
|
#define TEST_CLI_KEY_EC TEST_CLI_KEY_EC_PEM
|
|
|
|
#define TEST_CLI_PWD_EC ""
|
|
|
|
#define TEST_CLI_CRT_EC TEST_CLI_CRT_EC_PEM
|
|
|
|
|
|
|
|
#else /* MBEDTLS_PEM_PARSE_C */
|
|
|
|
|
|
|
|
/* DER encoded test CA certificates and keys */
|
|
|
|
|
|
|
|
#define TEST_CA_KEY_RSA TEST_CA_KEY_RSA_DER
|
|
|
|
#define TEST_CA_PWD_RSA ""
|
|
|
|
#define TEST_CA_CRT_RSA_SHA256 TEST_CA_CRT_RSA_SHA256_DER
|
|
|
|
#define TEST_CA_CRT_RSA_SHA1 TEST_CA_CRT_RSA_SHA1_DER
|
|
|
|
#define TEST_CA_KEY_EC TEST_CA_KEY_EC_DER
|
|
|
|
#define TEST_CA_PWD_EC ""
|
|
|
|
#define TEST_CA_CRT_EC TEST_CA_CRT_EC_DER
|
|
|
|
|
|
|
|
/* DER encoded test server certificates and keys */
|
Undo API change from SHA1 deprecation
The previous commit bd5ceee484f201b90a384636ba12de86bd330cba removed
the definition of the global constants
- mbedtls_test_ca_crt_rsa_len,
- mbedtls_test_cli_crt_rsa_len,
- mbedtls_test_ca_crt_rsa, and
- mbedtls_test_cli_crt_rsa.
This commit restores these to maintain ABI compatibility.
Further, it was noticed that without SHA256_C being enabled the
previous code failed to compile because because the SHA1 resp. SHA256
certificates were only defined when the respective SHAXXX_C options
were set, but the emission of the global variable mbedtls_test_ca_crt
was unconditionally defined through the SHA256
certificate. Previously, the RSA SHA1 certificate was unconditionally
defined and used for that.
As a remedy, this commit makes sure some RSA certificate is defined
and exported through the following rule:
1. If SHA256_C is active, define an RSA SHA256 certificate and export
it as mbedtls_test_ca_crt. Also, define SHA1 certificates only if
SHA1_C is set.
2. If SHA256_C is not set, always define SHA1 certificate and export
it as mbedtls_test_ca_crt.
2017-06-26 12:25:37 +02:00
|
|
|
|
2019-03-12 17:38:17 +01:00
|
|
|
#define TEST_SRV_KEY_RSA TEST_SRV_KEY_RSA_DER
|
|
|
|
#define TEST_SRV_PWD_RSA ""
|
|
|
|
#define TEST_SRV_CRT_RSA_SHA256 TEST_SRV_CRT_RSA_SHA256_DER
|
|
|
|
#define TEST_SRV_CRT_RSA_SHA1 TEST_SRV_CRT_RSA_SHA1_DER
|
|
|
|
#define TEST_SRV_KEY_EC TEST_SRV_KEY_EC_DER
|
|
|
|
#define TEST_SRV_PWD_EC ""
|
|
|
|
#define TEST_SRV_CRT_EC TEST_SRV_CRT_EC_DER
|
|
|
|
|
|
|
|
/* DER encoded test client certificates and keys */
|
|
|
|
|
|
|
|
#define TEST_CLI_KEY_RSA TEST_CLI_KEY_RSA_DER
|
|
|
|
#define TEST_CLI_PWD_RSA ""
|
|
|
|
#define TEST_CLI_CRT_RSA TEST_CLI_CRT_RSA_DER
|
|
|
|
#define TEST_CLI_KEY_EC TEST_CLI_KEY_EC_DER
|
|
|
|
#define TEST_CLI_PWD_EC ""
|
|
|
|
#define TEST_CLI_CRT_EC TEST_CLI_CRT_EC_DER
|
|
|
|
|
|
|
|
#endif /* MBEDTLS_PEM_PARSE_C */
|
|
|
|
|
|
|
|
const char mbedtls_test_ca_key_rsa[] = TEST_CA_KEY_RSA;
|
|
|
|
const char mbedtls_test_ca_pwd_rsa[] = TEST_CA_PWD_RSA;
|
|
|
|
const char mbedtls_test_ca_crt_rsa_sha256[] = TEST_CA_CRT_RSA_SHA256;
|
|
|
|
const char mbedtls_test_ca_crt_rsa_sha1[] = TEST_CA_CRT_RSA_SHA1;
|
|
|
|
const char mbedtls_test_ca_key_ec[] = TEST_CA_KEY_EC;
|
|
|
|
const char mbedtls_test_ca_pwd_ec[] = TEST_CA_PWD_EC;
|
|
|
|
const char mbedtls_test_ca_crt_ec[] = TEST_CA_CRT_EC;
|
|
|
|
|
|
|
|
const char mbedtls_test_srv_key_rsa[] = TEST_SRV_KEY_RSA;
|
|
|
|
const char mbedtls_test_srv_pwd_rsa[] = TEST_SRV_PWD_RSA;
|
|
|
|
const char mbedtls_test_srv_crt_rsa_sha256[] = TEST_SRV_CRT_RSA_SHA256;
|
|
|
|
const char mbedtls_test_srv_crt_rsa_sha1[] = TEST_SRV_CRT_RSA_SHA1;
|
|
|
|
const char mbedtls_test_srv_key_ec[] = TEST_SRV_KEY_EC;
|
|
|
|
const char mbedtls_test_srv_pwd_ec[] = TEST_SRV_PWD_EC;
|
|
|
|
const char mbedtls_test_srv_crt_ec[] = TEST_SRV_CRT_EC;
|
|
|
|
|
|
|
|
const char mbedtls_test_cli_key_rsa[] = TEST_CLI_KEY_RSA;
|
|
|
|
const char mbedtls_test_cli_pwd_rsa[] = TEST_CLI_PWD_RSA;
|
|
|
|
const char mbedtls_test_cli_crt_rsa[] = TEST_CLI_CRT_RSA;
|
|
|
|
const char mbedtls_test_cli_key_ec[] = TEST_CLI_KEY_EC;
|
|
|
|
const char mbedtls_test_cli_pwd_ec[] = TEST_CLI_PWD_EC;
|
|
|
|
const char mbedtls_test_cli_crt_ec[] = TEST_CLI_CRT_EC;
|
|
|
|
|
|
|
|
const size_t mbedtls_test_ca_key_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_key_rsa);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_pwd_rsa) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_rsa_sha256_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha256);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_rsa_sha1_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha1);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_key_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_key_ec);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_pwd_ec) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_ec);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_srv_key_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_key_rsa);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_pwd_rsa) -1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_rsa_sha256_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa_sha256);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_rsa_sha1_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa_sha1);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_key_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_key_ec);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_pwd_ec) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_ec);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_cli_key_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_key_rsa);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_pwd_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_pwd_rsa) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_crt_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_crt_rsa);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_key_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_key_ec);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_pwd_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_pwd_ec) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_crt_ec_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_cli_crt_ec);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dispatch between SHA-1 and SHA-256
|
|
|
|
*/
|
2018-03-30 10:42:50 +02:00
|
|
|
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA256)
|
2019-03-12 17:38:17 +01:00
|
|
|
#define TEST_CA_CRT_RSA TEST_CA_CRT_RSA_SHA256
|
|
|
|
#define TEST_SRV_CRT_RSA TEST_SRV_CRT_RSA_SHA256
|
|
|
|
#else
|
|
|
|
#define TEST_CA_CRT_RSA TEST_CA_CRT_RSA_SHA1
|
|
|
|
#define TEST_SRV_CRT_RSA TEST_SRV_CRT_RSA_SHA1
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA256 */
|
2018-03-30 10:42:50 +02:00
|
|
|
|
2019-03-12 17:38:17 +01:00
|
|
|
const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA;
|
|
|
|
const char mbedtls_test_srv_crt_rsa[] = TEST_SRV_CRT_RSA;
|
|
|
|
|
|
|
|
const size_t mbedtls_test_ca_crt_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_rsa_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_srv_crt_rsa);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dispatch between RSA and EC
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(MBEDTLS_RSA_C)
|
|
|
|
|
|
|
|
#define TEST_CA_KEY TEST_CA_KEY_RSA
|
|
|
|
#define TEST_CA_PWD TEST_CA_PWD_RSA
|
|
|
|
#define TEST_CA_CRT TEST_CA_CRT_RSA
|
|
|
|
|
|
|
|
#define TEST_SRV_KEY TEST_SRV_KEY_RSA
|
|
|
|
#define TEST_SRV_PWD TEST_SRV_PWD_RSA
|
|
|
|
#define TEST_SRV_CRT TEST_SRV_CRT_RSA
|
|
|
|
|
|
|
|
#define TEST_CLI_KEY TEST_CLI_KEY_RSA
|
|
|
|
#define TEST_CLI_PWD TEST_CLI_PWD_RSA
|
|
|
|
#define TEST_CLI_CRT TEST_CLI_CRT_RSA
|
|
|
|
|
|
|
|
#else /* no RSA, so assume ECDSA */
|
|
|
|
|
|
|
|
#define TEST_CA_KEY TEST_CA_KEY_EC
|
|
|
|
#define TEST_CA_PWD TEST_CA_PWD_EC
|
|
|
|
#define TEST_CA_CRT TEST_CA_CRT_EC
|
|
|
|
|
|
|
|
#define TEST_SRV_KEY TEST_SRV_KEY_EC
|
|
|
|
#define TEST_SRV_PWD TEST_SRV_PWD_EC
|
|
|
|
#define TEST_SRV_CRT TEST_SRV_CRT_EC
|
|
|
|
|
|
|
|
#define TEST_CLI_KEY TEST_CLI_KEY_EC
|
|
|
|
#define TEST_CLI_PWD TEST_CLI_PWD_EC
|
|
|
|
#define TEST_CLI_CRT TEST_CLI_CRT_EC
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_RSA_C */
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2019-03-12 17:38:17 +01:00
|
|
|
/* API stability forces us to declare
|
|
|
|
* mbedtls_test_{ca|srv|cli}_{key|pwd|crt}
|
|
|
|
* as pointers. */
|
|
|
|
static const char test_ca_key[] = TEST_CA_KEY;
|
|
|
|
static const char test_ca_pwd[] = TEST_CA_PWD;
|
|
|
|
static const char test_ca_crt[] = TEST_CA_CRT;
|
|
|
|
|
|
|
|
static const char test_srv_key[] = TEST_SRV_KEY;
|
|
|
|
static const char test_srv_pwd[] = TEST_SRV_PWD;
|
|
|
|
static const char test_srv_crt[] = TEST_SRV_CRT;
|
|
|
|
|
|
|
|
static const char test_cli_key[] = TEST_CLI_KEY;
|
|
|
|
static const char test_cli_pwd[] = TEST_CLI_PWD;
|
|
|
|
static const char test_cli_crt[] = TEST_CLI_CRT;
|
|
|
|
|
|
|
|
const char *mbedtls_test_ca_key = test_ca_key;
|
|
|
|
const char *mbedtls_test_ca_pwd = test_ca_pwd;
|
|
|
|
const char *mbedtls_test_ca_crt = test_ca_crt;
|
|
|
|
|
|
|
|
const char *mbedtls_test_srv_key = test_srv_key;
|
|
|
|
const char *mbedtls_test_srv_pwd = test_srv_pwd;
|
|
|
|
const char *mbedtls_test_srv_crt = test_srv_crt;
|
|
|
|
|
|
|
|
const char *mbedtls_test_cli_key = test_cli_key;
|
|
|
|
const char *mbedtls_test_cli_pwd = test_cli_pwd;
|
|
|
|
const char *mbedtls_test_cli_crt = test_cli_crt;
|
|
|
|
|
|
|
|
const size_t mbedtls_test_ca_key_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_ca_key);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_pwd_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_ca_pwd) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_ca_crt_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_ca_crt);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_srv_key_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_srv_key);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_pwd_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_srv_pwd) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_srv_crt_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_srv_crt);
|
2019-03-12 17:38:17 +01:00
|
|
|
|
|
|
|
const size_t mbedtls_test_cli_key_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_cli_key);
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_pwd_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_cli_pwd) - 1;
|
2019-03-12 17:38:17 +01:00
|
|
|
const size_t mbedtls_test_cli_crt_len =
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(test_cli_crt);
|
2013-09-25 13:23:33 +02:00
|
|
|
|
2019-03-12 17:38:17 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Lists of certificates
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* List of CAs in PEM or DER, depending on config */
|
2023-01-11 14:50:10 +01:00
|
|
|
const char *mbedtls_test_cas[] = {
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA1)
|
2017-05-05 18:56:30 +02:00
|
|
|
mbedtls_test_ca_crt_rsa_sha1,
|
|
|
|
#endif
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA256)
|
2017-05-05 18:56:30 +02:00
|
|
|
mbedtls_test_ca_crt_rsa_sha256,
|
2015-03-27 10:20:26 +01:00
|
|
|
#endif
|
2023-02-08 14:46:15 +01:00
|
|
|
#if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_test_ca_crt_ec,
|
2015-03-27 10:20:26 +01:00
|
|
|
#endif
|
|
|
|
NULL
|
|
|
|
};
|
2015-04-08 12:49:31 +02:00
|
|
|
const size_t mbedtls_test_cas_len[] = {
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA1)
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha1),
|
2017-05-05 18:56:30 +02:00
|
|
|
#endif
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_MD_CAN_SHA256)
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha256),
|
2015-03-27 10:20:26 +01:00
|
|
|
#endif
|
2023-02-08 14:46:15 +01:00
|
|
|
#if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_ec),
|
2015-03-27 10:20:26 +01:00
|
|
|
#endif
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2019-03-12 17:38:17 +01:00
|
|
|
/* List of all available CA certificates in DER format */
|
2023-01-11 14:50:10 +01:00
|
|
|
const unsigned char *mbedtls_test_cas_der[] = {
|
2019-03-12 17:38:17 +01:00
|
|
|
#if defined(MBEDTLS_RSA_C)
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA256)
|
2019-03-12 17:38:17 +01:00
|
|
|
mbedtls_test_ca_crt_rsa_sha256_der,
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA256 */
|
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA1)
|
2019-03-12 17:38:17 +01:00
|
|
|
mbedtls_test_ca_crt_rsa_sha1_der,
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA1 */
|
2019-03-12 17:38:17 +01:00
|
|
|
#endif /* MBEDTLS_RSA_C */
|
2023-02-08 14:46:15 +01:00
|
|
|
#if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
|
2019-03-12 17:38:17 +01:00
|
|
|
mbedtls_test_ca_crt_ec_der,
|
2023-02-08 14:46:15 +01:00
|
|
|
#endif /* MBEDTLS_PK_CAN_ECDSA_SOME */
|
2019-03-12 17:38:17 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const size_t mbedtls_test_cas_der_len[] = {
|
|
|
|
#if defined(MBEDTLS_RSA_C)
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA256)
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha256_der),
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA256 */
|
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA1)
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_rsa_sha1_der),
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA1 */
|
2019-03-12 17:38:17 +01:00
|
|
|
#endif /* MBEDTLS_RSA_C */
|
2023-02-08 14:46:15 +01:00
|
|
|
#if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
|
2023-01-11 14:50:10 +01:00
|
|
|
sizeof(mbedtls_test_ca_crt_ec_der),
|
2023-02-08 14:46:15 +01:00
|
|
|
#endif /* MBEDTLS_PK_CAN_ECDSA_SOME */
|
2019-03-12 17:38:17 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Concatenation of all available CA certificates in PEM format */
|
|
|
|
#if defined(MBEDTLS_PEM_PARSE_C)
|
|
|
|
const char mbedtls_test_cas_pem[] =
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_RSA_C)
|
2023-03-17 12:50:01 +01:00
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA256)
|
2019-03-12 17:38:17 +01:00
|
|
|
TEST_CA_CRT_RSA_SHA256_PEM
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA256 */
|
|
|
|
#if defined(MBEDTLS_MD_CAN_SHA1)
|
2019-03-12 17:38:17 +01:00
|
|
|
TEST_CA_CRT_RSA_SHA1_PEM
|
2023-03-17 12:50:01 +01:00
|
|
|
#endif /* MBEDTLS_MD_CAN_SHA1 */
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_RSA_C */
|
2023-02-08 14:46:15 +01:00
|
|
|
#if defined(MBEDTLS_PK_CAN_ECDSA_SOME)
|
2019-03-12 17:38:17 +01:00
|
|
|
TEST_CA_CRT_EC_PEM
|
2023-02-08 14:46:15 +01:00
|
|
|
#endif /* MBEDTLS_PK_CAN_ECDSA_SOME */
|
2019-03-12 17:38:17 +01:00
|
|
|
"";
|
2023-01-11 14:50:10 +01:00
|
|
|
const size_t mbedtls_test_cas_pem_len = sizeof(mbedtls_test_cas_pem);
|
2019-03-12 17:38:17 +01:00
|
|
|
#endif /* MBEDTLS_PEM_PARSE_C */
|