diff options
author | Péter Dimitrov <[email protected]> | 2018-12-13 15:41:07 +0100 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2019-01-11 09:59:12 +0100 |
commit | 8724ebf1e13fe4ebec73aaa9285011d9aa99e9cc (patch) | |
tree | 77b12bb31ff741ac92ebf148eaf9d1a807f2d6ff | |
parent | f552b7d03cd799324ac5e44f1c70bfb954ead4b8 (diff) | |
download | otp-8724ebf1e13fe4ebec73aaa9285011d9aa99e9cc.tar.gz otp-8724ebf1e13fe4ebec73aaa9285011d9aa99e9cc.tar.bz2 otp-8724ebf1e13fe4ebec73aaa9285011d9aa99e9cc.zip |
ssl: Fix encoding/decoding of supported_versions
Encode length of supported_versions in one octet instead of two.
Change-Id: If24b38f3d2a40f0aa7152bb05bc0392efca6454c
-rw-r--r-- | lib/ssl/src/ssl_handshake.erl | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index d45fea84be..5e3c767c2c 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -680,9 +680,9 @@ encode_extensions([#sni{hostname = Hostname} | Rest], Acc) -> encode_extensions([#client_hello_versions{versions = Versions0} | Rest], Acc) -> Versions = encode_versions(Versions0), VerLen = byte_size(Versions), - Len = VerLen + 2, + Len = VerLen + 1, encode_extensions(Rest, <<?UINT16(?SUPPORTED_VERSIONS_EXT), - ?UINT16(Len), ?UINT16(VerLen), Versions/binary, Acc/binary>>); + ?UINT16(Len), ?BYTE(VerLen), Versions/binary, Acc/binary>>); encode_extensions([#server_hello_selected_version{selected_version = Version0} | Rest], Acc) -> Version = encode_versions([Version0]), Len = byte_size(Version), %% 2 @@ -745,7 +745,6 @@ decode_handshake(Version, ?SERVER_HELLO, <<?BYTE(Major), ?BYTE(Minor), Random:32 ?BYTE(SID_length), Session_ID:SID_length/binary, Cipher_suite:2/binary, ?BYTE(Comp_method), ?UINT16(ExtLen), Extensions:ExtLen/binary>>) -> - HelloExtensions = decode_hello_extensions(Extensions, Version, {Major, Minor}, server_hello), #server_hello{ @@ -2222,7 +2221,7 @@ process_supported_versions_extension(<<>>, LocalVersion, _LegacyVersion) -> process_supported_versions_extension(<<?UINT16(?SUPPORTED_VERSIONS_EXT), ?UINT16(Len), ExtData:Len/binary, _Rest/binary>>, LocalVersion, _LegacyVersion) when Len > 2 -> - <<?UINT16(_),Versions0/binary>> = ExtData, + <<?BYTE(_),Versions0/binary>> = ExtData, [Highest|_] = decode_versions(Versions0), if Highest =< LocalVersion -> Highest; @@ -2375,7 +2374,7 @@ decode_extensions(<<?UINT16(?SNI_EXT), ?UINT16(Len), decode_extensions(<<?UINT16(?SUPPORTED_VERSIONS_EXT), ?UINT16(Len), ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) when Len > 2 -> - <<?UINT16(_),Versions/binary>> = ExtData, + <<?BYTE(_),Versions/binary>> = ExtData, decode_extensions(Rest, Version, MessageType, Acc#{client_hello_versions => #client_hello_versions{ |