upstream: github.com/mirleft/ocaml-tls
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Migrate from vendored crowbar to opam-pinned alcobar

- Remove vendored crowbar/ directory
- Replace all Crowbar references with Alcobar across 176 .ml files
- Update all fuzz dune files: crowbar → alcobar in libraries
- Remove 77 gen_corpus.ml files (alcobar handles corpus internally)
- Update dune-project files: crowbar → alcobar in dependencies
- Update merlint rules (e705, e726): Crowbar → Alcobar in checks,
docs, and examples
- Update merlint generated docs (index.html)

428 files changed, ~1200 lines removed net.

+42 -95
+1 -8
eio/tests/fuzz/dune
··· 12 12 (executable 13 13 (name fuzz) 14 14 (modules fuzz fuzz_tls) 15 - (libraries crowbar tls-eio eio.mock logs logs.fmt crypto-rng test_helpers)) 16 - 17 - (executable 18 - (name gen_corpus) 19 - (modules gen_corpus) 20 - (libraries unix)) 15 + (libraries alcobar tls-eio eio.mock logs logs.fmt crypto-rng test_helpers)) 21 16 22 17 (rule 23 18 (alias runtest) ··· 32 27 (deps 33 28 (source_tree corpus) 34 29 fuzz.exe 35 - gen_corpus.exe 36 30 server.pem 37 31 server.key) 38 32 (action 39 33 (progn 40 - (run %{exe:gen_corpus.exe}) 41 34 (run afl-fuzz -V 60 -i corpus -o _fuzz -- %{exe:fuzz.exe} @@))))
+1 -1
eio/tests/fuzz/fuzz.ml
··· 1 1 let () = 2 2 Logs.set_level (Some Warning); 3 3 Logs.set_reporter (Logs_fmt.reporter ()); 4 - Crowbar.(run "tls" [ Fuzz_tls.suite ]) 4 + Alcobar.(run "tls" [ Fuzz_tls.suite ])
+20 -20
eio/tests/fuzz/fuzz_tls.ml
··· 51 51 | Key_update of bool (* TLS 1.3: update keys; bool = request peer update *) 52 52 | Epoch (* Check epoch is accessible in current state *) 53 53 54 - let label name gen = Crowbar.with_printer Fmt.(const string name) gen 54 + let label name gen = Alcobar.with_printer Fmt.(const string name) gen 55 55 56 56 let op = 57 - Crowbar.choose 57 + Alcobar.choose 58 58 @@ [ 59 - Crowbar.(map [ range 4096 ]) (fun n -> Send n); 60 - Crowbar.(map [ range ~min:1 4096 ]) (fun n -> Transmit (`Bytes n)); 61 - label "drain" @@ Crowbar.const (Transmit `Drain); 62 - label "recv" @@ Crowbar.const Recv; 63 - label "shutdown-send" @@ Crowbar.const Shutdown_send; 64 - Crowbar.(map [ bool ]) (fun req -> Key_update req); 65 - label "epoch" @@ Crowbar.const Epoch; 59 + Alcobar.(map [ range 4096 ]) (fun n -> Send n); 60 + Alcobar.(map [ range ~min:1 4096 ]) (fun n -> Transmit (`Bytes n)); 61 + label "drain" @@ Alcobar.const (Transmit `Drain); 62 + label "recv" @@ Alcobar.const Recv; 63 + label "shutdown-send" @@ Alcobar.const Shutdown_send; 64 + Alcobar.(map [ bool ]) (fun req -> Key_update req); 65 + label "epoch" @@ Alcobar.const Epoch; 66 66 ] 67 67 68 68 type dir = To_client | To_server ··· 72 72 | To_client -> Fmt.string f "server-to-client" 73 73 74 74 let dir = 75 - Crowbar.choose 75 + Alcobar.choose 76 76 [ 77 - label "server-to-client" @@ Crowbar.const To_client; 78 - label "client-to-server" @@ Crowbar.const To_server; 77 + label "server-to-client" @@ Alcobar.const To_client; 78 + label "client-to-server" @@ Alcobar.const To_server; 79 79 ] 80 80 81 - let action = Crowbar.option (Crowbar.pair dir op) (* None means yield *) 81 + let action = Alcobar.option (Alcobar.pair dir op) (* None means yield *) 82 82 83 83 (* A [Path] is one direction (either server-to-client or client-to-server). *) 84 84 module Path : sig ··· 317 317 | Sm_epoch 318 318 319 319 let sm_op = 320 - Crowbar.choose 320 + Alcobar.choose 321 321 [ 322 - Crowbar.(map [ range 4096 ]) (fun n -> Sm_send n); 323 - label "shutdown_send" @@ Crowbar.const Sm_shutdown_send; 324 - Crowbar.(map [ bool ]) (fun req -> Sm_key_update req); 325 - label "epoch" @@ Crowbar.const Sm_epoch; 322 + Alcobar.(map [ range 4096 ]) (fun n -> Sm_send n); 323 + label "shutdown_send" @@ Alcobar.const Sm_shutdown_send; 324 + Alcobar.(map [ bool ]) (fun req -> Sm_key_update req); 325 + label "epoch" @@ Alcobar.const Sm_epoch; 326 326 ] 327 327 328 328 (* A list of explicit byte-chunk sizes to feed through the socket before ··· 330 330 drain mode activates — from "before the first byte" (empty list) to 331 331 "after N chunks of various sizes". *) 332 332 let pre_transmit = 333 - Crowbar.(list (map [ range ~min:1 4096 ] (fun n -> `Bytes n))) 333 + Alcobar.(list (map [ range ~min:1 4096 ] (fun n -> `Bytes n))) 334 334 335 335 let run_sm_ops tls message ops = 336 336 let sent = ref 0 in ··· 416 416 417 417 let suite = 418 418 ( "tls", 419 - Crowbar. 419 + Alcobar. 420 420 [ 421 421 test_case "random ops" [ bytes; bytes; list action ] main; 422 422 test_case "state machine"
+1 -1
eio/tests/fuzz/fuzz_tls.mli
··· 1 - val suite : string * Crowbar.test_case list 1 + val suite : string * Alcobar.test_case list
-23
eio/tests/fuzz/gen_corpus.ml
··· 1 - (** Generate seed corpus for AFL fuzzing of tls-eio. *) 2 - 3 - let write_seed dir n data = 4 - let filename = Printf.sprintf "%s/seed_%03d" dir n in 5 - let oc = open_out_bin filename in 6 - output_bytes oc data; 7 - close_out oc 8 - 9 - let () = 10 - let dir = "corpus" in 11 - (try Unix.mkdir dir 0o755 with Unix.Unix_error (Unix.EEXIST, _, _) -> ()); 12 - let n = ref 0 in 13 - let add data = 14 - write_seed dir !n data; 15 - incr n 16 - in 17 - (* Empty input *) 18 - add Bytes.empty; 19 - (* Minimal binary input *) 20 - add (Bytes.make 4 '\x00'); 21 - (* Quickstart flag set with some data *) 22 - add (Bytes.of_string "\x01\x00\x00\x00hello"); 23 - Printf.printf "Generated %d seed files in %s\n" !n dir
+2 -8
fuzz/dune
··· 1 1 (executable 2 2 (name fuzz) 3 3 (modules fuzz fuzz_tls) 4 - (libraries tls crowbar)) 5 - 6 - (executable 7 - (name gen_corpus) 8 - (modules gen_corpus) 9 - (libraries unix)) 4 + (libraries tls alcobar)) 10 5 11 6 (rule 12 7 (alias runtest) ··· 22 17 (= %{profile} afl)) 23 18 (deps 24 19 (source_tree corpus) 25 - fuzz.exe 26 - gen_corpus.exe) 20 + fuzz.exe) 27 21 (action 28 22 (echo "AFL fuzzer built: %{exe:fuzz.exe}\n")))
+1 -1
fuzz/fuzz.ml
··· 1 - let () = Crowbar.run "tls" [ Fuzz_tls.suite ] 1 + let () = Alcobar.run "tls" [ Fuzz_tls.suite ]
+15 -15
fuzz/fuzz_tls.ml
··· 18 18 See: 19 19 https://www.cvedetails.com/vulnerability-list/vendor_id-217/Openssl.html *) 20 20 21 - open Crowbar 21 + open Alcobar 22 22 23 23 (** Truncate input to reasonable size. *) 24 24 let truncate ?(max_len = 16384) buf = ··· 159 159 | Ok (level, typ) -> ( 160 160 let buf2 = Tls.Writer.assemble_alert ~level typ in 161 161 match Tls.Reader.parse_alert buf2 with 162 - | Error _ -> Crowbar.fail "alert roundtrip: re-parse failed" 163 - | Ok v2 -> Crowbar.check ((level, typ) = v2)) 162 + | Error _ -> Alcobar.fail "alert roundtrip: re-parse failed" 163 + | Ok v2 -> Alcobar.check ((level, typ) = v2)) 164 164 165 165 (** Version roundtrip: parse -> assemble -> parse must yield the same value. *) 166 166 let test_version_roundtrip buf = ··· 170 170 | Ok v -> ( 171 171 let buf2 = Tls.Writer.assemble_protocol_version v in 172 172 match Tls.Reader.parse_version buf2 with 173 - | Error _ -> Crowbar.fail "version roundtrip: re-parse failed" 174 - | Ok v2 -> Crowbar.check (v = v2)) 173 + | Error _ -> Alcobar.fail "version roundtrip: re-parse failed" 174 + | Ok v2 -> Alcobar.check (v = v2)) 175 175 176 176 (** Handshake roundtrip: parse -> assemble -> parse must yield the same value. 177 177 Covers all handshake message types including KeyUpdate (TLS 1.3) and ··· 183 183 | Ok hs -> ( 184 184 let buf2 = Tls.Writer.assemble_handshake hs in 185 185 match Tls.Reader.parse_handshake buf2 with 186 - | Error _ -> Crowbar.fail "handshake roundtrip: re-parse failed" 187 - | Ok hs2 -> Crowbar.check (hs = hs2)) 186 + | Error _ -> Alcobar.fail "handshake roundtrip: re-parse failed" 187 + | Ok hs2 -> Alcobar.check (hs = hs2)) 188 188 189 189 (** Certificates roundtrip: parse -> assemble -> parse. *) 190 190 let test_certificates_roundtrip buf = ··· 194 194 | Ok certs -> ( 195 195 let buf2 = Tls.Writer.assemble_certificates certs in 196 196 match Tls.Reader.parse_certificates buf2 with 197 - | Error _ -> Crowbar.fail "certificates roundtrip: re-parse failed" 198 - | Ok certs2 -> Crowbar.check (certs = certs2)) 197 + | Error _ -> Alcobar.fail "certificates roundtrip: re-parse failed" 198 + | Ok certs2 -> Alcobar.check (certs = certs2)) 199 199 200 200 (** DH parameters roundtrip: parse -> assemble -> parse. *) 201 201 let test_dh_params_roundtrip buf = ··· 205 205 | Ok (params, _, _) -> ( 206 206 let buf2 = Tls.Writer.assemble_dh_parameters params in 207 207 match Tls.Reader.parse_dh_parameters buf2 with 208 - | Error _ -> Crowbar.fail "DH params roundtrip: re-parse failed" 209 - | Ok (params2, _, _) -> Crowbar.check (params = params2)) 208 + | Error _ -> Alcobar.fail "DH params roundtrip: re-parse failed" 209 + | Ok (params2, _, _) -> Alcobar.check (params = params2)) 210 210 211 211 (** Digitally signed roundtrip (pre-1.2): parse -> assemble -> parse. *) 212 212 let test_digitally_signed_roundtrip buf = ··· 216 216 | Ok sig_ -> ( 217 217 let buf2 = Tls.Writer.assemble_digitally_signed sig_ in 218 218 match Tls.Reader.parse_digitally_signed buf2 with 219 - | Error _ -> Crowbar.fail "digitally signed roundtrip: re-parse failed" 220 - | Ok sig2 -> Crowbar.check (sig_ = sig2)) 219 + | Error _ -> Alcobar.fail "digitally signed roundtrip: re-parse failed" 220 + | Ok sig2 -> Alcobar.check (sig_ = sig2)) 221 221 222 222 (** KeyUpdate roundtrip: construct known KeyUpdate handshake messages and verify 223 223 they survive a parse/assemble/parse cycle. CVE-2021-3449 involved ··· 230 230 in 231 231 let buf = Tls.Writer.assemble_handshake hs in 232 232 match Tls.Reader.parse_handshake buf with 233 - | Error _ -> Crowbar.fail "key_update roundtrip: parse failed" 234 - | Ok hs2 -> Crowbar.check (hs = hs2) 233 + | Error _ -> Alcobar.fail "key_update roundtrip: parse failed" 234 + | Ok hs2 -> Alcobar.check (hs = hs2) 235 235 236 236 (** Test record overflow detection. CVE-2014-0160 (Heartbleed) exploited missing 237 237 length validation. *)
+1 -1
fuzz/fuzz_tls.mli
··· 1 - val suite : string * Crowbar.test_case list 1 + val suite : string * Alcobar.test_case list
-17
fuzz/gen_corpus.ml
··· 1 - (** Generate seed corpus for fuzz testing. *) 2 - 3 - let () = 4 - let dir = "corpus" in 5 - (try Unix.mkdir dir 0o755 with Unix.Unix_error (Unix.EEXIST, _, _) -> ()); 6 - let write name data = 7 - let oc = open_out_bin (Filename.concat dir name) in 8 - output_string oc data; 9 - close_out oc 10 - in 11 - write "seed_000" ""; 12 - write "seed_001" "\x00"; 13 - write "seed_002" "\xff"; 14 - write "seed_003" (String.make 16 '\x00'); 15 - write "seed_004" (String.make 16 '\xff'); 16 - write "seed_005" (String.init 256 Char.chr); 17 - Printf.printf "gen_corpus: wrote 6 seed files\n"