Skip to content

feat(libsrtp): add component (libsrtp v2.8.0 + ESP-IDF mbedTLS port)#1060

Open
vikramdattu wants to merge 3 commits into
espressif:masterfrom
vikramdattu:feat/libsrtp/add-component
Open

feat(libsrtp): add component (libsrtp v2.8.0 + ESP-IDF mbedTLS port)#1060
vikramdattu wants to merge 3 commits into
espressif:masterfrom
vikramdattu:feat/libsrtp/add-component

Conversation

@vikramdattu

@vikramdattu vikramdattu commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds libsrtp — an ESP-IDF wrapper around cisco/libsrtp pinned at the current upstream release tag v2.8.0 (commit 24b3bf8). Crypto routes through ESP-IDF's mbedTLS, so AES protect/unprotect goes through the chip's on-chip AES peripheral by default (CONFIG_MBEDTLS_HARDWARE_AES=y on esp32 / s2 / s3 / c3 / c5 / c6 / p4). Pairs with libwebsockets and (upcoming) usrsctp for the WebRTC transport stack.

Naming + versioning

Per discussion with @euripedesrocha and @suda-morris on the earlier (now-Draft) idf-extra-components#753: the component is named libsrtp (singular, no 2 suffix), aligned with cisco's project name on cisco/libsrtp. Version tracks whichever 2.x release is current upstream — v2.8.0 today. When cisco cuts the 3.0 release we bump the component to follow it; consumers handle the API change as a major-version event.

The IDF version constraint (>=5.4,<6) reflects that libsrtp v2.x's mbedTLS adapters predate the mbedTLS 4 / TF-PSA-Crypto split shipped by IDF v6+ ; the bound bumps when the component tracks a libsrtp release that speaks mbedTLS 4 (tracking cisco/libsrtp#812 for upstream's position).

Layout

components/libsrtp/
├── CMakeLists.txt        # idf_component_register + warning suppress
├── Kconfig               # log-level toggle
├── idf_component.yml     # registry manifest
├── sbom_libsrtp.yml      # SBOM for the wrapped upstream
├── port/
│   ├── config.h          # libsrtp build-time config tailored for IDF
│   └── crypto_kernel.c   # vendored upstream file with the AES-ICM-192-disable delta
├── examples/get_started/ # minimal init/shutdown sanity app
├── test_apps/            # embedded Unity smoke (esp32 + esp32c3)
├── host_test/            # IDF Linux-target AES-GCM-128 roundtrip (aborts on first failure)
└── libsrtp/              # cisco/libsrtp submodule @ 24b3bf8 (v2.8.0)

Crypto / supported SRTP profiles

  • AEAD: AEAD_AES_128_GCM, AEAD_AES_256_GCM
  • SRTP: AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32
  • Backend: mbedTLS (CONFIG_MBEDTLS_HARDWARE_AES-routed where the chip has the peripheral)

Port-side delta

One small ESP-IDF-specific delta lives in port/crypto_kernel.c — it replaces upstream's crypto/kernel/crypto_kernel.c (excluded from SRCS in CMakeLists.txt) to opt out of the AES-ICM-192 cipher registration when GCM is enabled. Pure binary-size optimisation. Re-port from upstream when bumping the submodule.

The file is vendored rather than applied as a patches/ + git apply step, so the component builds clean from the registry tarball (no .git dir at install time).

Local verification

  • examples/get_started/ on esp32: ✅ builds clean
  • test_apps/ on esp32 + esp32c3: ✅ builds clean
  • host_test/ on IDF Linux target: ✅ build clean + binary prints libsrtp host_test: PASS
  • pre-commit (astyle, yaml lint, eof/whitespace, large-file, case-conflict): ✅ all pass

CI matrix below will exercise the same.

Prior review

