pkg/tinydtls/contrib/sock_dtls: fix ep_to_session#17849
pkg/tinydtls/contrib/sock_dtls: fix ep_to_session#17849miri64 merged 1 commit intoRIOT-OS:masterfrom
Conversation
|
Niiice, will test if this takes care of the random handshake problems I had during my DoC evaluation once I am back from IETF (or if I find a quiet minute during IETF)! |
Do you have some references for that? The only doc on that I found was for the POSIX-version where the port is included in I still have problems establishing a session over CoAPS from a RIOT client to an Maybe the proper fix could be, to change tinydtls so that the In any case, I think |
|
Here is an excerpt from the log output of the Detailsand here is the |
The reason the handshake was failing in my case was because of an inconsistency in the cookie creation, because in these lines the hmac is updated with the address, and the size used was larger than the address. The two extra bytes messed the cookie creation randomly. https://github.com/eclipse/tinydtls/blob/706888256c3e03d9fcf1ec37bb1dd6499213be3c/dtls.c#L338-L339
Will change to this |
To be clear, since the #include <stdint.h>
#include "net/ipv6/addr.h"
typedef struct {
unsigned char size;
struct {
ipv6_addr_t addr;
uint16_t port;
} addr;
int ifindex;
} session_t;in the |
Maybe @obgm can help here 😅 |
I think the cookie creation is not the problem I face, the server reports the cookie as valid, if I enable DEBUG there: Details |
|
It makes sense to include the port for the cookie creation, this should be done as @miri64 proposes. I'll update this PR to add a patch to the package, and also make the PR with the same change upstream. |
See also doc on |
|
Thank you for clearing that up @miri64 - i missed thinking of socket-addr as addr + port (or some other complete location information of the other end of the connection) |
|
Turns out there already was a function to initialize the session, and sets the |
cd980d4 to
bca4f81
Compare
|
Upstream PR at eclipse-tinydtls/tinydtls#127 |
|
I'm fine with the changes, how they are at the moment. My faults indicate, that there is most likely yet another overflow somewhere, but that's a challenge for another day. Please squash. |
1590e50 to
981e4aa
Compare
981e4aa to
53b6aba
Compare
|
CI failed because I did not update the example to the new structure. It should be fixed now |
|
Murdock is green, not sure what's up with the other checks |
|
I guess another Github outage? Could you force-push? |
53b6aba to
05db36a
Compare
Yes, that's the way I left some comments in the tinydtls PR. |
Contribution description
The size field in the session_t structure should reflect the size of the addr field for the particular OS. This was producing random errors when calculating the client_hello cookie, because the address is part of the hash, and the length used to update the
sha256_updatefunction was set to 18.Testing procedure
dtls_sockapplication should work reliably.Issues/PRs references
None