-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sock_dtls: a DTLS sock API #10897
Comments
Sounds perfect for me 👍 Sadly, I was unable to retake my work with my original approach on the last months. I'll try to help with this new approach. |
Thanks for pursuing this! The API looks good at this level: send/recv functions as a wrapper for the underlying UDP sock, with additional setup/teardown infrastructure. The timeout parameter for sock_dtls_recv() is essential for gcoap, as is the ability to interrupt it when listening indefinitely. (The ability to interrupt probably is part of #8149.) I suggest developing a very simple end to end implementation to get a feel for how the API works for applications. |
You also might want to look at OSCORE, and the recently open sourced c_OSCORE embedded implementation [1,2]. From an application perspective it would be nice if there was some commonality with a DTLS based approach, but I don't know if that is feasible. [1] https://datatracker.ietf.org/doc/draft-ietf-core-object-security/ |
OSCORE and DTLS are very different approaches to communication encryption (one is on the application layer, one is on the transport layer). For now we should focus to have a common API to one protocol and then the other and then it might make sense to have a common API for both on top of this. But I don't think that we should mix those two on the very entry level into the protocol. Otherwise, we risk getting too complicated and too overengineered. |
I agree on starting simply, @miri64! Perhaps the most valuable API comparison between DTLS and OSCORE would be at the level of message encryption/decryption. |
Well to begin with OSCORE is more about encrypting the payload of a CoAP message (across different CoAP domains), while DTLS is about encrypting the payload of a UDP datagram (or datagrams of other protocols like DCCP or SCTP), so how it would interact with CoAP would already be pretty different (and in OSCORE's case as far as I understand pretty CoAP-specific). |
I opened a PR #11177 with latest draft and initial TinyDTLS implementation of the API. Changes since last initial draft:
First post will be updated. Following is what I'm considering right now and hope to get some feedback before I proceed with it:
void sock_dtls_init_server(sock_dtls_t *sock); Just leaving my thoughts out here. Removing the queue will also mean that |
Thanks for the tip. I updated the OP with the checklist and deleted my comment with the list to avoid confusion. |
Update: #11909 is now merged. OP updated. |
@pokgak what are your plans going forward on this? |
I'm currently integrating the new async dtls into gcoap but it'll be a bit slow as I can't focus on this much. Currently, I can already send a simple coap message with some dirty changes here and there. I'll work on making separate PRs for this changes. Current progress can be tracked here. |
Is this still on the table? |
Yes. I do have a somewhat working implementation here before I got sidetracked by other things. That will require a refactor now that sock dtls API is a lot more different now. |
@janosbrodbeck since you basically already picked up "Add DTLS integration for gcoap using DTLS sock", might there be a way to coax you into also looking into implementing |
Or maybe @fjmolinas, who I know, is also doing |
Coaxing would not be necessary ;) But want to finish the DTLS integration first, I expect feedback and lots of change requests when the PR arrives.
But depends on what is really meant by it. Restoring an existing session from an endpoint? (tinydtls seems to store some context internally - but just did a quick look into tinydtls last week). Would like to have a look at it before. |
@pokgak Are you planning on continuing your work on that wolfSSL implementation? If not maybe I will find some time to pick up your work. |
This issue will be used to track the current status of DTLS sock implementation and integration with gcoap. I'll try to keep it updated.
DTLS Sock TODO List
Extend credman to handle the second use case as described in this comment - Not started yetDone by extending library API e.g.gcoap_set_credential_tag()
gcoap_init()
from autoinit - gcoap: add lazy init mode #12529 replaced by net/gcoap: add macro to delay initialization of gcoap #12798sock_dtls_session_t
from asock_udp_ep_t
and vice-versaDescription
sock_dtls
aims to provide a wrapper around DTLS stack in RIOT so that users can choose the underlying stack by aUSEMODULE
in the Makefile.I am aware of @rfuentess's sock_secure and @danielinux's wolfSSL effort and have reviewed it together with @tcschmidt, @waehlisch, @miri64 (who also helps me with the API), @MichelRottleuthner and others (feel free to chime in if there is anything I missed/had it wrong here). This API hopes to solve the comments that we have, such as:
connect
,listen
in traditional socket has a different meaning when used in DTLS compared to TLS.sock_udp
internally.sock_dtls
is responsible for encrypting, decrypting of the packets and handshake. This should help by minimizing changes when integrating with existing applications such as gcoap.To implement this API, the implementors of stack must provide the definition the structs (like in sock_udp, sock_tcp) through the modules/pkgs.
Edit: The DTLS sock API is now merged in master. See
sys/net/sock/dtls.h
. Removed the API from this post for readability.The text was updated successfully, but these errors were encountered: