Start introducing test_cas NULL-terminated list

parent 75f90100
......@@ -30,10 +30,14 @@
extern "C" {
#endif
/* Concatenation of all available CA certificates */
/* Concatenation of all CA certificates in PEM format if available */
extern const char test_ca_list[];
extern const size_t test_ca_list_len;
/* List of all CA certificates, terminated by NULL */
extern const char * test_cas[];
extern const size_t test_cas_len[];
/*
* Convenience for users who just want a certificate:
* RSA by default, or ECDSA if RSA is not available
......
......@@ -305,6 +305,26 @@ const size_t test_dhm_params_len = sizeof( test_dhm_params );
const char test_ca_list[] = TEST_CA_CRT_RSA TEST_CA_CRT_EC;
const size_t test_ca_list_len = sizeof( test_ca_list );
/* List of all available CA certificates */
const char * test_cas[] = {
#if defined(POLARSSL_RSA_C)
test_ca_crt_rsa,
#endif
#if defined(POLARSSL_ECDSA_C)
test_ca_crt_ec,
#endif
NULL
};
const size_t test_cas_len[] = {
#if defined(POLARSSL_RSA_C)
test_ca_crt_rsa_len,
#endif
#if defined(POLARSSL_ECDSA_C)
test_ca_crt_ec_len,
#endif
0
};
#if defined(POLARSSL_RSA_C)
const char *test_ca_crt = test_ca_crt_rsa;
const char *test_ca_key = test_ca_key_rsa;
......
......@@ -946,8 +946,14 @@ int main( int argc, char *argv[] )
else
#endif
#if defined(POLARSSL_CERTS_C)
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list,
test_ca_list_len );
for( i = 0; test_cas[i] != NULL; i++ )
{
ret = x509_crt_parse( &cacert,
(const unsigned char *) test_cas[i],
test_cas_len[i] );
if( ret != 0 )
break;
}
#else
{
ret = 1;
......
......@@ -1327,8 +1327,14 @@ int main( int argc, char *argv[] )
else
#endif
#if defined(POLARSSL_CERTS_C)
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list,
test_ca_list_len );
for( i = 0; test_cas[i] != NULL; i++ )
{
ret = x509_crt_parse( &cacert,
(const unsigned char *) test_cas[i],
test_cas_len[i] );
if( ret != 0 )
break;
}
#else
{
ret = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment