1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

11289 Commits

Author SHA1 Message Date
Marian Buschsieweke
68beb52f14
sys/net/nanocoap: add and use coap_get_response_hdr_len()
Before, handlers writing blockwise transfer assumed that the response
header length will match the request header length. This is true for
UDP, but not for TCP: The CoAP over TCP header contains a Len field,
that gets extended for larger messages. Since the reply often is indeed
larger than the request, this is indeed often the case for CoAP over
TCP.

Note: Right now, no CoAP over TCP implementation is upstream. However,
      getting rid of incorrect assumptions now will make life easier
      later on.
2024-11-05 10:46:02 +01:00
Marian Buschsieweke
2c93dc9c3b
sys/net/nanocoap: fix coap_build_reply_header()
In case no payload is added, `coap_build_reply_header()` would return
`sizeof(coap_hdr_t) + token_length` regardless of the actual header
length returned by `coap_build_hdr()`. These can be different if
RFC 8974 extended tokens are enabled (module `nanocoap_token_ext`
used): If an extended token length field is used, its size is not
considered.

Co-authored-by: benpicco <benpicco@googlemail.com>
2024-11-04 21:18:07 +01:00
Marian Buschsieweke
765dc3a299
sys/net/gcoap: reduce insanity of hack
gcoap contains a hack where a `coap_pkt_t` is pulled out of thin air,
parts of the members are left uninitialized and a function is called on
that mostly uninitialized data while crossing fingers hard that the
result will be correct. (With the current implementation of the used
function this hack does actually work.)

Estimated level of insanity: 😱😱😱😱😱

This adds to insane functions to get the length of a token and the
length of a header of a CoAP packet while crossing fingers hard that
the packet is valid and that the functions do not overread.

Estimated level of insanity: 😱😱😱

The newly introduced insane functions are used to replace the old
insane hack, resulting in an estimated reduction of insanity of 😱😱.

Side note: This actually does fix a bug, as the old code did not take
           into account the length of the extended TKL field in case of
           RFC 8974 being used. But that is a bug in the abused API,
           and not in the caller abusing the API.
2024-11-01 16:32:59 +01:00
Marian Buschsieweke
469edf4827
sys/net/nanocoap: fix coap_get_total_hdr_len()
Before `coap_get_total_hdr_len()` did not take the extended TKL field
(RFC 8974) into account. This fixes the issue.
2024-11-01 13:58:34 +01:00
Armin Wolf
94f2b82ede sys/psa_crypto: Fix definition of PSA_ALG_IS_WILDCARD
A definition of PSA_ALG_HASH_ANY does not exist, use
PSA_ALG_ANY_HASH instead.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-10-29 17:57:56 +01:00
Armin Wolf
e713b3d863 sys/psa_crypto: Add HKDF-Extract/-Expand key derivation algorithms
The PSA crypto API specification 1.1.1 introduced two new algorithms
for HKDF. Add support for those.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-10-29 17:57:01 +01:00
Armin Wolf
b17402bc9f sys/psa_crypto: Split algorithm definitions into separate files
Split definition of psa_algorithm_t into a separate file, together
with some basic algorithm macros. Also move the definitions of the
hash/mac/cipher/AEAD/etc algorithm macros into separate files as
well.

