Skip to content
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

missing replay protection for data packets #53

Closed
hannesm opened this issue Apr 5, 2020 · 2 comments
Closed

missing replay protection for data packets #53

hannesm opened this issue Apr 5, 2020 · 2 comments

Comments

@hannesm
Copy link
Contributor

hannesm commented Apr 5, 2020

in Engine.incoming_data, replay protection should be initiated (discussed in #37 (comment)). An implementation suggestion from @cfcs:

module Sliding_window : sig
  type t
  val make : int -> t
  val add : int -> t -> (t, string) result
  val mem : t -> int -> bool
  val pp : Format.formatter -> t -> unit
end = struct
  type t = { window: int; counter: int; }
  let make counter = { window = 1; counter }
  let add n {window; counter} =
    if n <= counter then begin
      let diff = counter -n in
      if diff >= Sys.int_size
      then Error "n not in sliding window"
      else Ok {window = window lor (1 lsl diff); counter}
    end else begin (* counter > n; always succeeds *)
      let diff = n - counter in
      if diff >= Sys.int_size
      then Ok (make n) (* new window *)
      else Ok {window = (window lsl diff) lor 1; counter = n}
    end

  let pp ppf {window;counter} =
    Fmt.pf ppf "{ window = %d; counter = %d }" window counter

  let mem {window;counter} n =
    let diff = counter - n in
    if counter < n || diff > Sys.int_size
    then false
    else 0 <> window land (1 lsl diff)
end
@hannesm
Copy link
Contributor Author

hannesm commented Apr 5, 2020

related is that control frames are guarded with replay protection which potentially is bad (for udp, see #9) since it (a) rejects out-of-order packets and (b) doesn't do anything with the timestamp.

the data replay protection should be packet-id based, and in static key mode as well use the timestamp.

@hannesm
Copy link
Contributor Author

hannesm commented Nov 8, 2023

since there's no replay protection or retransmission for data packets, I'll close this. The control packet replay protection and sliding window is tracked in #148.

@hannesm hannesm closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant