Skip to content

sdp-types: read an SRTP suite by its whole name - #81

Merged
kbalt merged 1 commit into
kbalt:mainfrom
xdevs23:srtp-suite-whole-name
Oct 11, 2026
Merged

kbalt merged 1 commit into
kbalt:mainfrom
xdevs23:srtp-suite-whole-name

Conversation

@xdevs23

@xdevs23 xdevs23 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

SrtpSuite::parse compares the known suite names one by one as prefixes, so a suite whose name starts with a known one fails to parse. For a=crypto:2 AEAD_AES_256_GCM_8 inline:…, the name AEAD_AES_256_GCM matches and _8 is left in front of the key. The crypto attribute then fails, and with it the whole session description. The Ext branch for unknown suites never runs for such a name.

A SIP trunk offered AEAD_AES_256_GCM_8 in its second crypto attribute, after a suite the library knows. An endpoint built on ezk could not read that INVITE, so the call failed.

With this change the parser reads the whole name with take_while1 and then compares it with the known names. AEAD_AES_256_GCM_8 parses as SrtpSuite::Ext. The SrtpSuite type is unchanged.

  • cargo test -p ezk-sdp-types --all-features passed with 80 tests. Three are new: a known suite, a suite whose name starts with a known one, and a complete crypto attribute with such a suite.
  • The two new tests of the longer suite fail on the parser before this change.
  • cargo clippy -p ezk-sdp-types --all-features --all-targets and cargo fmt -p ezk-sdp-types --check passed.

The suite of an a=crypto attribute used to be matched by trying each
known name as a prefix. A suite whose name starts with a known one, such
as AEAD_AES_256_GCM_8, matched AEAD_AES_256_GCM and left "_8" behind.
The attribute then failed to parse, and with it the whole session
description. The branch for unknown suites never ran for such a name.

Now the suite parser reads the whole name first and then compares it
with the known names. AEAD_AES_256_GCM_8 parses as SrtpSuite::Ext, and
the parser reads the rest of the description.

This change replaces the alt over the known names in SrtpSuite::parse
with one take_while1 followed by a match on the name. It adds three
tests: a known suite, a suite whose name starts with a known one, and a
complete crypto attribute with such a suite. The change edits only the
sdp-types crate, and the SrtpSuite type is unchanged.

A SIP trunk offered AEAD_AES_256_GCM_8 in its second crypto attribute,
after a suite the library knows. A SIP endpoint built on ezk could not
read that offer, so the call failed, although the endpoint supports the
suite offered first.

Offers that list suites unknown to the library now parse. An
application can then pick a suite it supports from the offer.

Test: cargo test -p ezk-sdp-types --all-features (80 passed)
Test: the two new tests of the longer suite failed on the old parser
Test: cargo clippy -p ezk-sdp-types --all-features --all-targets
Test: cargo fmt -p ezk-sdp-types --check
@kbalt
kbalt merged commit bfebcaf into kbalt:main Oct 11, 2026
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