Fix return type of example key export callbacks
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
d8f32e72b4
commit
296fefeb98
1 changed files with 26 additions and 34 deletions
|
@ -25,47 +25,44 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||||
int eap_tls_key_derivation( void *p_expkey,
|
void eap_tls_key_derivation( void *p_expkey,
|
||||||
mbedtls_ssl_key_export_type secret_type,
|
mbedtls_ssl_key_export_type secret_type,
|
||||||
const unsigned char *secret,
|
const unsigned char *secret,
|
||||||
size_t secret_len,
|
size_t secret_len,
|
||||||
const unsigned char client_random[32],
|
const unsigned char client_random[32],
|
||||||
const unsigned char server_random[32],
|
const unsigned char server_random[32],
|
||||||
mbedtls_tls_prf_types tls_prf_type )
|
mbedtls_tls_prf_types tls_prf_type )
|
||||||
{
|
{
|
||||||
eap_tls_keys *keys = (eap_tls_keys *)p_expkey;
|
eap_tls_keys *keys = (eap_tls_keys *)p_expkey;
|
||||||
|
|
||||||
/* We're only interested in the TLS 1.2 master secret */
|
/* We're only interested in the TLS 1.2 master secret */
|
||||||
if( secret_type != MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET )
|
if( secret_type != MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET )
|
||||||
return( 0 );
|
return;
|
||||||
if( secret_len != sizeof( keys->master_secret ) )
|
if( secret_len != sizeof( keys->master_secret ) )
|
||||||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
return;
|
||||||
|
|
||||||
memcpy( keys->master_secret, secret, sizeof( keys->master_secret ) );
|
memcpy( keys->master_secret, secret, sizeof( keys->master_secret ) );
|
||||||
memcpy( keys->randbytes, client_random, 32 );
|
memcpy( keys->randbytes, client_random, 32 );
|
||||||
memcpy( keys->randbytes + 32, server_random, 32 );
|
memcpy( keys->randbytes + 32, server_random, 32 );
|
||||||
keys->tls_prf_type = tls_prf_type;
|
keys->tls_prf_type = tls_prf_type;
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int nss_keylog_export( void *p_expkey,
|
void nss_keylog_export( void *p_expkey,
|
||||||
mbedtls_ssl_key_export_type secret_type,
|
mbedtls_ssl_key_export_type secret_type,
|
||||||
const unsigned char *secret,
|
const unsigned char *secret,
|
||||||
size_t secret_len,
|
size_t secret_len,
|
||||||
const unsigned char client_random[32],
|
const unsigned char client_random[32],
|
||||||
const unsigned char server_random[32],
|
const unsigned char server_random[32],
|
||||||
mbedtls_tls_prf_types tls_prf_type )
|
mbedtls_tls_prf_types tls_prf_type )
|
||||||
{
|
{
|
||||||
char nss_keylog_line[ 200 ];
|
char nss_keylog_line[ 200 ];
|
||||||
size_t const client_random_len = 32;
|
size_t const client_random_len = 32;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
size_t j;
|
size_t j;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
/* We're only interested in the TLS 1.2 master secret */
|
/* We're only interested in the TLS 1.2 master secret */
|
||||||
if( secret_type != MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET )
|
if( secret_type != MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET )
|
||||||
return( 0 );
|
return;
|
||||||
|
|
||||||
((void) p_expkey);
|
((void) p_expkey);
|
||||||
((void) server_random);
|
((void) server_random);
|
||||||
|
@ -102,13 +99,11 @@ int nss_keylog_export( void *p_expkey,
|
||||||
|
|
||||||
if( ( f = fopen( opt.nss_keylog_file, "a" ) ) == NULL )
|
if( ( f = fopen( opt.nss_keylog_file, "a" ) ) == NULL )
|
||||||
{
|
{
|
||||||
ret = -1;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fwrite( nss_keylog_line, 1, len, f ) != len )
|
if( fwrite( nss_keylog_line, 1, len, f ) != len )
|
||||||
{
|
{
|
||||||
ret = -1;
|
|
||||||
fclose( f );
|
fclose( f );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -119,32 +114,29 @@ int nss_keylog_export( void *p_expkey,
|
||||||
exit:
|
exit:
|
||||||
mbedtls_platform_zeroize( nss_keylog_line,
|
mbedtls_platform_zeroize( nss_keylog_line,
|
||||||
sizeof( nss_keylog_line ) );
|
sizeof( nss_keylog_line ) );
|
||||||
return( ret );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined( MBEDTLS_SSL_DTLS_SRTP )
|
#if defined( MBEDTLS_SSL_DTLS_SRTP )
|
||||||
int dtls_srtp_key_derivation( void *p_expkey,
|
void dtls_srtp_key_derivation( void *p_expkey,
|
||||||
mbedtls_ssl_key_export_type secret_type,
|
mbedtls_ssl_key_export_type secret_type,
|
||||||
const unsigned char *secret,
|
const unsigned char *secret,
|
||||||
size_t secret_len,
|
size_t secret_len,
|
||||||
const unsigned char client_random[32],
|
const unsigned char client_random[32],
|
||||||
const unsigned char server_random[32],
|
const unsigned char server_random[32],
|
||||||
mbedtls_tls_prf_types tls_prf_type )
|
mbedtls_tls_prf_types tls_prf_type )
|
||||||
{
|
{
|
||||||
dtls_srtp_keys *keys = (dtls_srtp_keys *)p_expkey;
|
dtls_srtp_keys *keys = (dtls_srtp_keys *)p_expkey;
|
||||||
|
|
||||||
/* We're only interested in the TLS 1.2 master secret */
|
/* We're only interested in the TLS 1.2 master secret */
|
||||||
if( secret_type != MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET )
|
if( secret_type != MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET )
|
||||||
return( 0 );
|
return;
|
||||||
if( secret_len != sizeof( keys->master_secret ) )
|
if( secret_len != sizeof( keys->master_secret ) )
|
||||||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
return;
|
||||||
|
|
||||||
memcpy( keys->master_secret, secret, sizeof( keys->master_secret ) );
|
memcpy( keys->master_secret, secret, sizeof( keys->master_secret ) );
|
||||||
memcpy( keys->randbytes, client_random, 32 );
|
memcpy( keys->randbytes, client_random, 32 );
|
||||||
memcpy( keys->randbytes + 32, server_random, 32 );
|
memcpy( keys->randbytes + 32, server_random, 32 );
|
||||||
keys->tls_prf_type = tls_prf_type;
|
keys->tls_prf_type = tls_prf_type;
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue