test: Add dummy ChangeCipherSpec after ClientHello

This commit is contained in:
Sergey Prokhorov 2020-06-06 18:40:33 +02:00
parent d43152e9be
commit d63666ea35
No known key found for this signature in database
GPG key ID: 1C570244E4EF3337
2 changed files with 9 additions and 0 deletions

View file

@ -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,

View file

@ -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,