Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/tinydtls: auxiliary data API does not work for async sockets #16054

Open
janosbrodbeck opened this issue Feb 19, 2021 · 4 comments
Open

pkg/tinydtls: auxiliary data API does not work for async sockets #16054

janosbrodbeck opened this issue Feb 19, 2021 · 4 comments
Assignees
Labels
Area: network Area: Networking Area: pkg Area: External package ports Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@janosbrodbeck
Copy link
Member

janosbrodbeck commented Feb 19, 2021

This will most likely also affect the (WIP) port of wolfSSL.

Description

While #14706 works fine for synchronous DTLS sockets and is easily extensible, the aux API does not work for asynchronous DTLS sockets at all. The major problem lies in the way how async sockets work for DTLS:

aux_rx: When encrypted data is received on the underlying (also asynchronous) UDP socket, the internal _udp_cb() handles the incoming event. It hands the encrypted data over to tinydtls to decrypt it. After successful decrypt, tinydtls calls the _read()-function of the tinydtls riot port. This function receives the buffer holding the decrypted data, buffer len and the concerned session from tinydtls and sets it in provided fields in the associated DTLS socket. Now it finally fires the DTLS event for the user application. If the user now receives the data via sock_dtls_recv_aux() it just returns the previously set data in the socket. The aux object remains untouched.

aux_tx: No direct call of sock_udp_send_aux(), data is handed over to tinydtls and after encryption it calls _write() in the tinydtls riot port to send the data.

Expected results

Getting the requested aux fields

Actual results

Empty aux objects


The only fix that comes in my mind is similar how we "solved" #15755. Attach the aux objects to the socket and retrieve them after tinydtls has done it's job. For the aux_tx object this is easily doable without any potential problem afaik. But for the receiving aux object there would be no way to set custom aux_flags to determine which fields should be retrieved, since when the user event is fired the sock_udp_recv() has already been called. In this case we could only do all or nothing.

@maribu
Copy link
Member

maribu commented Feb 22, 2021

While #14706 works fine for synchronous DTLS sockets and is easily extensible, the aux API does not work for asynchronous DTLS sockets at all.

By asynchronous you mean using this API? https://doc.riot-os.org/group__net__sock__async__event.html

There is neither API nor implementation for retrieving auxiliary data via the async API (yet). So this is very much expected, isn't it?

@janosbrodbeck
Copy link
Member Author

While #14706 works fine for synchronous DTLS sockets and is easily extensible, the aux API does not work for asynchronous DTLS sockets at all.

By asynchronous you mean using this API? https://doc.riot-os.org/group__net__sock__async__event.html

Yes

There is neither API nor implementation for retrieving auxiliary data via the async API (yet). So this is very much expected, isn't it?

Oh, good point. Missed that the aux API does not yet support the async API. For UDP sockets it looked like it should work.

So I think we can close this for now.

@maribu
Copy link
Member

maribu commented Feb 22, 2021

Wait, on UDP it should and does work. I am even using this successfully in my PTP client. I will take a closer look when my kids are sleeping.

@maribu maribu reopened this Feb 22, 2021
@janosbrodbeck
Copy link
Member Author

janosbrodbeck commented Feb 22, 2021

Sorry, with UDP sockets I meant UDP sockets using the async API.

@jeandudey jeandudey added Area: network Area: Networking Area: pkg Area: External package ports Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) labels Mar 20, 2021
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 21, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: pkg Area: External package ports Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

5 participants