Commit Graph
1143 Commits
Author SHA1 Message Date
Jon Shallow fa6f292997 coap_dtls.h: Move coap_dtls_security_setup_t into coap_dtls_pki_t
Update functions appropriately.
Move coap_new_client_session_pki() back into coap_session.h (its correct place)
Add in enum coap_asn1_privatekey_type_t
2018-02-14 20:50:43 +00:00
Jon Shallow 047c9fb082 Fix coap_notls.c, coap_tinydtls.c: after update merge from obgm/develop
Conficts created by Pull request #134
2018-02-14 19:24:58 +00:00
Olaf Bergmann 0d2922a45b .travis.yml: enable unit tests for openssl builds
This change sets TESTS=yes for the TLS=openssl build
2018-02-14 17:43:33 +01:00
Olaf Bergmann c74e1da5a9 tests: add unit test boilerplate for (D)TLS
A simple structure for (D)TLS-specific unit tests has been added.
Currently, only general support and the version number as reported
by coap_get_tls_library_version() are checked.
2018-02-14 17:28:37 +01:00
Olaf Bergmann b1943714ad Merge branch 'mrdeep1-tls-supported' into develop
Close PR #134 [1]

[1] https://github.com/obgm/libcoap/pull/134
2018-02-14 17:25:53 +01:00
Olaf Bergmann 16685d7736 Merge branch 'tls-supported' of https://github.com/mrdeep1/libcoap into mrdeep1-tls-supported 2018-02-14 16:21:27 +01:00
Olaf Bergmann a3da53d5e3 tests: use IPv4 in unit tests for robustness
As unit tests with IPv6 addresses keep failing on docker-based
travis CI, this changes reverts to IPv4 usage in following files:

    test_wellknown.c
    test_sendqueue.c
2018-02-14 16:06:52 +01:00
Jon Shallow c4729fa801 libcoap-1.map, libcoap-1.sym: Expose coap_get_tls_library_version() 2018-02-14 09:55:53 +00:00
Jon Shallow 85e7f1fc54 libcoap-1.map, libcoap-1.sym: Add in new PSK and PKI functions
coap_context_set_pki
coap_dtls_context_check_keys_enabled
coap_dtls_context_set_pki
coap_dtls_context_set_psk
coap_new_client_session_pki
2018-02-12 10:21:01 +00:00
Jon Shallow 740680c365 net.c: Add in PKI support
Update coap_context_set_psk() to return on failure.  Add in call to
coap_dtls_context_set_psk() function

Add in new function coap_context_set_pki()

Update #includes for compilation
2018-02-12 10:19:56 +00:00
Jon Shallow 7ae49c3b41 coap_session.c: Support PSK new function and PKI
Update coap_new_client_session_psk() to clean up and return on error.  Add in
call to coap_dtls_context_set_psk()

Add in new function coap_new_client_session_pki()

Additional check for a call of coap_new_client_session_*() in
coap_new_endpoint()
2018-02-12 10:15:22 +00:00
Jon Shallow c4840b7ce1 coap_openssl.c: Fix coding error in coap_dtls_context_set_pki() 2018-02-12 10:14:01 +00:00
Jon Shallow 752da7179b coap_openssl.c: Seperate out PSK specifics and add in PKI support
Remove PSK specifics from coap_dtls_new_context() and put into new
coap_dtls_context_set_psk().

Create a new coap_dtls_context_set_pki() for PKI.

Include checks that either of coap_dtls_context_set_psk() or
coap_dtls_context_set_pki() have been called before setting up a (D)TLS
session

Update #includes for compilation
2018-02-12 09:52:31 +00:00
Jon Shallow aaa43301b7 coap_tinydtls.c: Add in PKI stub functions
Update #includes and add in stub functions
coap_dtls_context_set_pki
coap_dtls_context_set_psk
coap_dtls_context_check_keys_enabled
2018-02-12 09:50:32 +00:00
Jon Shallow 6d479ee6cb coap_notls.c: Add in PKI stub functions
Update #includes and add in stub functions
coap_dtls_context_set_pki
coap_dtls_context_set_psk
coap_dtls_context_check_keys_enabled
2018-02-12 09:48:42 +00:00
Jon Shallow 3e4de1273d coap_io.c: Update #include to allow compilation
Replace #include "coap_dtls.h" with #include "net.h"
2018-02-12 09:47:00 +00:00
Jon Shallow 0b88e51a88 net.h: Add in new function
New function coap_context_set_pki()

