mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-17 09:10:41 +01:00
webrtc-srtp 0.12.0 stored every sequence number and used a 100-packet window to guess the rollover counter. A NACK retransmission of a pre-wrap packet sent after the wrap (65000 after 85) rewound that state, so the next new packets were protected with ROC+1 and the viewer failed authentication on all of them: frozen video after the Windows viewer returned from the background. Vendor webrtc-srtp 0.12.0 with the RFC 3711 Appendix A half-space estimate and a high-water index that retransmissions cannot move back. Regression tests fail on upstream (65000 != 85) and pass with the fix for AES-CM/HMAC and AES-GCM. Co-authored-by: VallierDev <[email protected]> Co-authored-by: AYssu <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
121 lines
3.7 KiB
Rust
121 lines
3.7 KiB
Rust
use std::io;
|
|
|
|
use thiserror::Error;
|
|
use tokio::sync::mpsc::error::SendError as MpscSendError;
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
#[derive(Error, Debug, PartialEq)]
|
|
#[non_exhaustive]
|
|
pub enum Error {
|
|
#[error("duplicated packet")]
|
|
ErrDuplicated,
|
|
#[error("SRTP master key is not long enough")]
|
|
ErrShortSrtpMasterKey,
|
|
#[error("SRTP master salt is not long enough")]
|
|
ErrShortSrtpMasterSalt,
|
|
#[error("no such SRTP Profile")]
|
|
ErrNoSuchSrtpProfile,
|
|
#[error("indexOverKdr > 0 is not supported yet")]
|
|
ErrNonZeroKdrNotSupported,
|
|
#[error("exporter called with wrong label")]
|
|
ErrExporterWrongLabel,
|
|
#[error("no config provided")]
|
|
ErrNoConfig,
|
|
#[error("no conn provided")]
|
|
ErrNoConn,
|
|
#[error("failed to verify auth tag")]
|
|
ErrFailedToVerifyAuthTag,
|
|
#[error("packet is too short to be rtcp packet")]
|
|
ErrTooShortRtcp,
|
|
#[error("payload differs")]
|
|
ErrPayloadDiffers,
|
|
#[error("started channel used incorrectly, should only be closed")]
|
|
ErrStartedChannelUsedIncorrectly,
|
|
#[error("stream has not been inited, unable to close")]
|
|
ErrStreamNotInited,
|
|
#[error("stream is already closed")]
|
|
ErrStreamAlreadyClosed,
|
|
#[error("stream is already inited")]
|
|
ErrStreamAlreadyInited,
|
|
#[error("failed to cast child")]
|
|
ErrFailedTypeAssertion,
|
|
|
|
#[error("index_over_kdr > 0 is not supported yet")]
|
|
UnsupportedIndexOverKdr,
|
|
#[error("SRTP Master Key must be len {0}, got {1}")]
|
|
SrtpMasterKeyLength(usize, usize),
|
|
#[error("SRTP Salt must be len {0}, got {1}")]
|
|
SrtpSaltLength(usize, usize),
|
|
#[error("SyntaxError: {0}")]
|
|
ExtMapParse(String),
|
|
#[error("srtp ssrc={0} index={1}: duplicated")]
|
|
SrtpSsrcDuplicated(u32, u16),
|
|
#[error("srtcp ssrc={0} index={1}: duplicated")]
|
|
SrtcpSsrcDuplicated(u32, usize),
|
|
#[error("ssrc {0} not exist in srtcp_ssrc_state")]
|
|
SsrcMissingFromSrtcp(u32),
|
|
#[error("Stream with ssrc {0} exists")]
|
|
StreamWithSsrcExists(u32),
|
|
#[error("Session RTP/RTCP type must be same as input buffer")]
|
|
SessionRtpRtcpTypeMismatch,
|
|
#[error("Session EOF")]
|
|
SessionEof,
|
|
#[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
|
|
SrtpTooSmall(usize, usize),
|
|
#[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
|
|
SrtcpTooSmall(usize, usize),
|
|
#[error("failed to verify rtp auth tag")]
|
|
RtpFailedToVerifyAuthTag,
|
|
#[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
|
|
RtcpInvalidLengthAuthTag(usize, usize),
|
|
#[error("failed to verify rtcp auth tag")]
|
|
RtcpFailedToVerifyAuthTag,
|
|
#[error("SessionSRTP has been closed")]
|
|
SessionSrtpAlreadyClosed,
|
|
#[error("this stream is not a RTPStream")]
|
|
InvalidRtpStream,
|
|
#[error("this stream is not a RTCPStream")]
|
|
InvalidRtcpStream,
|
|
|
|
#[error("{0}")]
|
|
Io(#[source] IoError),
|
|
#[error("{0}")]
|
|
KeyingMaterial(#[from] util::KeyingMaterialExporterError),
|
|
#[error("mpsc send: {0}")]
|
|
MpscSend(String),
|
|
#[error("{0}")]
|
|
Util(#[from] util::Error),
|
|
#[error("{0}")]
|
|
Rtcp(#[from] rtcp::Error),
|
|
#[error("aes gcm: {0}")]
|
|
AesGcm(#[from] aes_gcm::Error),
|
|
|
|
#[error("{0}")]
|
|
Other(String),
|
|
}
|
|
|
|
#[derive(Debug, Error)]
|
|
#[error("io error: {0}")]
|
|
pub struct IoError(#[from] pub io::Error);
|
|
|
|
// Workaround for wanting PartialEq for io::Error.
|
|
impl PartialEq for IoError {
|
|
fn eq(&self, other: &Self) -> bool {
|
|
self.0.kind() == other.0.kind()
|
|
}
|
|
}
|
|
|
|
impl From<io::Error> for Error {
|
|
fn from(e: io::Error) -> Self {
|
|
Error::Io(IoError(e))
|
|
}
|
|
}
|
|
|
|
// Because Tokio SendError is parameterized, we sadly lose the backtrace.
|
|
impl<T> From<MpscSendError<T>> for Error {
|
|
fn from(e: MpscSendError<T>) -> Self {
|
|
Error::MpscSend(e.to_string())
|
|
}
|
|
}
|