This allows PSA crypto backends to use this definitions without
pulling in all the other type definitions.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-10-29 17:52:54 +01:00
mguetschow
00e25adfe3
Merge pull request #20720 from netd-tud/chacha20-glue-code-implementation
sys/psa_crypto: one-shot Chacha20 support
2024-10-29 16:52:30 +00:00
benpicco
1fc9d1bb82
Merge pull request #20934 from LasseRosenow/pthread-attr-setstack
sys/posix/pthread: Add pthread_attr_getstack and pthread_attr_setstack
2024-10-29 16:17:51 +00:00
Lasse Rosenow
459b8dc6aa
sys/posix/pthread: Add pthread_attr_getstack and pthread_attr_setstack 2024-10-29 13:29:54 +00:00
Marian Buschsieweke
02e059546f
Merge pull request #20944 from maribu/sys/usbus/stable-ids
sys/usb: Use luid_base for stable USB serials
2024-10-29 09:10:31 +00:00
Marian Buschsieweke
6b80a1a61e
sys/usb: Use luid_base for stable USB serials
This is useful when having multiple instances of the same board
connected via USB CDC ACM and telling the TTYs apart.
2024-10-29 09:40:22 +01:00
Marian Buschsieweke
49c151e432
sys/luid: luid_custom() use fixed width int
This changes the type of the last parameter of `luid_custom()` to a
fixed width integer for consistent behavior among different
architectures.
2024-10-28 14:51:44 +01:00
Teufelchen
b376bec667
Merge pull request #20847 from benpicco/event_assert
sys/event: add assertion that event has a handler
2024-10-25 08:11:51 +00:00
Marian Buschsieweke
ba83fefe3b
Merge pull request #20936 from maribu/drivers/periph_gpio/gpio_read/bool
drivers/periph_gpio: let gpio_read() return bool
2024-10-24 20:43:55 +00:00
benpicco
ae36fa4b37
Merge pull request #20921 from Vjorald/cord-doc
sys/net/app/cord: update doc
2024-10-24 16:59:01 +00:00
mguetschow
fbde0209d1
Merge pull request #20933 from benpicco/sys/net/application_layer/gcoap-ipv4
gcoap: fix build with IPv4
2024-10-24 09:28:23 +00:00
Marian Buschsieweke
7d1313b3bf
treewide: update rust-riot-wrappers 2024-10-24 09:57:36 +02:00
benpicco
87c825dd82
Merge pull request #20915 from fabian18/pr/gcoap_forward_proxy_timeout
gcoap/forward_proxy: handle timeout case
2024-10-23 21:58:57 +00:00
Benjamin Valentin
ce6d753aa1 gcoap: fix build with IPv4 2024-10-22 14:04:20 +02:00
benpicco
c48247f984
Merge pull request #20916 from derMihai/mir/event_sync_mainline
sys/event: add event_sync()
2024-10-21 09:55:56 +00:00
Vjorald
d2600f8eff cord/doc: Remove the label (Not Yet Implemented) and the group part
Co-authored-by: chrysn <chrysn@fsfe.org>
2024-10-18 23:55:07 +02:00
Vjorald
d4fb64cfbc cord/doc: Update references to RFC 9176 2024-10-18 23:52:35 +02:00
Joshua DeWeese
45942f6821 sys/ztimer: fix re-scheduling of timers
If the timer at the head of a ztimer clock's timer list is re-scheduled
(ztimer_set() called on an already set timer) and the timer is no longer
at the head after being re-scheduled, clock-ops->set() is never called
from inside ztimer_set(), and the underlying timer is left with an ISR
scheduled to expire at the timer's old time. The intended behavior is
that the clock's lower level timer should always be set to expire at the
time of the clocks head timer.

This patch changes ztimer_set() to call _ztimer_update(), which sets the
lower level timer according to the current list of timers, rather than
setting the timer directly inside of ztimer_set().
2024-10-18 14:52:11 -04:00
Mihai Renea
9996909b65 sys/event: add event_sync() 2024-10-18 13:14:04 +02:00
benpicco
ed9c6a2e47
Merge pull request #20919 from chrysn-pull-requests/rust-updates
treewide: Update Rust dependencies
2024-10-18 09:36:21 +00:00
benpicco
bada659375
Merge pull request #20918 from maribu/sys/net/nanocoap/coap_pkt_set_code
sys/nanocoap: add coap_pkt_set_code()
2024-10-17 16:02:19 +00:00
chrysn
bb3520fff0 treewide: Update Rust dependencies 2024-10-17 16:20:26 +02:00
Marian Buschsieweke
f16875b6ec
sys/nanocoap: add coap_pkt_set_code()
This adds a small convenience function to set the CoAP code of a packet
and converts users of coap_hdr_set_code() where applicable.
2024-10-17 14:56:54 +02:00
Marian Buschsieweke
835571c0a7
sys/net/nanocoap: fix UB when building hdr
Some calls to `coap_build_hdr()` were done with the target buffer for
the header and the source buffer for the token overlapping:
They reuse the buffer that held the request to assemble the response in.
We cannot use `memcpy()` in this case to copy the token into the target
buffer, as source and destination would (fully) overlap.

This commit makes reusing the request buffer for the response a special
case: `memcpy()` is only used to copy the token if source and
destination address of the token differ.

