aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl/src/tls_handshake.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-09-17 15:28:20 +0200
committerIngela Anderton Andin <[email protected]>2013-12-02 09:44:49 +0100
commitb3d5f82bd3baf5b63ea97c017cb83674ca703c66 (patch)
tree9e69018308dd59d9224129fe81e718fdeb78e341 /lib/ssl/src/tls_handshake.erl
parent810c34a7991f2b6edd5e9f41e3c667958a5b2bc8 (diff)
downloadotp-b3d5f82bd3baf5b63ea97c017cb83674ca703c66.tar.gz
otp-b3d5f82bd3baf5b63ea97c017cb83674ca703c66.tar.bz2
otp-b3d5f82bd3baf5b63ea97c017cb83674ca703c66.zip
ssl: Refactor connection and handshake handling
Diffstat (limited to 'lib/ssl/src/tls_handshake.erl')
-rw-r--r--lib/ssl/src/tls_handshake.erl58
1 files changed, 3 insertions, 55 deletions
diff --git a/lib/ssl/src/tls_handshake.erl b/lib/ssl/src/tls_handshake.erl
index f783bacff6..003614b448 100644
--- a/lib/ssl/src/tls_handshake.erl
+++ b/lib/ssl/src/tls_handshake.erl
@@ -30,9 +30,8 @@
-include("ssl_internal.hrl").
-include_lib("public_key/include/public_key.hrl").
--export([client_hello/8, server_hello/4, hello/4,
- get_tls_handshake/3, encode_handshake/2, decode_handshake/3,
- init_handshake_history/0, update_handshake_history/2]).
+-export([client_hello/8, hello/4,
+ get_tls_handshake/3, encode_handshake/2, decode_handshake/3]).
%%====================================================================
%% Internal application API
@@ -68,25 +67,6 @@ client_hello(Host, Port, ConnectionStates,
}.
%%--------------------------------------------------------------------
--spec server_hello(binary(), tls_version(), #connection_states{},
- #hello_extensions{}) -> #server_hello{}.
-%%
-%% Description: Creates a server hello message.
-%%--------------------------------------------------------------------
-server_hello(SessionId, Version, ConnectionStates, Extensions) ->
- Pending = ssl_record:pending_connection_state(ConnectionStates, read),
- SecParams = Pending#connection_state.security_parameters,
-
- #server_hello{server_version = Version,
- cipher_suite = SecParams#security_parameters.cipher_suite,
- compression_method =
- SecParams#security_parameters.compression_algorithm,
- random = SecParams#security_parameters.server_random,
- session_id = SessionId,
- extensions = Extensions
- }.
-
-%%--------------------------------------------------------------------
-spec hello(#server_hello{} | #client_hello{}, #ssl_options{},
#connection_states{} | {inet:port_number(), #session{}, db_handle(),
atom(), #connection_states{}, binary() | undefined},
@@ -165,36 +145,8 @@ get_tls_handshake(Version, Data, Buffer) ->
get_tls_handshake_aux(Version, list_to_binary([Buffer, Data]), []).
%%--------------------------------------------------------------------
--spec init_handshake_history() -> tls_handshake_history().
-
-%%
-%% Description: Initialize the empty handshake history buffer.
-%%--------------------------------------------------------------------
-init_handshake_history() ->
- {[], []}.
-
-%%--------------------------------------------------------------------
--spec update_handshake_history(tls_handshake_history(), Data ::term()) ->
- tls_handshake_history().
-%%
-%% Description: Update the handshake history buffer with Data.
+%%% Internal functions
%%--------------------------------------------------------------------
-update_handshake_history(Handshake, % special-case SSL2 client hello
- <<?CLIENT_HELLO, ?UINT24(_), ?BYTE(Major), ?BYTE(Minor),
- ?UINT16(CSLength), ?UINT16(0),
- ?UINT16(CDLength),
- CipherSuites:CSLength/binary,
- ChallengeData:CDLength/binary>>) ->
- update_handshake_history(Handshake,
- <<?CLIENT_HELLO, ?BYTE(Major), ?BYTE(Minor),
- ?UINT16(CSLength), ?UINT16(0),
- ?UINT16(CDLength),
- CipherSuites:CSLength/binary,
- ChallengeData:CDLength/binary>>);
-update_handshake_history({Handshake0, _Prev}, Data) ->
- {[Data|Handshake0], Handshake0}.
-
-
get_tls_handshake_aux(Version, <<?BYTE(Type), ?UINT24(Length),
Body:Length/binary,Rest/binary>>, Acc) ->
Raw = <<?BYTE(Type), ?UINT24(Length), Body/binary>>,
@@ -203,10 +155,6 @@ get_tls_handshake_aux(Version, <<?BYTE(Type), ?UINT24(Length),
get_tls_handshake_aux(_Version, Data, Acc) ->
{lists:reverse(Acc), Data}.
-%%--------------------------------------------------------------------
-%%% Internal functions
-%%--------------------------------------------------------------------
-
decode_handshake(_, ?HELLO_REQUEST, <<>>) ->
#hello_request{};