DTLSHandshake 'fragment_offset' field initialized incorrectly
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
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
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