anchor.diff:  	     negotiated_protocol = CurrentProtocol,
   	     key_algorithm = KeyExAlg,
   	     ssl_options = SslOpts} = State) ->
  -    case tls_handshake:hello(Hello, SslOpts, {Port, Session0, Cache, CacheCb,
  -					      ConnectionStates0, Cert, KeyExAlg}, Renegotiation) of
  -        #alert{} = Alert ->
  -            ssl_connection:handle_own_alert(Alert, ClientVersion, hello,
  -                                            State#state{negotiated_version
  -                                                        = ClientVersion});
  -        {Version, {Type, Session},
  -	 ConnectionStates, Protocol0, ServerHelloExt, HashSign} when Version < {3,4} ->
  -	    Protocol = case Protocol0 of
  -			   undefined -> CurrentProtocol;
  -			   _ -> Protocol0
  -		       end,
  -            gen_handshake(?FUNCTION_NAME, internal, {common_client_hello, Type, ServerHelloExt},
  -                          State#state{connection_states  = ConnectionStates,
  -                                      negotiated_version = Version,
  -                                      hashsign_algorithm = HashSign,
  -                                      client_hello_version = ClientVersion,
  -                                      session = Session,
  -                                      negotiated_protocol = Protocol});
  -        %% TLS 1.3
  -        {Version, {Type, Session},
  -	 ConnectionStates, Protocol0, ServerHelloExt, HashSign} ->
  -	    Protocol = case Protocol0 of
  -			   undefined -> CurrentProtocol;
  -			   _ -> Protocol0
  -		       end,
  -            tls_connection_1_3:gen_handshake(?FUNCTION_NAME,
  -                                             internal,
  -                                             {common_client_hello, Type, ServerHelloExt},
  -                                             State#state{connection_states  = ConnectionStates,
  -                                                         negotiated_version = Version,
  -                                                         hashsign_algorithm = HashSign,
  -                                                         client_hello_version = ClientVersion,
  -                                                         session = Session,
  -                                                         negotiated_protocol = Protocol})
  +    case choose_tls_version(SslOpts, Hello) of
  +        'tls_v1.3' ->
  +            %% Continue in TLS 1.3 'start' state
  +            {next_state, start, State, [{next_event, internal, Hello}]};
  +        'tls_v1.2' ->
  +            case tls_handshake:hello(Hello,
  +                                     SslOpts,
  +                                     {Port, Session0, Cache, CacheCb,
  +                                      ConnectionStates0, Cert, KeyExAlg},
  +                                     Renegotiation) of
  +                #alert{} = Alert ->
  +                    ssl_connection:handle_own_alert(Alert, ClientVersion, hello,
  +                                                    State#state{negotiated_version
  +                                                                = ClientVersion});
  +                {Version, {Type, Session},
  +                 ConnectionStates, Protocol0, ServerHelloExt, HashSign} ->
  +                    Protocol = case Protocol0 of
  +                                   undefined -> CurrentProtocol;
  +                                   _ -> Protocol0
  +                               end,
  +                    gen_handshake(?FUNCTION_NAME,
  +                                  internal,
  +                                  {common_client_hello, Type, ServerHelloExt},
  +                                  State#state{connection_states  = ConnectionStates,
  +                                              negotiated_version = Version,
  +                                              hashsign_algorithm = HashSign,
  +                                              client_hello_version = ClientVersion,
  +                                              session = Session,
  +                                              negotiated_protocol = Protocol})
  +            end
       end;
   hello(internal, #server_hello{} = Hello,      
         #state{connection_states = ConnectionStates0,
  
positive.code: 						       malformed_handshake_data), 
  					    Version, StateName, State)  
      end.
  	    
  unprocessed_events(Events) ->
      %% The first handshake event will be processed immediately
  
negative.code: 					    Version, StateName, State)  
      end.
  
  gen_handshake_1_3(StateName, Type, Event,
  	      #state{negotiated_version = Version} = State) ->
      try tls_connection_1_3:StateName(Type, Event, State, ?MODULE) of
  	Result ->
  	    Result
      catch
  	_:_ ->
              ssl_connection:handle_own_alert(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE,
  						       malformed_handshake_data),
  					    Version, StateName, State)
      end.
  
  gen_info(Event, connection = StateName,  #state{negotiated_version = Version} = State) ->
      try handle_info(Event, StateName, State) of
  	Result ->
  