anchor.diff:     | ClientKeyExchangeDHE    of SessionInfo * (* DHE.sk * *) log 
      | CertificateVerify       of SessionInfo * masterSecret * log 
      | ClientCCS               of SessionInfo * masterSecret * log
  -   | ClientFinished          of SessionInfo * masterSecret * epoch * StatefulAEAD.writer * log 
  +   | ClientFinished          of SessionInfo * masterSecret * epoch * StatefulAEAD.writer
      (* by convention, the parameters are named si, cv, cr', sr', ms, log *)
  -   | ServerWritingCCS        of SessionInfo * epoch * StatefulAEAD.writer * bytes (* outgoing after CCS; this and next state shared only for full HS *)
  -   | ServerWritingFinished
  -   | ServerWritingCCSResume  of SessionInfo * masterSecret * crand * srand * bytes (* ougoing after CCS *) * log
  -   | ClientCCSResume         of SessionInfo * masterSecret * crand * srand * epoch * StatefulAEAD.reader * log (* St-AEAD.reader is redundant, but kept here for efficiency *)
  -   | ClientFinishedResume    of SessionInfo * masterSecret * log 
  +   | ServerWritingCCS        of SessionInfo * masterSecret * epoch * StatefulAEAD.writer
  +   | ServerWritingFinished   of SessionInfo * masterSecret
  +   | ServerWritingCCSResume  of ConnectionInfo * StatefulAEAD.writer * StatefulAEAD.reader
  +   | ClientCCSResume         of epoch * StatefulAEAD.reader
  +   | ClientFinishedResume
      | ServerIdle
      (* the ProtocolVersion is the highest TLS version proposed by the client *)
   
  
positive.code:         match hstype with
          | HT_client_hello ->
              match sState with
              | x when x = ClientHello || x = SIdle ->
                  match parseClientHello payload with
                  | Error(x,y) -> InError(HSError(AD_decode_error),HSSendAlert,state)
                  | Correct (cHello) ->
                  let state = {state with ki_crand = cHello.ch_random} in
                  (* Log the received message *)
                  let new_log = state.hs_msg_log @| to_log in
                  let state = {state with hs_msg_log = new_log} in
                  (* handle extensions: for now only renegotiation_info *)
                  let extRes =
                      if state.poptions.safe_renegotiation then
  
negative.code:                 | _ -> OutSome(rg,f,state)
              | PSServer(sstate) ->
                  match sstate with
                  | ServerWritingFinished(si,ms) ->
                      let sDB =
                          if equalBytes si.sessionID [||] then
                              state.sDB
                          else
                              SessionDB.insert state.sDB si.sessionID (si,ms,Server)
                      let state = {state with pstate = PSServer(ServerIdle)   
                                              sDB = sDB} in
                      OutComplete(rg,f,state)
                  | ClientCCSResume(_) ->
                      OutFinished(rg,f,state)
                  | _ -> OutSome(rg,f,state)
          | _ -> OutSome(rg,f,state)
                  
  
  