From da0f19e53243e75ec305e3697e7b3028e141b74b Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin Date: Thu, 18 Aug 2016 17:04:28 +0200 Subject: dtls: Add renegotiate/2 --- lib/ssl/src/dtls_connection.erl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/ssl/src/dtls_connection.erl') diff --git a/lib/ssl/src/dtls_connection.erl b/lib/ssl/src/dtls_connection.erl index 22abb5da02..0afb02afb3 100644 --- a/lib/ssl/src/dtls_connection.erl +++ b/lib/ssl/src/dtls_connection.erl @@ -42,7 +42,7 @@ -export([next_record/1, next_event/3]). %% Handshake handling --export([%%renegotiate/2, +-export([renegotiate/2, reinit_handshake_data/1, send_handshake/2, queue_handshake/2, queue_change_cipher/2]). @@ -684,6 +684,25 @@ next_event(StateName, Record, State, Actions) -> sequence(#connection_states{dtls_write_msg_seq = Seq} = CS) -> {Seq, CS#connection_states{dtls_write_msg_seq = Seq + 1}}. +renegotiate(#state{role = client} = State, Actions) -> + %% Handle same way as if server requested + %% the renegotiation + Hs0 = ssl_handshake:init_handshake_history(), + {next_state, connection, State#state{tls_handshake_history = Hs0, + protocol_buffers = #protocol_buffers{}}, + [{next_event, internal, #hello_request{}} | Actions]}; + +renegotiate(#state{role = server, + connection_states = CS0} = State0, Actions) -> + HelloRequest = ssl_handshake:hello_request(), + State1 = send_handshake(HelloRequest, + State0#state{connection_states = + CS0#connection_states{dtls_write_msg_seq = 0}}), + Hs0 = ssl_handshake:init_handshake_history(), + {Record, State} = next_record(State1#state{tls_handshake_history = Hs0, + protocol_buffers = #protocol_buffers{}}), + next_event(hello, Record, State, Actions). + handle_alerts([], Result) -> Result; handle_alerts(_, {stop,_} = Stop) -> -- cgit v1.2.3