Hi All,
I've captured a few webrtc streams and I'm trying to decrypt them with a custom app using libsrtp. I create different SRTP sessions for the audio stream and video stream, but when I go to decrypt them (srtp_unprotect), the very first audio packet and video packet are successful in their sessions, but every subsequent packet I get 'err_status_replay_fail'.
According to the SRTP docs, this means "the SRTP packet is a replay (e.g. packet has already been processed and accepted)." I am definitely not decrypting the same packet twice. So I'm at a loss as to why I get this error. Does anyone with expertise with SRTP have any knowledge as to why I would get this error?
Some other notes:
- I am using libsrtp 1.4.2 downloaded from http://srtp.sourceforge.net/download.html Is that a problem? Does WebRTC use a newer version or a custom version that 1.4.2. is incompatible with?
- ( I suspect WebRTC encrypts with a newer version due to some code I saw in libjingle that is not in my version of libsrtp, namely 'policy.window_size = 1024;' and 'policy.allow_repeat_tx = 1;' The structure in 1.4.2 does not have window_size and allow_repear_tx.)
- which is the correct crypto policy to use?
- { sec_serv_none = 0, sec_serv_conf = 1, sec_serv_auth = 2, sec_serv_conf_and_auth = 3 } ? I thought it was 'sec_serv_conf ', ?
- which is the correct type to set for decrypting a stream that is received?
- { ssrc_undefined = 0, ssrc_specific = 1, ssrc_any_inbound = 2, ssrc_any_outbound = 3 } ? I assume 'ssrc_any_inbound'?
- should I be passing the RTCP sender reports to the same srtp_session or to a different one?
- due to my SRTP noobness, I wasn't sure if RTP & RTCP are muxed together if they should be sent to the same srtp_session or different ones. Right now I am sending to different ones.
- related, I think I saw a few payload types different than audio/video (payload type 228 if I recall correctly? what is that?) , should those also be sent to the same srtp RTP session instance?
- I am decrypting in the order that the packet is received which is not exactly in increasing sequence order in the threading model of my test app (i don't buffer/store in reordering queues), so I might not be decrypting in increasing sequence numbers. Just wondering if there is some special case for WebRTC that may require decrypting in increasing sequence number only.
- In fact I confirmed that I wasn't. I decrypt 1268, then 1267, then 1270, then 1269, etc. but again, for decryption (not encryption), according to the docs that should be fine "the sequence numbers of the RTP packets presented to this function need not be consecutive, but they must be out of order by less than 2^15 = 32,768 packets."
- another somewhat silly question but I haven't investigated yet, is srtp_unprotect thread safe? will calling it from multiple threads simultaneously for the same session cause any problems?
I have been using WebRTC for about 1.5 yrs now so very experienced and comfortable with the high layer interfaces and some of the native API interfaces. I am just new to SRTP and toying around with a custom built app. I'm sure I will figure it the next time I try in a day or two, but I figured I'd ask here anyway to save me some time if someone's already dealt with this. but until then any input for you guys will surely help :) The next logical step for me to try it to find out which libsrtp version Chrome is using and try that using a single thread and reordering buffer just to see if that works. I'm guess 1.4.2. is too old and incompatible ... that's probably my problem but I figured perhaps there is some other assumption I am making due to my SRTP noobness that may also be incorrect.
Thanks,
-Dennis