Commit Graph

343 Commits

Author SHA1 Message Date
Olaf Bergmann
0538a50a0d session.h: Move inclusion of string.h into .c files
string.h is required for memcmp() that is used in session.c and
dtls_debug.c. Therefore, the header file needs to be included
only in these two files.

Change-Id: I11db1c37a7cc13d8fa2826f6d3e38d3765f4a4ec
2023-07-12 12:39:29 +02:00
Achim Kraus
b82a72b816 Amend source formatting with rule for function definitions with multiple
lines.

See discussion in PR #184.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-04-24 13:21:08 +02:00
Jon Shallow
a5fa982aa5 dtls_prng_posix.c: Fix random() only support
Use of random() requires that _GNU_SOURCE is defined.
Cannot use variables named rand.

Make sure that dtls_prng.o is rebuilt whenever any of the
platform-specific/dtls_prng_*.c files are updated.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2023-04-24 11:31:29 +02:00
Jon Shallow
11c8e7d612 dtls.c: Reduce logging for unsupported tls extensions
Every unsupported tls extension is logged using dtls_warn(), and the default
logging level is set to DTLS_LOG_WARN.

Update logging call to dtls_notice(), to reduce logging output noise.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2023-04-24 11:30:34 +02:00
Achim Kraus
90ca321f0e Add cipher suite selection to test applications.
Introduce new cli argument -c.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-04-17 14:07:10 +02:00
Achim Kraus
9eb6780c4c Fix some typos and return values.
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-04-17 14:07:10 +02:00
Achim Kraus
f08802f93d dtls.c: add callback for peer specific selection of parameters as cipher
suites.

Adds dtls_user_parameters_t for these user parameters.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-04-17 14:07:10 +02:00
Achim Kraus
004aba8f7a dtls.c: add cipher_suite_param_t
Use cipher_suite_param_t for cipher-suite specific mac_len and
key_exchange_algorithm. Introduce dtls_cipher_index_t for simplified
cipher-suite parameter lookup. Cleanup old functions.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-04-01 10:29:04 +02:00
Achim Kraus
224aa865ea dtls.c: add support for CCM cipher suites.
Add cipher suites with full 16 byte MAC.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-04-01 10:29:04 +02:00
Achim Kraus
de74a02cb5 dtls.c: fix processing of alerts.
If alerts remove the peer, additional records need to be dropped.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-03-31 23:46:52 +02:00
Benjamin Valentin
5e14e4930b RIOT: make use od for hexdump 2023-02-25 14:37:17 +01:00
Achim Kraus
5477e6885b dtls_prng_posix.c: fail for posix without HAVE_GETRANDOM nor
HAVE_RANDOM.

Support random().
Add #error with explanation and hint to solve it.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-02-25 14:34:25 +01:00
Achim Kraus
86f23c65ff dtls-server.c: drop messages exceeding the buffer size.
Add function "is_command" and command "server:exit".

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-01-24 13:08:18 +01:00
Achim Kraus
efb9dc203e dtls-client.c: fix "buf" size error in "handle_stdin".
Replace the "sizeof(buf)" with passed in size.
Drop received messages exceeding the buffer size.
Introduced "buf_ready", true, if last character in "buf" is a newline.
Use "strstr" to detect command.
Add "client:exit" command.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-01-24 13:08:18 +01:00
Achim Kraus
0c4ddd0e1c dtls-server.c: apply source code formating.
Add license header.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-01-24 13:08:18 +01:00
Achim Kraus
5aca36f9c5 dtls-client.c: apply source code formating.
Add license header.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-01-24 13:08:18 +01:00
Achim Kraus
c58f484ac4 dtls.c: minor cleanup of cookie check.
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2023-01-21 11:14:01 +01:00
Benjamin Valentin
4cb6adcd58 RIOT: remove redundant CFLAGS
Those flags are already configured by the RIOT package.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2023-01-21 11:13:28 +01:00
Benjamin Valentin
8a36274474 RIOT: make use of log.h for dsrv_log()
Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2023-01-21 11:13:28 +01:00
Achim Kraus
fb1e746513 dtls.c: remove renegotiation.
Remove renegotiation also from test applications.
Complies with RFC7925, 17.  Renegotiation Attacks.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-12-07 16:16:51 +01:00
Benjamin Valentin
b9b5e2d49c global.h: enable constrained stack if DTLS_MAX_BUF is too large 2022-11-29 14:41:57 +01:00
Jan Romann
614297524d windows: move _CRT_RAND_S to tinydtls.h 2022-11-29 14:29:03 +01:00
Jon Shallow
c84e36ff60 LwIP: Fix unused parameter compiler warnings
Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-10-26 13:02:38 +02:00
Jon Shallow
70a2b397af dtls_debug: Add in support for separate logging handler
Allow the application to define a log handler callback to use to provide
consistency in the logging output logic.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-10-26 13:00:29 +02:00
Jon Shallow
cd02cad6c3 LwIP: Support LwIP builds when NO_SYS = 1
Follow the model of how things are done for Contiki.

Set up a new WITH_LWIP_NO_SOCKET (which happens with NO_SYS = 1)
and use this when setting up addresses.

Add in platform specific for dtls_prng_lwip.c and lwip_platform.h

Update dtls_time.[ch] to handle LWIP version of time.

Code works for NO_SYS = 1 or NO_SYS = 0.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-10-21 16:30:16 +02:00
Jon Shallow
1e1edc0da6 doc: Correct Doxygen information
Dynamically build DoxygenLayout.xml to get the latest layout for the current
version of doxygen.

