1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Adapt ssl_set_own_cert() to generic keys

This commit is contained in:
Manuel Pégourié-Gonnard
2013-08-19 14:10:16 +02:00
parent 09edda888e
commit ac75523593
9 changed files with 92 additions and 62 deletions

View File

@ -257,7 +257,7 @@ int main( int argc, char *argv[] )
#if defined(POLARSSL_X509_PARSE_C)
x509_cert cacert;
x509_cert clicert;
rsa_context rsa;
pk_context pkey;
#endif
char *p, *q;
const int *list;
@ -271,7 +271,7 @@ int main( int argc, char *argv[] )
#if defined(POLARSSL_X509_PARSE_C)
memset( &cacert, 0, sizeof( x509_cert ) );
memset( &clicert, 0, sizeof( x509_cert ) );
memset( &rsa, 0, sizeof( rsa_context ) );
pk_init( &pkey );
#endif
if( argc == 0 )
@ -626,11 +626,11 @@ int main( int argc, char *argv[] )
#if defined(POLARSSL_FS_IO)
if( strlen( opt.key_file ) )
ret = x509parse_keyfile_rsa( &rsa, opt.key_file, "" );
ret = x509parse_keyfile( &pkey, opt.key_file, "" );
else
#endif
#if defined(POLARSSL_CERTS_C)
ret = x509parse_key_rsa( &rsa, (const unsigned char *) test_cli_key,
ret = x509parse_key( &pkey, (const unsigned char *) test_cli_key,
strlen( test_cli_key ), NULL, 0 );
#else
{
@ -640,7 +640,7 @@ int main( int argc, char *argv[] )
#endif
if( ret != 0 )
{
printf( " failed\n ! x509parse_key_rsa returned -0x%x\n\n", -ret );
printf( " failed\n ! x509parse_key returned -0x%x\n\n", -ret );
goto exit;
}
@ -711,7 +711,7 @@ int main( int argc, char *argv[] )
#if defined(POLARSSL_X509_PARSE_C)
ssl_set_ca_chain( &ssl, &cacert, NULL, opt.server_name );
ssl_set_own_cert( &ssl, &clicert, &rsa );
ssl_set_own_cert( &ssl, &clicert, &pkey );
#endif
#if defined(POLARSSL_KEY_EXCHANGE_PSK_ENABLED)
@ -911,7 +911,7 @@ exit:
#if defined(POLARSSL_X509_PARSE_C)
x509_free( &clicert );
x509_free( &cacert );
rsa_free( &rsa );
pk_free( &pkey );
#endif
ssl_session_free( &saved_session );
ssl_free( &ssl );