mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 15:14:17 +01:00
Use both RSA and ECDSA CA if available
This commit is contained in:
parent
420edcaf1d
commit
641de714b6
@ -31,6 +31,9 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Concatenation of all available CA certificates */
|
||||||
|
extern const char test_ca_list[];
|
||||||
|
|
||||||
/* First set of certificates: RSA, or ECDSA if RSA is not available */
|
/* First set of certificates: RSA, or ECDSA if RSA is not available */
|
||||||
extern const char *test_ca_crt;
|
extern const char *test_ca_crt;
|
||||||
extern const char *test_ca_key;
|
extern const char *test_ca_key;
|
||||||
|
@ -28,22 +28,23 @@
|
|||||||
#if defined(POLARSSL_CERTS_C)
|
#if defined(POLARSSL_CERTS_C)
|
||||||
|
|
||||||
#if defined(POLARSSL_ECDSA_C)
|
#if defined(POLARSSL_ECDSA_C)
|
||||||
const char test_ca_crt_ec[] =
|
#define TEST_CA_CRT_EC \
|
||||||
"-----BEGIN CERTIFICATE-----\r\n"
|
"-----BEGIN CERTIFICATE-----\r\n" \
|
||||||
"MIICUjCCAdegAwIBAgIJAMFD4n5iQ8zoMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYT\r\n"
|
"MIICUjCCAdegAwIBAgIJAMFD4n5iQ8zoMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYT\r\n" \
|
||||||
"Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n"
|
"Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \
|
||||||
"QyBDQTAeFw0xMzA5MjQxNTQ5NDhaFw0yMzA5MjIxNTQ5NDhaMD4xCzAJBgNVBAYT\r\n"
|
"QyBDQTAeFw0xMzA5MjQxNTQ5NDhaFw0yMzA5MjIxNTQ5NDhaMD4xCzAJBgNVBAYT\r\n" \
|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f8w\r\n" \
|
||||||
"CgYIKoZIzj0EAwIDaQAwZgIxAMO0YnNWKJUAfXgSJtJxexn4ipg+kv4znuR50v56\r\n"
|
"CgYIKoZIzj0EAwIDaQAwZgIxAMO0YnNWKJUAfXgSJtJxexn4ipg+kv4znuR50v56\r\n" \
|
||||||
"t4d0PCu412mUC6Nnd7izvtE2MgIxAP1nnJQjZ8BWukszFQDG48wxCCyci9qpdSMv\r\n"
|
"t4d0PCu412mUC6Nnd7izvtE2MgIxAP1nnJQjZ8BWukszFQDG48wxCCyci9qpdSMv\r\n" \
|
||||||
"uCjn8pwUOkABXK8Mss90fzCfCEOtIA==\r\n"
|
"uCjn8pwUOkABXK8Mss90fzCfCEOtIA==\r\n" \
|
||||||
"-----END CERTIFICATE-----\r\n";
|
"-----END CERTIFICATE-----\r\n"
|
||||||
|
const char test_ca_crt_ec[] = TEST_CA_CRT_EC;
|
||||||
|
|
||||||
const char test_ca_key_ec[] =
|
const char test_ca_key_ec[] =
|
||||||
"-----BEGIN EC PRIVATE KEY-----\r\n"
|
"-----BEGIN EC PRIVATE KEY-----\r\n"
|
||||||
@ -103,31 +104,34 @@ const char test_cli_key_ec[] =
|
|||||||
"AwEHoUQDQgAEV+WusXPf06y7k7iB/xKu7uZTrM5VU/Y0Dswu42MlC9+Y4vNcYDaW\r\n"
|
"AwEHoUQDQgAEV+WusXPf06y7k7iB/xKu7uZTrM5VU/Y0Dswu42MlC9+Y4vNcYDaW\r\n"
|
||||||
"wNUYFHDlf5/VS0UY5bBs1Vz4lo+HcKPkxw==\r\n"
|
"wNUYFHDlf5/VS0UY5bBs1Vz4lo+HcKPkxw==\r\n"
|
||||||
"-----END EC PRIVATE KEY-----\r\n";
|
"-----END EC PRIVATE KEY-----\r\n";
|
||||||
|
#else
|
||||||
|
#define TEST_CA_CRT_EC
|
||||||
#endif /* POLARSSL_ECDSA_C */
|
#endif /* POLARSSL_ECDSA_C */
|
||||||
|
|
||||||
#if defined(POLARSSL_RSA_C)
|
#if defined(POLARSSL_RSA_C)
|
||||||
const char test_ca_crt_rsa[] =
|
#define TEST_CA_CRT_RSA \
|
||||||
"-----BEGIN CERTIFICATE-----\r\n"
|
"-----BEGIN CERTIFICATE-----\r\n" \
|
||||||
"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n"
|
"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" \
|
||||||
"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n"
|
"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \
|
||||||
"MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n"
|
"MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \
|
||||||
"A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n"
|
"A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \
|
||||||
"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n"
|
"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \
|
||||||
"mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n"
|
"mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \
|
||||||
"50BwFMtEonILwuVA+T7lpg6z+exKY8C4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kiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ\r\n"
|
"dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ\r\n" \
|
||||||
"SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H\r\n"
|
"SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H\r\n" \
|
||||||
"DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF\r\n"
|
"DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF\r\n" \
|
||||||
"pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf\r\n"
|
"pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf\r\n" \
|
||||||
"m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n"
|
"m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n" \
|
||||||
"7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n"
|
"7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n" \
|
||||||
"-----END CERTIFICATE-----\r\n";
|
"-----END CERTIFICATE-----\r\n"
|
||||||
|
const char test_ca_crt_rsa[] = TEST_CA_CRT_RSA;
|
||||||
|
|
||||||
const char test_ca_key_rsa[] =
|
const char test_ca_key_rsa[] =
|
||||||
"-----BEGIN RSA PRIVATE KEY-----\r\n"
|
"-----BEGIN RSA PRIVATE KEY-----\r\n"
|
||||||
@ -264,6 +268,8 @@ const char test_cli_key_rsa[] =
|
|||||||
"bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n"
|
"bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n"
|
||||||
"8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n"
|
"8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n"
|
||||||
"-----END RSA PRIVATE KEY-----\r\n";
|
"-----END RSA PRIVATE KEY-----\r\n";
|
||||||
|
#else
|
||||||
|
#define TEST_CA_CRT_RSA
|
||||||
#endif /* POLARSSL_RSA_C */
|
#endif /* POLARSSL_RSA_C */
|
||||||
|
|
||||||
#if defined(POLARSSL_DHM_C)
|
#if defined(POLARSSL_DHM_C)
|
||||||
@ -275,6 +281,9 @@ const char test_dhm_params[] =
|
|||||||
"-----END DH PARAMETERS-----\r\n";
|
"-----END DH PARAMETERS-----\r\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Concatenation of all available CA certificates */
|
||||||
|
const char test_ca_list[] = TEST_CA_CRT_RSA TEST_CA_CRT_EC;
|
||||||
|
|
||||||
#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;
|
||||||
|
@ -109,8 +109,8 @@ int main( int argc, char *argv[] )
|
|||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
#if defined(POLARSSL_CERTS_C)
|
#if defined(POLARSSL_CERTS_C)
|
||||||
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_crt,
|
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
#else
|
#else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
printf("POLARSSL_CERTS_C not defined.");
|
printf("POLARSSL_CERTS_C not defined.");
|
||||||
|
@ -576,8 +576,8 @@ 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_crt,
|
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -145,8 +145,8 @@ int main( int argc, char *argv[] )
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_crt,
|
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
|
printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
|
||||||
|
@ -484,8 +484,8 @@ 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_crt,
|
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -125,8 +125,8 @@ int main( int argc, char *argv[] )
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_crt,
|
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
|
printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
|
||||||
|
@ -549,8 +549,8 @@ 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_crt,
|
ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -218,8 +218,8 @@ static int ssl_test( struct options *opt )
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_crt,
|
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list,
|
||||||
strlen( test_ca_crt ) );
|
strlen( test_ca_list ) );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
printf( " ! x509_crt_parse returned %d\n\n", ret );
|
printf( " ! x509_crt_parse returned %d\n\n", ret );
|
||||||
|
Loading…
Reference in New Issue
Block a user