1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2020-2022. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%
-module(openssl_key_update_SUITE).
%% Callback functions
-export([all/0,
groups/0,
init_per_suite/1,
end_per_suite/1,
init_per_group/2,
end_per_group/2,
init_per_testcase/2,
end_per_testcase/2]).
%% Testcases
-export([openssl_client_explicit_key_update/0,
openssl_client_explicit_key_update/1,
openssl_server_explicit_key_update/0,
openssl_server_explicit_key_update/1]).
-include_lib("common_test/include/ct.hrl").
all() ->
[{group, 'tlsv1.3'}].
groups() ->
[{'tlsv1.3', [], tls_1_3_tests()}].
tls_1_3_tests() ->
[openssl_client_explicit_key_update,
openssl_server_explicit_key_update].
init_per_suite(Config0) ->
Config1 = ssl_test_lib:init_per_suite(Config0, openssl),
case proplists:get_bool(ecdh, proplists:get_value(public_keys, crypto:supports()))
of
true ->
ssl_test_lib:make_ecdsa_cert(Config1);
false ->
{skip, "Missing EC crypto support"}
end.
end_per_suite(Config) ->
ssl_test_lib:end_per_suite(Config).
init_per_group(GroupName, Config) ->
ssl_test_lib:init_per_group_openssl(GroupName, Config).
end_per_group(GroupName, Config) ->
ssl_test_lib:end_per_group(GroupName, Config).
init_per_testcase(_TestCase, Config) ->
ssl_test_lib:ct_log_supported_protocol_versions(Config),
ct:timetrap({seconds, 10}),
Config.
end_per_testcase(_TestCase, Config) ->
Config.
%%--------------------------------------------------------------------
%% Test Cases --------------------------------------------------------
%%--------------------------------------------------------------------
openssl_client_explicit_key_update() ->
[{doc,"Test ssl:update_key/2 between openssl s_client and erlang server."}].
openssl_client_explicit_key_update(Config) ->
Data = "123456789012345", %% 15 bytes
Server = ssl_test_lib:start_server(erlang, [], Config),
Port = ssl_test_lib:inet_port(Server),
Client = ssl_test_lib:start_client(openssl, [{port, Port}], Config),
ssl_test_lib:send(Client, Data),
Data = ssl_test_lib:check_active_receive(Server, Data),
%% TODO s_client can hang after sending special commands e.g "k", "K"
%% ssl_test_lib:update_keys(Client, write),
%% ssl_test_lib:update_keys(Client, read_write),
ssl_test_lib:update_keys(Server, write),
ssl_test_lib:update_keys(Server, read_write),
ssl_test_lib:send(Client, Data),
Data = ssl_test_lib:check_active_receive(Server, Data),
ssl_test_lib:close(Client),
ssl_test_lib:close(Server).
openssl_server_explicit_key_update() ->
[{doc,"Test ssl:update_key/2 between ssl client and s_server."}].
openssl_server_explicit_key_update(Config) ->
Data = "123456789012345", %% 15 bytes
Server = ssl_test_lib:start_server(openssl, [], Config),
Port = ssl_test_lib:inet_port(Server),
Client = ssl_test_lib:start_client(erlang, [{port, Port},
{versions, ['tlsv1.2','tlsv1.3']}],Config),
ssl_test_lib:send(Server, Data),
Data = ssl_test_lib:check_active_receive(Client, Data),
ssl_test_lib:update_keys(Client, write),
ssl_test_lib:update_keys(Client, read_write),
ssl_test_lib:update_keys(Server, write),
ssl_test_lib:update_keys(Server, read_write),
ssl_test_lib:send(Server, Data),
Data = ssl_test_lib:check_active_receive(Client, Data),
ssl_test_lib:close(Client),
ssl_test_lib:close(Server).
|