test: Add dummy ChangeCipherSpec after ClientHello

parent d43152e9
......@@ -21,6 +21,7 @@
-ifdef(TEST).
-export([make_client_hello/2,
make_client_hello/4,
make_dummy_change_cipher/0,
parse_server_hello/1]).
-endif.
......@@ -295,6 +296,13 @@ add_padding_ext(RealExtensions, ExtLen) ->
(binary:copy(<<0>>, PadSize))/binary>>,
<<RealExtensions/binary, PaddingExt/binary>>.
%% https://tools.ietf.org/html/rfc8446#appendix-D.4
make_dummy_change_cipher() ->
<<?TLS_REC_CHANGE_CIPHER,
?TLS_12_VERSION,
1:?u16,
1>>.
%% Parses "ServerHello" (the one produced by from_client_hello/2). Used for tests only.
parse_server_hello(<<?TLS_REC_HANDSHAKE, ?TLS_12_VERSION, HSLen:?u16, Handshake:HSLen/binary,
?TLS_REC_CHANGE_CIPHER, ?TLS_12_VERSION, CCLen:?u16, ChangeCipher:CCLen/binary,
......
......@@ -49,6 +49,7 @@ connect(Host, Port, Seed, Secret, DcId, Protocol0) ->
ok = gen_tcp:send(Sock, ClientHello),
%% Let's hope whole server hello will arrive in a single chunk
Tail_ = recv_server_hello(Sock, Timeout, <<>>),
ok = gen_tcp:send(Sock, mtp_fake_tls:make_dummy_change_cipher()),
{mtp_secure, true, mtp_fake_tls:new(), Tail_};
_ -> {Protocol0, false, undefined, <<>>}
end,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment