mirror of
https://github.com/seriyps/mtproto_proxy.git
synced 2026-05-13 16:57:10 +00:00
test: Add dummy ChangeCipherSpec after ClientHello
This commit is contained in:
parent
d43152e9be
commit
d63666ea35
2 changed files with 9 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue