Skip to content

Commit

Permalink
Merge pull request #694 from pabuhler/keystream-prefix
Browse files Browse the repository at this point in the history
align behavior when using keystream prefix
  • Loading branch information
pabuhler authored Apr 25, 2024
2 parents 8a05a38 + 947e0d9 commit f6faf5d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions srtp/srtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4263,6 +4263,21 @@ srtp_err_status_t srtp_unprotect_rtcp(srtp_t ctx,
return srtp_err_status_cipher_fail;
}

/*
* if we're authenticating using a universal hash, put the keystream
* prefix into the authentication tag
*/
prefix_len = srtp_auth_get_prefix_length(session_keys->rtcp_auth);
if (prefix_len) {
status =
srtp_cipher_output(session_keys->rtcp_cipher, tmp_tag, &prefix_len);
debug_print(mod_srtp, "keystream prefix: %s",
srtp_octet_string_hex_string(tmp_tag, prefix_len));
if (status) {
return srtp_err_status_cipher_fail;
}
}

/* initialize auth func context */
status = srtp_auth_start(session_keys->rtcp_auth);
if (status) {
Expand All @@ -4285,21 +4300,6 @@ srtp_err_status_t srtp_unprotect_rtcp(srtp_t ctx,
return srtp_err_status_auth_fail;
}

/*
* if we're authenticating using a universal hash, put the keystream
* prefix into the authentication tag
*/
prefix_len = srtp_auth_get_prefix_length(session_keys->rtcp_auth);
if (prefix_len) {
status = srtp_cipher_output(session_keys->rtcp_cipher, auth_tag,
&prefix_len);
debug_print(mod_srtp, "keystream prefix: %s",
srtp_octet_string_hex_string(auth_tag, prefix_len));
if (status) {
return srtp_err_status_cipher_fail;
}
}

/* if we're decrypting, exor keystream into the message */
if (enc_start) {
status = srtp_cipher_decrypt(session_keys->rtcp_cipher, enc_start,
Expand Down

0 comments on commit f6faf5d

Please sign in to comment.