anchor.diff:  	  opts = [],
   	  timeout = 5000,			% ms
   	  seen_hello = false,
  -	  enc = <<>>,
   	  ssh = #ssh{},				% #ssh{}
   	  alg_neg = {undefined,undefined},      % {own_kexinit, peer_kexinit}
   	  alg,                                  % #alg{}
   	  vars = dict:new(),
   	  reply = [],				% Some repy msgs are generated hidden in ssh_transport :[
   	  prints = [],
  -	  return_value
  -	 }).
  +	  return_value,
  +
  +          %% Packet retrival and decryption
  +          decrypted_data_buffer     = <<>>,
  +          encrypted_data_buffer     = <<>>,
  +          aead_data                 = <<>>,
  +          undecrypted_packet_length
  +         }).
   
   -define(role(S), ((S#s.ssh)#ssh.role) ).
   
  
positive.code: 
  %%%================================================================
  try_find_crlf(Seen, S0) ->
      case erlang:decode_packet(line,S0#s.enc,[]) of
  	{more,_} ->
  	    Line = <<Seen/binary,(S0#s.enc)/binary>>,
  	    S0#s{seen_hello = {more,Line},
  		 enc = <<>>,	       % didn't find a complete line 
  				       % -> no more characters to test
  		 return_value = {more,Line}
  	       };
  
negative.code: 	{{Vp,Vs}, server} ->   S#s{ssh = C#ssh{c_vsn=Vp, c_version=Vs}}
      end.
  
  receive_binary_msg(S0=#s{}) ->
       case ssh_transport:handle_packet_part(
             S0#s.decrypted_data_buffer,
             S0#s.encrypted_data_buffer,
             S0#s.aead_data,
             S0#s.undecrypted_packet_length,
             S0#s.ssh)
       of
           {packet_decrypted, DecryptedBytes, EncryptedDataRest, Ssh1} ->
               S1 = S0#s{ssh = Ssh1#ssh{recv_sequence = ssh_transport:next_seqnum(Ssh1#ssh.recv_sequence)},
                         decrypted_data_buffer = <<>>,
                         undecrypted_packet_length = undefined,
                         aead_data = <<>>,
                         encrypted_data_buffer = EncryptedDataRest},
               case
                   catch ssh_message:decode(set_prefix_if_trouble(DecryptedBytes,S1))
               of
                   {'EXIT',_} -> fail(decode_failed,S1);
  
                   Msg ->
                       Ssh2 = case Msg of
                                #ssh_msg_kexinit{} ->
                                    ssh_transport:key_init(opposite_role(Ssh1), Ssh1, DecryptedBytes);
                                _ ->
                                    Ssh1
  			 end,
                       S2 = opt(print_messages, S1,
                                fun(X) when X==true;X==detail -> {"Recv~n~s~n",[format_msg(Msg)]} end),
                       S3 = opt(print_messages, S2, 
                                fun(detail) -> {"decrypted bytes ~p~n",[DecryptedBytes]} end),
                       S3#s{ssh = inc_recv_seq_num(Ssh2),
                            return_value = Msg
                           }
               end;
  
           {get_more, DecryptedBytes, EncryptedDataRest, AeadData, TotalNeeded, Ssh1} ->
               %% Here we know that there are not enough bytes in
               %% EncryptedDataRest to use. We must wait for more.
               Remaining = case TotalNeeded of
                               undefined -> 8;
                               _ -> TotalNeeded - size(DecryptedBytes) - size(EncryptedDataRest)
                           end,
               receive_binary_msg(
                 receive_wait(Remaining,
                              S0#s{encrypted_data_buffer = EncryptedDataRest,
                                   decrypted_data_buffer = DecryptedBytes,
                                   undecrypted_packet_length = TotalNeeded,
                                   aead_data = AeadData,
                                   ssh = Ssh1}
                             ))
       end.
  
  
  
  old_receive_binary_msg(S0=#s{ssh=C0=#ssh{decrypt_block_size = BlockSize,
  				     recv_mac_size = MacSize
  				    }
  			}) ->
      case size(S0#s.encrypted_data_buffer) >= max(8,BlockSize) of
  	false ->
  	    %% Need more bytes to decode the packet_length field
  	    Remaining = max(8,BlockSize) - size(S0#s.encrypted_data_buffer),
  	    receive_binary_msg( receive_wait(Remaining, S0) );
  	true ->
  	    %% Has enough bytes to decode the packet_length field
  	    {_, <<?UINT32(PacketLen), _/binary>>, _} =
  		ssh_transport:decrypt_blocks(S0#s.encrypted_data_buffer, BlockSize, C0), % FIXME: BlockSize should be at least 4
  
  	    %% FIXME: Check that ((4+PacketLen) rem BlockSize) == 0 ?
  
  