diff options
author | Ingela Anderton Andin <[email protected]> | 2017-03-17 16:15:29 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2017-04-13 11:30:14 +0200 |
commit | babaa7132c4f14515b8f53e998aab2d93b16cf04 (patch) | |
tree | c82057a0515f5c917f43159aa49efae468aed9ea | |
parent | d669ce6f7693c7b3a71b1eb9df0fb1674a4643b0 (diff) | |
download | otp-babaa7132c4f14515b8f53e998aab2d93b16cf04.tar.gz otp-babaa7132c4f14515b8f53e998aab2d93b16cf04.tar.bz2 otp-babaa7132c4f14515b8f53e998aab2d93b16cf04.zip |
ssl, dtls: Correct integer type for sequence number
-rw-r--r-- | lib/ssl/src/dtls_record.erl | 3 | ||||
-rw-r--r-- | lib/ssl/src/ssl_cipher.erl | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/ssl/src/dtls_record.erl b/lib/ssl/src/dtls_record.erl index 0ee51c24b6..c5992a72fa 100644 --- a/lib/ssl/src/dtls_record.erl +++ b/lib/ssl/src/dtls_record.erl @@ -528,5 +528,4 @@ mac_hash(Version, MacAlg, MacSecret, SeqNo, Type, Length, Fragment) -> Length, Fragment). calc_aad(Type, {MajVer, MinVer}, Epoch, SeqNo) -> - NewSeq = (Epoch bsl 48) + SeqNo, - <<NewSeq:64/integer, ?BYTE(Type), ?BYTE(MajVer), ?BYTE(MinVer)>>. + <<?UINT16(Epoch), ?UINT48(SeqNo), ?BYTE(Type), ?BYTE(MajVer), ?BYTE(MinVer)>>. diff --git a/lib/ssl/src/ssl_cipher.erl b/lib/ssl/src/ssl_cipher.erl index 8e6860e9dc..3919070e9a 100644 --- a/lib/ssl/src/ssl_cipher.erl +++ b/lib/ssl/src/ssl_cipher.erl @@ -157,7 +157,7 @@ cipher_aead(?CHACHA20_POLY1305, CipherState, SeqNo, AAD, Fragment, Version) -> aead_cipher(chacha20_poly1305, #cipher_state{key=Key} = CipherState, SeqNo, AAD0, Fragment, _Version) -> CipherLen = erlang:iolist_size(Fragment), AAD = <<AAD0/binary, ?UINT16(CipherLen)>>, - Nonce = <<SeqNo:64/integer>>, + Nonce = ?uint64(SeqNo), {Content, CipherTag} = crypto:block_encrypt(chacha20_poly1305, Key, Nonce, {AAD, Fragment}), {<<Content/binary, CipherTag/binary>>, CipherState}; aead_cipher(Type, #cipher_state{key=Key, iv = IV0, nonce = Nonce} = CipherState, _SeqNo, AAD0, Fragment, _Version) -> @@ -280,7 +280,7 @@ aead_ciphertext_to_state(chacha20_poly1305, SeqNo, _IV, AAD0, Fragment, _Version CipherLen = size(Fragment) - 16, <<CipherText:CipherLen/bytes, CipherTag:16/bytes>> = Fragment, AAD = <<AAD0/binary, ?UINT16(CipherLen)>>, - Nonce = <<SeqNo:64/integer>>, + Nonce = ?uint64(SeqNo), {Nonce, AAD, CipherText, CipherTag}; aead_ciphertext_to_state(_, _SeqNo, <<Salt:4/bytes, _/binary>>, AAD0, Fragment, _Version) -> CipherLen = size(Fragment) - 24, @@ -1533,7 +1533,7 @@ random_bytes(N) -> calc_aad(Type, {MajVer, MinVer}, #{sequence_number := SeqNo}) -> - <<SeqNo:64/integer, ?BYTE(Type), ?BYTE(MajVer), ?BYTE(MinVer)>>. + <<?UINT64(SeqNo), ?BYTE(Type), ?BYTE(MajVer), ?BYTE(MinVer)>>. calc_mac_hash(Type, Version, PlainFragment, #{sequence_number := SeqNo, |