aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl/src/tls_handshake.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-06-18 12:30:38 +0200
committerIngela Anderton Andin <[email protected]>2013-09-10 09:37:29 +0200
commitb9a31f24053c84d9a7ffa4281bc11f47b3be5905 (patch)
treee0698a95d56b1fd6070d916033cd07f098d3b5ed /lib/ssl/src/tls_handshake.erl
parentfb6ac178ac437fcc04f1675df75b0583c1d24ad7 (diff)
downloadotp-b9a31f24053c84d9a7ffa4281bc11f47b3be5905.tar.gz
otp-b9a31f24053c84d9a7ffa4281bc11f47b3be5905.tar.bz2
otp-b9a31f24053c84d9a7ffa4281bc11f47b3be5905.zip
ssl: DTLS record handling
Also refactor so that TLS and DTLS can have common functions when possible.
Diffstat (limited to 'lib/ssl/src/tls_handshake.erl')
-rw-r--r--lib/ssl/src/tls_handshake.erl19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/ssl/src/tls_handshake.erl b/lib/ssl/src/tls_handshake.erl
index 066590afb1..fef1464c64 100644
--- a/lib/ssl/src/tls_handshake.erl
+++ b/lib/ssl/src/tls_handshake.erl
@@ -33,7 +33,7 @@
-include_lib("public_key/include/public_key.hrl").
-export([client_hello/8, server_hello/4, hello/4,
- get_tls_handshake/3, encode_handshake/2,
+ get_tls_handshake/3, encode_handshake/2, decode_handshake/3,
init_handshake_history/0, update_handshake_history/2]).
%%====================================================================
@@ -197,17 +197,22 @@ update_handshake_history(Handshake, % special-case SSL2 client hello
update_handshake_history({Handshake0, _Prev}, Data) ->
{[Data|Handshake0], Handshake0}.
-%%--------------------------------------------------------------------
-%%% Internal functions
-%%--------------------------------------------------------------------
+
get_tls_handshake_aux(Version, <<?BYTE(Type), ?UINT24(Length),
Body:Length/binary,Rest/binary>>, Acc) ->
Raw = <<?BYTE(Type), ?UINT24(Length), Body/binary>>,
- H = decode_handshake(Version, Type, Body),
- get_tls_handshake_aux(Version, Rest, [{H,Raw} | Acc]);
+ Handshake = decode_handshake(Version, Type, Body),
+ get_tls_handshake_aux(Version, Rest, [{Handshake,Raw} | Acc]);
get_tls_handshake_aux(_Version, Data, Acc) ->
{lists:reverse(Acc), Data}.
+%%--------------------------------------------------------------------
+%%% Internal functions
+%%--------------------------------------------------------------------
+
+decode_handshake(_, ?HELLO_REQUEST, <<>>) ->
+ #hello_request{};
+
%% Client hello v2.
%% The server must be able to receive such messages, from clients that
%% are willing to use ssl v3 or higher, but have ssl v2 compatibility.
@@ -217,7 +222,7 @@ decode_handshake(_Version, ?CLIENT_HELLO, <<?BYTE(Major), ?BYTE(Minor),
CipherSuites:CSLength/binary,
ChallengeData:CDLength/binary>>) ->
#client_hello{client_version = {Major, Minor},
- random = ssl_ssl2:client_random(ChallengeData, CDLength),
+ random = ssl_v2:client_random(ChallengeData, CDLength),
session_id = 0,
cipher_suites = ssl_handshake:decode_suites('3_bytes', CipherSuites),
compression_methods = [?NULL],