anchor.diff:          | _ -> (* Handshake already ongoing, ignore this request *)
               (false,state)
   
  -let storeSession sDB (sinfo, ms, role) =
  -    match sinfo.sessionID with
  -    | [||] -> (* Non-resumable session *)
  -        sDB
  -    | sid ->
  -        SessionDB.insert sDB sinfo.sessionID (sinfo, ms, role)
  -
  -// FIXME: Seems we can skip this function with the new state machine *)
  -(*
  -let goToIdle state =
  -    let init_sessionInfo = null_sessionInfo state.poptions.minVer in
  -    match state.pstate with
  -    | PSClient (_) ->
  -        let sDB = storeSession Client state in
  -        {hs_outgoing = [||];
  -         ccs_outgoing = None;
  -         hs_outgoing_after_ccs = [||];
  -         hs_incoming = [||];
  -         ccs_incoming = None
  -         poptions = state.poptions;
  -         sDB = sDB;
  -         pstate = PSClient(CIdle);
  -         hs_msg_log = [||]
  -         hs_next_info = init_sessionInfo
  -         next_ms = empty_masterSecret init_sessionInfo
  -         ki_crand = [||]
  -         ki_srand = [||]
  -         hs_renegotiation_info_cVerifyData = state.hs_renegotiation_info_cVerifyData
  -         hs_renegotiation_info_sVerifyData = state.hs_renegotiation_info_sVerifyData}
  -    | PSServer (_) ->
  -        let rand = makeRandom () in
  -        let init_sessionInfo = {init_sessionInfo with init_srand = rand} in
  -        let sDB = storeSession Server state in
  -        {hs_outgoing = [||];
  -         ccs_outgoing = None;
  -         hs_outgoing_after_ccs = [||];
  -         hs_incoming = [||];
  -         ccs_incoming = None
  -         poptions = state.poptions;
  -         sDB = sDB;
  -         pstate = PSServer(SIdle);
  -         hs_msg_log = [||]
  -         hs_next_info = init_sessionInfo
  -         next_ms = empty_masterSecret init_sessionInfo
  -         ki_crand = [||]
  -         ki_srand = rand
  -         hs_renegotiation_info_cVerifyData = state.hs_renegotiation_info_cVerifyData
  -         hs_renegotiation_info_sVerifyData = state.hs_renegotiation_info_sVerifyData}
  -*)
  -
   let invalidateSession ci state =
       let si = epochSI(ci.id_in) // FIXME: which epoch to choose? Here it matters since they could be mis-aligned
       match si.sessionID with
  
positive.code:             | _ -> OutIdle(state)
          | PSServer(sstate) ->
              match sstate with
              | _ -> unexpectedError "TODO"
      | outBuf ->
          let (((rg,f),_),(_,remBuf)) = makeFragment ci.id_out outBuf in
          let state = {state with hs_outgoing = remBuf} in
  
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)
                  
  
  