Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
dtls: Support DTLS 1.2 Connection IDs
Browse files Browse the repository at this point in the history
Add a new Kconfig option for using DTLS 1.2 Connection IDs.

Set the connection ID socket option when the connection
ID Kconfig option is set.

Signed-off-by: Sam Friedman <sam@golioth.io>
  • Loading branch information
sam-golioth committed Nov 1, 2023
1 parent 7f828df commit 84413b0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/golioth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ module = GOLIOTH
module-str = golioth
source "subsys/logging/Kconfig.template.log_config"

config GOLIOTH_USE_CONNECTION_ID
bool "Use DTLS 1.2 Connection IDs"
select MBEDTLS_SSL_DTLS_CONNECTION_ID
help
Use DTLS 1.2 Connection IDs. Connection IDs replace IP
addresses as the session identifier, and can be used to
reduce the number of handshakes a device has to make in
certain scenarios.

choice GOLIOTH_AUTH_METHOD
prompt "Authentication method support"

Expand Down
12 changes: 12 additions & 0 deletions net/golioth/golioth.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ static int golioth_setsockopt_dtls(struct golioth_client *client, int sock,
}
}

/* If Connection IDs are enabled, set socket option to send CIDs, but not require that the
* server sends one in return.
*/
#ifdef CONFIG_GOLIOTH_USE_CONNECTION_ID
int enabled = 1;

ret = zsock_setsockopt(sock, SOL_TLS, TLS_DTLS_CID, &enabled, sizeof(enabled));
if (ret < 0) {
return -errno;
}
#endif /* CONFIG_GOLIOTH_USE_CONNECTION_ID */

return 0;
}

Expand Down
13 changes: 13 additions & 0 deletions samples/hello/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ tests:
- CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y
- CONFIG_MBEDTLS_CIPHER_MODE_CBC_ENABLED=n
- CONFIG_GOLIOTH_CIPHERSUITES="TLS_PSK_WITH_AES_128_CCM_8"
sample.golioth.hello.psk.fast.cid:
platform_allow: >
esp32_devkitc_wroom
mimxrt1060_evkb
nrf52840dk_nrf52840
qemu_x86
extra_configs:
- CONFIG_GOLIOTH_USE_CONNECTION_ID=y
sample.golioth.hello.psk.long_start.cid:
platform_allow: nrf9160dk_nrf9160_ns
timeout: 120
extra_configs:
- CONFIG_GOLIOTH_USE_CONNECTION_ID=y
sample.golioth.hello.psk.long_start:
platform_allow: nrf9160dk_nrf9160_ns
timeout: 120
Expand Down

0 comments on commit 84413b0

Please sign in to comment.