diff options
author | Ingela Anderton Andin <[email protected]> | 2017-04-26 21:35:24 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2017-04-26 21:35:24 +0200 |
commit | b65187abe4c18b05bd2391f56a8309ca1e78750d (patch) | |
tree | 3f34ce78dcde66511a7e4af8c02227148807c79f /lib/ssl/src/dtls_record.erl | |
parent | 77c6f46a92bd695840c25118a28d801ec51372cf (diff) | |
download | otp-b65187abe4c18b05bd2391f56a8309ca1e78750d.tar.gz otp-b65187abe4c18b05bd2391f56a8309ca1e78750d.tar.bz2 otp-b65187abe4c18b05bd2391f56a8309ca1e78750d.zip |
ssl: Correct DTLS mac handling
Diffstat (limited to 'lib/ssl/src/dtls_record.erl')
-rw-r--r-- | lib/ssl/src/dtls_record.erl | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/ssl/src/dtls_record.erl b/lib/ssl/src/dtls_record.erl index de6b6e400f..bc2097c021 100644 --- a/lib/ssl/src/dtls_record.erl +++ b/lib/ssl/src/dtls_record.erl @@ -534,8 +534,7 @@ calc_mac_hash(Type, Version, #{mac_secret := MacSecret, security_parameters := #security_parameters{mac_algorithm = MacAlg}}, Epoch, SeqNo, Fragment) -> Length = erlang:iolist_size(Fragment), - NewSeq = (Epoch bsl 48) + SeqNo, - mac_hash(Version, MacAlg, MacSecret, NewSeq, Type, + mac_hash(Version, MacAlg, MacSecret, Epoch, SeqNo, Type, Length, Fragment). highest_protocol_version() -> @@ -548,9 +547,11 @@ sufficient_dtlsv1_2_crypto_support() -> CryptoSupport = crypto:supports(), proplists:get_bool(sha256, proplists:get_value(hashs, CryptoSupport)). -mac_hash(Version, MacAlg, MacSecret, SeqNo, Type, Length, Fragment) -> - dtls_v1:mac_hash(Version, MacAlg, MacSecret, SeqNo, Type, - Length, Fragment). - +mac_hash({Major, Minor}, MacAlg, MacSecret, Epoch, SeqNo, Type, Length, Fragment) -> + Value = [<<?UINT16(Epoch), ?UINT48(SeqNo), ?BYTE(Type), + ?BYTE(Major), ?BYTE(Minor), ?UINT16(Length)>>, + Fragment], + dtls_v1:hmac_hash(MacAlg, MacSecret, Value). + calc_aad(Type, {MajVer, MinVer}, Epoch, SeqNo) -> <<?UINT16(Epoch), ?UINT48(SeqNo), ?BYTE(Type), ?BYTE(MajVer), ?BYTE(MinVer)>>. |