Update function coap_context_set_psk ()to return failure value
2018-02-11 20:04:04 +00:00
Jon Shallow 5b340adfb8 coap_dtls.h: Add support for setting up PKI
Define
coap_dtls_pki_t
coap_dtls_security_setup_t

Functions
coap_new_client_session_pki
coap_dtls_context_set_psk
coap_dtls_context_set_pki
coap_dtls_context_check_keys_enabled
2018-02-11 19:32:15 +00:00
Jon Shallow 47205bd56c coap_openssl.c: Add in coap_get_tls_library_version() function
Add in coap_get_tls_library_version() for determining TLS build base + version

Do not allow a dynamic openssl library to be loaded and used at application
runtime that is less than OpenSSL version 1.1.0.
2018-02-10 19:39:27 +00:00
Jon Shallow 30794440af coap_tinydtls.c: Add in coap_get_tls_library_version() function
Add in coap_get_tls_library_version() for determining TLS build base + version
2018-02-10 19:38:08 +00:00
Jon Shallow 7d14b745c9 coap_notls.c: Add in coap_get_tls_library_version() function
Add in coap_get_tls_library_version() for determining TLS build base + version
2018-02-10 19:35:28 +00:00
Jon Shallow e1fa280d88 coap_dtls.h: Add in TLS library determination support
A new function coap_get_tls_library_version() that returns a pointer to a
coap_tls_version_t structure that contains both the TLS library type libcoap
was compiled against as well as the current TLS library version.
2018-02-10 18:34:42 +00:00
Olaf Bergmann 82c9ccc75b build.sh: bugfix for tinydtls build
When TLS=tinydtls is set, configure must be called with --disable-shared.

Thanks to Michael Zimmer for pointing this out.
2018-01-18 15:30:26 +01:00
Olaf Bergmann 660c4168bc coap_session.c: send COAP_DEFAULT_MTU in CSM
This change replaces the hard-coded 1152 bytes by the configurable
COAP_DEFAULT_MTU.
2017-12-22 14:31:56 +01:00
Olaf Bergmann 6607f942ed updated symbol maps 2017-12-22 14:31:08 +01:00
Olaf Bergmann 8e011ec500 net.c: dynamically grow PDU size for TCP
This change was provided by Jean-Claude Michelou to fix issue #123 [1].
It dynamically grows a partial TCP PDU during read.

[1] https://github.com/obgm/libcoap/issues/123
2017-12-22 13:56:48 +01:00
Olaf Bergmann d3b5535960 pdu.[hc]: Export coap_pdu_resize() 2017-12-22 13:55:37 +01:00
Olaf Bergmann 8ee4bb2586 pdu.c: fix len returned by coap_get_data() for empty payload
John Carter has provided this (slightly edited) patch to set len to 0
for PDUs that do not contain a payload. This makes this function more
robust for callers that do not care about the function result.

This change fixes issue 120 [1].

