Commit Graph
2858 Commits
Author SHA1 Message Date
Jon Shallow dae064c7e8 scan-build: Add scan-build into the workflow testing 2024-05-09 10:57:16 +01:00
Jon Shallow 4a94cc7c80 scan-build: Fix warnings 2024-05-09 10:57:16 +01:00
Jon Shallow d5a0d9c116 PKI: Add in coap_pki_key_define_t support to remaining TLS interfaces 2024-05-09 10:14:33 +01:00
Jon Shallow cec964e0b0 locking: Unlock context when calling request/response handlers
This is to reduce contention on the context lock when a request/response
handler takes time to get / update information.
2024-05-09 10:04:31 +01:00
Jon Shallow cd88fad218 coap_net.c: Silently drop incorrect CoAP version packets
As per https://datatracker.ietf.org/doc/html/rfc7252#section-3

Implementations of this specification MUST set this field to 1
(01 binary). Other values are reserved for future versions. Messages
with unknown version numbers MUST be silently ignored.
2024-05-09 09:58:40 +01:00
Jon Shallow 62a4934b6d coap_block.c: Use /.well-known/core when testing for Q-Block Support
It is possible the server does not support / resource, but does
support Q-Block - and responds with a 4.04, so Q-Block support
cannot be detected.
2024-05-06 10:50:30 +01:00
Jon Shallow a67426c655 coap_net.c: Tidy up Observe cancellation in coap_send()
If Observe cancellation is detected in sending pdu in coap_send()
invoke coap_cancel_observe() to to the necessary work.
2024-05-06 09:46:13 +01:00
Jon Shallow 9f9129cca8 OpenSSL: Add in support for configuring an alternative TLS ENGINE
Two new functions added

coap_tls_engine_configure()
coap_tls_engine_remove()

Added in new PKI key type coap_pki_key_define_t which allows the CA, Public Cert
and Private Key to be different types (e.g. PEM, DER etc.).

Added a new key type ENGINE to make use of the configured tls_engine.

Added in a -q option to coap-server and coap-client for testing ENGINE.

Note: ENGINE is only supported by OpenSSL.
2024-05-06 09:09:58 +01:00
kkrentz 466463304b Contiki-NG: Fix compilation error "unknown type name 'fd_set'" 2024-05-02 12:21:12 +01:00
Jon Shallow 9f1418e87d coap_block.c: Handle Block1 packets with random order block numbers
Add in new COAP_BLOCK_NOT_RANDOM_BLOCK1 option for
coap_context_set_block_mode(). This disables receipt of any Block1
packet (but not Q-BLock1) if the block numbers are not sequentially
received starting with 0.  A 4.08 code is returned for every packet
out of order and its data is ignored.

If COAP_BLOCK_SINGLE_BODY is set in coap_context_set_block_mode(),
but not COAP_BLOCK_NOT_RANDOM_BLOCK1, then all Block1 packets are
assembled in the correct order before passing the body up to the
application.  The receive logic will timeout after MAX_TRANSMIT_WAIT
(93 seconds) if there are any missing blocks, or 10 seconds if the
last block is seen.

If COAP_BLOCK_SINGLE_BODY is not set in coap_context_set_block_mode(),
and not COAP_BLOCK_NOT_RANDOM_BLOCK1, then the random order packets
are passed up to the application layer where it is the application's
responsibility to decide what to do with the randomly ordered packets,
and what response code to send.
2024-04-26 14:41:00 +01:00
Jon Shallow 758a341546 doc: Update coap_session_set_type_client() documentation 2024-04-25 14:52:44 +01:00
Jon Shallow 65f2f408be Build Tests: Fix Contiki build on macOS
Add libtool to the brew setup.
2024-04-25 14:46:07 +01:00
Jon Shallow ae438cb4bb man: Format examples as per CONTRIBUTION guidelines 2024-04-25 14:09:33 +01:00
Jon Shallow 749e16f6f6 Reporting: Encourage people to use github instead of mailing list 2024-04-23 16:43:17 +01:00
Jon Shallow c081bb6ffa doc: Tidy up documentation errors 2024-04-17 14:59:26 +01:00
Jon Shallow e3a662a934 wolfSSL: Set up initial port
Includes some porting ideas from qursa-uc3m libcoap-wolfssl work.

