1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +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

@ -104,7 +104,7 @@ int main( int argc, char *argv[] )
ctr_drbg_context ctr_drbg;
ssl_context ssl;
x509_cert srvcert;
rsa_context rsa;
pk_context pkey;
((void) argc);
((void) argv);
@ -139,7 +139,7 @@ int main( int argc, char *argv[] )
/*
* This demonstration program uses embedded test certificates.
* Instead, you may want to use x509parse_crtfile() to read the
* server and CA certificates, as well as x509parse_keyfile_rsa().
* server and CA certificates, as well as x509parse_keyfile().
*/
ret = x509parse_crt( &srvcert, (const unsigned char *) test_srv_crt,
strlen( test_srv_crt ) );
@ -157,12 +157,12 @@ int main( int argc, char *argv[] )
goto exit;
}
rsa_init( &rsa, RSA_PKCS_V15, 0 );
ret = x509parse_key_rsa( &rsa, (const unsigned char *) test_srv_key,
pk_init( &pkey );
ret = x509parse_key( &pkey, (const unsigned char *) test_srv_key,
strlen( test_srv_key ), NULL, 0 );
if( ret != 0 )
{
printf( " failed\n ! x509parse_key_rsa returned %d\n\n", ret );
printf( " failed\n ! x509parse_key returned %d\n\n", ret );
goto exit;
}
@ -265,7 +265,7 @@ int main( int argc, char *argv[] )
net_send, &client_fd );
ssl_set_ca_chain( &ssl, srvcert.next, NULL, NULL );
ssl_set_own_cert( &ssl, &srvcert, &rsa );
ssl_set_own_cert( &ssl, &srvcert, &pkey );
/*
* 5. Handshake
@ -363,7 +363,7 @@ exit:
net_close( client_fd );
x509_free( &srvcert );
rsa_free( &rsa );
pk_free( &pkey );
ssl_free( &ssl );
#if defined(_WIN32)