libsrtp/lib.rs
1#![doc = include_str!("../README.md")]
2use std::fmt;
3
4/// Error codes definition, most of the API returns a Result< , SrtpError>
5///
6/// Error names are self explanatory
7#[derive(Debug, PartialEq)]
8pub enum SrtpError {
9 Encryption,
10 Authentication,
11 ContextNotReady,
12 InvalidKeySize,
13 TransformDispatch,
14 KdfDispatch,
15 InvalidPacket,
16 InvalidProfile,
17 InvalidPacketIndex,
18 InvalidMki,
19 StreamNotFound,
20 /// KeyLimit error carries informations to identify the error source
21 /// as it is passed as parameter to the key limit handler
22 KeyLimit {
23 /// identify if the error was generated from a RTP or RTCP operation
24 is_rtp: bool,
25 /// - true when the key reached the end of its lifetime
26 /// - false when it reaches the soft limit (default to 2^16)
27 ///
28 /// Note: Soft limit error is only returned through the key limit handler when provided by the
29 /// session user using [Session::set_key_limit_handler]
30 is_dead: bool,
31 /// mki used when the error was generated
32 mki: Option<Vec<u8>>,
33 /// ssrc of the stream that generated the error
34 ssrc: u32,
35 },
36}
37
38impl fmt::Display for SrtpError {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 write!(f, "{:?}", self)
41 }
42}
43impl std::error::Error for SrtpError {}
44
45mod header;
46mod key_derivation;
47mod protection_profile;
48mod replay;
49mod session;
50mod stream;
51mod transform;
52
53pub use protection_profile::ProtectionProfile;
54pub use session::{RecvSession, SendSession, Session};
55pub use stream::{MasterKey, StreamConfig};