Some common ASN1 code moved from coap_gnutls.c to coap_asn1.c to support RPK.

WolfSSL build
$ ./configure --enable-all --enable-dtls13 CFLAGS="-DBUILD_TLS_PSK_WITH_AES_128_CCM -DHAVE_RPK"

Interoperability requirements

DTLS1.3 downgrade requires
https://github.com/eclipse/tinydtls/pull/230
https://github.com/wolfSSL/wolfssl/pull/7367

TLS1.3 downgrade requires
https://github.com/wolfSSL/wolfssl/pull/7367

(D)TLS1.2 use of RPK requires
https://github.com/wolfSSL/wolfssl/pull/7375

MbedTLS using TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 requires
https://github.com/wolfSSL/wolfssl/pull/7132

GnuTLS using PSK and TLS1.3 requires
https://github.com/wolfSSL/wolfssl/pull/7407
2024-04-16 11:03:24 +01:00
Jon Shallow 04b239f55a main.yml: Fix node.js 16 warnings 2024-04-03 13:32:15 +01:00
Jon Shallow c88c783aea RIOT: Modify Kconfig / app.config to remove dep model 2024-04-02 21:28:57 +01:00
Jon Shallow 214665ac4b coap_pdu.c: Fix UndefinedBehaviorSanitizer: undefined-behavior
This fixes a reported error in coap_update_token() where a size_t
calculation is overflowed (but all ends up with the correct value).

Instead of adding an overflowed size_t, now subtract the reversed
size_t calculation as appropriate.

coap_update_option() and coap_insert_option() similarily updated.
2024-03-26 17:40:43 +00:00
Jon Shallow 0a39b6c03b versioning: Make current configure.ac version available in CMakeLists.txt
Create a CMakeLists.txt.in copy of CMakeLists.txt containing LIBCOAP_*
skeletons where appropriate. When ./configure is run, CMakeLists.txt then
gets updated with the latest versioning ready for distribution and using.

CMake unfortunately does not handle, for example, 4.3.5rc1 (the rc1 suffix)
for the "project (libcoap VERSION xxx)", so this has to end up as 4.3.5
in CMakeLists.txt.
2024-03-20 11:25:29 +00:00
Jon Shallow e3f7dbeec8 doc: Support hyper-linking to defined structures for man pages 2024-03-15 09:04:52 +00:00
Jon Shallow b332a188e5 Coverity: Fix 1584343
Reorganize code in the coap_lock_lock_func().
2024-03-15 09:02:19 +00:00
Jon Shallow d4beecbbc5 coap_tinydtls.c: Debug log unencrypted sent/received traffic sizes 2024-03-14 16:34:29 +00:00
Jon Shallow 1bde6f6ce6 coap_config.h*: Make the various OS coap_config.h more consistent
Add in coap_config.h.contiki.in to aid versioning updates.

Make the PACKAGE_ definitions consistent.
2024-03-14 16:30:26 +00:00
Jon Shallow be37ebb806 Coverity: Fix 1584357, 1584358 and 1584359 2024-03-14 16:27:11 +00:00
Jon Shallow 547379a4d0 coap_io_process: Handle COAP_IO_WAIT properly 2024-03-14 16:24:31 +00:00
Jon Shallow 79840df101 Coverity: Fix 1583538, 1583565 and 1583573
For the test suite, treat these tests as using the public API so locking
is handled by the underlying libcoap.

The only exception is for coap_delete_node() which is an internal function
and expects context to be locked on entry.
2024-03-14 08:53:29 +00:00
Jon Shallow a637024fa1 coap_io.c: Fix client only builds for coap_socket_bind_udp 2024-03-13 11:54:03 +00:00
Jon Shallow e25cf94d2a RIOT: Update to use SOCK i/f, not Posix
Remove all references to Posix functions, using Sock functions as appropriate.

