man/coap_attribute.txt.in:
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_recovery.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
man/coap_tls_library.txt.in:
Add in reference to MbedTLS where appropriate.
man/coap_encryption.txt.in:
Add in PKI Key type COAP_PKI_KEY_PEM_BUF for passing in PEM information
that is held in memory instead of in a file.
Existing COAP_PKI_KEY_PEM key type reads the PEM file from disk.
COAP_PKI_KEY_PEM_BUF key type has the same PEM content format, but provided
in a memory buffer. The buffer should be NULL terminated and the size of
the buffer passed in should include the NULL terminator.
src/coap_gnutls.c:
Add in support for COAP_PKI_KEY_PEM_BUF.
Make use of COAP_DTLS_RETRANSMIT_MS and COAP_DTLS_RETRANSMIT_TOTAL_MS rather
than hard coded numbers.
src/coap_openssl.c:
Add in support for COAP_PKI_KEY_PEM_BUF.
Add in MbedTLS library support as another alternative TLS library
Makefile.am:
Include new src/coap_mbedtls.c file.
configure.ac:
Add in --with-mbedtls support which generates HAVE_MBEDTLS in coap_config.h.
include/coap2/coap_dtls.h:
Add in TLS Library type COAP_TLS_LIBRARY_MBEDTLS and make COAP_TLS_LIBRARY_*
defines an enum.
Add in PKI Key type COAP_PKI_KEY_PEM_BUF for passing in PEM information
that is held in memory instead of in a file.
Add in #define COAP_DTLS_RETRANSMIT_MS, COAP_DTLS_RETRANSMIT_TOTAL_MS
and COAP_DTLS_RETRANSMIT_COAP_TICKS
src/coap_debug.c:
Output MbedTLS information if appropriate.
src/coap_mbedtls.c: (New)
Contains the MbedTLS interface code.
src/coap_notls.c:
Do not use code if MbedTLS is being built.
tests/test_tls.c:
Include MbedTLS library checks.
README.md:
Include MbedTLS as a valid (D)TLS library.
https://tools.ietf.org/html/rfc7641#section-4.5 requires that non-confirmable
observe responses should be sent as confirmable at least once every 24 hours.
However there is a requirement to override this periodical confirmable sending
behavior in lossy under DDoS attack type environments.
https://tools.ietf.org/html/draft-ietf-dots-signal-channel-41#section-4.4.2.1
Add in support for, and document, a new coap_resource_init() flag
COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS to handle this non RFC7641 requirement.
PR #338 broke the PKI/PSK selection order for the encryption type
to use when trying to include the SNI even if PSK or PKI had not
been configured - even though coaps or coaps+tcp was in use. If
PSK had been defined, then it failed.
This fix puts the creation of the correct type of session into a separate function
which is then called from 2 places.
In ea72c3d7, the r->partiallydirty is set to 0 before the limitation.
A new request will be dropped when the last request hasn't received its
ACK.
The force clear operation of 'r->dirty' after 'LL_FOREACH' loop will
drop new request too.
resource.c:
In coap_notify_observers(), outstanding CON requests limitation, set
'r->partiallydirty' & 'obs->dirty' to 1 before 'continue'.
examples/client.c:
Update to send SNI if coaps, but certs/PSK not defined.
examples/coap-server.c:
Add in -S option to support changing certificate/ca if there is as SNI match.
man/coap-server.txt.in:
Update man page with new -S option.
doc/main.md:
Correct copyright date
man/Makefile.am:
Update A2X_EXTRA_PAGES to include man pages that have digits in the name
man/coap_context.txt.in:
man/coap_encryption.txt.in:
man/coap_handler.txt.in:
man/coap_logging.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:
Update with _psk2() information.
Update examples to remove compiler warnings
man/coap-client.txt.in:
man/coap-rd.txt.in:
man/coap-server.txt.in:
Add in documentation on additional support for using / testing out the new
_psk2() functionality
examples/client.c:
Update code to use the new coap_new_client_session_psk2() function, adding
the new Identity Hint callback.
Add in new option -h to define a file containing new PSK information if
Identity Hint is matched.
examples/coap-server.c:
Update code to use the new coap_context_set_psk2() function, adding
the new Identity and SNI callbacks.
Add in new option -i to define a file containing new Pre-Shared Key
if Hint and Identity is matched.
Add in new option -s to define a file containing new PSK information if
SNI is matched.
include/coap2/coap_dtls.h:
include/coap2/coap_session.h:
Update coap_dtls_cpsk_key_t and coap_dtls_spsk_key_t to use coap_bin_const_t.
Update coap_dtls_id_callback_t to return coap_bin_const_t*.
Update coap_session_t to use coap_bin_const_t for psk_identity, psk_hint
and psk_key.
Update coap_session_refresh_psk_key() to have a coap_bin_const_t parameter.
src/coap_gnutls.c:
src/coap_openssl.c:
src/coap_tinydtls.c:
Add in new callback functions to handle SNI, Identity and Hint request
information following the principles used for the PKI logic.
Install the appropriate callback functions by setting them up by using the
appropriate TLS library functions.
src/coap_session.c:
src/net.c:
Use the new versions of coap_dtls_cpsk_key_t and coap_dtls_spsk_key_t.
src/coap_session.c:
Add in new coap_session_refresh_psk_hint() function.
Update coap_session_refresh_psk_key() function.
This fix is in preparation for the full coap_new_client_session_psk2()
and coap_context_set_psk2() functions. Structures are updated with the
necessary information, as well as provide the high level support.
As new sessions are now created for every genuine incoming session (#333),
coap_context_t will only hold the initial information provided by
coap_context_set_psk2() (server mode), but if there is any updated
(triggered by SNI or Indentity), this will be kept in coap_session_t.
Likewise, the client initial information will be kept in the
coap_session_t, and if modified (triggered by Hint) will be kept separately
in coap_session_t.
This change does not include the support required in the DTLS interface modules
other than changes required to make the code compilable and still run the
existing examples - so it is a standalone change.
Makefile.am:
Make coap_dtls_context_set_cpsk, coap_dtls_context_set_spsk,
coap_session_refresh_psk_key and coap_session_refresh_psk_hint hidden
Remove coap_dtls_context_set_psk
include/coap2/*.h:
Replace call-back with callback for consistency
include/coap2/coap_dtls.h:
Include coap_dtls_cpsk_key_t and coap_dtls_spsk_key_t definitions
Define coap_dtls_spsk_key_t for the new coap_*_psk2 functions.
Include all the new call back function definitions
include/coap2/coap_session.h:
Update coap_session_t with the new PSK information
Define coap_new_client_session_psk2(), coap_session_refresh_psk_key() and
coap_session_refresh_psk_hint() functions
include/coap2/net.h:
Update coap_context_t with the new PSK information
Define the coap_context_set_psk2() function
include/coap2/str.h:
Add in a new struct coap_bin_const_t
Define new functions coap_new_bin_const(), coap_delete_bin_const()
and coap_binary_equal().
libcoap-2.{map|sym}
Expose the new coap_context_set_psk2, coap_new_client_session_psk2,
coap_new_bin_const and coap_delete_bin_const functions
src/coap_gnutls.c:
src/coap_notls.c:
src/coap_tinydtls.c:
Replace coap_dtls_context_set_psk() with coap_dtls_context_set_spsk()
and coap_dtls_context_set_cpsk()
src/coap_openssl.c:
Replace coap_dtls_context_set_psk() with coap_dtls_context_set_spsk()
and coap_dtls_context_set_cpsk()
Update the SSL_CTX_use* and SSL_set_* functions with the new variable
locations
src/coap_session.c:
Free off new information on coap_session_t in coap_session_mfree()
Build parameters for coap_new_client_session_psk2() in
coap_new_client_session_psk() and call coap_new_client_session_psk2() instead
of coap_session_create_client().
Create new coap_new_client_session_psk2().
Create new coap_session_refresh_psk_key() (will be used when DTLS interface
code is updated
src/net.c:
Update coap_get_session_client_psk() to use the new PSK locations.
Update coap_get_session_server_psk() to use the new PSK locations.
Update coap_get_session_server_hint() to use the new PSK locations.
Build parameters for coap_context_set_psk2() in
coap_context_set_psk() and call coap_context_set_psk2().
Create new coap_context_set_psk2().
Cleanup usage of old PSK information in coap_free_context()
src/str.c:
Code for coap_new_bin_const() and coap_delete_bin_const() functions
man/coap_resource.txt.in:
Add in coap_resource_set_userdata() and coap_resource_get_userdata()
documentation
include/coap2/resource.h:
Re-organize order and put into appropriate doxygen groups
include/coap2/subscribe.h:
Fix Doxygen title case
Make sure that session is not freed off in one of the callbacks while
testing the socket flags in the epoll logic.
Wrap the code with a coap_session_reference(session) and
coap_session_release(session) and remove all the interim wrappers.
Issue found when coap_read_session() internally does a coap_session_release().
Casting an unsigned long to void * caused a compiler warning
on 32-bit architectures. This change uses unsigned int as
this has a sufficient range for the respective calculation
and introduces a union to avoid the explicit type cast.
src/coap_openssl.c:
Remove NULL as a valid cipher from the cipher list.
Add in TLSv1.3 ciphers if OpenSSL 1.1.1 (they are already included in
TLSv1.2 definition, but this is to document this is happening).
Remove the TLSv1.0 deprecated ciphers.
Cipher strings can now be overridden during compilation by
using -DCOAP_OPENSSL_CIPHERS=xxx compiler option where xxx is the
cipher string as defined in
https://www.openssl.org/docs/man1.1.0/man1/ciphers.html
Explicit PSK cipher strings can now be overridden during compilation
by using -DCOAP_OPENSSL_PSK_CIPHERS=xxx compiler option where xxx is the
cipher string.
Log the client ciphers presented, and the cipher chosen.
include/coap2/coap_debug.h:
src/coap_debug.c:
Add in COAP_LOG_CIPHERS as a debug level (value 9) which matches getting the
cipher information reported in GnuTLS, and is now used for OpenSSL.
man/coap-client.txt.in:
man/coap-rd.txt.in:
man/coap-server.txt.in:
Include OpenSSL for verbosity > 7.
coap_write() and coap_read() are really internal functions that are called
from within coap_run_once() separated by a select() to wait for i/o and
ideally should not be used in applications.
However, currently, coap_write() and coap_read() are needed instead of
coap_run_once() if there is no epoll support in libcoap so that if additional
non libcoap FDs need to be set up and monitored by the select() call they
then can be processed accordingly if the non libcoap FDs are set in the
select() response.
coap_io_process_with_fds() is a new function extending coap_run_once() that
allows non libcoap FDs to be monitored in the coap_run_once() internal
select() call and can then be tested by the caller of
coap_io_process_with_fds().
coap_run_once() now calls coap_io_process_with_fds() with readfds, writefds,
exceptfds set to NULL and nfds set to 0.
Note: nfds, readfds, writefds and exceptfds are ignored if there is underlying
epoll support in libcoap as epoll functions are used, not select(). Use
coap_context_get_coap_fd() to get a single FD that covers all the libcoap
FDs that can be used in the application along with other non-libcoap FDs
when there is epoll support. See coap_io(3) for further information.
include/coap2/net.h:
libcoap-2.map:
libcoap-2.sym:
man/coap_io.txt.in:
src/coap_io.c:
Include and document the new coap_io_process_with_fds() function.