An alternative fix would have been to use `memmove()` unconditionally.
But `memmove()` does not make any assumption about the layout of target
and source buffer, while we know that the token either will already be
at the right position (when reusing the request buffer for the response)
or be in a non-overlapping buffer (when generating a fresh token). This
approach is more efficient than `memmove()`.
2024-10-17 14:02:06 +02:00
Wunderbaeumchen
b9396c4739 sys/psa_crypto: chacha20 oneshot gluecode 2024-10-17 10:25:59 +02:00
Fabian Hüßler
224fdb2294 gcoap/farward_proxy: handle timeout case 2024-10-16 16:10:28 +02:00
benpicco
3706589959
Merge pull request #20834 from derMihai/mir/nib/drop_for_unreachable_rebase
gnrc/ipv6/nib: don't queue packets on 6lo neighbors and drop/flush if…
2024-10-16 09:16:40 +00:00
Mihai Renea
3a5612ee57 gnrc/ipv6/nib: don't queue packets on 6lo neighbors and drop/flush if UNREACHABLE 2024-10-16 09:01:36 +02:00
benpicco
9123b5e8c6
Merge pull request #20911 from fabian18/pr/event_periodic_no_delay
sys/event: add API to start periodic event without initial delay
2024-10-15 22:13:00 +00:00
Fabian Hüßler
90473c62f0 sys/event: add event_periodic_start_now() 2024-10-14 21:17:38 +02:00
Fabian Hüßler
2b682585a7 sys/ztimer: add ztimer_periodic_start_now() 2024-10-14 21:15:50 +02:00
Marian Buschsieweke
71b91a1d0e
sys/net/gcoap_forward_proxy: fix compilation issues 2024-10-14 14:30:20 +02:00
Marian Buschsieweke
54f4cd7cd1
sys/matstat: fix compilation with newlib
newlib (nano) does not support 64 bit types (neither in stdio nor with
corresponding `PRI*64` macros). With GCC 13.2.1 (as shipped in Ubuntu
24.04.1 LTS), this triggers the following compilation error (even with
`ENABLE_DEBUG == 0`):

    sys/matstat/matstat.c:57:21: error: expected ')' before 'PRIu64'
       57 |     DEBUG("Var: (%" PRIu64 " / (%" PRId32 " - 1)) = %" PRIu64 "\n",
          |                     ^~~~~~

This fixes the issue by falling back to printing 32 bit values when
the `PRIu64` macro is not defined. A `!trunc` is appended when the
64 bit exceeds the range of [0:UINT32_MAX].
2024-10-09 22:23:40 +02:00
Mikolai Gütschow
f0e6776d40
treewide: apply codespell corrections 2024-10-09 13:03:52 +02:00
mguetschow
a54ba26285
Merge pull request #20893 from benpicco/THREAD_CREATE_STACKTEST-cleanup
treewide: clean up remnants of THREAD_CREATE_STACKTEST
2024-10-08 09:55:52 +00:00
Benjamin Valentin
97128eef48 treewide: clean up remnants of THREAD_CREATE_STACKTEST 2024-10-07 17:31:31 +02:00
chrysn
13188e13f2
Merge pull request #20887 from chrysn-pull-requests/fmt
static_tests: Add test for Rust code formatting rules
2024-10-04 08:24:07 +00:00
benpicco
248371e11a
Merge pull request #20881 from Teufelchen1/fix/rpble
bluetil: Ensure advertisement length does not exceed pkt len
2024-10-03 12:50:32 +00:00
benpicco
8a933a56ae
Merge pull request #20882 from Teufelchen1/fix/dhcpv6
net/dhcpv6: Improve option parsing in dhcpv6 advertise
2024-10-03 12:50:12 +00:00
chrysn
69a89b80ca treewide/rust: cargo fmt 2024-10-02 22:17:08 +02:00
Teufelchen1
f88285de75 net/dhcpv6: Improve option parsing in dhcpv6 advertise 2024-10-02 09:47:22 +02:00
Teufelchen1
84f1ae3635 bluetil: Ensure advertisement length does not exceed pkt len 2024-10-01 14:49:09 +02:00
Teufelchen1
51537908d1 gnrc_lorawan: Ensure minimal packet length 2024-10-01 12:11:05 +02:00
Marian Buschsieweke
4f15523741
Merge pull request #20879 from benpicco/gnrc_sixlowpan_frag-gnrc_netif_pktq
gnrc_sixlowpan_frag: enable `gnrc_netif_pktq` if `netdev_new_api` is used
2024-09-30 14:00:33 +00:00
Benjamin Valentin
0b99d4fffe gnrc_sixlowpan_frag: enable gnrc_netif_pktq if netdev_new_api is used 2024-09-30 14:07:35 +02:00
benpicco
9bdb697edb
Merge pull request #20857 from benpicco/dns_msg-fix_skip
dns_msg: skip RDLENGTH_LENGTH field when skipping record
2024-09-27 15:57:17 +00:00
Ollrogge
9c6051b0d3 fido2: Change public api && return ctap_status_code_t instead of int 2024-09-27 07:32:00 +02:00
Ollrogge
efcbc1eab8 fido2/ctap_hid: remove dependency on ztimer64 2024-09-27 07:31:59 +02:00
Mihai Renea
b7eee2c8b7 event/timeout: event_timeout_set() enqueues immediately if timeout is zero 2024-09-25 10:00:58 +02:00
benpicco
5c06502c4d
Merge pull request #20835 from xnumad/nib-route-hide-on-link-prefixes
gnrc/ipv6: `nib route`: hide off-link PLEs
2024-09-24 15:42:48 +00:00
xnumad
92b77ed944 gnrc_ipv6_nib: refactor
Co-Authored-By: benpicco <benpicco@googlemail.com>
2024-09-18 16:09:58 +02:00
mguetschow
5d958957be
Merge pull request #20854 from netd-tud/psa-headers
Various PSA Crypto fixes
2024-09-18 08:10:44 +00:00
Armin Wolf
fe56b7d19c sys/psa_crypto: Implement PSA_MAC_MAX_SIZE()
This support macro is necessary for full MAC support.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-09-17 21:37:10 +02:00
Armin Wolf
98d268040a sys/psa_crypto: Implement PSA_HASH_BLOCK_LENGTH()
The initial implementation was inspired by MbedTLS, with the
addition of the MD2 and MD4 algorithms.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-09-17 21:37:10 +02:00
Marian Buschsieweke
1fa7db2eda
Merge pull request #20855 from benpicco/coap_block_finish-fix
nanocoap: always write at least 1 byte in coap_block2_finish()
2024-09-12 15:01:19 +00:00
Benjamin Valentin
344d4b80bf sock_dns: add debug output 2024-09-12 11:00:41 +02:00
Benjamin Valentin
bc2ad626f3 dns_msg: rename addrlen -> rdlen 2024-09-12 11:00:41 +02:00
Benjamin Valentin
305b5db4eb dns_msg: add debug output 2024-09-12 11:00:41 +02:00
Benjamin Valentin
74356c9737 dns_msg: skip RDLENGTH_LENGTH field when skipping record
fixes #20355
2024-09-12 11:00:41 +02:00
Fabian Hüßler
02e513e04b sys/include/net: better documentation of nanocoap_sock_request_cb 2024-09-10 16:44:19 +02:00
Fabian Hüßler
95b46ee2a5 sys/net/application_layer/nanocoap: add nanocoap_sock_get_non 2024-09-10 16:43:44 +02:00
Benjamin Valentin
66fe083d9b nanocoap: always write at least 1 byte in coap_block2_finish()
The CoAP block option gets written twice:
First a 'dummy' value is written by `coap_opt_add_block2()`, later this gets
overwritten by the real option value by coap_block2_finish().

The problem arises when the size of the option changes.
If the option ends up smaller than the dummy, we have garbage bytes after the
real option value, corrupting the packet.

To mitigate this, always write at least one option byte (which will be a 0 byte)
to ensure the dummy data is overwritten.

fixes #20686
2024-09-07 16:11:23 +02:00
Armin Wolf
82b07318ec sys/psa_crypto: Fix missing usage flags when creating new keys
The PSA crypto specification states that when creating keys,
the usage flags PSA_KEY_USAGE_SIGN_HASH/PSA_KEY_USAGE_VERIFY_HASH
automatically set the usage flags
PSA_KEY_USAGE_SIGN_MESSAGE/PSA_KEY_USAGE_VERIFY_MESSAGE on the key.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-09-07 12:12:22 +02:00
Armin Wolf
d0c4e01ca3 sys/psa_crypto: Move PSA status definition to separate file
When psa_status_t is defined inside crypto_types.h, then all
users of psa_status_t are forced to pull the full range of PSA
Crypto API type definitions.

This however means that psa_status_t cannot be used when defining
those PSA Crypto API types, since doing so would create a cycle.

Fix this by moving the PSA status definitions into a separate header
file which additionally is compatible with the PSA Status code API.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-09-07 12:12:19 +02:00
benpicco
73e90c5049
Merge pull request #20371 from xnumad/nib-next-hop-addr
gnrc_ipv6_nib: Force unspecified next hop addresses
2024-09-02 12:13:28 +00:00
xnumad
8b73628dc8 gnrc_ipv6_nib: refactor
Invert condition, add assert
2024-08-31 10:40:17 +02:00
Benjamin Valentin
16c447afb1 gcoap: make use of event_callback_post() 2024-08-29 17:35:54 +02:00
Benjamin Valentin
6177380762 event_periodic_callback: add assertion that event has a handler 2024-08-29 17:20:16 +02:00
Benjamin Valentin
10f28b873e sys/event_callback: add event_callback_post() 2024-08-29 17:19:43 +02:00
Benjamin Valentin
18e6eaca00 sys/event: add assertion that event has a handler 2024-08-29 17:19:13 +02:00
benpicco
022630c043
Merge pull request #20836 from benpicco/sys/gcoap-thread_name
gcoap: the name of the gcoap thread should be gcoap
2024-08-27 08:56:50 +00:00
xnumad
606a11b87d gnrc_ipv6_nib: fix: offl-only: overwrite unspecified address
Co-Authored-By: fabian18 <15147337+fabian18@users.noreply.github.com>
2024-08-26 18:26:57 +02:00
xnumad
48a2417892 gnrc/ipv6: nib route: hide off-link PLEs 2024-08-26 16:30:58 +02:00
benpicco
1626919da7
Merge pull request #20684 from fabian18/pr/fix_gcoap_observe_response_correlation
sys/net/application_layer/gcoap: fix Observe notifications correlation
2024-08-26 14:11:59 +00:00
Benjamin Valentin
f95dc978fa gcoap: the name of the gcoap thread should be gcoap 2024-08-26 15:44:26 +02:00
benpicco
73581fa56e
Merge pull request #20784 from ML-PA-Consulting-GmbH/dl/riot/20240715__nib__static_ll_addr_excludes
nib.c: add interface selection rules for static link local address assignment
2024-08-26 09:59:44 +00:00
Daniel Lockau
7240d37fc2 nib.c: allow selection of interfaces for static link local addresses 2024-08-26 08:31:21 +02:00
chrysn
ea40036529 rust: Update all locked versions
This pulls in several updates for which there is no urgent need, but
also no good reason *not* to do them (especially as they may contain bug
fixes, even critical ones).
2024-08-22 17:49:39 +02:00
chrysn
2ef929369f rust: Update locked riot-wrappers and riot-example-modules versions 2024-08-22 17:49:25 +02:00
chrysn
c0288f7d40 rust: Update to riot-wrappers 0.9 2024-08-22 17:33:40 +02:00
Fabian Hüßler
a181c7b543 sys/gcoap: add public function to find a resource by path 2024-08-21 17:49:48 +02:00
Fabian Hüßler
c1535d25ba nanocoap: constify coap_match_path() API 2024-08-21 17:49:48 +02:00
Fabian Hüßler
08f6ec49c4 gcoap: lock CoAP state mutex in observe API 2024-08-21 17:49:48 +02:00
Fabian Hüßler
a2a7f41a59 gcoap: send Observe notifications from request address 2024-08-21 17:34:18 +02:00
Fabian Hüßler
04d95ab0e8 gcoap: debug for _find_req_memo_by_token() 2024-08-21 17:34:18 +02:00
chrysn
a26366371d sys/ztimer: Remove the deprecated ztimer_now64
This has been scheduled for removal after 2022.10, and its replacement
ztimer64_now has long been available.
2024-08-20 20:52:37 +02:00
Fabian Hüßler
0614db9cd5 sys/net/application_layer/gcoap: fix Observe notifications correlation 2024-07-31 23:01:17 +02:00
Martine Lenders
11ea4a359d
Merge pull request #20801 from Teufelchen1/fix/dhcpv6
net/dhcpv6: Improve option handling in dhcpv6 advertise
2024-07-31 07:51:42 +00:00
Bennet Blischke
cc9855b3ae net/dhcpv6: Improve option handling in dhcpv6 advertise 2024-07-30 19:21:09 +02:00
Teufelchen
1e6164fd68
Merge pull request #20549 from chrysn-pull-requests/gcoap-asan
gcoap: Avoid reading beyond defined input buffer
2024-07-30 10:13:41 +00:00
mguetschow
fe3a4e24a1
Merge pull request #20798 from benpicco/gcoap-fix-guards
net/gcoap: fix guards around defines
2024-07-30 08:13:06 +00:00
xnumad
3ab7896b18 gnrc_ipv6_nib: Force unspecified next hop addresses 2024-07-29 20:10:13 +02:00
Benjamin Valentin
2aaaf6df9e net/gcoap: fix guards around defines 2024-07-29 19:04:15 +02:00
benpicco
9781bc0ad3
Merge pull request #20757 from xnumad/offl-lifetimes
gnrc/ipv6: Store all SLAAC prefixes
2024-07-29 14:06:22 +00:00