Update coap_address_t to be RIOT specific when doing RIOT builds.
2024-03-12 17:15:01 +00:00
Jon Shallow 11d8e7cd72 coap_net.c: Response PDU not set to CON if reliable protocol
Fix generated response PDU in handle_request() to be of type CON
if reliable protocol (as a lot of code assumes it to be of pseudo
type CON) to stop a warning in coap_show_pdu().
2024-03-11 10:21:24 +00:00
Jon Shallow db6409bb80 QNX: Add in build support
Support compiling QNX 7 SDK.
2024-03-06 12:17:35 +00:00
Jon Shallow 1039f05294 SO_VERSION: Bump LT_LIBCOAP_REVISION to match release-4.3.4-patches
This is to make the SO Version 3.1.2, to match that that of branch
release-4.3.4-patches and tag v4.3.4a.
2024-03-06 12:15:09 +00:00
Jon Shallow 25e434d883 configure.ac: Correct libtool documentation 2024-03-06 12:10:34 +00:00
Mihaela-Madalina Nuta 3e4358844d ESP32: Add platform support 2024-03-04 11:29:16 +00:00
Jon Shallow 9f499ad42f coap_netif.c: Update incoming packet addresses earlier for any logging
Update session->addr_info from packet->addr_info before logging incoming
packet.  Only seen on the first incoming packet for a client as subsequent
packets likely to be the same address..
2024-02-29 11:22:49 +00:00
Jon Shallow e253183a5e coap_session.c: Fix token generation in coap_session_new_token()
Revert out change from #1276 and decrement token in coap_session_init_token() to
make sure starting token used is the same as that provided to
coap_session_init_token().
2024-02-29 11:15:28 +00:00
Jon Shallow a733325b16 multithread: Re-arrange lock checks for locked callbacks
Should fix CIDs
1583518-1583525
1583527-1583549
1583551-1583553
1583555-1583562
1583565-1583584
1583586-1583589
2024-02-21 16:54:32 +00:00
Jon Shallow 7660069944 coap_openssl.c: Add in support for changing the DTLS retry timeout
As done for GnuTLS and MbedTLS, add compile time support for changing
the DTLS retry timoouts.

$ ./configure CFLAGS=-DCOAP_DTLS_RETRANSMIT_MS=3000

to make it 3000 ms instead of the default of 1000ms.
2024-02-20 11:20:07 +00:00
Jon Shallow 9510cf9032 coap_io.c: Further cleanup of timeout checking code
Fixes issue caused by #1314 found during testing.

Code re-worked to make more readable for flow checking.
2024-02-15 10:02:05 +00:00
Jon Shallow 852d7371b5 coap-client.c: Correct sending of SNI using localhost for PSK 2024-02-12 14:11:14 +00:00
Jon Shallow 3852554fe2 coap-server.txt.in: Correct typo 2024-02-12 14:10:09 +00:00
Jon Shallow f34d955440 coap_mbedtls.c: Enable PSA Crypto support if available 2024-02-12 14:09:15 +00:00
Jon Shallow 9603622715 coap-client.c: Enable (D)TLS1.3 support for PSK
Only set up Identity Hint checks (not available for (D)TLS1.3, and so
forces downgrade to (D)TLS1.2) if -h option is used for the coap-client.
2024-02-12 14:07:46 +00:00
Jon Shallow 5cb998b489 coap-server.c: Fix CID 1583585 2024-02-12 14:06:04 +00:00
Jon Shallow abcc291c3f coap_session.c: Fix CID 1583554 2024-02-12 14:04:22 +00:00
Jon Shallow ebc693fec0 coap-server.c: Fix CID 1583550 2024-02-12 14:03:00 +00:00
Jon Shallow 841626f64f coap_session.c: Fix CID 1583526 2024-02-12 14:01:49 +00:00
Jon Shallow bfbfd69ff5 coap_threadsafe.c: Fix CID 1566426 2024-02-12 14:00:18 +00:00
Jon Shallow 224aa74a03 coap_io.c: Cleanup timeout checking code in coap_io_process_with_fds()
Should fix CID: 1583564
2024-02-12 13:52:22 +00:00
Jon Shallow 5efe163af2 Zephyr: Initial Zephyr integration setup
zephyr/ Initial files added
2024-02-12 13:42:04 +00:00