mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Make key export callback and context connection-specific
Fixes #2188 Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
committed by
Dave Rodgman
parent
a7991f2e11
commit
7e6c178b6d
@ -1736,27 +1736,6 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_ssl_conf_encrypt_then_mac( &conf, opt.etm );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
if( opt.eap_tls != 0 )
|
||||
{
|
||||
mbedtls_ssl_conf_export_keys_cb( &conf, eap_tls_key_derivation,
|
||||
&eap_tls_keying );
|
||||
}
|
||||
else if( opt.nss_keylog != 0 )
|
||||
{
|
||||
mbedtls_ssl_conf_export_keys_cb( &conf,
|
||||
nss_keylog_export,
|
||||
NULL );
|
||||
}
|
||||
#if defined( MBEDTLS_SSL_DTLS_SRTP )
|
||||
else if( opt.use_srtp != 0 )
|
||||
{
|
||||
mbedtls_ssl_conf_export_keys_cb( &conf, dtls_srtp_key_derivation,
|
||||
&dtls_srtp_keying );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
|
||||
#if defined(MBEDTLS_DHM_C)
|
||||
if( opt.dhmlen != DFL_DHMLEN )
|
||||
mbedtls_ssl_conf_dhm_min_bitlen( &conf, opt.dhmlen );
|
||||
@ -1886,6 +1865,27 @@ int main( int argc, char *argv[] )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
if( opt.eap_tls != 0 )
|
||||
{
|
||||
mbedtls_ssl_set_export_keys_cb( &ssl, eap_tls_key_derivation,
|
||||
&eap_tls_keying );
|
||||
}
|
||||
else if( opt.nss_keylog != 0 )
|
||||
{
|
||||
mbedtls_ssl_set_export_keys_cb( &ssl,
|
||||
nss_keylog_export,
|
||||
NULL );
|
||||
}
|
||||
#if defined( MBEDTLS_SSL_DTLS_SRTP )
|
||||
else if( opt.use_srtp != 0 )
|
||||
{
|
||||
mbedtls_ssl_set_export_keys_cb( &ssl, dtls_srtp_key_derivation,
|
||||
&dtls_srtp_keying );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 )
|
||||
{
|
||||
|
@ -2525,27 +2525,6 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_ssl_conf_encrypt_then_mac( &conf, opt.etm );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
if( opt.eap_tls != 0 )
|
||||
{
|
||||
mbedtls_ssl_conf_export_keys_cb( &conf, eap_tls_key_derivation,
|
||||
&eap_tls_keying );
|
||||
}
|
||||
else if( opt.nss_keylog != 0 )
|
||||
{
|
||||
mbedtls_ssl_conf_export_keys_cb( &conf,
|
||||
nss_keylog_export,
|
||||
NULL );
|
||||
}
|
||||
#if defined( MBEDTLS_SSL_DTLS_SRTP )
|
||||
else if( opt.use_srtp != 0 )
|
||||
{
|
||||
mbedtls_ssl_conf_export_keys_cb( &conf, dtls_srtp_key_derivation,
|
||||
&dtls_srtp_keying );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
if( opt.alpn_string != NULL )
|
||||
if( ( ret = mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list ) ) != 0 )
|
||||
@ -2872,6 +2851,27 @@ int main( int argc, char *argv[] )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
if( opt.eap_tls != 0 )
|
||||
{
|
||||
mbedtls_ssl_set_export_keys_cb( &ssl, eap_tls_key_derivation,
|
||||
&eap_tls_keying );
|
||||
}
|
||||
else if( opt.nss_keylog != 0 )
|
||||
{
|
||||
mbedtls_ssl_set_export_keys_cb( &ssl,
|
||||
nss_keylog_export,
|
||||
NULL );
|
||||
}
|
||||
#if defined( MBEDTLS_SSL_DTLS_SRTP )
|
||||
else if( opt.use_srtp != 0 )
|
||||
{
|
||||
mbedtls_ssl_set_export_keys_cb( &ssl, dtls_srtp_key_derivation,
|
||||
&dtls_srtp_keying );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
|
||||
io_ctx.ssl = &ssl;
|
||||
io_ctx.net = &client_fd;
|
||||
mbedtls_ssl_set_bio( &ssl, &io_ctx, send_cb, recv_cb,
|
||||
|
Reference in New Issue
Block a user