-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unbundle libSRTP #123
base: master
Are you sure you want to change the base?
Unbundle libSRTP #123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Builds as expected against libsrtp 2.5.0 on OpenBSD/amd64 7.3-current, thanks.
Avoid private symbols and link against system-wide libSRTP. The excluded code in SrtpSession looks unreachable from the call integration in Telegram Desktop.
@@ -290,6 +294,9 @@ bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { | |||
bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { | |||
RTC_DCHECK(thread_checker_.IsCurrent()); | |||
RTC_DCHECK(IsExternalAuthActive()); | |||
#ifdef HAVE_LIBSRTP | |||
return false; | |||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be #endif
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work. Because in that case the preprocessor does not exclude using of the private API and we get compilation errors.
Building CXX object CMakeFiles/tg_owt.dir/src/pc/srtp_session.cc.o
/usr/bin/c++ -DABSL_ALLOCATOR_NOTHROW=1 -DBWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0 -DHAVE_LIBSRTP -DHAVE_NETINET_IN_H -DHAVE_SCTP -DHAVE_WEBRTC_VIDEO -DLIBVPX_VERSION_MAJOR=1 -DLIBVPX_VERSION_MINOR=12 -DLIBVPX_VERSION_PATCH=0 -DLIBVPX_VERSION_STR=\"1.12.0\" -DNO_MAIN_THREAD_WRAPPING -DRTC_DISABLE_TRACE_EVENTS -DRTC_ENABLE_VP9 -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_DLOPEN_PIPEWIRE -DWEBRTC_DUMMY_AUDIO_BUILD -DWEBRTC_ENABLE_PROTOBUF=0 -DWEBRTC_HAVE_DCSCTP -DWEBRTC_HAVE_SCTP -DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE -DWEBRTC_LIBRARY_IMPL -DWEBRTC_LINUX -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1 -DWEBRTC_OPUS_SUPPORT_120MS_PTIME=1 -DWEBRTC_OPUS_VARIABLE_COMPLEXITY=0 -DWEBRTC_POSIX -DWEBRTC_USE_BUILTIN_ISAC_FLOAT -DWEBRTC_USE_H264 -DWEBRTC_USE_PIPEWIRE -DWEBRTC_USE_RNNOISE=0 -DWEBRTC_USE_X11 -I/build/libtgowt/obj-x86_64-linux-gnu/gen -I/build/libtgowt/src -I/build/libtgowt/src/third_party/pffft/src -I/build/libtgowt/src/third_party/libyuv/include -I/build/libtgowt/obj-x86_64-linux-gnu/cmake/protobuf -I/build/libtgowt/obj-x86_64-linux-gnu/openh264_include -I/build/libtgowt/src/third_party/crc32c/src/include -isystem /usr/include/gio-unix-2.0 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/pipewire-0.3 -isystem /usr/include/spa-0.2 -isystem /usr/include/libdrm -isystem /usr/include/opus -isystem /build/libtgowt/src/third_party/openh264/src/include -O0 -ffile-prefix-map=/build/libtgowt=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -Wno-deprecated-declarations -Wno-attributes -Wno-narrowing -Wno-return-type -std=gnu++20 -MD -MT CMakeFiles/tg_owt.dir/src/pc/srtp_session.cc.o -MF CMakeFiles/tg_owt.dir/src/pc/srtp_session.cc.o.d -o CMakeFiles/tg_owt.dir/src/pc/srtp_session.cc.o -c /build/libtgowt/src/pc/srtp_session.cc
/build/libtgowt/src/pc/srtp_session.cc: In member function ‘bool cricket::SrtpSession::GetRtpAuthParams(uint8_t**, int*, int*)’:
/build/libtgowt/src/pc/srtp_session.cc:307:3: error: ‘srtp_stream_ctx_t’ was not declared in this scope
307 | srtp_stream_ctx_t* srtp_context = session_->stream_template;
| ^~~~~~~~~~~~~~~~~
/build/libtgowt/src/pc/srtp_session.cc:307:22: error: ‘srtp_context’ was not declared in this scope; did you mean ‘srtp_protect’?
307 | srtp_stream_ctx_t* srtp_context = session_->stream_template;
| ^~~~~~~~~~~~
| srtp_protect
/build/libtgowt/src/pc/srtp_session.cc:307:45: error: invalid use of incomplete type ‘struct srtp_ctx_t_’
307 | srtp_stream_ctx_t* srtp_context = session_->stream_template;
| ^~
In file included from /build/libtgowt/src/pc/srtp_session.cc:11:
/build/libtgowt/src/pc/srtp_session.h:26:8: note: forward declaration of ‘struct srtp_ctx_t_’
26 | struct srtp_ctx_t_;
| ^~~~~~~~~~~
/build/libtgowt/src/pc/srtp_session.cc: In member function ‘bool cricket::SrtpSession::GetSendStreamPacketIndex(void*, int, int64_t*)’:
/build/libtgowt/src/pc/srtp_session.cc:349:3: error: ‘srtp_hdr_t’ was not declared in this scope; did you mean ‘srtp_ssrc_t’?
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^~~~~~~~~~
| srtp_ssrc_t
/build/libtgowt/src/pc/srtp_session.cc:349:15: error: ‘hdr’ was not declared in this scope; did you mean ‘chdir’?
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^~~
| chdir
/build/libtgowt/src/pc/srtp_session.cc:349:38: error: ‘srtp_hdr_t’ does not name a type; did you mean ‘srtp_ssrc_t’?
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^~~~~~~~~~
| srtp_ssrc_t
/build/libtgowt/src/pc/srtp_session.cc:349:48: error: expected ‘>’ before ‘*’ token
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^
/build/libtgowt/src/pc/srtp_session.cc:349:48: error: expected ‘(’ before ‘*’ token
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^
| (
/build/libtgowt/src/pc/srtp_session.cc:349:49: error: expected primary-expression before ‘>’ token
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^
/build/libtgowt/src/pc/srtp_session.cc:349:53: error: expected ‘)’ before ‘;’ token
349 | srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
| ^
| )
/build/libtgowt/src/pc/srtp_session.cc:350:3: error: ‘srtp_stream_ctx_t’ was not declared in this scope
350 | srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc);
| ^~~~~~~~~~~~~~~~~
/build/libtgowt/src/pc/srtp_session.cc:350:22: error: ‘stream’ was not declared in this scope; did you mean ‘std::io_errc::stream’?
350 | srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc);
| ^~~~~~
| std::io_errc::stream
In file included from /usr/include/c++/12/streambuf:41,
from /usr/include/c++/12/bits/streambuf_iterator.h:35,
from /usr/include/c++/12/iterator:66,
from /usr/include/absl/strings/string_view.h:35,
from /build/libtgowt/src/api/field_trials_view.h:15,
from /build/libtgowt/src/pc/srtp_session.h:19:
/usr/include/c++/12/bits/ios_base.h:204:24: note: ‘std::io_errc::stream’ declared here
204 | enum class io_errc { stream = 1 };
| ^~~~~~
/build/libtgowt/src/pc/srtp_session.cc:350:31: error: ‘srtp_get_stream’ was not declared in this scope; did you mean ‘srtp_add_stream’?
350 | srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc);
| ^~~~~~~~~~~~~~~
| srtp_add_stream
/build/libtgowt/src/pc/srtp_session.cc:357:7: error: ‘srtp_rdbx_get_packet_index’ was not declared in this scope
357 | srtp_rdbx_get_packet_index(&stream->rtp_rdbx) << 16));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work. Because in that case the preprocessor does not exclude using of the private API and we get compilation errors.
You're right, my bad.
@@ -313,6 +320,7 @@ bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { | |||
*key_len = external_hmac->key_length; | |||
*tag_len = rtp_auth_tag_len_; | |||
return true; | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... so that this hunk can go entirely.
@@ -336,6 +344,9 @@ bool SrtpSession::GetSendStreamPacketIndex(void* p, | |||
int in_len, | |||
int64_t* index) { | |||
RTC_DCHECK(thread_checker_.IsCurrent()); | |||
#ifdef HAVE_LIBSRTP | |||
return false; | |||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Patch works fine, built tg_owt against srtp-2.6.0. |
Avoid private symbols and link against system-wide libSRTP. The excluded code in SrtpSession looks unreachable from the call integration in Telegram Desktop.