Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align behavior when using keystream prefix #694

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading