Skip to content

Commit

Permalink
ssl: Structural perarparation to support DTLS
Browse files Browse the repository at this point in the history
Also phase in tls module as main API instead of ssl. To
make API clearer. As TLS is the new protocol name.
Maybe keep some API functions in ssl
  • Loading branch information
IngelaAndin committed Jun 4, 2013
1 parent 036a9c4 commit e7f8deb
Show file tree
Hide file tree
Showing 25 changed files with 1,572 additions and 1,150 deletions.
23 changes: 15 additions & 8 deletions lib/ssl/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ BEHAVIOUR_MODULES= \

MODULES= \
ssl \
tls \
dtls \
ssl_alert \
ssl_app \
ssl_dist_sup\
Expand All @@ -51,22 +53,26 @@ MODULES= \
ssl_pkix_db\
ssl_cipher \
ssl_srp_primes \
ssl_connection \
tls_connection \
dtls_connection \
ssl_connection_sup \
ssl_handshake \
tls_handshake \
dtls_handshake\
ssl_manager \
ssl_session \
ssl_session_cache \
ssl_socket \
ssl_record \
tls_record \
dtls_record \
ssl_ssl2 \
ssl_ssl3 \
ssl_tls1 \
ssl_tls_dist_proxy

INTERNAL_HRL_FILES = \
ssl_alert.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_internal.hrl \
ssl_record.hrl ssl_srp.hrl
ssl_alert.hrl ssl_cipher.hrl ssl_handshake.hrl tls_handshake.hrl \
dtls_handshake.hrl ssl_internal.hrl \
ssl_record.hrl tls_record.hrl dtls_record.hrl ssl_srp.hrl

ERL_FILES= \
$(MODULES:%=%.erl) \
Expand Down Expand Up @@ -134,13 +140,14 @@ release_docs_spec:
# Dependencies
# ----------------------------------------------------
$(EBIN)/inet_tls_dist.$(EMULATOR): ../../kernel/include/net_address.hrl ../../kernel/include/dist.hrl ../../kernel/include/dist_util.hrl
$(EBIN)/ssl.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ../../public_key/include/public_key.hrl
$(EBIN)/tls.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ../../public_key/include/public_key.hrl
$(EBIN)/ssl_alert.$(EMULATOR): ssl_alert.hrl ssl_record.hrl
$(EBIN)/ssl_certificate.$(EMULATOR): ssl_internal.hrl ssl_alert.hrl ssl_handshake.hrl ../../public_key/include/public_key.hrl
$(EBIN)/ssl_certificate_db.$(EMULATOR): ssl_internal.hrl ../../public_key/include/public_key.hrl ../../kernel/include/file.hrl
$(EBIN)/ssl_cipher.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
$(EBIN)/ssl_connection.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
$(EBIN)/ssl_handshake.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
$(EBIN)/tls_connection.$(EMULATOR): ssl_internal.hrl tls_record.hrl ssl_cipher.hrl tls_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
$(EBIN)/dtls_connection.$(EMULATOR): ssl_internal.hrl dtls_record.hrl ssl_cipher.hrl dtls_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
$(EBIN)/tls_handshake.$(EMULATOR): ssl_internal.hrl tls_record.hrl ssl_cipher.hrl tls_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
$(EBIN)/ssl_manager.$(EMULATOR): ssl_internal.hrl ssl_handshake.hrl ../../kernel/include/file.hrl
$(EBIN)/ssl_record.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl
$(EBIN)/ssl_session.$(EMULATOR): ssl_internal.hrl ssl_handshake.hrl
Expand Down
28 changes: 7 additions & 21 deletions lib/ssl/src/ssl_debug.hrl → lib/ssl/src/dtls.erl
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2007-2009. All Rights Reserved.
%%
%%
%% Copyright Ericsson AB 1999-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%%
%% %CopyrightEnd%
%%

%%

%%% Purpose : API for DTLS.

-ifndef(ssl_debug).
-define(ssl_debug, true).

-ifdef(SSL_DEBUG).
-define(DBG_HEX(V), ssl_debug:hex_data(??V, V, ?MODULE, ?LINE)).
-define(DBG_TERM(T), ssl_debug:term_data(??T, T, ?MODULE, ?LINE)).
-else.
-define(DBG_HEX(V), ok).
-define(DBG_TERM(T), ok).
-endif.

-endif. % -ifdef(ssl_debug).




-module(dtls).

19 changes: 19 additions & 0 deletions lib/ssl/src/dtls_connection.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2013-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%
-module(dtls_connection).
18 changes: 18 additions & 0 deletions lib/ssl/src/dtls_handshake.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2013-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
-module(dtls_handshake).
50 changes: 50 additions & 0 deletions lib/ssl/src/dtls_handshake.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2013-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%

%%
%%----------------------------------------------------------------------
%% Purpose: Record and constant defenitions for the DTLS-handshake protocol
%% that differs from TLS see RFC 6347
%%----------------------------------------------------------------------
-ifndef(dtls_handshake).
-define(dtls_handshake, true).

-include("ssl_handshake.hrl"). %% Common TLS and DTLS records and Constantes

-record(client_hello, {
client_version,
random,
session_id, % opaque SessionID<0..32>
cookie, % opaque<2..2^16-1>
cipher_suites, % cipher_suites<2..2^16-1>
compression_methods, % compression_methods<1..2^8-1>,
%% Extensions
renegotiation_info,
hash_signs, % supported combinations of hashes/signature algos
next_protocol_negotiation = undefined % [binary()]
}).

-record(hello_verify_request {
protocol_version,
cookie
}).

-define(HELLO_VERIFY_REQUEST, 3).

-endif. % -ifdef(dtls_handshake).
18 changes: 18 additions & 0 deletions lib/ssl/src/dtls_record.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2013-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
-module(dtls_record).
44 changes: 44 additions & 0 deletions lib/ssl/src/dtls_record.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2013-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%

%%
%%----------------------------------------------------------------------
%% Purpose: Record and constant defenitions for the DTLS-record protocol
%% see RFC 6347
%%----------------------------------------------------------------------

-ifndef(dtls_record).
-define(dtls_record, true).

-include("ssl_record.hrl"). %% Common TLS and DTLS records and Constantes

%% Used to handle tls_plain_text, tls_compressed and tls_cipher_text

-record(ssl_tls, {
type,
version,
record_seq, % used in plain_text
epoch, % used in plain_text
message_seq,
fragment_offset,
fragment_length,
fragment
}).

-endif. % -ifdef(dtls_record).
23 changes: 17 additions & 6 deletions lib/ssl/src/ssl.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{application, ssl,
[{description, "Erlang/OTP SSL application"},
{vsn, "%VSN%"},
{modules, [ssl,
{modules, [
%% TLS/SSL
tls,
tls_connection,
tls_handshake,
tls_record,
%% DTLS
dtls_record,
dtls_handshake,
dtls_connection,
dtls,
%% Backwards compatibility
ssl,
%% Both TLS/SSL and DTLS
ssl_app,
ssl_sup,
inet_tls_dist,
Expand All @@ -14,11 +27,11 @@
ssl_session_cache_api,
ssl_session_cache,
ssl_socket,
ssl_record,
%%ssl_record,
ssl_manager,
ssl_handshake,
%%ssl_handshake,
ssl_connection_sup,
ssl_connection,
%%ssl_connection,
ssl_cipher,
ssl_srp_primes,
ssl_pkix_db,
Expand All @@ -31,5 +44,3 @@
{mod, {ssl_app, []}}]}.




Loading

0 comments on commit e7f8deb

Please sign in to comment.