RIOT
RIOT copied to clipboard
net/sock_dtls: add public key verification
Contribution description
This adds a pseudomodule to enable public key verification of peers. When sock_dtls_verify_public_key
is enabled the public key sent by the peer is checked against the registered keys on the corresponding sock. The implementation for tinydtls is added, as well as the corresponding changes to use it on the dtls-sock
example.
Testing procedure
Run examples/dtls-sock
with ECC enabled, the public key should be verified. You can try removing the server's public key from the client, the connection should be aborted.
Issues/PRs references
Loosely related to #19838
I'm wondering whether this feature should actually be opt-out instead.
Murdock results
:heavy_check_mark: PASSED
6d9a9a35a75e4f2bce12b61ae0e1f4c6d0f91adc examples/dtls-sock: cleanup credentials
Success | Failures | Total | Runtime |
---|---|---|---|
10009 | 0 | 10009 | 07m:27s |
Artifacts
I found the code in the example to be confusing due to naming of the key variables and lack of comments. If you want to go the extra mile and and a bit of ✨ that would be neat but totally optional for this PR.
I gave it a try. It's still not perfect, but I think much clearer. I tried clearly splitting both sets of credentials. A bonus: now the client can actively use the PSK hint to decide on the key to use.
This needs a rebase
Rebased. I also modified a bit the example: the server only stores one client public key, but has two key pairs. It allows the user to select which one to use on the handshake. As the client knows both public keys form the server, any will work. I think this showcases a bit better the usage of the callbacks and multiple credentials. I also updated the docs including this and the new command.
This is great! Way easier to understand!
Could you fix the format issues in the *credentials.h
files?
Don't forget to squash!
Fixed and squashed!
Ping?
Thanks for the review!