scapy-ssl_tls icon indicating copy to clipboard operation
scapy-ssl_tls copied to clipboard

DTLSHandshake 'fragment_offset' field initialized incorrectly

Open 4Kp3n opened this issue 7 years ago • 2 comments

Hi,

I'm having some trouble sending DTLS messages. I created some very basic DTLSClientHello like so:

p = DTLSRecord(version=version)/DTLSHandshake()/DTLSClientHello(cipher_suites=cipher)

and send it via a UDP socket to the DTLS server:

s.sendto(bytes(p), (ip, port))

However examining the Wireshark trace and the output of p.show2() shows, that the fragment_offset field of the DTLSHandshake layer get's initialized to x = len(pkt.payload) in the i2m function. This is not right as the RFC states:

fragment_offset (the number of bytes contained in previous fragments)

and no previous fragments have been sent.

Any help appreciated.

Cheers Skllrn

4Kp3n avatar Aug 01 '18 14:08 4Kp3n

Hi @skllrn,

thanks for raising this issue. I haven't yet looked into this but would you be able to provide a PR fixing this?

cheers, tin

tintinweb avatar Aug 12 '18 18:08 tintinweb

Hey @tintinweb,

thanks for the reply.

In order to calculate the fragment_offset one would have to inspect the package, determine if the payload is bigger than the networks MTU and split the payload accordingly onto multiple DTLSRecords.

It would be neccessary to make sendall in TLSSocket do these splits and calculate the three affected fields

length fragment_length fragment_offset

of the DTLSHandshake object accordingly. The recvall function in contrast should detect the fragments, buffer them and reasemble when all fragements are received.

Not sure I can do it without guidance but I'll have a try.

Cheers, skllrn

4Kp3n avatar Aug 23 '18 10:08 4Kp3n