Skip to content

srtp: locate the MKI correctly for RCC mode 1 packets without a tag - #821

Merged
pabuhler merged 2 commits into
cisco:mainfrom
lenamonj:rcc-mode1-mki
Sep 10, 2026
Merged

srtp: locate the MKI correctly for RCC mode 1 packets without a tag#821
pabuhler merged 2 commits into
cisco:mainfrom
lenamonj:rcc-mode1-mki

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

With RFC 4771 RCC mode 1 and an MKI, every packet that does not carry the ROC failed srtp_unprotect with bad_mki: srtp_protect appends no authentication tag to those packets, but the key lookup still stepped a full tag length back from the packet end before reading the MKI.

srtp_get_session_keys_for_rtp_packet now takes the packet's rcc_carry state and derives what trails the MKI from it: the 4-octet ROC of a mode 3 ROC-carrying AES-GCM packet, nothing for a mode 1 packet without the ROC, the full tag otherwise. The ad-hoc mode 3 subtraction in srtp_unprotect folds into that one place. Non-RCC streams compute exactly what they did before.

The new test rcc_mode1_rate4_mki_untagged fails on main with bad_mki and passes here; format.sh is clean.

lenamonj and others added 2 commits September 6, 2026 00:41
With RFC 4771 RCC mode 1 and an MKI, every packet that did not carry the
ROC failed srtp_unprotect with bad_mki: srtp_protect appends no
authentication tag to those packets, but the key lookup still stepped a
full tag length back from the packet end before reading the MKI.

srtp_get_session_keys_for_rtp_packet now takes the packet's rcc_carry
state and derives what trails the MKI from it: the 4-octet ROC of a mode
3 ROC-carrying AES-GCM packet, nothing for a mode 1 packet without the
ROC, the full tag otherwise. The ad-hoc mode 3 subtraction in
srtp_unprotect folds into that one place. Non-RCC streams compute exactly
what they did before. rcc_mode1_rate4_mki_untagged pins it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@pabuhler pabuhler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lenamonj , out of curiosity how was this discovered, through testing or AI code review?

@lenamonj

lenamonj commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

AI code review rather than testing. I build and run an automated review loop, so I am constantly pointing it at real repositories to evaluate and improve the method, and libsrtp came up because the RCC and MKI mechanics are exactly the kind of state dependent layout I have been working to make it better at. It flagged the key lookup stepping back a full tag length on a mode 1 packet that srtp_protect never tagged. I confirmed it, wrote the test that fails on main with bad_mki, and checked the derivation against RFC 4771 before filing.

@pabuhler
pabuhler merged commit 32a3a3a into cisco:main Sep 10, 2026
46 checks passed
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