[1] https://github.com/obgm/libcoap/issues/120
2017-11-16 14:18:20 +01:00
Olaf Bergmann 0c837cdc77 pdu.h: increase Max-Message-Size by 256 B
To allow for 8 MiB payloads, the maximum message size value for
TCP has been increased by 256 B option space.
2017-11-11 10:06:16 +01:00
obgm 614b096319 Merge pull request #116 from spinetix/spx-leak
Fix memory leaks in sessions and openssl context.
2017-11-06 12:16:36 +01:00
jcmichelou c93f535d4a openssl, session: Fix memory leaks. 2017-11-04 23:38:02 +01:00
Olaf Bergmann e5064a47e7 client.c: removed dead code in message_handler()
Coverity scan has detected dead code that has been removed in this
change. (CID 1382575)
2017-11-03 15:15:06 +01:00
Olaf Bergmann 9bf7032232 coap_session.c: additional NULL pointer check
Coverity scan CID 1458386 has detected a potential NULL pointer
being dereferenced in coap_session_free().
2017-11-03 15:05:48 +01:00
Olaf Bergmann 6fb2e671d1 async.c: added missing check for NULL in coap_free_async()
Coverity scan has detected a possible NULL pointer being dereferenced
before it is checked, see CID 1458391.
2017-11-03 14:55:33 +01:00
Olaf Bergmann 1f51ba7636 coap_openssl.c: removed dead code from coap_dgram_ctrl()
The dead code detected by Coverity scan in CID 1458395 has been
replaced with explicitly setting the return value to 1 (the default
that has previously been used).
2017-11-03 14:42:05 +01:00
Olaf Bergmann a569e16584 coap_time.h: cast COAP_TICKS_PER_SECOND to coap_tick_t for type safety
CID 1458396 detected by Coverity scan points out that integer
arithmetics may lead to an overflow without the typecast to
coap_tick_t.
2017-11-03 14:29:49 +01:00
Olaf Bergmann 4b52182b8d net.c: fix possible NULL pointer dereference
Fixes CID 1458397 detected by Coverity scan.
2017-11-03 14:22:32 +01:00
Olaf Bergmann edca08249b coap-server.c: fixed memory leak in get_context()
When getaddrinfo() failed, the context object was not released before
returning NULL. Coverity scan has detected this with CID 1458398.
2017-11-03 14:18:19 +01:00
Olaf Bergmann 29692faa86 coap-server.c: fix use after free in check_async()
As coap_send() automatically releases the specified pdu, it must
not be accessed after coap_send() has returned.

This change fixes CID 1458399 reported by Coverity scan.
2017-11-03 14:12:22 +01:00
Olaf Bergmann 67a9210dbd net.c: fixed memory leak in coap_send()
coap_send() always takes the ownership of the pdu that is passed
as argument to send, i.e., the memory will be released automatically
when the pdu is not needed anymore.
2017-11-03 14:07:16 +01:00
Olaf Bergmann 027d9601eb net.c: always initialize bytes_read
In CID 1459612, Coverity scan has complained about uninitialized use
of the variable bytes_read. Although this is a false positive here,
it seems to be more safe to always initialize bytes_read.
2017-11-03 13:54:07 +01:00
Olaf Bergmann 313a655a9a pdu.c: fix explicit NULL pointer dereference
Fixes CID 1459615 found by Coverity scan.
2017-11-03 13:37:56 +01:00
Olaf Bergmann 5cc5273867 Doxyfile.in: decrease verbosity of doxygen output
To avoid cluttering the build output with lots of doxygen messages
the QUIET parameter now has been set to YES.
2017-11-03 13:36:24 +01:00
Olaf Bergmann 6a3abd257e coap_session.c: fixed default port selection for client TCP session
In coap_session_create_client(), the default port for TCP did not
correctly distinguish between TCP and TLS as pointed out in [1] by
Joan Shallow. This change applies the suggested fix.

[1] https://sourceforge.net/p/libcoap/mailman/message/36092184/
2017-11-03 10:41:05 +01:00
obgm a5dd017ec1 Merge pull request #114 from spinetix/spx-observe
Fix issues #90, #91 and #92
2017-10-30 09:31:18 +01:00
jcmichelou 3f77c117ea resource: Fix issues #90, #91 and #92
The value of the observe option is kept for each resource rather than being global to the context.
The value of the observe option must wrap to be stay below 2^24.
The value of the observe option must be different from the initial value when a notification is sent.
2017-10-25 20:22:01 +02:00
obgm 3630436499 Merge pull request #113 from spinetix/tcp-tls
Add support for TCP and TLS transports
2017-10-24 09:47:52 +02:00
jcmichelou e125888ded openssl: Handshake can also complete in SSL_accept and SSL_connect. 2017-10-21 19:16:23 +02:00
jcmichelou 1c4d6913af net.c, symbols: fix gcc warning and regenerate symbol files 2017-10-21 18:26:40 +02:00
jcmichelou 3340f10541 net.c: Correct payload size for wellknown response. 2017-10-21 17:35:43 +02:00