Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file protocol.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136openUtillethandle_sss=State.mix_dh_keys~remote:Static~local:Staticlethandle_ees=State.mix_dh_keys~remote:Ephemeral~local:Ephemeralletwrite_handler_payloadpayloads0=State.encrypt_and_hashs0payloadletwrite_handlersteps0=letopenPatterninletreturnr=let%mapx=rin(x,Cstruct.empty)inmatchstepwith|E->(matchState.e_pubs0with|None->Error"No ephemeral public key"|Someepub->lets1=State.mix_hash_and_psks0epubinOk(s1,Public_key.bytesepub))|ES->letlocal,remote=letopenStateinifis_initiators0then(Ephemeral,Static)else(Static,Ephemeral)inreturn@@State.mix_dh_keys0~local~remote|SE->letlocal,remote=letopenStateinifis_initiators0then(Static,Ephemeral)else(Ephemeral,Static)inreturn@@State.mix_dh_keys0~local~remote|S->(matchState.s_pubs0with|None->Error"No static public key"|Somes_pub->letplaintext=Public_key.bytess_pubinState.encrypt_and_hashs0plaintext)|SS->return@@handle_sss0|EE->return@@handle_ees0|PSK->return@@State.mix_key_and_hash_psks0letcompose_write_handlerspayloadstatesteps=letrecgomsgss=function|[]->Ok(s,Cstruct.concat(List.revmsgs))|hdl::hdls->let%bindnew_s,new_msg=hdlsingo(new_msg::msgs)new_shdlsinlethandlers=List.mapwrite_handlerstepsinlethandlers=handlers@[write_handler_payloadpayload]ingo[]statehandlersletapply_transport~is_lasts=ifis_lastthenState.setup_transportselsesletwrite_messages0payload=lets1,state=State.nexts0inmatchstatewith|Handshake_step(steps,is_last)->let%maps2,ciphertext=compose_write_handlerspayloads1stepsinlets3=apply_transport~is_lasts2in(s3,ciphertext)|Transport->State.send_transports1payloadletread_handler_payloadsmsg=State.decrypt_and_hashsmsgletread_handlersteps0msg0=letopenPatterninmatchstepwith|E->letre,msg1=State.split_dh~clear:trues0msg0inlet%maps1=State.set_res0reinlets2=State.mix_hash_and_psks1rein(s2,msg1)|ES->letlocal,remote=letopenStateinifis_initiators0then(Ephemeral,Static)else(Static,Ephemeral)inlet%maps1=State.mix_dh_keys0~remote~localin(s1,msg0)|SE->letlocal,remote=letopenStateinifis_initiators0then(Static,Ephemeral)else(Ephemeral,Static)inlet%maps1=State.mix_dh_keys0~remote~localin(s1,msg0)|S->lettemp,msg1=State.split_dhs0msg0inlet%binds1,plaintext=State.decrypt_and_hashs0(Public_key.bytestemp)inlet%maps2=State.set_rss1(Public_key.of_bytesplaintext)in(s2,msg1)|SS->let%maps1=handle_sss0in(s1,msg0)|EE->let%maps1=handle_ees0in(s1,msg0)|PSK->let%maps1=State.mix_key_and_hash_psks0in(s1,msg0)letreccompose_read_handlerssstepsmsg=matchstepswith|step::steps->lethdl=read_handlerstepinlet%bindnext_s,next_msg=hdlsmsgincompose_read_handlersnext_sstepsnext_msg|[]->read_handler_payloadsmsgletread_messages0msg=lets1,state=State.nexts0inmatchstatewith|Handshake_step(steps,is_last)->let%maps2,plaintext=compose_read_handlerss1stepsmsginlets3=apply_transport~is_lasts2in(s3,plaintext)|Transport->State.receive_transports1msgletinitializes~prologue~public_keys=List.fold_leftState.mix_hashs(prologue::List.mapPublic_key.bytespublic_keys)