Skip to content

Properly support null crypto and null auth scenario#757

Merged
pabuhler merged 2 commits intocisco:mainfrom
freemangordon:null_crypto_null_auth
Jun 25, 2025
Merged

Properly support null crypto and null auth scenario#757
pabuhler merged 2 commits intocisco:mainfrom
freemangordon:null_crypto_null_auth

Conversation

@freemangordon
Copy link
Copy Markdown
Contributor

Currently, it is silently assumed that we always have master key provided, even when the policy says we don't use encryption and authentication. This results in streams with such policy to fail.

Fix that by properly calculating the expected master key length by taking in account authentication type too. Correctly set expected key length for null crypto policy to 0. Do not assume we have HMAC if the policy is set to not have.

Add a test case for null/null policy while at it.

@freemangordon
Copy link
Copy Markdown
Contributor Author

This shall be back-ported to 2.5 (which is in debian stable) and newer releases, as they are currently broken in null/null scenario, IIUC. Do I have to make pull requests for those versions?

@pabuhler
Copy link
Copy Markdown
Member

This shall be back-ported to 2.5 (which is in debian stable) and newer releases, as they are currently broken in null/null scenario, IIUC. Do I have to make pull requests for those versions?

Once this PR is landed then either you or I can back port to 2_x_dev in order to create what ever 2.x releases are needed.

@pabuhler
Copy link
Copy Markdown
Member

@freemangordon I understand that this was a change in behavior, but from my reading of the RFC it does not allow for SRTCP with a null authentication https://datatracker.ietf.org/doc/html/rfc3711#section-9.5 .
My preference here would be to maybe revert the behavior in the 2.x branch if it causes issues, but for the main 3.0 branch I would instead remove the ability to configure an "invalid" combination.
Is there a real world use case to support null cipher and null auth for both RTP and RTCP, at that point just don't use SRTP as it provides nothing besides and insecure replay protection.
What even happens if some one tries to configure null & null but then sets a MKI, it just seams like an invalid setup to not pass a key of any type.
What do you think?

@freemangordon
Copy link
Copy Markdown
Contributor Author

@freemangordon I understand that this was a change in behavior, but from my reading of the RFC it does not allow for SRTCP with a null authentication https://datatracker.ietf.org/doc/html/rfc3711#section-9.5 . My preference here would be to maybe revert the behavior in the 2.x branch if it causes issues, but for the main 3.0 branch I would instead remove the ability to configure an "invalid" combination.

Yes, RFC mandates authentication for SRTCP, however it seems the functionality has been there since the beginning of time. One may consider SRTCP with no crypto/auth to be a fallback to RTCP, no?

Also, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/ext/srtp/gstsrtpenc.c?ref_type=heads#L80. Looks like back then somebody didn't read/grok the specs :) .

Is there a real world use case to support null cipher and null auth for both RTP and RTCP, at that point just don't use SRTP as it provides nothing besides and insecure replay protection.

Agree, but from the application POV it is easier to use a single SRTP/RTP library instead of maintaining separate interfaces for 2 libraries. At least gstreamer and farstream seem to count on libsrtp doing fallback to RTP when encryption and authentication are not required:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/ext/srtp/gstsrtpenc.c?ref_type=heads#L385
https://gitlab.freedesktop.org/farstream/farstream/-/blob/master/gst/fsrtpconference/fs-rtp-session.c?ref_type=heads#L5552

What even happens if some one tries to configure null & null but then sets a MKI, it just seams like an invalid setup to not pass a key of any type. What do you think?

That's clearly an error to set MKI without providing a key and the library can handle it in various ways (like simply ignore it or error out), but that's another story.

So, for us as downstream users, it is much easier if a library does what is told to do, even if specs need to be bent a bit :). After all it is not library's fault if application misuses it.

Just think about the amount of changes such a removal would require (I gave 2 examples I know of, I guess pidgin is affected too, and who knows what else).

@freemangordon freemangordon force-pushed the null_crypto_null_auth branch from ae91e48 to 713f377 Compare June 1, 2025 07:30
Currently, it is silently assumed that we always have master key provided,
even when the policy says we don't use encryption and authentication. This
results in streams with such policy to fail.

Fix that by properly calculating the expected master key length by taking
in account authentication type too. Correctly set expected key length for
null crypto policy to 0. Do not assume we have HMAC if the policy is set to
not have.

Add a test case for null/null policy while at it.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
@freemangordon freemangordon force-pushed the null_crypto_null_auth branch from 713f377 to 23d70f3 Compare June 1, 2025 07:34
@pabuhler
Copy link
Copy Markdown
Member

pabuhler commented Jun 3, 2025

@freemangordon I will attempt to review the PR in depth over the weekend. I do agree that it should be fixed mostly as it is a regression. But going forward we may consider making it "harder" or requiring more explicit configure to allow libsrtp to be configured in a totally insecure manor, I think as a security library we have some responsibility to prevent users from accidentally configuring it in an insecure manor.

@pabuhler
Copy link
Copy Markdown
Member

@freemangordon I made one small change but otherwise I think this is ok. If there are no more comments then will merge shortly.

@pabuhler pabuhler merged commit 066243a into cisco:main Jun 25, 2025
39 checks passed
pabuhler added a commit to pabuhler/libsrtp that referenced this pull request Jun 25, 2025
seyednasermoravej pushed a commit to seyednasermoravej/libsrtp that referenced this pull request Nov 9, 2025
Properly support null crypto and null auth scenario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants