webrtc_srtp_replay (webrtc v0.1.0)
View SourceSliding window replay list (RFC 3711 §3.3.2, RFC 2401 style bitmap).
The window remembers the highest accepted index Top and a bitmap of the Size indices ending at Top (bit 0 is Top, bit k is Top - k). An index is accepted when it is ahead of Top, or inside the window and not yet seen. Indices at or below Top - Size are rejected as too_old.
check/2 never changes the window. Call update/2 only after the packet has been authenticated, so forged packets cannot move it.
Summary
Functions
Empty window of Size entries. RFC 3711 §3.3.2 requires at least 64.
Window of Size entries in which every index up to Top counts as received: only later indices are accepted.
Highest accepted index, or -1 when nothing has been accepted.
Record Index as received. The caller must have checked it with check/2 first.
Types
Functions
-spec check(non_neg_integer(), window()) -> ok | {error, replay | too_old}.
-spec new(pos_integer()) -> window().
Empty window of Size entries. RFC 3711 §3.3.2 requires at least 64.
-spec seen(pos_integer(), integer()) -> window().
Window of Size entries in which every index up to Top counts as received: only later indices are accepted.
Highest accepted index, or -1 when nothing has been accepted.
-spec update(non_neg_integer(), window()) -> window().
Record Index as received. The caller must have checked it with check/2 first.
-spec window_size(window()) -> pos_integer().