Update Doxyfile.in to the Ubuntu20 version.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-10-05 11:00:50 +02:00
Jon Shallow
0bd943fc3e cmake: Convert files to unix format from dos format
Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-09-28 15:25:52 +02:00
Achim Kraus
f903906475 Fix cmake warnings of zephyr builds.
Exclude cmake options for zephyr builds, if these are set by zephyr.
Exclude file(CONFIGURE ..), if cmake is older than 3.18.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-09-28 14:27:46 +02:00
Jon Shallow
65ac5c3ca1 CMake: Force all Warnings to Errors when doing github actions
Add new option WARNING_TO_ERROR for CMakeLists.txt and tests/CMakelist.txt
and update github workflows to use it.

Do the cmake in a sub-directory.

Fix warnings generated by mac-os build in dtls.c and sha2.c.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-09-28 13:53:04 +02:00
Jan Romann
9320251212 Add Windows support 2022-09-27 14:31:54 +02:00
Jon Shallow
86f4988fc4 github: Add in build and test workflow
Unfortunately out of path builds do not work at present.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-08-08 09:55:21 +02:00
Achim Kraus
388888486a dtls.c: do not skip cipher suites and compression methods.
Do not skip cipher suites and compression methods in dtls_create_cookie,
as documented at the begin of the function.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-08-07 13:46:38 +02:00
Achim Kraus
3e5fdf6169 dtls.c: fix msglen check in dtls_create_cookie.
Add length of field to read next to the checks.
Ensure the msg is long enough to read that field.

Fixes: issue #134

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-08-07 13:43:43 +02:00
Jan Romann
efef18bf3c dtls: redefine dtls_write without static inline 2022-08-05 09:00:30 +02:00
Jan Romann
79b004f02b dtls.c: consider max identity length in DTLS_CKXEC_LENGTH 2022-08-05 08:51:29 +02:00
Benjamin Valentin
297fced854 dtls.c: introduce dtls_writev() 2022-07-28 12:17:19 +02:00
Achim Kraus
bda40789a7 dtls.c: consider data_length when processing incoming alert.
Ignore malformed alerts instead of process them as fatal_alert.

Fixes: Issue #136

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-07-23 06:53:39 +02:00
Jon Shallow
89fc1ce53c configure.ac: Fix with test for inet_ntop for building dtls_debug.o
Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-07-23 06:50:34 +02:00
Jon Shallow
e4aa73eed8 session.h: Support compiling for LwIP
Required for libcoap LwIP builds that need encryption.

Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
2022-07-23 06:50:20 +02:00
Achim Kraus
14e24b1b20 Improve slightly the logging in dtls_handle_message.
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-07-08 15:00:50 +02:00
Achim Kraus
16d3764191 Support zephyr.
Add initial support for zephyr.
Mutex is currently not supported, nor used.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-07-08 14:51:05 +02:00
Olaf Bergmann
f38f8b4ea5 dtls.c: Fix incomplete release of peer
In handle_0_verified_client_hello(), an existing peer is released and
replaced by a new peer object. To ensure that references to this peer
are cleared, dtls_destroy_peer() must be called.

Moreover, when handle_verified_client_hello() fails for the new peer
structure, dtls_destroy_peer() must be called for that peer as well to
ensure removal from the sendqueue. DTLS_DESTROY_PEER is specified to
indicate that the peer should not continue the handshake.

This issue has been reported by Shisong Qin.

Change-Id: I522ba03f93914d0c08aac5b810309c17cf660185
2022-07-07 12:54:58 +02:00
Olaf Bergmann
5c24c6c037 dtls.c: optionally suppress CloseNotify in dtls_destroy_peer()
The parameter unlink for dtls_destroy_peer() has been in use for
several years and therefore can be safely removed.
The third argument for dtls_destroy_peer() now is treated as
flags. The only value currently defined is DTLS_DESTROY_CLOSE to
indicate that the connection should be closed (no CloseNotify is sent
when the session is already closed or closing).

Change-Id: I752708b50d4fbe926802a6b1be44a898acb2d485
2022-07-07 12:01:20 +02:00
Achim Kraus
7657d28bd0 Merge pull request #151 from boaks/new_contribution_process
Add instructions for main and develop branch.
2022-07-06 14:42:10 +02:00
Achim Kraus
6e45467e28 README.md: truncate lines to at most 80 characters.
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-07-06 14:40:38 +02:00
Achim Kraus
a4b1ab6d87 CONTRIBUTING.md: add instructions for main and develop branch.
Reformat lines to fit into range 72-80 characters.
Removes "coding standards" from developer resources, it's not provider
there.
Removes "gerrit", it's not longer in use.
Replaces CLA by the new ECA.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-07-06 14:40:27 +02:00
Olaf Bergmann
667a538aaa dtls.c: fix off-by-one error in dtls_asn1_len()
For ASN.1 integers greater than 128 (i.e., with the most significant
bit set) the encoded length might exceed *data_len. The length check
is done upfront to ensure that the specified number of octets does
not exceed the actual *data_len.

This bug was reported by Shisong Qin.

Change-Id: Ica021b4783b718c7f4c2ffc4970e2dd9d9da453a
2022-07-06 13:08:02 +02:00
Achim Kraus
fce3372793 Merge pull request #146 from boaks/remove_obsolete_if
crypto.c: remove obsolete if.
2022-06-27 14:56:44 +02:00
Achim Kraus
d1a2dc4f90 Merge pull request #150 from boaks/fix_epl_1_0
Use EPL-1.0 for recently new files.
2022-06-27 14:55:29 +02:00
Achim Kraus
2749d5f522 Use EPL-1.0 for recently new files.
Currently tinydtls uses EPL-1.0 and mixing with EPl-2.0 is not
recommended. Therefore adjust the EPL-2.0 of new files to
EPL-1.0.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
2022-06-27 11:20:22 +02:00