Start introducing test_cas NULL-terminated list

This commit is contained in:
Manuel Pégourié-Gonnard 2015-03-27 10:20:26 +01:00
parent 75f901006b
commit 2f165060f0
4 changed files with 41 additions and 5 deletions

View File

@ -30,10 +30,14 @@
extern "C" { extern "C" {
#endif #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 char test_ca_list[];
extern const size_t test_ca_list_len; 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: * Convenience for users who just want a certificate:
* RSA by default, or ECDSA if RSA is not available * RSA by default, or ECDSA if RSA is not available

View File

@ -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 char test_ca_list[] = TEST_CA_CRT_RSA TEST_CA_CRT_EC;
const size_t test_ca_list_len = sizeof( test_ca_list ); 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) #if defined(POLARSSL_RSA_C)
const char *test_ca_crt = test_ca_crt_rsa; const char *test_ca_crt = test_ca_crt_rsa;
const char *test_ca_key = test_ca_key_rsa; const char *test_ca_key = test_ca_key_rsa;

View File

@ -946,8 +946,14 @@ int main( int argc, char *argv[] )
else else
#endif #endif
#if defined(POLARSSL_CERTS_C) #if defined(POLARSSL_CERTS_C)
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list, for( i = 0; test_cas[i] != NULL; i++ )
test_ca_list_len ); {
ret = x509_crt_parse( &cacert,
(const unsigned char *) test_cas[i],
test_cas_len[i] );
if( ret != 0 )
break;
}
#else #else
{ {
ret = 1; ret = 1;

View File

@ -1327,8 +1327,14 @@ int main( int argc, char *argv[] )
else else
#endif #endif
#if defined(POLARSSL_CERTS_C) #if defined(POLARSSL_CERTS_C)
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list, for( i = 0; test_cas[i] != NULL; i++ )
test_ca_list_len ); {
ret = x509_crt_parse( &cacert,
(const unsigned char *) test_cas[i],
test_cas_len[i] );
if( ret != 0 )
break;
}
#else #else
{ {
ret = 1; ret = 1;