Make API safer
Signed-off-by: Johan Pascal <johan.pascal@belledonne-communications.com>
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index cee8ba1..0739b8f 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -4751,10 +4751,16 @@
return( 0 );
}
-const mbedtls_dtls_srtp_info *
+mbedtls_dtls_srtp_info
mbedtls_ssl_get_dtls_srtp_negotiation_result( const mbedtls_ssl_context *ssl )
{
- return( &( ssl->dtls_srtp_info ) );
+ mbedtls_dtls_srtp_info ret = ssl->dtls_srtp_info;
+ /* discard the mki if there is no chosen profile */
+ if ( ret.chosen_dtls_srtp_profile == MBEDTLS_TLS_SRTP_UNSET )
+ {
+ ret.mki_len = 0;
+ }
+ return( ret );
}
#endif /* MBEDTLS_SSL_DTLS_SRTP */