This component went through a full review cycle on espressif/idf-extra-components#753 (now marked Draft). The feedback from @igrr, @suda-morris and the GitHub Copilot review bot is already baked into this PR. Summary of what's changed since 753's first iteration:

  • Component renamed libsrtp2libsrtp (suda-morris, igrr).
  • Component-local .github/workflows/{build,publish}.yml removed (mono-repo doesn't honour them).
  • patches/ dropped — port/crypto_kernel.c is vendored.
  • targets: list dropped from manifest (works on all targets the mbedTLS dep supports).
  • Tags trimmed; SBOM, NOTICE, CHANGELOG, port/config.h PACKAGE_VERSION all aligned to 2.8.0 / SHA 24b3bf8.
  • IDF version constraint tightened to >=5.4,<6 with a comment.
  • host_test exits non-zero on first libsrtp failure (no continue-on-error).
  • .cz.yaml added (commitizen + ci/changelog.py integration, per CONTRIBUTING.md).
  • pytest convention aligned with components/mosquitto/ style.
  • port/config.h CPU_CISC replaced with CPU_RISC gated on __XTENSA__ || __riscv.
  • Manifest URLs + READMEs all point at espressif/esp-protocols/components/libsrtp.

Out of scope (deliberate): no extra Kconfig toggles for alternative crypto backends (OpenSSL/NSS/WolfSSL) — the port wires mbedTLS only, matching esp_mqtt_cxx's minimal-knob approach.

License

Apache-2.0 AND BSD-3-Clause — port glue under components/libsrtp/ is Apache-2.0; the bundled cisco/libsrtp submodule remains under upstream's BSD-3-Clause.

Adds libsrtp — an ESP-IDF wrapper around cisco/libsrtp pinned at v2.8.0
(commit 24b3bf8). Crypto routes through ESP-IDF's mbedTLS, so AES
protect/unprotect goes through the chip's on-chip AES peripheral by
default (CONFIG_MBEDTLS_HARDWARE_AES=y on esp32 / s2 / s3 / c3 / c5 /
c6 / p4). Pairs with libwebsockets and (upcoming) usrsctp for the
WebRTC transport stack.

The wrapper bundles cisco/libsrtp as a git submodule and compiles its
sources directly into the IDF component archive — no internal libsrtp2.a
dance. One small port-side delta in port/crypto_kernel.c opts out of
the AES-ICM-192 cipher registration when GCM is enabled (saves binary
size; AES-CM-128 + AES-GCM cover all WebRTC SRTP suites in use).

Naming + version follow cisco's release line. Component is named
'libsrtp' (registry: espressif/libsrtp) tracking whichever 2.x release
is current upstream — v2.8.0 today. The IDF version constraint
(>=5.4,<6) reflects the fact that libsrtp v2.x's mbedTLS adapters
predate the mbedTLS 4 / TF-PSA-Crypto split shipped by IDF v6; bump
when the component tracks a release that speaks mbedTLS 4.

Supported SRTP profiles via the mbedTLS backend:
  AEAD: AEAD_AES_128_GCM, AEAD_AES_256_GCM
  SRTP: AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32

Tests included:
  test_apps/         — embedded Unity smoke (esp32 + esp32c3 via
                       .build-test-rules)
  host_test/         — IDF Linux-target binary, AES-GCM-128 protect/
                       unprotect roundtrip; aborts on the first libsrtp
                       failure with EXPECT() for boolean assertions
  examples/get_started/ — minimal init/shutdown sanity app

License: Apache-2.0 (port glue) AND BSD-3-Clause (bundled cisco/libsrtp).

(Previously prepared as espressif/idf-extra-components#753; relocated to
esp-protocols where it naturally sits alongside libwebsockets and the
other transport-stack components.)
@vikramdattu vikramdattu force-pushed the feat/libsrtp/add-component branch from 52b17f1 to 5186919 Compare May 25, 2026 09:40
@vikramdattu

Copy link
Copy Markdown
Contributor Author

Quick CI note — the new .github/workflows/libsrtp__build.yml follows the project's label-gate convention (matches lws_build.yml, mosq__build.yml, etc.):

if: contains(github.event.pull_request.labels.*.name, 'libsrtp') || github.event_name == 'push'

So the build / host-test jobs won't kick in here until someone with write access adds the libsrtp label to this PR. @euripedesrocha @david-cermak — could one of you add it when you get a chance?

Locally verified (macOS arm64): examples/get_started builds clean for esp32, pre-commit hooks pass, host_test builds + the binary prints libsrtp host_test: PASS on the IDF Linux target.

@espressif-bot espressif-bot added the Status: Opened Issue is new label May 25, 2026
@vikramdattu

Copy link
Copy Markdown
Contributor Author

@euripedesrocha @david-cermak — would appreciate a look when you have time. The PR is essentially the same component I'd prepped at espressif/idf-extra-components#753 (now Draft), with all the feedback from there already baked in + the conventions adapted to esp-protocols (.cz.yaml, paths under components/libsrtp/, build-test-rules relocated, etc.). CI gated on the libsrtp label — adding it would kick the build matrix.

@david-cermak david-cermak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very nice and thorough work, yet with minimal port layer 👏

Left just a couple of nitpicks.
Another think is the release process in esp-protocols: we require specific "Bump commit" to run the release process in CI, I'll guide you through it when this is ready for merging.

Question: About the mbedtls-v4-shim for IDF v6.x: Do you maintain a component shim like that? FYI: I have my own (private) simplified layer: https://github.com/david-cermak/mbedtls_v3_shim

Comment thread components/libsrtp/port/config.h
Comment thread components/libsrtp/port/config.h
Comment thread components/libsrtp/port/config.h
Comment thread components/libsrtp/port/config.h Outdated
Comment thread components/libsrtp/port/config.h Outdated
Comment thread components/libsrtp/examples/get_started/README.md Outdated
Comment thread components/libsrtp/CHANGELOG.md Outdated
Comment thread components/libsrtp/idf_component.yml
Comment thread components/libsrtp/LICENSE
Comment thread components/libsrtp/sbom.yml
vikramdattu added a commit to vikramdattu/esp-protocols that referenced this pull request Jun 1, 2026
- config.h: drop three duplicate macro defines (HAVE_STDINT_H,
  HAVE_SYS_TYPES_H, ERR_REPORTING_STDOUT)
- crypto_kernel.c: gate AES-ICM-192 on SOC_AES_SUPPORT_AES_192 instead
  of unconditional #if 0; ESP32 (only SoC with hw AES-192) now enables
  the cipher, other SoCs continue to skip it since mbedtls_aes_setkey
  returns PLATFORM_FEATURE_UNSUPPORTED for 192-bit keys there
- examples/get_started/README.md: fix link, repo migrated from
  idf-extra-components to esp-protocols
- LICENSE: prepend dual-license header (Apache-2.0 wrapper +
  BSD-3-Clause bundled libsrtp), keep Apache full text below
@vikramdattu

Copy link
Copy Markdown
Contributor Author

Question: About the mbedtls-v4-shim for IDF v6.x: Do you maintain a component shim like that? FYI: I have my own (private) simplified layer: https://github.com/david-cermak/mbedtls_v3_shim

@david-cermak that's nice way to handle it. I have in mind to port srtp2 to work with mbedtls4 instead. Discussions this and this
I think your idea of using the shim to trick existing libs to use mbedtls4 is also great till it converges. I think, I will consider using similar strategy as a transition.

@david-cermak david-cermak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the quick update! The PR LGTM from my side.

vikramdattu added a commit to vikramdattu/esp-protocols that referenced this pull request Jun 2, 2026
- config.h: drop three duplicate macro defines (HAVE_STDINT_H,
  HAVE_SYS_TYPES_H, ERR_REPORTING_STDOUT)
- crypto_kernel.c: gate AES-ICM-192 on SOC_AES_SUPPORT_AES_192 instead
  of unconditional #if 0; ESP32 (only SoC with hw AES-192) now enables
  the cipher, other SoCs continue to skip it since mbedtls_aes_setkey
  returns PLATFORM_FEATURE_UNSUPPORTED for 192-bit keys there
- examples/get_started/README.md: fix link, repo migrated from
  idf-extra-components to esp-protocols
- LICENSE: prepend dual-license header (Apache-2.0 wrapper +
  BSD-3-Clause bundled libsrtp), keep Apache full text below
@vikramdattu vikramdattu force-pushed the feat/libsrtp/add-component branch from 95b9aa0 to 2c23e7e Compare June 2, 2026 10:43
- config.h: drop three duplicate macro defines (HAVE_STDINT_H,
  HAVE_SYS_TYPES_H, ERR_REPORTING_STDOUT)
- crypto_kernel.c: gate AES-ICM-192 on SOC_AES_SUPPORT_AES_192 instead
  of unconditional #if 0; ESP32 (only SoC with hw AES-192) now enables
  the cipher, other SoCs continue to skip it since mbedtls_aes_setkey
  returns PLATFORM_FEATURE_UNSUPPORTED for 192-bit keys there
- examples/get_started/README.md: fix link, repo migrated from
  idf-extra-components to esp-protocols
- LICENSE: prepend dual-license header (Apache-2.0 wrapper +
  BSD-3-Clause bundled libsrtp), keep Apache full text below
@vikramdattu vikramdattu force-pushed the feat/libsrtp/add-component branch from 2c23e7e to dfb498d Compare June 2, 2026 11:14
… commit)

Signed-off-by: Vikram Dattu <vikram.dattu@espressif.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants