mte/unikernel/duniverse/ocaml-tls/tests/readertests.ml

1554 lines
104 KiB
OCaml
Raw Normal View History

2025-11-11 02:07:51 +01:00
open Tls
open OUnit2
open Testlib
let good_any_version_parser major minor result _ =
let ver = list_to_cstruct [ major ; minor ] in
match Reader.parse_any_version ver with
| Ok v -> assert_equal v result
| Error _ -> assert_failure "Version parser broken"
let bad_any_version_parser major minor _ =
let ver = list_to_cstruct [ major ; minor ] in
match Reader.parse_any_version ver with
| Ok _ -> assert_failure "Version parser broken"
| Error _ -> ()
let parse_any_version_too_short _ =
let ver = list_to_cstruct [ 0 ] in
match Reader.parse_any_version ver with
| Ok _ -> assert_failure "Version parser broken"
| Error _ -> ()
let any_version_parser_tests = [
good_any_version_parser 3 0 `SSL_3 ;
good_any_version_parser 3 1 `TLS_1_0 ;
good_any_version_parser 3 2 `TLS_1_1 ;
good_any_version_parser 3 3 `TLS_1_2 ;
good_any_version_parser 3 4 `TLS_1_3 ;
good_any_version_parser 3 42 (`TLS_1_X 42);
bad_any_version_parser 2 4 ;
bad_any_version_parser 4 4 ;
bad_any_version_parser 0 2 ;
parse_any_version_too_short
]
let any_version_tests =
List.mapi
(fun i f -> "Parse any version " ^ string_of_int i >:: f)
any_version_parser_tests
let good_version_parser major minor result _ =
let ver = list_to_cstruct [ major ; minor ] in
match Reader.parse_version ver with
| Ok v -> assert_equal v result
| Error _ -> assert_failure "Version parser broken"
let bad_version_parser major minor _ =
let ver = list_to_cstruct [ major ; minor ] in
match Reader.parse_version ver with
| Ok _ -> assert_failure "Version parser broken"
| Error _ -> ()
let parse_version_too_short _ =
let ver = list_to_cstruct [ 0 ] in
match Reader.parse_version ver with
| Ok _ -> assert_failure "Version parser broken"
| Error _ -> ()
let version_parser_tests = [
good_version_parser 3 1 `TLS_1_0 ;
good_version_parser 3 2 `TLS_1_1 ;
good_version_parser 3 3 `TLS_1_2 ;
good_version_parser 3 4 `TLS_1_3 ;
bad_version_parser 3 0 ;
bad_version_parser 3 42 ;
bad_version_parser 2 4 ;
bad_version_parser 4 4 ;
bad_version_parser 0 2 ;
parse_version_too_short
]
let version_tests =
List.mapi
(fun i f -> "Parse version " ^ string_of_int i >:: f)
version_parser_tests
let good_record_parser (bytes, result) _ =
let buf = list_to_cstruct bytes in
let open Reader in
match parse_record buf, result with
| Ok (`Record ((hdr, x), f)), `Record ((rhdr, y), g) ->
assert_equal rhdr hdr ;
assert_cs_eq y x ;
assert_cs_eq g f
| Ok `Fragment x, `Fragment y -> assert_cs_eq y x
| Error `Record_overflow x, `Overflow y -> assert_equal y x
| Error `Protocol_version `Unknown_record x, `UnknownVersion y -> assert_equal y x
| Error `Unexpected `Content_type x, `UnknownContent y -> assert_equal y x
| _ -> assert_failure "record parser broken"
let good_records =
let open Core in
let open Packet in
let empty = "" in
[
([ 20 ; 3 ; 1 ; 0 ; 0 ], `Record (({ content_type = CHANGE_CIPHER_SPEC ; version = `TLS_1_0 }, empty), empty) ) ;
([ 21 ; 3 ; 2 ; 0 ; 0 ], `Record (({ content_type = ALERT ; version = `TLS_1_1 }, empty), empty) ) ;
([ 22 ; 3 ; 3 ; 0 ; 0 ], `Record (({ content_type = HANDSHAKE ; version = `TLS_1_2 }, empty), empty) ) ;
([ 23 ; 3 ; 0 ; 0 ; 0 ], `Record (({ content_type = APPLICATION_DATA ; version = `SSL_3 }, empty), empty) ) ;
([ 16 ; 3 ; 1 ; 0 ; 0 ], `UnknownContent 16 ) ;
([ 19 ; 3 ; 1 ; 0 ; 0 ], `UnknownContent 19 ) ;
([ 20 ; 5 ; 1 ; 0 ; 0 ], `UnknownVersion (5, 1) ) ;
([ 20 ; 3 ; 1 ; 0 ; 100 ], `Fragment (list_to_cstruct [ 20 ; 3 ; 1 ; 0 ; 100 ] )) ;
([ 0 ], `Fragment (list_to_cstruct [ 0 ])) ;
([ ], `Fragment empty) ;
([ 20 ; 3 ; 1 ; 0 ; 0 ; 0 ], `Record (({ content_type = CHANGE_CIPHER_SPEC ; version = `TLS_1_0 }, empty), list_to_cstruct [ 0 ]) ) ;
([ 0 ; 0 ; 0 ; 255 ; 255 ], `Overflow 65535) ;
([ 0 ; 0 ; 0 ; 72 ; 1 ], `Overflow 18433)
]
let good_records_tests =
List.mapi
(fun i args -> "Good record " ^ string_of_int i >:: good_record_parser args)
good_records
let good_alert_parser (lvl, typ, expected) _ =
let buf = list_to_cstruct [ lvl ; typ ] in
match Reader.parse_alert buf with
| Ok al -> assert_equal al expected
| Error _ -> assert_failure "alert parser broken"
let good_alerts =
let w = Packet.WARNING in
let f = Packet.FATAL in
[
(1, 0, (w, Packet.CLOSE_NOTIFY));
(2, 0, (f, Packet.CLOSE_NOTIFY));
(* (1, 10, (w, Packet.UNEXPECTED_MESSAGE)); *)
(2, 10, (f, Packet.UNEXPECTED_MESSAGE));
(* (1, 20, (w, Packet.BAD_RECORD_MAC)); *)
(2, 20, (f, Packet.BAD_RECORD_MAC));
(* (1, 22, (w, Packet.RECORD_OVERFLOW)); *)
(2, 22, (f, Packet.RECORD_OVERFLOW));
(* (1, 40, (w, Packet.HANDSHAKE_FAILURE)); *)
(2, 40, (f, Packet.HANDSHAKE_FAILURE));
(* (1, 42, (w, Packet.BAD_CERTIFICATE)); *)
(2, 42, (f, Packet.BAD_CERTIFICATE));
(1, 45, (w, Packet.CERTIFICATE_EXPIRED));
(2, 45, (f, Packet.CERTIFICATE_EXPIRED));
(* (1, 50, (w, Packet.DECODE_ERROR)); *)
(2, 50, (f, Packet.DECODE_ERROR));
(* (1, 70, (w, Packet.PROTOCOL_VERSION)); *)
(2, 70, (f, Packet.PROTOCOL_VERSION));
(1, 90, (w, Packet.USER_CANCELED));
(* (2, 90, (f, Packet.USER_CANCELED)); *)
(1, 100, (w, Packet.NO_RENEGOTIATION));
(* (2, 100, (f, Packet.NO_RENEGOTIATION)); *)
(* (1, 110, (w, Packet.UNSUPPORTED_EXTENSION)); *)
(2, 110, (f, Packet.UNSUPPORTED_EXTENSION));
(* (1, 112, (w, Packet.UNRECOGNIZED_NAME)); *)
(2, 112, (f, Packet.UNRECOGNIZED_NAME));
(2, 120, (f, Packet.NO_APPLICATION_PROTOCOL));
]
let good_alert_tests =
List.mapi
(fun i args -> "Good alert " ^ string_of_int i >:: good_alert_parser args)
good_alerts
let alert_too_small _ =
let buf = list_to_cstruct [ 0 ] in
match Reader.parse_alert buf with
| Ok _ -> assert_failure "short alert passes"
| Error _ -> ()
let alert_too_small2 _ =
let buf = list_to_cstruct [ 25 ] in
match Reader.parse_alert buf with
| Ok _ -> assert_failure "short alert passes"
| Error _ -> ()
let bad_alerts_tests =
[ ("short alert" >:: alert_too_small) ;
("short alert 2" >:: alert_too_small2) ]
let good_dhparams = [
[
0x01; 0x00; 0xf6; 0x42; 0x57; 0xb7; 0x08; 0x7f; 0x08; 0x17; 0x72; 0xa2; 0xba; 0xd6; 0xa9; 0x42;
0xf3; 0x05; 0xe8; 0xf9; 0x53; 0x11; 0x39; 0x4f; 0xb6; 0xf1; 0x6e; 0xb9; 0x4b; 0x38; 0x20; 0xda;
0x01; 0xa7; 0x56; 0xa3; 0x14; 0xe9; 0x8f; 0x40; 0x55; 0xf3; 0xd0; 0x07; 0xc6; 0xcb; 0x43; 0xa9;
0x94; 0xad; 0xf7; 0x4c; 0x64; 0x86; 0x49; 0xf8; 0x0c; 0x83; 0xbd; 0x65; 0xe9; 0x17; 0xd4; 0xa1;
0xd3; 0x50; 0xf8; 0xf5; 0x59; 0x5f; 0xdc; 0x76; 0x52; 0x4f; 0x3d; 0x3d; 0x8d; 0xdb; 0xce; 0x99;
0xe1; 0x57; 0x92; 0x59; 0xcd; 0xfd; 0xb8; 0xae; 0x74; 0x4f; 0xc5; 0xfc; 0x76; 0xbc; 0x83; 0xc5;
0x47; 0x30; 0x61; 0xce; 0x7c; 0xc9; 0x66; 0xff; 0x15; 0xf9; 0xbb; 0xfd; 0x91; 0x5e; 0xc7; 0x01;
0xaa; 0xd3; 0x5b; 0x9e; 0x8d; 0xa0; 0xa5; 0x72; 0x3a; 0xd4; 0x1a; 0xf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; 0x0b; 0x14; 0xa1; 0xda; 0x0a;
0x56; 0x4f; 0xff; 0x8c; 0xdd; 0x84; 0x7c; 0xd8; 0xcc; 0xa8; 0xc1; 0xc3; 0xa1; 0xbf; 0x15; 0x38;
0xc9; 0x4f; 0xc3; 0x7b; 0xde; 0xf3; 0x37; 0xf3; 0x2f; 0x8e; 0x72; 0x4d; 0xfb; 0x69; 0xc6; 0x4d;
0xe4; 0x84; 0x46; 0x64; 0xe1; 0xb5; 0x02; 0xe8; 0xf9; 0xbd; 0x94; 0xbf; 0x40; 0x5e; 0x1f; 0xb6;
0x39; 0xb9; 0x0b; 0x1a; 0x79; 0xf1; 0xa6; 0x3d; 0xee; 0x7a; 0x02; 0xff; 0x62; 0x0d; 0xc6; 0x1e;
0xfb; 0x5a; 0xcd; 0x36; 0xee; 0x6d; 0x67; 0x5f; 0x81; 0xf4; 0xde; 0x62; 0x15; 0xb6; 0x9a; 0xf3;
0x24; 0xa2; 0xb3; 0x95; 0xdf; 0x6a; 0xa2
]
]
let good_dh_param_parser xs _ =
let buf = list_to_cstruct xs in
match Reader.parse_dh_parameters buf with
| Error _ -> assert_failure "dh params parser broken"
| Ok (_, _, rst) -> assert_equal 0 (String.length rst)
let good_dh_params_tests =
List.mapi
(fun i f -> "Parse good dh_param " ^ string_of_int i >:: good_dh_param_parser f)
good_dhparams
let bad_dh_param_parser buf _ =
match Reader.parse_dh_parameters buf with
| Error _ -> ()
| Ok (_, _, rst) ->
if String.length rst = 0 then
assert_failure "dh params parser broken"
let bad_dh_params_tests =
let param = list_to_cstruct (List.hd good_dhparams) in
let l = String.length param in
let bad_params =
[
param ^ String.make 1 '\x00' ;
String.sub param 2 20 ;
String.sub param 0 20 ;
list_to_cstruct [2] ^ param ;
list_to_cstruct [0] ^ param ;
list_to_cstruct [0; 1] ^ param ;
list_to_cstruct [0; 0] ^ param ;
list_to_cstruct [0xff; 0xff] ^ param ;
list_to_cstruct [0; 0xff] ^ param ;
String.sub param 1 (String.length param - 1);
String.sub param 0 (pred l)
]
in
let lastparam = list_to_cstruct (List.nth good_dhparams 5) in
let l = String.length lastparam in
let more_bad =
[
String.sub lastparam 0 130 ^ list_to_cstruct [0 ; 5 ; 1] ^ String.sub lastparam 130 (l - 130) ;
String.sub lastparam 0 133 ^ list_to_cstruct [0 ; 5 ; 1] ^ String.sub lastparam 133 (l - 133)
]
in
List.mapi
(fun i f -> "Parse bad dh_param " ^ string_of_int i >:: bad_dh_param_parser f)
(bad_params @ more_bad)
let good_digitally_signed_1_2 = [
[
0x06; 0x01; 0x01; 0x00; 0x30; 0x92; 0xf4; 0x70; 0xb1; 0x02; 0x0a; 0x51; 0xb6; 0x0e; 0x49; 0x1e;
0x16; 0x6d; 0x9f; 0xb5; 0xfe; 0x73; 0x5e; 0x2f; 0x18; 0xbc; 0xf7; 0x87; 0xab; 0x2c; 0xad; 0x7e;
0x54; 0x40; 0x99; 0x30; 0xa2; 0x2e; 0x55; 0xe0; 0xf3; 0x05; 0xe1; 0x81; 0x67; 0x78; 0x49; 0x29;
0xe6; 0x5d; 0x2c; 0x64; 0x57; 0xeb; 0x8c; 0x68; 0x24; 0xe1; 0xba; 0x69; 0x50; 0xc7; 0xda; 0x73;
0x9a; 0x02; 0xe4; 0xbc; 0xc0; 0x76; 0x65; 0xaf; 0x31; 0x93; 0xbc; 0x2f; 0x5c; 0xdb; 0xa5; 0x1d;
0x4e; 0xb2; 0x75; 0x0d; 0xb4; 0x22; 0x23; 0x05; 0x5b; 0x8c; 0xa0; 0x14; 0x4c; 0x64; 0xb9; 0x91;
0xa6; 0x22; 0xc2; 0x49; 0xaa; 0x41; 0xb0; 0x42; 0x04; 0x2a; 0x03; 0x03; 0x1e; 0x62; 0x74; 0x64;
0x98; 0xaf; 0xcf; 0x9a; 0xd0; 0x22; 0xa8; 0xf3; 0xa5; 0x0a; 0x0d; 0xe9; 0xdc; 0xe2; 0x89; 0xe5;
0x54; 0xa2; 0x28; 0x25; 0x69; 0x4e; 0xe5; 0xc3; 0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x21; 0x8d; 0x0b; 0x20; 0x00; 0x5a; 0x21;
0x5f; 0x8e; 0x1a; 0x77; 0xd0; 0x70; 0xfb; 0x8c; 0x98; 0x9d; 0x63; 0xb3; 0x9a; 0x6a; 0x3f; 0xc3;
0x89; 0x43; 0xfe; 0x1c; 0xa7; 0x6f; 0xb6; 0xd6; 0x1f; 0xa9; 0x3e; 0x6c; 0xe2; 0x7a; 0x8e; 0x31;
0xbc; 0x8f; 0x4e; 0xe4; 0xc0; 0x36; 0x8d; 0x72; 0x01; 0xf4; 0x65; 0x71; 0xff; 0x16; 0xa6; 0xc7;
0x0a; 0x59; 0xf1; 0x18
]
]
let good_digitally_signed_1_2_parser xs _ =
let buf = list_to_cstruct xs in
match Reader.parse_digitally_signed_1_2 buf with
| Error _ -> assert_failure "digitally signed 1.2 parser broken"
| Ok _ -> ()
let good_digitally_signed_1_2_tests =
List.mapi
(fun i f -> "Parse good digitally signed 1_2 " ^ string_of_int i >:: good_digitally_signed_1_2_parser f)
good_digitally_signed_1_2
let bad_dss_1_2 =
let ds = list_to_cstruct (List.hd good_digitally_signed_1_2) in
let l = String.length ds in
[
String.sub ds 2 20 ;
String.sub ds 0 20 ;
list_to_cstruct [2] ^ ds ;
list_to_cstruct [0] ^ ds ;
list_to_cstruct [0; 1] ^ ds ;
list_to_cstruct [0; 0] ^ ds ;
list_to_cstruct [0xff; 0xff] ^ ds ;
list_to_cstruct [0; 0xff] ^ ds ;
String.sub ds 2 (String.length ds - 2) ;
String.sub ds 0 (pred l) ;
list_to_cstruct [7] ^ String.sub ds 1 (String.length ds - 1) ;
list_to_cstruct [8] ^ String.sub ds 1 (String.length ds - 1) ;
list_to_cstruct [1 ; 7] ^ String.sub ds 2 (String.length ds - 2) ;
list_to_cstruct [7 ; 2] ^ String.sub ds 2 (String.length ds - 2) ;
list_to_cstruct [1 ; 1 ; 1; 0xff] ^ String.sub ds 4 (String.length ds - 4) ;
list_to_cstruct [1 ; 1 ; 0xff ; 0] ^ String.sub ds 4 (String.length ds - 4) ;
ds ^ String.make 1 '\x00'
]
let bad_digitally_signed_1_2_parser buf _ =
match Reader.parse_digitally_signed_1_2 buf with
| Error _ -> ()
| Ok _ -> assert_failure "digitally signed 1.2 parser broken"
let bad_digitally_signed_1_2_tests =
List.mapi
(fun i f -> "Parse bad digitally signed 1.2 " ^ string_of_int i >:: bad_digitally_signed_1_2_parser f)
bad_dss_1_2
let good_digitally_signed_parser xs _ =
let buf =
let b = list_to_cstruct xs in
String.sub b 2 (String.length b - 2)
in
match Reader.parse_digitally_signed buf with
| Error _ -> assert_failure "digitally signed parser broken"
| Ok _ -> ()
let good_digitally_signed_tests =
List.mapi
(fun i f -> "Parse good digitally signed " ^ string_of_int i >:: good_digitally_signed_parser f)
good_digitally_signed_1_2
let bad_dss =
let ds =
let buf = list_to_cstruct (List.hd good_digitally_signed_1_2) in
String.sub buf 2 (String.length buf - 2) in
let l = String.length ds in
[
list_to_cstruct [0xff ; 0xff] ^ ds ;
list_to_cstruct [0xff ; 0xff] ^ String.sub ds 2 (String.length ds - 2);
String.sub ds 2 (String.length ds - 2) ;
String.sub ds 0 (pred l) ;
list_to_cstruct [1; 1] ^ String.sub ds 2 (String.length ds - 2);
ds ^ String.make 1 '\x00'
]
let bad_digitally_signed_parser buf _ =
match Reader.parse_digitally_signed buf with
| Error _ -> ()
| Ok _ -> assert_failure "digitally signed parser broken"
let bad_digitally_signed_tests =
List.mapi
(fun i f -> "Parse bad digitally signed " ^ string_of_int i >:: bad_digitally_signed_parser f)
bad_dss
let good_handshake_hdrs =
let data = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11 ] in
let empty = "" in
[
([0; 0; 0], (None, list_to_cstruct [0;0;0])) ;
([0; 0; 0; 0], (Some (list_to_cstruct [0;0;0;0]), empty)) ;
([0; 0; 0; 0xFF], (None, list_to_cstruct [0;0;0;255])) ;
([0; 0; 1; 0], (None, list_to_cstruct [0;0;1;0])) ;
([16; 0; 0; 12] @ data , (Some (list_to_cstruct ([16;0;0;12] @ data)), empty)) ;
([16; 0; 0; 14] @ data , (None, list_to_cstruct ([16;0;0;14] @ data)))
]
let good_handshake_hdr_parser (xs, (hs, rest)) _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake_frame buf, hs with
| (Some x, rest'), Some y ->
assert_cs_eq y x ;
assert_cs_eq rest rest' ;
| (None, rest'), None ->
assert_cs_eq rest rest' ;
| _ -> assert_failure "handshake_frame parser broken"
let good_handshake_hdr_tests =
List.mapi
(fun i f -> "Parse good handshake header " ^ string_of_int i >:: good_handshake_hdr_parser f)
good_handshake_hdrs
(* 1byte type ; 3 byte length ; data *)
let good_handshakes_no_data = [
([0; 0; 0; 0] , Core.HelloRequest) ;
([14; 0; 0; 0] , Core.ServerHelloDone) ;
]
let good_handshake_no_data_parser (xs, res) _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok r -> assert_equal res r
| Error _ -> assert_failure "handshake no data parser failed"
let good_handshake_no_data_tests =
List.mapi
(fun i f -> "Parse good handshake " ^ string_of_int i >:: good_handshake_no_data_parser f)
good_handshakes_no_data
let bad_handshakes_no_data = [
[0; 0; 0; 3] ;
[14; 0; 0; 5] ;
[245; 0; 0; 0] ;
[0; 0; 0; 3; 0; 0; 0] ;
[14; 0; 0; 5; 0; 0; 0; 0; 0]
]
let bad_handshake_no_data_parser xs _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok _ -> assert_failure "bad handshake no data parser failed"
| Error _ -> ()
let bad_handshake_no_data_tests =
List.mapi
(fun i f -> "Parse bad handshake (no data) " ^ string_of_int i >:: bad_handshake_no_data_parser f)
bad_handshakes_no_data
let good_handshake_cstruct_data =
let data = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11 ] in
let data_cs = list_to_cstruct data in
let gh1 = list_to_cstruct [
0x30; 0x82; 0x05; 0xe0; 0x30; 0x82;
0x04; 0xc8; 0xa0; 0x03; 0x02; 0x01; 0x02; 0x02; 0x10; 0x0c; 0x00; 0x93; 0x10; 0xd2; 0x06; 0xdb;
0xe3; 0x37; 0x55; 0x35; 0x80; 0x11; 0x8d; 0xdc; 0x87; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48;
0x86; 0xf7; 0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x30; 0x75; 0x31; 0x0b; 0x30; 0x09; 0x06; 0x03;
0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x15; 0x30; 0x13; 0x06; 0x03; 0x55; 0x04; 0x0a;
0x13; 0x0c; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x20; 0x49; 0x6e; 0x63; 0x31; 0x19;
0x30; 0x17; 0x06; 0x03; 0x55; 0x04; 0x0b; 0x13; 0x10; 0x77; 0x77; 0x77; 0x2e; 0x64; 0x69; 0x67;
0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x31; 0x34; 0x30; 0x32; 0x06; 0x03; 0x55;
0x04; 0x03; 0x13; 0x2b; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x20; 0x53; 0x48; 0x41;
0x32; 0x20; 0x45; 0x78; 0x74; 0x65; 0x6e; 0x64; 0x65; 0x64; 0x20; 0x56; 0x61; 0x6c; 0x69; 0x64;
0x61; 0x74; 0x69; 0x6f; 0x6e; 0x20; 0x53; 0x65; 0x72; 0x76; 0x65; 0x72; 0x20; 0x43; 0x41; 0x30;
0x1e; 0x17; 0x0d; 0x31; 0x34; 0x30; 0x34; 0x30; 0x38; 0x30; 0x30; 0x30; 0x30; 0x30; 0x30; 0x5a;
0x17; 0x0d; 0x31; 0x36; 0x30; 0x34; 0x31; 0x32; 0x31; 0x32; 0x30; 0x30; 0x30; 0x30; 0x5a; 0x30;
0x81; 0xf0; 0x31; 0x1d; 0x30; 0x1b; 0x06; 0x03; 0x55; 0x04; 0x0f; 0x0c; 0x14; 0x50; 0x72; 0x69;
0x76; 0x61; 0x74; 0x65; 0x20; 0x4f; 0x72; 0x67; 0x61; 0x6e; 0x69; 0x7a; 0x61; 0x74; 0x69; 0x6f;
0x6e; 0x31; 0x13; 0x30; 0x11; 0x06; 0x0b; 0x2b; 0x06; 0x01; 0x04; 0x01; 0x82; 0x37; 0x3c; 0x02;
0x01; 0x03; 0x13; 0x02; 0x55; 0x53; 0x31; 0x19; 0x30; 0x17; 0x06; 0x0b; 0x2b; 0x06; 0x01; 0x04;
0x01; 0x82; 0x37; 0x3c; 0x02; 0x01; 0x02; 0x13; 0x08; 0x44; 0x65; 0x6c; 0x61; 0x77; 0x61; 0x72;
0x65; 0x31; 0x10; 0x30; 0x0e; 0x06; 0x03; 0x55; 0x04; 0x05; 0x13; 0x07; 0x35; 0x31; 0x35; 0x37;
0x35; 0x35; 0x30; 0x31; 0x17; 0x30; 0x15; 0x06; 0x03; 0x55; 0x04; 0x09; 0x13; 0x0e; 0x35; 0x34;
0x38; 0x20; 0x34; 0x74; 0x68; 0x20; 0x53; 0x74; 0x72; 0x65; 0x65; 0x74; 0x31; 0x0e; 0x30; 0x0c;
0x06; 0x03; 0x55; 0x04; 0x11; 0x13; 0x05; 0x39; 0x34; 0x31; 0x30; 0x37; 0x31; 0x0b; 0x30; 0x09;
0x06; 0x03; 0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x13; 0x30; 0x11; 0x06; 0x03; 0x55;
0x04; 0x08; 0x13; 0x0a; 0x43; 0x61; 0x6c; 0x69; 0x66; 0x6f; 0x72; 0x6e; 0x69; 0x61; 0x31; 0x16;
0x30; 0x14; 0x06; 0x03; 0x55; 0x04; 0x07; 0x13; 0x0d; 0x53; 0x61; 0x6e; 0x20; 0x46; 0x72; 0x61;
0x6e; 0x63; 0x69; 0x73; 0x63; 0x6f; 0x31; 0x15; 0x30; 0x13; 0x06; 0x03; 0x55; 0x04; 0x0a; 0x13;
0x0c; 0x47; 0x69; 0x74; 0x48; 0x75; 0x62; 0x2c; 0x20; 0x49; 0x6e; 0x63; 0x2e; 0x31; 0x13; 0x30;
0x11; 0x06; 0x03; 0x55; 0x04; 0x03; 0x13; 0x0a; 0x67; 0x69; 0x74; 0x68; 0x75; 0x62; 0x2e; 0x63;
0x6f; 0x6d; 0x30; 0x82; 0x01; 0x22; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86; 0xf7; 0x0d;
0x01; 0x01; 0x01; 0x05; 0x00; 0x03; 0x82; 0x01; 0x0f; 0x00; 0x30; 0x82; 0x01; 0x0a; 0x02; 0x82;
0x01; 0x01; 0x00; 0xb1; 0xd4; 0xdc; 0x3c; 0xaf; 0xfd; 0xf3; 0x4e; 0xed; 0xc1; 0x67; 0xad; 0xe6;
0xcb; 0x22; 0xe8; 0xb7; 0xe2; 0xab; 0x28; 0xf2; 0xf7; 0xdc; 0x62; 0x70; 0x08; 0xd1; 0x0c; 0xaf;
0xd6; 0x16; 0x6a; 0x21; 0xb0; 0x36; 0x4b; 0x17; 0x0d; 0x36; 0x63; 0x04; 0xae; 0xbf; 0xea; 0x20;
0x51; 0x95; 0x65; 0x66; 0xf2; 0xbf; 0xb9; 0x4d; 0xa4; 0x0c; 0x29; 0xeb; 0xf5; 0x15; 0xb1; 0xe8;
0x35; 0xb3; 0x70; 0x10; 0x94; 0xd5; 0x1b; 0x59; 0xb4; 0x26; 0x0f; 0xd6; 0x83; 0x57; 0x59; 0x9d;
0xe1; 0x7c; 0x09; 0xdd; 0xe0; 0x13; 0xca; 0x4d; 0x6f; 0x43; 0x9b; 0xcd; 0xcf; 0x87; 0x3a; 0x15;
0xa7; 0x85; 0xdd; 0x66; 0x83; 0xed; 0x93; 0x0c; 0xfe; 0x2b; 0x6d; 0x38; 0x1c; 0x79; 0x88; 0x90;
0xcf; 0xad; 0x58; 0x18; 0x2d; 0x51; 0xd1; 0xc2; 0xa3; 0xf2; 0x47; 0x8c; 0x6f; 0x38; 0x09; 0xb9;
0xb8; 0xef; 0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0x14; 0x6a; 0x43; 0x90; 0x7d;
0x3b; 0x98; 0x14; 0x72; 0x52; 0x95; 0x3a; 0xaa; 0x28; 0x0a; 0x43; 0xf8; 0x51; 0x7e; 0xd3; 0xa6;
0x30; 0x25; 0x06; 0x03; 0x55; 0x1d; 0x11; 0x04; 0x1e; 0x30; 0x1c; 0x82; 0x0a; 0x67; 0x69; 0x74;
0x68; 0x75; 0x62; 0x2e; 0x63; 0x6f; 0x6d; 0x82; 0x0e; 0x77; 0x77; 0x77; 0x2e; 0x67; 0x69; 0x74;
0x68; 0x75; 0x62; 0x2e; 0x63; 0x6f; 0x6d; 0x30; 0x0e; 0x06; 0x03; 0x55; 0x1d; 0x0f; 0x01; 0x01;
0xff; 0x04; 0x04; 0x03; 0x02; 0x05; 0xa0; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x25; 0x04; 0x16;
0x30; 0x14; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x03; 0x01; 0x06; 0x08; 0x2b; 0x06;
0x01; 0x05; 0x05; 0x07; 0x03; 0x02; 0x30; 0x75; 0x06; 0x03; 0x55; 0x1d; 0x1f; 0x04; 0x6e; 0x30;
0x6c; 0x30; 0x34; 0xa0; 0x32; 0xa0; 0x30; 0x86; 0x2e; 0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f;
0x63; 0x72; 0x6c; 0x33; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f;
0x6d; 0x2f; 0x73; 0x68; 0x61; 0x32; 0x2d; 0x65; 0x76; 0x2d; 0x73; 0x65; 0x72; 0x76; 0x65; 0x72;
0x2d; 0x67; 0x31; 0x2e; 0x63; 0x72; 0x6c; 0x30; 0x34; 0xa0; 0x32; 0xa0; 0x30; 0x86; 0x2e; 0x68;
0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x63; 0x72; 0x6c; 0x34; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63;
0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x2f; 0x73; 0x68; 0x61; 0x32; 0x2d; 0x65; 0x76; 0x2d;
0x73; 0x65; 0x72; 0x76; 0x65; 0x72; 0x2d; 0x67; 0x31; 0x2e; 0x63; 0x72; 0x6c; 0x30; 0x42; 0x06;
0x03; 0x55; 0x1d; 0x20; 0x04; 0x3b; 0x30; 0x39; 0x30; 0x37; 0x06; 0x09; 0x60; 0x86; 0x48; 0x01;
0x86; 0xfd; 0x6c; 0x02; 0x01; 0x30; 0x2a; 0x30; 0x28; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05;
0x07; 0x02; 0x01; 0x16; 0x1c; 0x68; 0x74; 0x74; 0x70; 0x73; 0x3a; 0x2f; 0x2f; 0x77; 0x77; 0x77;
0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x2f; 0x43; 0x50;
0x53; 0x30; 0x81; 0x88; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x01; 0x01; 0x04; 0x7c;
0x30; 0x7a; 0x30; 0x24; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x30; 0x01; 0x86; 0x18;
0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x6f; 0x63; 0x73; 0x70; 0x2e; 0x64; 0x69; 0x67; 0x69;
0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x30; 0x52; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05;
0x05; 0x07; 0x30; 0x02; 0x86; 0x46; 0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x63; 0x61; 0x63;
0x65; 0x72; 0x74; 0x73; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f;
0x6d; 0x2f; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x53; 0x48; 0x41; 0x32; 0x45; 0x78;
0x74; 0x65; 0x6e; 0x64; 0x65; 0x64; 0x56; 0x61; 0x6c; 0x69; 0x64; 0x61; 0x74; 0x69; 0x6f; 0x6e;
0x53; 0x65; 0x72; 0x76; 0x65; 0x72; 0x43; 0x41; 0x2e; 0x63; 0x72; 0x74; 0x30; 0x0c; 0x06; 0x03;
0x55; 0x1d; 0x13; 0x01; 0x01; 0xff; 0x04; 0x02; 0x30; 0x00; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86;
0x48; 0x86; 0xf7; 0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x03; 0x82; 0x01; 0x01; 0x00; 0x6f; 0xe7;
0x6d; 0xcb; 0x82; 0xf3; 0xef; 0x90; 0x87; 0x09; 0xd7; 0x0f; 0x15; 0x22; 0x2c; 0x8c; 0xfe; 0xd3;
0xab; 0x1c; 0x8a; 0x96; 0xdb; 0x5d; 0x12; 0x5d; 0xd1; 0x78; 0xc0; 0x31; 0xb0; 0xff; 0x45; 0xc8;
0x89; 0xf7; 0x08; 0x98; 0x52; 0x17; 0x1f; 0x4c; 0x4b; 0x20; 0x64; 0x6a; 0x6d; 0xdb; 0x50; 0xd7;
0x10; 0xbe; 0x7e; 0xab; 0xfe; 0x2f; 0x80; 0xd8; 0xa9; 0x4a; 0x58; 0x41; 0x69; 0x81; 0x72; 0x19;
0x08; 0x83; 0x9b; 0x92; 0x10; 0x4e; 0x62; 0x2d; 0x7b; 0x46; 0x70; 0x43; 0x6e; 0xa3; 0x53; 0x13;
0x1f; 0xe2; 0x93; 0xa6; 0x23; 0x5b; 0xf7; 0x92; 0x3e; 0x37; 0x14; 0x75; 0x3b; 0xb9; 0x4b; 0x24;
0x41; 0x2e; 0xa5; 0x3d; 0x48; 0x0d; 0x0f; 0x99; 0xea; 0x1e; 0x42; 0x97; 0xc6; 0xfe; 0x95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 0xf7; 0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x30;
0x6c; 0x31; 0x0b; 0x30; 0x09; 0x06; 0x03; 0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x15;
0x30; 0x13; 0x06; 0x03; 0x55; 0x04; 0x0a; 0x13; 0x0c; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72;
0x74; 0x20; 0x49; 0x6e; 0x63; 0x31; 0x19; 0x30; 0x17; 0x06; 0x03; 0x55; 0x04; 0x0b; 0x13; 0x10;
0x77; 0x77; 0x77; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d;
0x31; 0x2b; 0x30; 0x29; 0x06; 0x03; 0x55; 0x04; 0x03; 0x13; 0x22; 0x44; 0x69; 0x67; 0x69; 0x43;
0x65; 0x72; 0x74; 0x20; 0x48; 0x69; 0x67; 0x68; 0x20; 0x41; 0x73; 0x73; 0x75; 0x72; 0x61; 0x6e;
0x63; 0x65; 0x20; 0x45; 0x56; 0x20; 0x52; 0x6f; 0x6f; 0x74; 0x20; 0x43; 0x41; 0x30; 0x1e; 0x17;
0x0d; 0x31; 0x33; 0x31; 0x30; 0x32; 0x32; 0x31; 0x32; 0x30; 0x30; 0x30; 0x30; 0x5a; 0x17; 0x0d;
0x32; 0x38; 0x31; 0x30; 0x32; 0x32; 0x31; 0x32; 0x30; 0x30; 0x30; 0x30; 0x5a; 0x30; 0x75; 0x31;
0x0b; 0x30; 0x09; 0x06; 0x03; 0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x15; 0x30; 0x13;
0x06; 0x03; 0x55; 0x04; 0x0a; 0x13; 0x0c; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x20;
0x49; 0x6e; 0x63; 0x31; 0x19; 0x30; 0x17; 0x06; 0x03; 0x55; 0x04; 0x0b; 0x13; 0x10; 0x77; 0x77;
0x77; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x31; 0x34;
0x30; 0x32; 0x06; 0x03; 0x55; 0x04; 0x03; 0x13; 0x2b; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72;
0x74; 0x20; 0x53; 0x48; 0x41; 0x32; 0x20; 0x45; 0x78; 0x74; 0x65; 0x6e; 0x64; 0x65; 0x64; 0x20;
0x56; 0x61; 0x6c; 0x69; 0x64; 0x61; 0x74; 0x69; 0x6f; 0x6e; 0x20; 0x53; 0x65; 0x72; 0x76; 0x65;
0x72; 0x20; 0x43; 0x41; 0x30; 0x82; 0x01; 0x22; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86;
0xf7; 0x0d; 0x01; 0x01; 0x01; 0x05; 0x00; 0x03; 0x82; 0x01; 0x0f; 0x00; 0x30; 0x82; 0x01; 0x0a;
0x02; 0x82; 0x01; 0x01; 0x00; 0xd7; 0x53; 0xa4; 0x04; 0x51; 0xf8; 0x99; 0xa6; 0x16; 0x48; 0x4b;
0x67; 0x27; 0xaa; 0x93; 0x49; 0xd0; 0x39; 0xed; 0x0c; 0xb0; 0xb0; 0x00; 0x87; 0xf1; 0x67; 0x28;
0x86; 0x85; 0x8c; 0x8e; 0x63; 0xda; 0xbc; 0xb1; 0x40; 0x38; 0xe2; 0xd3; 0xf5; 0xec; 0xa5; 0x05;
0x18; 0xb8; 0x3d; 0x3e; 0xc5; 0x99; 0x17; 0x32; 0xec; 0x18; 0x8c; 0xfa; 0xf1; 0x0c; 0xa6; 0x64;
0x21; 0x85; 0xcb; 0x07; 0x10; 0x34; 0xb0; 0x52; 0x88; 0x2b; 0x1f; 0x68; 0x9b; 0xd2; 0xb1; 0x8f;
0x12; 0xb0; 0xb3; 0xd2; 0xe7; 0x88; 0x1f; 0x1f; 0xef; 0x38; 0x77; 0x54; 0x53; 0x5f; 0x80; 0x79;
0x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01; 0x01; 0xff; 0x04; 0x08; 0x30; 0x06;
0x01; 0x01; 0xff; 0x02; 0x01; 0x00; 0x30; 0x0e; 0x06; 0x03; 0x55; 0x1d; 0x0f; 0x01; 0x01; 0xff;
0x04; 0x04; 0x03; 0x02; 0x01; 0x86; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x25; 0x04; 0x16; 0x30;
0x14; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x03; 0x01; 0x06; 0x08; 0x2b; 0x06; 0x01;
0x05; 0x05; 0x07; 0x03; 0x02; 0x30; 0x34; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x01;
0x01; 0x04; 0x28; 0x30; 0x26; 0x30; 0x24; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x30;
0x01; 0x86; 0x18; 0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x6f; 0x63; 0x73; 0x70; 0x2e; 0x64;
0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x30; 0x4b; 0x06; 0x03; 0x55;
0x1d; 0x1f; 0x04; 0x44; 0x30; 0x42; 0x30; 0x40; 0xa0; 0x3e; 0xa0; 0x3c; 0x86; 0x3a; 0x68; 0x74;
0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x63; 0x72; 0x6c; 0x34; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65;
0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x2f; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x48;
0x69; 0x67; 0x68; 0x41; 0x73; 0x73; 0x75; 0x72; 0x61; 0x6e; 0x63; 0x65; 0x45; 0x56; 0x52; 0x6f;
0x6f; 0x74; 0x43; 0x41; 0x2e; 0x63; 0x72; 0x6c; 0x30; 0x3d; 0x06; 0x03; 0x55; 0x1d; 0x20; 0x04;
0x36; 0x30; 0x34; 0x30; 0x32; 0x06; 0x04; 0x55; 0x1d; 0x20; 0x00; 0x30; 0x2a; 0x30; 0x28; 0x06;
0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x02; 0x01; 0x16; 0x1c; 0x68; 0x74; 0x74; 0x70; 0x73;
0x3a; 0x2f; 0x2f; 0x77; 0x77; 0x77; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e;
0x63; 0x6f; 0x6d; 0x2f; 0x43; 0x50; 0x53; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x0e; 0x04; 0x16;
0x04; 0x14; 0x3d; 0xd3; 0x50; 0xa5; 0xd6; 0xa0; 0xad; 0xee; 0xf3; 0x4a; 0x60; 0x0a; 0x65; 0xd3;
0x21; 0xd4; 0xf8; 0xf8; 0xd6; 0x0f; 0x30; 0x1f; 0x06; 0x03; 0x55; 0x1d; 0x23; 0x04; 0x18; 0x30;
0x16; 0x80; 0x14; 0xb1; 0x3e; 0xc3; 0x69; 0x03; 0xf8; 0xbf; 0x47; 0x01; 0xd4; 0x98; 0x26; 0x1a;
0x08; 0x02; 0xef; 0x63; 0x64; 0x2b; 0xc3; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86; 0xf7;
0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x03; 0x82; 0x01; 0x01; 0x00; 0x9d; 0xb6; 0xd0; 0x90; 0x86;
0xe1; 0x86; 0x02; 0xed; 0xc5; 0xa0; 0xf0; 0x34; 0x1c; 0x74; 0xc1; 0x8d; 0x76; 0xcc; 0x86; 0x0a;
0xa8; 0xf0; 0x4a; 0x8a; 0x42; 0xd6; 0x3f; 0xc8; 0xa9; 0x4d; 0xad; 0x7c; 0x08; 0xad; 0xe6; 0xb6;
0x50; 0xb8; 0xa2; 0x1a; 0x4d; 0x88; 0x07; 0xb1; 0x29; 0x21; 0xdc; 0xe7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bf; 0x87; 0x0d; 0x79; 0x50; 0x91; 0x90; 0x9b; 0x18; 0x3b; 0x91; 0x59;
0x27; 0xf1; 0x35; 0x28; 0x13; 0xab; 0x26; 0x7e; 0xd5; 0xf7; 0x7a ] in
[ ([12; 0; 0; 12] @ data , (Core.ServerKeyExchange data_cs)) ;
([20; 0; 0; 12] @ data , (Core.Finished data_cs)) ;
([16; 0; 0; 12] @ data , (Core.ClientKeyExchange data_cs)) ;
([11; 0; 0; 3; 0; 0; 0] , (Core.Certificate (Writer.assemble_certificates []))) ;
([11; 0; 0; 18; 0; 0; 15; 0; 0; 12] @ data , (Core.Certificate (Writer.assemble_certificates [data_cs]))) ;
([11; 0; 0; 33; 0; 0; 30; 0; 0; 12] @ data @ [0; 0; 12] @ data ,
(Core.Certificate (Writer.assemble_certificates [data_cs ; data_cs]))) ;
([
0x0b; 0x00; 0x0a; 0xa7;
0x00; 0x0a; 0xa4;
0x00; 0x05; 0xe4;
0x30; 0x82; 0x05; 0xe0; 0x30; 0x82;
0x04; 0xc8; 0xa0; 0x03; 0x02; 0x01; 0x02; 0x02; 0x10; 0x0c; 0x00; 0x93; 0x10; 0xd2; 0x06; 0xdb;
0xe3; 0x37; 0x55; 0x35; 0x80; 0x11; 0x8d; 0xdc; 0x87; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48;
0x86; 0xf7; 0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x30; 0x75; 0x31; 0x0b; 0x30; 0x09; 0x06; 0x03;
0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x15; 0x30; 0x13; 0x06; 0x03; 0x55; 0x04; 0x0a;
0x13; 0x0c; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x20; 0x49; 0x6e; 0x63; 0x31; 0x19;
0x30; 0x17; 0x06; 0x03; 0x55; 0x04; 0x0b; 0x13; 0x10; 0x77; 0x77; 0x77; 0x2e; 0x64; 0x69; 0x67;
0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x31; 0x34; 0x30; 0x32; 0x06; 0x03; 0x55;
0x04; 0x03; 0x13; 0x2b; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x20; 0x53; 0x48; 0x41;
0x32; 0x20; 0x45; 0x78; 0x74; 0x65; 0x6e; 0x64; 0x65; 0x64; 0x20; 0x56; 0x61; 0x6c; 0x69; 0x64;
0x61; 0x74; 0x69; 0x6f; 0x6e; 0x20; 0x53; 0x65; 0x72; 0x76; 0x65; 0x72; 0x20; 0x43; 0x41; 0x30;
0x1e; 0x17; 0x0d; 0x31; 0x34; 0x30; 0x34; 0x30; 0x38; 0x30; 0x30; 0x30; 0x30; 0x30; 0x30; 0x5a;
0x17; 0x0d; 0x31; 0x36; 0x30; 0x34; 0x31; 0x32; 0x31; 0x32; 0x30; 0x30; 0x30; 0x30; 0x5a; 0x30;
0x81; 0xf0; 0x31; 0x1d; 0x30; 0x1b; 0x06; 0x03; 0x55; 0x04; 0x0f; 0x0c; 0x14; 0x50; 0x72; 0x69;
0x76; 0x61; 0x74; 0x65; 0x20; 0x4f; 0x72; 0x67; 0x61; 0x6e; 0x69; 0x7a; 0x61; 0x74; 0x69; 0x6f;
0x6e; 0x31; 0x13; 0x30; 0x11; 0x06; 0x0b; 0x2b; 0x06; 0x01; 0x04; 0x01; 0x82; 0x37; 0x3c; 0x02;
0x01; 0x03; 0x13; 0x02; 0x55; 0x53; 0x31; 0x19; 0x30; 0x17; 0x06; 0x0b; 0x2b; 0x06; 0x01; 0x04;
0x01; 0x82; 0x37; 0x3c; 0x02; 0x01; 0x02; 0x13; 0x08; 0x44; 0x65; 0x6c; 0x61; 0x77; 0x61; 0x72;
0x65; 0x31; 0x10; 0x30; 0x0e; 0x06; 0x03; 0x55; 0x04; 0x05; 0x13; 0x07; 0x35; 0x31; 0x35; 0x37;
0x35; 0x35; 0x30; 0x31; 0x17; 0x30; 0x15; 0x06; 0x03; 0x55; 0x04; 0x09; 0x13; 0x0e; 0x35; 0x34;
0x38; 0x20; 0x34; 0x74; 0x68; 0x20; 0x53; 0x74; 0x72; 0x65; 0x65; 0x74; 0x31; 0x0e; 0x30; 0x0c;
0x06; 0x03; 0x55; 0x04; 0x11; 0x13; 0x05; 0x39; 0x34; 0x31; 0x30; 0x37; 0x31; 0x0b; 0x30; 0x09;
0x06; 0x03; 0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x13; 0x30; 0x11; 0x06; 0x03; 0x55;
0x04; 0x08; 0x13; 0x0a; 0x43; 0x61; 0x6c; 0x69; 0x66; 0x6f; 0x72; 0x6e; 0x69; 0x61; 0x31; 0x16;
0x30; 0x14; 0x06; 0x03; 0x55; 0x04; 0x07; 0x13; 0x0d; 0x53; 0x61; 0x6e; 0x20; 0x46; 0x72; 0x61;
0x6e; 0x63; 0x69; 0x73; 0x63; 0x6f; 0x31; 0x15; 0x30; 0x13; 0x06; 0x03; 0x55; 0x04; 0x0a; 0x13;
0x0c; 0x47; 0x69; 0x74; 0x48; 0x75; 0x62; 0x2c; 0x20; 0x49; 0x6e; 0x63; 0x2e; 0x31; 0x13; 0x30;
0x11; 0x06; 0x03; 0x55; 0x04; 0x03; 0x13; 0x0a; 0x67; 0x69; 0x74; 0x68; 0x75; 0x62; 0x2e; 0x63;
0x6f; 0x6d; 0x30; 0x82; 0x01; 0x22; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86; 0xf7; 0x0d;
0x01; 0x01; 0x01; 0x05; 0x00; 0x03; 0x82; 0x01; 0x0f; 0x00; 0x30; 0x82; 0x01; 0x0a; 0x02; 0x82;
0x01; 0x01; 0x00; 0xb1; 0xd4; 0xdc; 0x3c; 0xaf; 0xfd; 0xf3; 0x4e; 0xed; 0xc1; 0x67; 0xad; 0xe6;
0xcb; 0x22; 0xe8; 0xb7; 0xe2; 0xab; 0x28; 0xf2; 0xf7; 0xdc; 0x62;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xe9; 0x1d; 0xa1; 0x8a; 0xa7; 0x87; 0xbe; 0x66; 0x25; 0x69; 0xbf; 0xbe; 0x3b;
0x72; 0x6e; 0x4f; 0xe0; 0xe4; 0x85; 0x25; 0x08; 0xb1; 0x91; 0x89; 0xb8; 0xd6; 0x74; 0x65; 0x76;
0x9b; 0x2c; 0x4f; 0x62; 0x1f; 0xa1; 0xfa; 0x3a; 0xbe; 0x9c; 0x24; 0xbf; 0x9f; 0xca; 0xb0; 0xc5;
0xc0; 0x67; 0x8d; 0x02; 0x03; 0x01; 0x00; 0x01; 0xa3; 0x82; 0x01; 0xee; 0x30; 0x82; 0x01; 0xea;
0x30; 0x1f; 0x06; 0x03; 0x55; 0x1d; 0x23; 0x04; 0x18; 0x30; 0x16; 0x80; 0x14; 0x3d; 0xd3; 0x50;
0xa5; 0xd6; 0xa0; 0xad; 0xee; 0xf3; 0x4a; 0x60; 0x0a; 0x65; 0xd3; 0x21; 0xd4; 0xf8; 0xf8; 0xd6;
0x0f; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x0e; 0x04; 0x16; 0x04; 0x14; 0x6a; 0x43; 0x90; 0x7d;
0x3b; 0x98; 0x14; 0x72; 0x52; 0x95; 0x3a; 0xaa; 0x28; 0x0a; 0x43; 0xf8; 0x51; 0x7e; 0xd3; 0xa6;
0x30; 0x25; 0x06; 0x03; 0x55; 0x1d; 0x11; 0x04; 0x1e; 0x30; 0x1c; 0x82; 0x0a; 0x67; 0x69; 0x74;
0x68; 0x75; 0x62; 0x2e; 0x63; 0x6f; 0x6d; 0x82; 0x0e; 0x77; 0x77; 0x77; 0x2e; 0x67; 0x69; 0x74;
0x68; 0x75; 0x62; 0x2e; 0x63; 0x6f; 0x6d; 0x30; 0x0e; 0x06; 0x03; 0x55; 0x1d; 0x0f; 0x01; 0x01;
0xff; 0x04; 0x04; 0x03; 0x02; 0x05; 0xa0; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x25; 0x04; 0x16;
0x30; 0x14; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x03; 0x01; 0x06; 0x08; 0x2b; 0x06;
0x01; 0x05; 0x05; 0x07; 0x03; 0x02; 0x30; 0x75; 0x06; 0x03; 0x55; 0x1d; 0x1f; 0x04; 0x6e; 0x30;
0x6c; 0x30; 0x34; 0xa0; 0x32; 0xa0; 0x30; 0x86; 0x2e; 0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f;
0x63; 0x72; 0x6c; 0x33; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f;
0x6d; 0x2f; 0x73; 0x68; 0x61; 0x32; 0x2d; 0x65; 0x76; 0x2d; 0x73; 0x65; 0x72; 0x76; 0x65; 0x72;
0x2d; 0x67; 0x31; 0x2e; 0x63; 0x72; 0x6c; 0x30; 0x34; 0xa0; 0x32; 0xa0; 0x30; 0x86; 0x2e; 0x68;
0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x63; 0x72; 0x6c; 0x34; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63;
0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x2f; 0x73; 0x68; 0x61; 0x32; 0x2d; 0x65; 0x76; 0x2d;
0x73; 0x65; 0x72; 0x76; 0x65; 0x72; 0x2d; 0x67; 0x31; 0x2e; 0x63; 0x72; 0x6c; 0x30; 0x42; 0x06;
0x03; 0x55; 0x1d; 0x20; 0x04; 0x3b; 0x30; 0x39; 0x30; 0x37; 0x06; 0x09; 0x60; 0x86; 0x48; 0x01;
0x86; 0xfd; 0x6c; 0x02; 0x01; 0x30; 0x2a; 0x30; 0x28; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05;
0x07; 0x02; 0x01; 0x16; 0x1c; 0x68; 0x74; 0x74; 0x70; 0x73; 0x3a; 0x2f; 0x2f; 0x77; 0x77; 0x77;
0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x2f; 0x43; 0x50;
0x53; 0x30; 0x81; 0x88; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x01; 0x01; 0x04; 0x7c;
0x30; 0x7a; 0x30; 0x24; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x30; 0x01; 0x86; 0x18;
0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x6f; 0x63; 0x73; 0x70; 0x2e; 0x64; 0x69; 0x67; 0x69;
0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x30; 0x52; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05;
0x05; 0x07; 0x30; 0x02; 0x86; 0x46; 0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x63; 0x61; 0x63;
0x65; 0x72; 0x74; 0x73; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f;
0x6d; 0x2f; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x53; 0x48; 0x41; 0x32; 0x45; 0x78;
0x74; 0x65; 0x6e; 0x64; 0x65; 0x64; 0x56; 0x61; 0x6c; 0x69; 0x64; 0x61; 0x74; 0x69; 0x6f; 0x6e;
0x53; 0x65; 0x72; 0x76; 0x65; 0x72; 0x43; 0x41; 0x2e; 0x63; 0x72; 0x74; 0x30; 0x0c; 0x06; 0x03;
0x55; 0x1d; 0x13; 0x01; 0x01; 0xff; 0x04; 0x02; 0x30; 0x00; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86;
0x48; 0x86; 0xf7; 0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x03; 0x82; 0x01; 0x01; 0x00; 0x6f; 0xe7;
0x6d; 0xcb; 0x82; 0xf3; 0xef; 0x90; 0x87; 0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x0b; 0xc0; 0x48; 0x30; 0xa9; 0x82; 0x34; 0xad; 0xf7; 0x70; 0x46; 0x03; 0x7c; 0x35; 0x91; 0x3a;
0xd5; 0xbb; 0x24; 0xd8; 0x01; 0xbc; 0x14; 0xf0; 0xc3; 0x0f; 0x23; 0x3b; 0x58; 0x32; 0xba; 0x0f;
0x12; 0x6c; 0x66; 0x7a; 0x6d; 0x9d; 0xe4; 0xf0; 0xe5; 0x7c; 0x5d; 0x7e; 0x02; 0xd8; 0xd7; 0xac;
0x89; 0x97; 0x0b; 0x61; 0xb7; 0x36; 0x9f; 0xb0; 0x7d; 0x3b; 0xee; 0xb7; 0x33; 0x69;
0x00; 0x04; 0xba;
0x30; 0x82; 0x04; 0xb6; 0x30; 0x82; 0x03; 0x9e; 0xa0; 0x03; 0x02; 0x01; 0x02; 0x02; 0x10;
0x0c; 0x79; 0xa9; 0x44; 0xb0; 0x8c; 0x11; 0x95; 0x20; 0x92; 0x61; 0x5f; 0xe2; 0x6b; 0x1d; 0x83;
0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86; 0xf7; 0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x30;
0x6c; 0x31; 0x0b; 0x30; 0x09; 0x06; 0x03; 0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x15;
0x30; 0x13; 0x06; 0x03; 0x55; 0x04; 0x0a; 0x13; 0x0c; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72;
0x74; 0x20; 0x49; 0x6e; 0x63; 0x31; 0x19; 0x30; 0x17; 0x06; 0x03; 0x55; 0x04; 0x0b; 0x13; 0x10;
0x77; 0x77; 0x77; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d;
0x31; 0x2b; 0x30; 0x29; 0x06; 0x03; 0x55; 0x04; 0x03; 0x13; 0x22; 0x44; 0x69; 0x67; 0x69; 0x43;
0x65; 0x72; 0x74; 0x20; 0x48; 0x69; 0x67; 0x68; 0x20; 0x41; 0x73; 0x73; 0x75; 0x72; 0x61; 0x6e;
0x63; 0x65; 0x20; 0x45; 0x56; 0x20; 0x52; 0x6f; 0x6f; 0x74; 0x20; 0x43; 0x41; 0x30; 0x1e; 0x17;
0x0d; 0x31; 0x33; 0x31; 0x30; 0x32; 0x32; 0x31; 0x32; 0x30; 0x30; 0x30; 0x30; 0x5a; 0x17; 0x0d;
0x32; 0x38; 0x31; 0x30; 0x32; 0x32; 0x31; 0x32; 0x30; 0x30; 0x30; 0x30; 0x5a; 0x30; 0x75; 0x31;
0x0b; 0x30; 0x09; 0x06; 0x03; 0x55; 0x04; 0x06; 0x13; 0x02; 0x55; 0x53; 0x31; 0x15; 0x30; 0x13;
0x06; 0x03; 0x55; 0x04; 0x0a; 0x13; 0x0c; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x20;
0x49; 0x6e; 0x63; 0x31; 0x19; 0x30; 0x17; 0x06; 0x03; 0x55; 0x04; 0x0b; 0x13; 0x10; 0x77; 0x77;
0x77; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x31; 0x34;
0x30; 0x32; 0x06; 0x03; 0x55; 0x04; 0x03; 0x13; 0x2b; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72;
0x74; 0x20; 0x53; 0x48; 0x41; 0x32; 0x20; 0x45; 0x78; 0x74; 0x65; 0x6e; 0x64; 0x65; 0x64; 0x20;
0x56; 0x61; 0x6c; 0x69; 0x64; 0x61; 0x74; 0x69; 0x6f; 0x6e; 0x20; 0x53; 0x65; 0x72; 0x76; 0x65;
0x72; 0x20; 0x43; 0x41; 0x30; 0x82; 0x01; 0x22; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86;
0xf7; 0x0d; 0x01; 0x01; 0x01; 0x05; 0x00; 0x03; 0x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; 0x4d; 0x0c; 0x89; 0xdc; 0x39; 0x26; 0x17; 0xdd; 0xf6; 0xd7; 0x94; 0x85; 0xd8; 0x04;
0x21; 0x70; 0x9d; 0x6f; 0x6f; 0xff; 0x5c; 0xba; 0x19; 0xe1; 0x45; 0xcb; 0x56; 0x57; 0x28; 0x7e;
0x1c; 0x0d; 0x41; 0x57; 0xaa; 0xb7; 0xb8; 0x27; 0xbb; 0xb1; 0xe4; 0xfa; 0x2a; 0xef; 0x21; 0x23;
0x75; 0x1a; 0xad; 0x2d; 0x9b; 0x86; 0x35; 0x8c; 0x9c; 0x77; 0xb5; 0x73; 0xad; 0xd8; 0x94; 0x2d;
0xe4; 0xf3; 0x0c; 0x9d; 0xee; 0xc1; 0x4e; 0x62; 0x7e; 0x17; 0xc0; 0x71; 0x9e; 0x2c; 0xde; 0xf1;
0xf9; 0x10; 0x28; 0x19; 0x33; 0x02; 0x03; 0x01; 0x00; 0x01; 0xa3; 0x82; 0x01; 0x49; 0x30; 0x82;
0x01; 0x45; 0x30; 0x12; 0x06; 0x03; 0x55; 0x1d; 0x13; 0x01; 0x01; 0xff; 0x04; 0x08; 0x30; 0x06;
0x01; 0x01; 0xff; 0x02; 0x01; 0x00; 0x30; 0x0e; 0x06; 0x03; 0x55; 0x1d; 0x0f; 0x01; 0x01; 0xff;
0x04; 0x04; 0x03; 0x02; 0x01; 0x86; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x25; 0x04; 0x16; 0x30;
0x14; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x03; 0x01; 0x06; 0x08; 0x2b; 0x06; 0x01;
0x05; 0x05; 0x07; 0x03; 0x02; 0x30; 0x34; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x01;
0x01; 0x04; 0x28; 0x30; 0x26; 0x30; 0x24; 0x06; 0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x30;
0x01; 0x86; 0x18; 0x68; 0x74; 0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x6f; 0x63; 0x73; 0x70; 0x2e; 0x64;
0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x30; 0x4b; 0x06; 0x03; 0x55;
0x1d; 0x1f; 0x04; 0x44; 0x30; 0x42; 0x30; 0x40; 0xa0; 0x3e; 0xa0; 0x3c; 0x86; 0x3a; 0x68; 0x74;
0x74; 0x70; 0x3a; 0x2f; 0x2f; 0x63; 0x72; 0x6c; 0x34; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65;
0x72; 0x74; 0x2e; 0x63; 0x6f; 0x6d; 0x2f; 0x44; 0x69; 0x67; 0x69; 0x43; 0x65; 0x72; 0x74; 0x48;
0x69; 0x67; 0x68; 0x41; 0x73; 0x73; 0x75; 0x72; 0x61; 0x6e; 0x63; 0x65; 0x45; 0x56; 0x52; 0x6f;
0x6f; 0x74; 0x43; 0x41; 0x2e; 0x63; 0x72; 0x6c; 0x30; 0x3d; 0x06; 0x03; 0x55; 0x1d; 0x20; 0x04;
0x36; 0x30; 0x34; 0x30; 0x32; 0x06; 0x04; 0x55; 0x1d; 0x20; 0x00; 0x30; 0x2a; 0x30; 0x28; 0x06;
0x08; 0x2b; 0x06; 0x01; 0x05; 0x05; 0x07; 0x02; 0x01; 0x16; 0x1c; 0x68; 0x74; 0x74; 0x70; 0x73;
0x3a; 0x2f; 0x2f; 0x77; 0x77; 0x77; 0x2e; 0x64; 0x69; 0x67; 0x69; 0x63; 0x65; 0x72; 0x74; 0x2e;
0x63; 0x6f; 0x6d; 0x2f; 0x43; 0x50; 0x53; 0x30; 0x1d; 0x06; 0x03; 0x55; 0x1d; 0x0e; 0x04; 0x16;
0x04; 0x14; 0x3d; 0xd3; 0x50; 0xa5; 0xd6; 0xa0; 0xad; 0xee; 0xf3; 0x4a; 0x60; 0x0a; 0x65; 0xd3;
0x21; 0xd4; 0xf8; 0xf8; 0xd6; 0x0f; 0x30; 0x1f; 0x06; 0x03; 0x55; 0x1d; 0x23; 0x04; 0x18; 0x30;
0x16; 0x80; 0x14; 0xb1; 0x3e; 0xc3; 0x69; 0x03; 0xf8; 0xbf; 0x47; 0x01; 0xd4; 0x98; 0x26; 0x1a;
0x08; 0x02; 0xef; 0x63; 0x64; 0x2b; 0xc3; 0x30; 0x0d; 0x06; 0x09; 0x2a; 0x86; 0x48; 0x86; 0xf7;
0x0d; 0x01; 0x01; 0x0b; 0x05; 0x00; 0x03; 0x82; 0x01; 0x01; 0x00; 0x9d; 0xb6; 0xd0; 0x90; 0x86;
0xe1; 0x86; 0x02; 0xed; 0xc5; 0xa0; 0xf0; 0x34; 0x1c; 0x74; 0xc1; 0x8d; 0x76; 0xcc; 0x86; 0x0a;
0xa8; 0xf0; 0x4a; 0x8a; 0x42; 0xd6; 0x3f; 0xc8; 0xa9; 0x4d; 0xad; 0x7c; 0x08; 0xad; 0xe6; 0xb6;
0x50; 0xb8; 0xa2; 0x1a; 0x4d; 0x88; 0x07; 0xb1; 0x29; 0x21; 0xdc; 0xe7; 0xda; 0xc6; 0x3c; 0x21;
0xe0; 0xe3; 0x11; 0x49; 0x70; 0xac; 0x7a; 0x1d; 0x01; 0xa4; 0xca; 0x11; 0x3a; 0x57; 0xab; 0x7d;
0x57; 0x2a; 0x40; 0x74; 0xfd; 0xd3; 0x1d; 0x85; 0x18; 0x50; 0xdf; 0x57; 0x47; 0x75; 0xa1; 0x7d;
0x55; 0x20; 0x2e; 0x47; 0x37; 0x50; 0x72; 0x8c; 0x7f; 0x82; 0x1b; 0xd2; 0x62; 0x8f; 0x2d; 0x03;
0x5a; 0xda; 0xc3; 0xc8; 0xa1; 0xce; 0x2c; 0x52; 0xa2; 0x00; 0x63; 0xeb; 0x73; 0xba; 0x71; 0xc8;
0x49; 0x27; 0x23; 0x97; 0x64; 0x85; 0x9e; 0x38; 0x0e; 0xad; 0x63; 0x68; 0x3c; 0xba; 0x52; 0x81;
0x58; 0x79; 0xa3; 0x2c; 0x0c; 0xdf; 0xde; 0x6d; 0xeb; 0x31; 0xf2; 0xba; 0xa0; 0x7c; 0x6c; 0xf1;
0x2c; 0xd4; 0xe1; 0xbd; 0x77; 0x84; 0x37; 0x03; 0xce; 0x32; 0xb5; 0xc8; 0x9a; 0x81; 0x1a; 0x4a;
0x92; 0x4e; 0x3b; 0x46; 0x9a; 0x85; 0xfe; 0x83; 0xa2; 0xf9; 0x9e; 0x8c; 0xa3; 0xcc; 0x0d; 0x5e;
0xb3; 0x3d; 0xcf; 0x04; 0x78; 0x8f; 0x14; 0x14; 0x7b; 0x32; 0x9c; 0xc7; 0x00; 0xa6; 0x5c; 0xc4;
0xb5; 0xa1; 0x55; 0x8d; 0x5a; 0x56; 0x68; 0xa4; 0x22; 0x70; 0xaa; 0x3c; 0x81; 0x71; 0xd9; 0x9d;
0xa8; 0x45; 0x3b; 0xf4; 0xe5; 0xf6; 0xa2; 0x51; 0xdd; 0xc7; 0x7b; 0x62; 0xe8; 0x6f; 0x0c; 0x74;
0xeb; 0xb8; 0xda; 0xf8; 0xbf; 0x87; 0x0d; 0x79; 0x50; 0x91; 0x90; 0x9b; 0x18; 0x3b; 0x91; 0x59;
0x27; 0xf1; 0x35; 0x28; 0x13; 0xab; 0x26; 0x7e; 0xd5; 0xf7; 0x7a ],
Core.Certificate (Writer.assemble_certificates [gh1 ; gh2]) )
]
let cmp_handshake_cstruct hs hs' =
Core.(match hs, hs' with
| Finished xs, Finished ys -> assert_cs_eq xs ys
| ServerKeyExchange xs, ServerKeyExchange ys -> assert_cs_eq xs ys
| Certificate xs, Certificate ys -> assert_cs_eq xs ys
| ClientKeyExchange xs, ClientKeyExchange ys -> assert_cs_eq xs ys
| _ -> assert_failure "handshake cstruct data parser broken")
let good_handshake_cstruct_data_parser (xs, res) _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok r -> cmp_handshake_cstruct r res
| Error _ -> assert_failure "handshake cstruct data parser failed"
let good_handshake_cstruct_data_tests =
List.mapi
(fun i f -> "Parse good handshake " ^ string_of_int i >:: good_handshake_cstruct_data_parser f)
good_handshake_cstruct_data
let bad_handshake_cstruct_data =
let data = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11 ] in
[ [12; 0; 0; 13] @ data ;
[12; 0; 0; 11] @ data ;
[20; 0; 1; 12] @ data ;
[20; 0; 0; 11] @ data ;
[16; 0; 0; 15; 0; 12] @ data ;
[25; 0; 0; 14; 0; 12] @ data ;
[255; 0; 0; 14; 0; 12] @ data ;
[11; 0; 0; 17; 0; 0; 15; 0; 0; 12] @ data ;
]
let bad_handshake_cstruct_data_parser xs _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok _ -> assert_failure "bad handshake cstruct parser won"
| Error _ -> ()
let bad_handshake_cstruct_data_tests =
List.mapi
(fun i f -> "Parse bad handshake " ^ string_of_int i >:: bad_handshake_cstruct_data_parser f)
bad_handshake_cstruct_data
let bad_certificate_cstruct_data =
let data = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11 ] in
[ [11; 0; 0; 3; 0; 0; 2] ;
[11; 0; 0; 4; 0; 0; 0; 0] ;
[11; 0; 0; 18; 0; 0; 15; 0; 0; 11] @ data ;
[11; 0; 0; 18; 0; 0; 14; 0; 0; 11] @ data ;
[11; 0; 0; 33; 0; 0; 29; 0; 0; 12] @ data @ [0; 0; 12] @ data ;
[11; 0; 0; 33; 0; 0; 31; 0; 0; 12] @ data @ [0; 0; 12] @ data ;
[11; 0; 0; 33; 0; 0; 30; 0; 0; 11] @ data @ [0; 0; 12] @ data
]
let bad_certificate_cstruct_data_parser xs _ =
let buf = list_to_cstruct xs in
Reader.(match parse_handshake buf with
| Ok (Core.Certificate cs) ->
(match Reader.parse_certificates cs with
| Ok _ -> assert_failure "bad certificate parser won"
| Error _ -> ())
| _ -> assert_failure "should've been a certificate")
let bad_certificate_cstruct_data_tests =
List.mapi
(fun i f -> "Parse bad certificate " ^ string_of_int i >:: bad_certificate_cstruct_data_parser f)
bad_certificate_cstruct_data
let good_client_hellos =
(* I rolled the dice 16 times *)
let rnd = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15 ] in
let rand = rnd @ rnd in
let client_random = list_to_cstruct rand in
Core.(let ch : client_hello =
{ client_version = `TLS_1_2 ;
client_random ;
sessionid = None ;
ciphersuites = [] ;
extensions = []}
in
[
(* versions *)
([1; 0; 0; 38; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , ch ) ;
([1; 0; 0; 38; 3; 0] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , { ch with client_version = `SSL_3 } ) ;
([1; 0; 0; 38; 3; 1] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , { ch with client_version = `TLS_1_0 } ) ;
([1; 0; 0; 38; 3; 2] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , { ch with client_version = `TLS_1_1 } ) ;
([1; 0; 0; 38; 3; 4] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , { ch with client_version = `TLS_1_3 } ) ;
([1; 0; 0; 38; 3; 5] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , { ch with client_version = `TLS_1_X 5 } ) ;
(* well-formed compression (not available in higher layer) *)
([1; 0; 0; 39; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 1; 0; (* exts *)] , ch ) ;
([1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 2; 0; 1; (* exts *)] , ch ) ;
(* ciphersuites *)
([1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 2; 0; 0x0A; (* comp *) 0; (* exts *)] , { ch with ciphersuites = [Packet.TLS_RSA_WITH_3DES_EDE_CBC_SHA] } ) ;
([1; 0; 0; 42; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 4; 0; 0x0A; 0; 0x16; (* comp *) 0; (* exts *)] , { ch with ciphersuites = Packet.([TLS_RSA_WITH_3DES_EDE_CBC_SHA ; TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA]) } ) ;
(* ignore unknown ciphersuite *)
([1; 0; 0; 42; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 4; 0; 0x0A; 0; 0x47; (* comp *) 0; (* exts *)] , { ch with ciphersuites = [Packet.TLS_RSA_WITH_3DES_EDE_CBC_SHA] } ) ;
(* ignore unknown compression method *)
([1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 2; 0; 42; (* exts *)] , ch ) ;
(* TODO: unknown extensions should be ignored (check again with rfc) *)
(* TODO: validate client_hello:
- non-empty ciphersuites
- no duplicated ciphersuites
- those required by protocol version should be in the list!
- no duplicated extensions
- no unsupported extensions (SignatureAlgorithms in TLS < 1.2)
- empty ServerName extension is useless
*)
(* combine ciphersuite + compression *)
([1; 0; 0; 44; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 4; 0; 0x0A; 0; 0x16; (* comp *) 2; 0; 1; (* exts *)] , { ch with ciphersuites = Packet.([TLS_RSA_WITH_3DES_EDE_CBC_SHA ; TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA]) }) ;
(* session id *)
([1; 0; 0; 41; 3; 3] @ rand @ [(* session id *) 3; 1; 2; 3; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] , { ch with sessionid = Some (list_to_cstruct [1; 2; 3] ) } ) ;
(* combine ciphersuite + compression + session id *)
([1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 3; 1; 2; 3; (* cipher *) 0; 4; 0; 0x0A; 0; 0x16; (* comp *) 2; 0; 1; (* exts *)] , { ch with ciphersuites = Packet.([TLS_RSA_WITH_3DES_EDE_CBC_SHA ; TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA]) ; sessionid = Some (list_to_cstruct [1; 2; 3]) }) ;
(* extensions *)
(* empty *)
([1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 0] , ch ) ;
(* some hostname *)
([1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0; 0; 8; 0; 6; 0; 0; 3; 102; 111; 111] , { ch with extensions = [make_hostname_ext "foo"] } ) ;
(* some other hostname *)
([1; 0; 0; 59; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 19; 0; 0; 0; 15; 0; 13; 0; 0; 10; 102; 111; 111; 98; 97; 114; 46; 99; 111; 109] , { ch with extensions = [make_hostname_ext "foobar.com"] } ) ;
(* max fragment length *)
([1; 0; 0; 45; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 5; 0; 1; 0; 1; 3] , { ch with extensions = [`MaxFragmentLength Packet.TWO_11] } ) ;
(* empty SupportedGroups *)
([1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 6; 0; 0xA; 0; 2; 0; 0] , { ch with extensions = [`SupportedGroups []] } ) ;
(* one supported group *)
([1; 0; 0; 48; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 8; 0; 0xA; 0; 4; 0; 2; 0; 25] , { ch with extensions = [`SupportedGroups [Packet.SECP521R1]] } ) ;
(* two supported groups *)
([1; 0; 0; 50; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 10; 0; 0xA; 0; 6; 0; 4; 0; 25; 0; 24] , { ch with extensions = [`SupportedGroups Packet.([SECP521R1; SECP384R1])] } ) ;
(* three supported groups, one unknown *)
([1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0xA; 0; 8; 0; 6; 0; 25; 0xFF; 0xFF; 0; 24] , { ch with extensions = [`SupportedGroups Packet.([SECP521R1; SECP384R1])] } ) ;
(* secure renegotiation *)
([1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0xFF; 1; 0; 3; 2; 1; 2] , { ch with extensions = [`SecureRenegotiation (list_to_cstruct [1;2])] } ) ;
(* Padding *)
([1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 21; 0; 3; 0; 0; 0] , { ch with extensions = [`Padding 3] } ) ;
(* signature algorithm *)
([1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 6; 0; 13; 0; 2; 0; 0] , { ch with extensions = [`SignatureAlgorithms []] } ) ;
([1; 0; 0; 48; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 8; 0; 13; 0; 4; 0; 2; 1; 1] , { ch with extensions = [`SignatureAlgorithms [`RSA_PKCS1_MD5]] } ) ;
([1; 0; 0; 50; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 10; 0; 13; 0; 6; 0; 4; 2; 1; 1; 1] , { ch with extensions = [`SignatureAlgorithms [`RSA_PKCS1_SHA1; `RSA_PKCS1_MD5]] }) ;
(* unknown one *)
([1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 13; 0; 8; 0; 6; 42; 42; 2; 1; 1; 1] , { ch with extensions = [`SignatureAlgorithms [`RSA_PKCS1_SHA1; `RSA_PKCS1_MD5]] } ) ;
(* ALPN *)
([1; 0; 0; 58; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 18; 0; 16; 0; 14; 0; 12; (* h2 *) 2; 104; 50; (* http/1.1*) 8; 104; 116; 116; 112; 47; 49; 46; 49] , { ch with extensions = [`ALPN ["h2"; "http/1.1"]] } ) ;
(* combinations from the real world *)
([0x01; (* hello *)
0x00; 0x00; 0xaf; (* length *)
0x03; 0x01; (* version *)
0x7c; 0x53; 0x05; 0x72; 0x7a; 0x1b; 0x84; 0x70; 0x30; 0x89; 0xef; 0xad; 0xfb; 0x56; 0xc1; 0x3d; 0x73; 0x4b; 0xc7; 0xcb; 0x8c; 0xc8; 0x75; 0x43; 0x01; 0x12; 0x32; 0xd6; 0x74; 0x87; 0xcb; 0x18; (* random *)
0x00; (* session id *)
0x00; 0x68; (* ciphersuites *)
0xc0; 0x14; 0xc0; 0x0a; 0xc0; 0x22; 0xc0; 0x21; 0x00; 0x39; 0x00; 0x38; 0x00; 0x88; 0x00; 0x87; 0xc0; 0x0f; 0xc0; 0x05; 0x00; 0x35; 0x00; 0x84; 0xc0; 0x12; 0xc0; 0x08; 0xc0; 0x1c; 0xc0; 0x1b; 0x00; 0x16; 0x00; 0x13; 0xc0; 0x0d; 0xc0; 0x03; 0x00; 0x0a; 0xc0; 0x13; 0xc0; 0x09; 0xc0; 0x1f; 0xc0; 0x1e; 0x00; 0x33; 0x00; 0x32; 0x00; 0x9a; 0x00; 0x99; 0x00; 0x45; 0x00; 0x44; 0xc0; 0x0e; 0xc0; 0x04; 0x00; 0x2f; 0x00; 0x96; 0x00; 0x41; 0x00; 0x07; 0xc0; 0x11; 0xc0; 0x07; 0xc0; 0x0c; 0xc0; 0x02; 0x00; 0x05; 0x00; 0x04; 0x00; 0x15; 0x00; 0x12; 0x00; 0x09; 0x00; 0x14; 0x00; 0x11; 0x00; 0x08; 0x00; 0x06; 0x00; 0x03; 0x00; 0xff;
0x01; 0x00; (* compression *)
0x00; 0x1e; (* extensions *)
0x00; 0x0a; 0x00; 0x08; (* elliptic curves *)
0x00; 0x06; 0x00; 0x19; 0x00; 0x18; 0x00; 0x17;
0x00; 0x10; 0x00; 0x0e; 0x00; 0x0c; (* ALPN *)
0x02; 0x68; 0x32;
0x08; 0x68; 0x74; 0x74; 0x70; 0x2f; 0x31; 0x2e; 0x31 ]
(* 0x00; 0x23; 0x00; 0x00; (* sessionticket_tls *)
0x00; 0x0f; 0x00; 0x01; 0x01 (* heartbeat *) *) ,
{ ch with
client_version = `TLS_1_0 ;
client_random = list_to_cstruct [0x7c; 0x53; 0x05; 0x72; 0x7a; 0x1b; 0x84; 0x70; 0x30; 0x89; 0xef; 0xad; 0xfb; 0x56; 0xc1; 0x3d; 0x73; 0x4b; 0xc7; 0xcb; 0x8c; 0xc8; 0x75; 0x43; 0x01; 0x12; 0x32; 0xd6; 0x74; 0x87; 0xcb; 0x18] ;
ciphersuites = Packet.([TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA; TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA; TLS_DHE_RSA_WITH_AES_256_CBC_SHA; TLS_RSA_WITH_AES_256_CBC_SHA; TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA; TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA; TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA; TLS_RSA_WITH_3DES_EDE_CBC_SHA; TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA; TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA; TLS_DHE_RSA_WITH_AES_128_CBC_SHA; TLS_RSA_WITH_AES_128_CBC_SHA; TLS_EMPTY_RENEGOTIATION_INFO_SCSV]);
extensions = [`SupportedGroups Packet.([SECP521R1; SECP384R1; SECP256R1]);
`ALPN ["h2"; "http/1.1"] ] } ) ;
(
[ 0x01; (* client hello *)
0x00; 0x01; 0xc6; (* length *)
0x03; 0x03; (* protocol version *)
0xb7; 0x36; 0xeb; 0x21; 0xec; 0x81; 0x4d; 0x01; 0xfc; 0xf4; 0xe2; 0x06; 0x9a; 0x34; 0xb7; 0x21; 0xe1; 0x23; 0x6f; 0xbe; 0x50; 0xbf; 0xfe; 0x33; 0x9b; 0xc9; 0x5b; 0x20; 0x0e; 0x15; 0x02; 0x27; (* random *)
0x00; (* session id *)
0x00; 0xa0; (* ciphersuites *)
0xc0; 0x30; 0xc0; 0x2c; 0xc0; 0x28; 0xc0; 0x24; 0xc0; 0x14; 0xc0; 0x0a; 0xc0; 0x22; 0xc0; 0x21; 0x00; 0xa3; 0x00; 0x9f; 0x00; 0x6b; 0x00; 0x6a; 0x00; 0x39; 0x00; 0x38; 0x00; 0x88; 0x00; 0x87; 0xc0; 0x32; 0xc0; 0x2e; 0xc0; 0x2a; 0xc0; 0x26; 0xc0; 0x0f; 0xc0; 0x05; 0x00; 0x9d; 0x00; 0x3d; 0x00; 0x35; 0x00; 0x84; 0xc0; 0x12; 0xc0; 0x08; 0xc0; 0x1c; 0xc0; 0x1b; 0x00; 0x16; 0x00; 0x13; 0xc0; 0x0d; 0xc0; 0x03; 0x00; 0x0a; 0xc0; 0x2f; 0xc0; 0x2b; 0xc0; 0x27; 0xc0; 0x23; 0xc0; 0x13; 0xc0; 0x09; 0xc0; 0x1f; 0xc0; 0x1e; 0x00; 0xa2; 0x00; 0x9e; 0x00; 0x67; 0x00; 0x40; 0x00; 0x33; 0x00; 0x32; 0x00; 0x9a; 0x00; 0x99; 0x00; 0x45; 0x00; 0x44; 0xc0; 0x31; 0xc0; 0x2d; 0xc0; 0x29; 0xc0; 0x25; 0xc0; 0x0e; 0xc0; 0x04; 0x00; 0x9c; 0x00; 0x3c; 0x00; 0x2f; 0x00; 0x96; 0x00; 0x41; 0x00; 0x07; 0xc0; 0x11; 0xc0; 0x07; 0xc0; 0x0c; 0xc0; 0x02; 0x00; 0x05; 0x00; 0x04; 0x00; 0x15; 0x00; 0x12; 0x00; 0x09; 0x00; 0x14; 0x00; 0x11; 0x00; 0x08; 0x00; 0x06; 0x00; 0x03; 0x00; 0xff;
0x01; 0x00; (* compression *)
0x00; 0xFD; (* extensions *)
0x00; 0x0a; 0x00; 0x08; (* ec curves *)
0x00; 0x06; 0x00; 0x19; 0x00; 0x18; 0x00; 0x17;
(* 0x00; 0x23; 0x00; 0x00; *)
0x00; 0x0d; 0x00; 0x0c; (* signature algorithms *)
0x00; 0x0a; 0x06; 0x01; 0x05; 0x01; 0x04; 0x01; 0x03; 0x01; 0x02; 0x01;
0x00; 0x15; 0x00; 0xcb; (* padding *)
0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00; 0x00;
0x00; 0x10; 0x00; 0x0e; 0x00; 0x0c; (* ALPN *)
0x02; 0x68; 0x32;
0x08; 0x68; 0x74; 0x74; 0x70; 0x2f; 0x31; 0x2e; 0x31 ],
{ ch with
client_version = `TLS_1_2 ;
client_random = list_to_cstruct [0xb7; 0x36; 0xeb; 0x21; 0xec; 0x81; 0x4d; 0x01; 0xfc; 0xf4; 0xe2; 0x06; 0x9a; 0x34; 0xb7; 0x21; 0xe1; 0x23; 0x6f; 0xbe; 0x50; 0xbf; 0xfe; 0x33; 0x9b; 0xc9; 0x5b; 0x20; 0x0e; 0x15; 0x02; 0x27] ;
ciphersuites = Packet.([TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384; TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384; TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384; TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384; TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA; TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA; TLS_DHE_RSA_WITH_AES_256_GCM_SHA384; TLS_DHE_RSA_WITH_AES_256_CBC_SHA256; TLS_DHE_RSA_WITH_AES_256_CBC_SHA; TLS_RSA_WITH_AES_256_GCM_SHA384; TLS_RSA_WITH_AES_256_CBC_SHA256; TLS_RSA_WITH_AES_256_CBC_SHA; TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA; TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA; TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA; TLS_RSA_WITH_3DES_EDE_CBC_SHA; TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256; TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256; TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256; TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256; TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA; TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA; TLS_DHE_RSA_WITH_AES_128_GCM_SHA256; TLS_DHE_RSA_WITH_AES_128_CBC_SHA256; TLS_DHE_RSA_WITH_AES_128_CBC_SHA; TLS_RSA_WITH_AES_128_GCM_SHA256; TLS_RSA_WITH_AES_128_CBC_SHA256; TLS_RSA_WITH_AES_128_CBC_SHA; TLS_EMPTY_RENEGOTIATION_INFO_SCSV]) ;
extensions = [`SupportedGroups Packet.([SECP521R1; SECP384R1; SECP256R1]);
`SignatureAlgorithms
[`RSA_PKCS1_SHA512 ;
`RSA_PKCS1_SHA384 ;
`RSA_PKCS1_SHA256 ;
`RSA_PKCS1_SHA224 ;
`RSA_PKCS1_SHA1 ] ;
`Padding 203 ;
`ALPN ["h2"; "http/1.1"] ] } );
( [ 0x01; (* client hello *)
0x00; 0x00; 0x74; (* length *)
0x03; 0x04; (* version *)
0xf1; 0xb2; 0x50; 0x16; 0x4b; 0x77; 0x50; 0xb3; 0xdc; 0xcb; 0x1c; 0x6a; 0xae; 0x1a; 0x94; 0x87;
0xc4; 0x17; 0xbb; 0xa4; 0xf7; 0x92; 0xf8; 0x16; 0x56; 0x12; 0x03; 0x38; 0x1e; 0xe5; 0xc1; 0xae; (* client random *)
0x00; (* session id *)
0x00; 0x10; 0x00; 0x35; 0x00; 0x39; 0x00; 0x2f; 0x00; 0x33; 0x00; 0x16; 0x00; 0x0a; 0x00; 0x05; 0x00; 0x04; (* ciphersuites *)
0x01; 0x00; (* compression *)
0x00; 0x3b; (* extensions *)
0xff; 0x01; 0x00; 0x01; 0x00; (* secure reneg *)
0x00; 0x00; 0x00; 0x10; 0x00; 0x0e; 0x00; 0x00; 0x0b; 0x65; 0x78; 0x61; 0x6d; 0x70; 0x6c; 0x65; 0x2e; 0x63; 0x6f; 0x6d; (* SNI example.com *)
0x00; 0x0d; 0x00; 0x0c; 0x00; 0x0a; 0x06; 0x01; 0x05; 0x01; 0x04; 0x01; 0x02; 0x01; 0x01; 0x01; (* SignatureAlgorithms *)
0x00; 0x10; 0x00; 0x0e; 0x00; 0x0c; (* ALPN *)
0x02; 0x68; 0x32;
0x08; 0x68; 0x74; 0x74; 0x70; 0x2f; 0x31; 0x2e; 0x31
],
{ ch with client_version = `TLS_1_3 ;
client_random = list_to_cstruct [ 0xf1; 0xb2; 0x50; 0x16; 0x4b; 0x77; 0x50; 0xb3; 0xdc; 0xcb; 0x1c; 0x6a; 0xae; 0x1a; 0x94; 0x87; 0xc4; 0x17; 0xbb; 0xa4; 0xf7; 0x92; 0xf8; 0x16; 0x56; 0x12; 0x03; 0x38; 0x1e; 0xe5; 0xc1; 0xae ] ;
ciphersuites = Packet.([TLS_RSA_WITH_AES_256_CBC_SHA ; TLS_DHE_RSA_WITH_AES_256_CBC_SHA ; TLS_RSA_WITH_AES_128_CBC_SHA ; TLS_DHE_RSA_WITH_AES_128_CBC_SHA ; TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA ; TLS_RSA_WITH_3DES_EDE_CBC_SHA]) ;
extensions = [ `SecureRenegotiation "" ;
make_hostname_ext "example.com" ;
`SignatureAlgorithms
[`RSA_PKCS1_SHA512 ;
`RSA_PKCS1_SHA384 ;
`RSA_PKCS1_SHA256 ;
`RSA_PKCS1_SHA1 ;
`RSA_PKCS1_MD5] ;
`ALPN ["h2"; "http/1.1"] ]
}
)
])
let cmp_client_hellos ch ch' =
let open Core in
assert_equal ch.client_version ch'.client_version ;
assert_cs_eq ch.client_random ch'.client_random ;
assert_sessionid_equal ch.sessionid ch'.sessionid ;
assert_lists_eq assert_equal ch.ciphersuites ch'.ciphersuites ;
assert_lists_eq assert_client_extension_equal ch.extensions ch'.extensions
let good_client_hellos_parser (xs, res) _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok (Core.ClientHello ch) -> cmp_client_hellos ch res
| _ -> assert_failure "handshake client hello parser failed"
let good_client_hellos_tests =
List.mapi
(fun i f -> "Parse good client hello " ^ string_of_int i >:: good_client_hellos_parser f)
good_client_hellos
let bad_client_hellos =
(* I rolled the dice 16 times *)
let rnd = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15 ] in
let rand = rnd @ rnd in
[
(* versions *)
[1; 0; 0; 38; 4; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
(* invalid length *)
[1; 0; 0; 39; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
(* should be broken as well due to missing compression_algos *)
[1; 0; 0; 38; 3; 3] @ rand @ [(* session id *) 1; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
(* ciphersuites *)
[1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 1; 0; 0; (* comp *) 0; (* exts *)] ;
[1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 3; 0; 0; (* comp *) 0; (* exts *)] ;
[1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 1; 3; 0; 0; (* comp *) 0; (* exts *)] ;
(* extensions *)
(* empty *)
[1; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 1] ;
(* some hostname *)
[1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0; 0; 8; 0; 6; 0; 0; 4; 102; 111; 111] ;
[1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0; 0; 8; 0; 6; 0; 0; 4; 102; 111; 111; 111] ;
[1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0; 0; 8; 0; 7; 0; 0; 4; 102; 111; 111; 111] ;
[1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0; 0; 9; 0; 7; 0; 0; 4; 102; 111; 111; 111] ;
[1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 13; 0; 0; 0; 9; 0; 7; 0; 0; 4; 102; 111; 111; 111] ;
[1; 0; 0; 52; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 12; 0; 0; 0; 8; 0; 5; 0; 0; 2; 102; 111; 111] ;
(* multiple hostnames - legal in RFC, not accepted by any implementation *)
[1; 0; 0; 58; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 18; 0; 0; 0; 14; 0; 12; 0; 0; 3; 102; 111; 111; 0; 0; 3; 98; 97; 114] ;
(* empty SupportedGroups *)
[1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 6; 0; 0xA; 0; 1; 0; 0] ;
[1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 5; 0; 0xA; 0; 2; 0; 0] ;
[1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 6; 0; 0xA; 0; 2; 0; 1] ;
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 0xA; 0; 3; 0; 1; 0] ;
[1; 0; 0; 50; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 10; 0; 0xA; 0; 6; 0; 2; 0; 25; 0; 20] ;
(* secure renegotiation *)
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0xFF; 1; 0; 5; 2; 1; 2] ;
[1; 0; 0; 49; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0xFF; 1; 0; 5; 2; 1; 2; 3; 4] ;
[1; 0; 0; 49; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 9; 0xFF; 1; 0; 3; 2; 1; 2; 3; 4] ;
[1; 0; 0; 49; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 9; 0xFF; 1; 0; 5; 10; 1; 2; 3; 4] ;
[1; 0; 0; 49; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 9; 0xFF; 1; 0; 5; 2; 1; 2; 3; 4] ;
(* max fragment length *)
[1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 6; 0; 1; 0; 2; 3; 4] ;
[1; 0; 0; 44; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 4; 0; 1; 0; 0] ;
[1; 0; 0; 45; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 5; 0; 1; 0; 1; 42] ;
(* Padding *)
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 21; 0; 3; 1; 2; 3] ;
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 21; 0; 5; 0; 0; 0] ;
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 9; 0; 21; 0; 5; 0; 0; 0] ;
[1; 0; 0; 49; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 9; 0; 21; 0; 5; 0; 0; 0] ;
[1; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 21; 0; 3; 0; 0; 0] ;
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 21; 0; 2; 0; 0; 0] ;
(* sig hash *)
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 13; 0; 3; 0; 1; 0] ;
[1; 0; 0; 47; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 7; 0; 13; 0; 3; 0; 0; 0] ;
]
let bad_client_hello_parser xs _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok _ -> assert_failure "bad client hello parser won"
| Error _ -> ()
let bad_client_hello_tests =
List.mapi
(fun i f -> "Parse bad client hello " ^ string_of_int i >:: bad_client_hello_parser f)
bad_client_hellos
let good_server_hellos =
(* I rolled the dice 16 times *)
let rnd = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15 ] in
let rand = rnd @ rnd in
let server_random = list_to_cstruct rand in
Core.(let sh : server_hello =
{ server_version = `TLS_1_2 ;
server_random ;
sessionid = None ;
ciphersuite = `RSA_WITH_AES_128_CCM ;
extensions = []}
in
[
(* versions *)
([2; 0; 0; 38; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *)] , sh ) ;
([2; 0; 0; 38; 3; 1] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *)] , { sh with server_version = `TLS_1_0 } ) ;
([2; 0; 0; 38; 3; 2] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *)] , { sh with server_version = `TLS_1_1 } ) ;
(* session id *)
([2; 0; 0; 41; 3; 3] @ rand @ [(* session id *) 3; 1; 2; 3; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *)] , { sh with sessionid = Some (list_to_cstruct [1; 2; 3]) } ) ;
(* ciphersuite *)
([2; 0; 0; 38; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9d; (* comp *) 0; (* exts *)] , { sh with ciphersuite = `RSA_WITH_AES_256_CCM } ) ;
(* extensions *)
(* empty *)
([2; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *) 0; 0] , sh ) ;
(* empty hostname *)
([2; 0; 0; 44; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *) 0; 4; 0; 0; 0; 0] , { sh with extensions = [`Hostname] } ) ;
(* ALPN *)
([2; 0; 0; 49; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0xc0; 0x9c; (* comp *) 0; (* exts *) 0; 9; 0; 16; 0; 5; 0; 3; 2; 104; 50] , { sh with extensions = [`ALPN "h2"] } ) ;
(* TODO: chosen ciphersuite must not be renegotiation (0x00ff) *)
(* TODO: validation of extensions
- ServerName, if present, should be None
- Padding is not allowed
- EC stuff must be present if EC ciphersuite chosen
- protocol version dependencies (SignatureAlgorithm)
- no duplicates!
- only those which are in a client hello are allowed
- is there an ordering?
*)
( [
0x02; (* typ *)
0x00; 0x00; 0x5A; (* len *)
0x03; 0x03; (* version *)
0x53; 0x66; 0x2d; 0xf0; 0x1b; 0x61; 0x55; 0x8f; 0x74; 0x2a; 0xbf; 0xf4; 0x99; 0x86; 0x30; 0x99; 0x32; 0xe4; 0xd0; 0x1e; 0x2b; 0xa9; 0x2e; 0x86; 0x7b; 0xeb; 0x03; 0x00; 0xf9; 0x11; 0x3e; 0xc5; (* random *)
0x20; (* session ID *)
0xd1; 0x54; 0xd9; 0x05; 0x61; 0x41; 0x53; 0x33; 0xb2; 0xf0; 0x13; 0x78; 0x1a; 0x17; 0xb3; 0x1d; 0x09; 0xf6; 0x59; 0x70; 0xfe; 0x5d; 0x58; 0x22; 0xfa; 0x8c; 0x5c; 0x89; 0xe9; 0xa2; 0xb4; 0x70;
0x00; 0x2f; (* cipher *)
0x00; (* compression *)
0x00; 0x12; (* extensions *)
0x00; 0x00; 0x00; 0x00; (* servername *)
0xff; 0x01; 0x00; 0x01; 0x00; (* secure renegotiation *)
0x00; 0x10; 0x00; 0x05; 0x00; 0x03; (* ALPN *)
0x02; 0x68; 0x32
], { sh with
ciphersuite = `RSA_WITH_AES_128_CBC_SHA ;
server_random = list_to_cstruct [ 0x53; 0x66; 0x2d; 0xf0; 0x1b; 0x61; 0x55; 0x8f; 0x74; 0x2a; 0xbf; 0xf4; 0x99; 0x86; 0x30; 0x99; 0x32; 0xe4; 0xd0; 0x1e; 0x2b; 0xa9; 0x2e; 0x86; 0x7b; 0xeb; 0x03; 0x00; 0xf9; 0x11; 0x3e; 0xc5 ] ;
sessionid = Some (list_to_cstruct [ 0xd1; 0x54; 0xd9; 0x05; 0x61; 0x41; 0x53; 0x33; 0xb2; 0xf0; 0x13; 0x78; 0x1a; 0x17; 0xb3; 0x1d; 0x09; 0xf6; 0x59; 0x70; 0xfe; 0x5d; 0x58; 0x22; 0xfa; 0x8c; 0x5c; 0x89; 0xe9; 0xa2; 0xb4; 0x70 ]) ;
extensions = [`Hostname;
`SecureRenegotiation "";
`ALPN "h2"] }) ;
( [
0x02;
0x00; 0x00; 0x51;
0x03; 0x03;
0x53; 0x66; 0x2f; 0xb7; 0x35; 0x3a; 0x42; 0xee; 0x1c; 0xe6; 0xed; 0x63; 0x8a; 0x1d; 0x3d; 0xb3; 0x71; 0x9c; 0xf5; 0x64; 0x45; 0xc5; 0xe9; 0xf4; 0x11; 0x8b; 0x9f; 0x41; 0x5a; 0x5f; 0xf1; 0xf6;
0x20;
0xdf; 0xe1; 0x09; 0x8a; 0x42; 0xf0; 0x25; 0xc7; 0xbd; 0xe5; 0xe9; 0x02; 0x6a; 0x03; 0xaf; 0xb4; 0x70; 0x80; 0xe9; 0x2f; 0x07; 0x3f; 0x53; 0xd3; 0xc8; 0x97; 0x3f; 0xc4; 0x44; 0x23; 0xf5; 0x94;
0x00; 0x2f;
0x00;
0x00; 0x09;
0x00; 0x00; 0x00; 0x00;
0xff; 0x01; 0x00; 0x01; 0x00 ],
{ sh with
ciphersuite = `RSA_WITH_AES_128_CBC_SHA ;
server_random = list_to_cstruct [ 0x53; 0x66; 0x2f; 0xb7; 0x35; 0x3a; 0x42; 0xee; 0x1c; 0xe6; 0xed; 0x63; 0x8a; 0x1d; 0x3d; 0xb3; 0x71; 0x9c; 0xf5; 0x64; 0x45; 0xc5; 0xe9; 0xf4; 0x11; 0x8b; 0x9f; 0x41; 0x5a; 0x5f; 0xf1; 0xf6 ] ;
sessionid = Some (list_to_cstruct [ 0xdf; 0xe1; 0x09; 0x8a; 0x42; 0xf0; 0x25; 0xc7; 0xbd; 0xe5; 0xe9; 0x02; 0x6a; 0x03; 0xaf; 0xb4; 0x70; 0x80; 0xe9; 0x2f; 0x07; 0x3f; 0x53; 0xd3; 0xc8; 0x97; 0x3f; 0xc4; 0x44; 0x23; 0xf5; 0x94 ] ) ;
extensions = [`Hostname;
`SecureRenegotiation ""] }) ;
])
let cmp_server_hellos sh sh' =
let open Core in
assert_equal sh.server_version sh'.server_version ;
assert_cs_eq sh.server_random sh'.server_random ;
assert_sessionid_equal sh.sessionid sh'.sessionid ;
assert_equal sh.ciphersuite sh'.ciphersuite ;
assert_lists_eq assert_server_extension_equal sh.extensions sh'.extensions
let good_server_hellos_parser (xs, res) _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok (Core.ServerHello sh) -> cmp_server_hellos sh res
| _ -> assert_failure "handshake server hello parser failed"
let good_server_hellos_tests =
List.mapi
(fun i f -> "Parse good server hello " ^ string_of_int i >:: good_server_hellos_parser f)
good_server_hellos
let bad_server_hellos =
(* I rolled the dice 16 times *)
let rnd = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15 ] in
let rand = rnd @ rnd in
[
[2; 0; 0; 38; 3; 0] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
[2; 0; 0; 38; 3; 4] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
[2; 0; 0; 30; 4; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
[2; 0; 0; 38; 4; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
[2; 0; 0; 44; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
[2; 0; 0; 38; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0xFF; 0xFF; (* comp *) 0; (* exts *)] ;
[2; 0; 0; 38; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 42; (* exts *)] ;
(* session id *)
[2; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 3; 1; 2; (* cipher *) 0; 0; (* comp *) 0; (* exts *)] ;
(* extensions *)
(* empty *)
[2; 0; 0; 40; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 1] ;
[2; 0; 0; 41; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 1] ;
[2; 0; 0; 41; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 1; 0] ;
(* ALPN ext with a list of protocols *)
[2; 0; 0; 46; 3; 3] @ rand @ [(* session id *) 0; (* cipher *) 0; 0; (* comp *) 0; (* exts *) 0; 18; 0; 16; 0; 8; 0; 6; 3; 0x41; 0x41; 3; 0x42; 0x42] ;
]
let bad_server_hellos_parser xs _ =
let buf = list_to_cstruct xs in
match Reader.parse_handshake buf with
| Ok _ -> assert_failure "handshake server hello parser succeeded"
| Error _ -> ()
let bad_server_hellos_tests =
List.mapi
(fun i f -> "Parse bad server hello " ^ string_of_int i >:: bad_server_hellos_parser f)
bad_server_hellos
let reader_tests =
any_version_tests @ version_tests @
good_records_tests @
good_alert_tests @ bad_alerts_tests @
good_dh_params_tests @ bad_dh_params_tests @
good_digitally_signed_1_2_tests @ bad_digitally_signed_1_2_tests @
good_digitally_signed_tests @ bad_digitally_signed_tests @
good_handshake_hdr_tests @
good_handshake_no_data_tests @ bad_handshake_no_data_tests @
good_handshake_cstruct_data_tests @ bad_handshake_cstruct_data_tests @ bad_certificate_cstruct_data_tests @
good_client_hellos_tests @ bad_client_hello_tests @
good_server_hellos_tests @ bad_server_hellos_tests