feat(libsrtp): add component (libsrtp v2.8.0 + ESP-IDF mbedTLS port)#1060
feat(libsrtp): add component (libsrtp v2.8.0 + ESP-IDF mbedTLS port)#1060vikramdattu wants to merge 3 commits into
Conversation
e9f8895 to
52b17f1
Compare
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.)
52b17f1 to
5186919
Compare
|
Quick CI note — the new 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 Locally verified (macOS arm64): |
|
@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 |
david-cermak
left a comment
There was a problem hiding this comment.
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
- 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
@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 |
david-cermak
left a comment
There was a problem hiding this comment.
Thanks for the quick update! The PR LGTM from my side.
- 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
95b9aa0 to
2c23e7e
Compare
- 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
2c23e7e to
dfb498d
Compare
… commit) Signed-off-by: Vikram Dattu <vikram.dattu@espressif.com>
Summary
Adds
libsrtp— an ESP-IDF wrapper around cisco/libsrtp pinned at the current upstream release tagv2.8.0(commit24b3bf8). 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=yon esp32 / s2 / s3 / c3 / c5 / c6 / p4). Pairs withlibwebsocketsand (upcoming)usrsctpfor 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, no2suffix), aligned with cisco's project name oncisco/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
Crypto / supported SRTP profiles
AEAD_AES_128_GCM,AEAD_AES_256_GCMAES_CM_128_HMAC_SHA1_80,AES_CM_128_HMAC_SHA1_32CONFIG_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'scrypto/kernel/crypto_kernel.c(excluded fromSRCSinCMakeLists.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 applystep, so the component builds clean from the registry tarball (no.gitdir at install time).Local verification
examples/get_started/onesp32: ✅ builds cleantest_apps/onesp32+esp32c3: ✅ builds cleanhost_test/on IDF Linux target: ✅ build clean + binary printslibsrtp host_test: PASSCI 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:
libsrtp2→libsrtp(suda-morris, igrr)..github/workflows/{build,publish}.ymlremoved (mono-repo doesn't honour them).patches/dropped —port/crypto_kernel.cis vendored.targets:list dropped from manifest (works on all targets the mbedTLS dep supports).port/config.h PACKAGE_VERSIONall aligned to 2.8.0 / SHA24b3bf8.>=5.4,<6with a comment.host_testexits non-zero on first libsrtp failure (no continue-on-error)..cz.yamladded (commitizen +ci/changelog.pyintegration, perCONTRIBUTING.md).components/mosquitto/style.port/config.hCPU_CISCreplaced withCPU_RISCgated on__XTENSA__ || __riscv.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 undercomponents/libsrtp/is Apache-2.0; the bundledcisco/libsrtpsubmodule remains under upstream's BSD-3-Clause.