diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-11-06 23:19:50 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-11-06 23:19:58 +0100 |
commit | c76700178f85f3bae45c296eaafba6187fb36d4e (patch) | |
tree | 577109bd59b6589903470b9ed7b5b2885ac216e2 /lib/ext | |
parent | 30e0eed098299705dae650b120d54562dffa4280 (diff) | |
download | gnutls-c76700178f85f3bae45c296eaafba6187fb36d4e.tar.gz |
Do not succeed if no MKI was received.
The gnutls_srtp_get_mki() function succeeds only when the MKI was received by the peer.
Also store the received MKI -if any- in the session resumption data.
Diffstat (limited to 'lib/ext')
-rw-r--r-- | lib/ext/srtp.c | 28 | ||||
-rw-r--r-- | lib/ext/srtp.h | 1 |
2 files changed, 22 insertions, 7 deletions
diff --git a/lib/ext/srtp.c b/lib/ext/srtp.c index 0dc7cf18eb..f4e86810d9 100644 --- a/lib/ext/srtp.c +++ b/lib/ext/srtp.c @@ -234,6 +234,7 @@ _gnutls_srtp_recv_params (gnutls_session_t session, { DECR_LEN (data_size, priv->mki_size); memcpy(priv->mki, p, priv->mki_size); + priv->mki_received = 1; } return 0; @@ -343,8 +344,8 @@ gnutls_srtp_get_selected_profile (gnutls_session_t session, * @mki: will hold the MKI * * This function exports the negotiated Master Key Identifier, - * if any. The returned value in @mki should be treated as - * constant and valid only during the session's lifetime. + * received by the peer if any. The returned value in @mki should be + * treated as constant and valid only during the session's lifetime. * * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, * otherwise a negative error code is returned. @@ -363,12 +364,12 @@ gnutls_srtp_get_mki (gnutls_session_t session, _gnutls_ext_get_session_data (session, GNUTLS_EXTENSION_SRTP, &epriv); if (ret < 0) - { - gnutls_assert (); - return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; - } + return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE); priv = epriv.ptr; + + if (priv->mki_received == 0) + return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE); mki->data = priv->mki; mki->size = priv->mki_size; @@ -647,7 +648,13 @@ _gnutls_srtp_pack (extension_priv_data_t epriv, gnutls_buffer_st * ps) { BUFFER_APPEND_NUM (ps, priv->profiles[i]); } - BUFFER_APPEND_NUM (ps, priv->selected_profile); + + BUFFER_APPEND_NUM (ps, priv->mki_received); + if (priv->mki_received) + { + BUFFER_APPEND_NUM (ps, priv->selected_profile); + BUFFER_APPEND_PFX4 (ps, priv->mki, priv->mki_size); + } return 0; } @@ -674,6 +681,13 @@ _gnutls_srtp_unpack (gnutls_buffer_st * ps, } BUFFER_POP_NUM (ps, priv->selected_profile); + BUFFER_POP_NUM (ps, priv->mki_received); + if (priv->mki_received) + { + BUFFER_POP_NUM (ps, priv->mki_size); + BUFFER_POP (ps, priv->mki, priv->mki_size); + } + epriv.ptr = priv; *_priv = epriv; diff --git a/lib/ext/srtp.h b/lib/ext/srtp.h index 73552f716b..bb565b7df4 100644 --- a/lib/ext/srtp.h +++ b/lib/ext/srtp.h @@ -33,6 +33,7 @@ typedef struct gnutls_srtp_profile_t selected_profile; uint8_t mki[256]; unsigned mki_size; + unsigned int mki_received; } srtp_ext_st; extern extension_entry_st ext_mod_srtp; |