1c87c5fbaSopenharmony_ci// -*- mode:doc; -*-
2c87c5fbaSopenharmony_ci// vim: set syntax=asciidoc tw=0
3c87c5fbaSopenharmony_ci
4c87c5fbaSopenharmony_cicoap_tls_library(3)
5c87c5fbaSopenharmony_ci===================
6c87c5fbaSopenharmony_ci:doctype: manpage
7c87c5fbaSopenharmony_ci:man source:   coap_tls_library
8c87c5fbaSopenharmony_ci:man version:  @PACKAGE_VERSION@
9c87c5fbaSopenharmony_ci:man manual:   libcoap Manual
10c87c5fbaSopenharmony_ci
11c87c5fbaSopenharmony_ciNAME
12c87c5fbaSopenharmony_ci----
13c87c5fbaSopenharmony_cicoap_tls_library,
14c87c5fbaSopenharmony_cicoap_dtls_is_supported,
15c87c5fbaSopenharmony_cicoap_tls_is_supported,
16c87c5fbaSopenharmony_cicoap_dtls_psk_is_supported,
17c87c5fbaSopenharmony_cicoap_dtls_pki_is_supported,
18c87c5fbaSopenharmony_cicoap_dtls_pkcs11_is_supported,
19c87c5fbaSopenharmony_cicoap_dtls_rpk_is_supported,
20c87c5fbaSopenharmony_cicoap_tcp_is_supported,
21c87c5fbaSopenharmony_cicoap_get_tls_library_version,
22c87c5fbaSopenharmony_cicoap_string_tls_support,
23c87c5fbaSopenharmony_cicoap_string_tls_version,
24c87c5fbaSopenharmony_cicoap_show_tls_version
25c87c5fbaSopenharmony_ci- Work with CoAP TLS libraries
26c87c5fbaSopenharmony_ci
27c87c5fbaSopenharmony_ciSYNOPSIS
28c87c5fbaSopenharmony_ci--------
29c87c5fbaSopenharmony_ci*#include <coap@LIBCOAP_API_VERSION@/coap.h>*
30c87c5fbaSopenharmony_ci
31c87c5fbaSopenharmony_ci*int coap_dtls_is_supported(void);*
32c87c5fbaSopenharmony_ci
33c87c5fbaSopenharmony_ci*int coap_tls_is_supported(void);*
34c87c5fbaSopenharmony_ci
35c87c5fbaSopenharmony_ci*int coap_dtls_psk_is_supported(void);*
36c87c5fbaSopenharmony_ci
37c87c5fbaSopenharmony_ci*int coap_dtls_pki_is_supported(void);*
38c87c5fbaSopenharmony_ci
39c87c5fbaSopenharmony_ci*int coap_dtls_pkcs11_is_supported(void);*
40c87c5fbaSopenharmony_ci
41c87c5fbaSopenharmony_ci*int coap_dtls_rpk_is_supported(void);*
42c87c5fbaSopenharmony_ci
43c87c5fbaSopenharmony_ci*int coap_tcp_is_supported(void);*
44c87c5fbaSopenharmony_ci
45c87c5fbaSopenharmony_ci*coap_tls_version_t *coap_get_tls_library_version(void);*
46c87c5fbaSopenharmony_ci
47c87c5fbaSopenharmony_ci*char *coap_string_tls_support(char *_buffer_, size_t _bufsize_);*
48c87c5fbaSopenharmony_ci
49c87c5fbaSopenharmony_ci*char *coap_string_tls_version(char *_buffer_, size_t _bufsize_);*
50c87c5fbaSopenharmony_ci
51c87c5fbaSopenharmony_ci*void coap_show_tls_version(coap_log_t _level_);*
52c87c5fbaSopenharmony_ci
53c87c5fbaSopenharmony_ciFor specific (D)TLS library support, link with
54c87c5fbaSopenharmony_ci*-lcoap-@LIBCOAP_API_VERSION@-notls*, *-lcoap-@LIBCOAP_API_VERSION@-gnutls*,
55c87c5fbaSopenharmony_ci*-lcoap-@LIBCOAP_API_VERSION@-openssl*, *-lcoap-@LIBCOAP_API_VERSION@-mbedtls*
56c87c5fbaSopenharmony_cior *-lcoap-@LIBCOAP_API_VERSION@-tinydtls*.   Otherwise, link with
57c87c5fbaSopenharmony_ci*-lcoap-@LIBCOAP_API_VERSION@* to get the default (D)TLS library support.
58c87c5fbaSopenharmony_ci
59c87c5fbaSopenharmony_ciDESCRIPTION
60c87c5fbaSopenharmony_ci-----------
61c87c5fbaSopenharmony_ciWhen the libcoap library was built, it will have been compiled using a
62c87c5fbaSopenharmony_cispecific TLS implementation type (e.g. https://www.openssl.org[OpenSSL],
63c87c5fbaSopenharmony_cihttps://www.gnutls.org[GnuTLS],
64c87c5fbaSopenharmony_cihttps://www.trustedfirmware.org/projects/mbed-tls/[Mbed TLS],
65c87c5fbaSopenharmony_cihttps://github.com/eclipse/tinydtls[TinyDTLS] or noTLS).
66c87c5fbaSopenharmony_ciWhen the libcoap library is linked into an application, it is possible that
67c87c5fbaSopenharmony_cithe application needs to dynamically determine whether DTLS or TLS is
68c87c5fbaSopenharmony_cisupported, what type of TLS implementation libcoap was compiled with, as well
69c87c5fbaSopenharmony_cias detect what is the version of the currently loaded TLS library is.
70c87c5fbaSopenharmony_ci
71c87c5fbaSopenharmony_ci*NOTE:* If OpenSSL is being used, then the minimum OpenSSL library version is
72c87c5fbaSopenharmony_ci1.1.0.
73c87c5fbaSopenharmony_ci
74c87c5fbaSopenharmony_ci*NOTE:* If GnuTLS is being used, then the minimum GnuTLS library version is
75c87c5fbaSopenharmony_ci3.3.0.
76c87c5fbaSopenharmony_ci
77c87c5fbaSopenharmony_ci*NOTE:* If GnuTLS is going to interoperate with TinyDTLS, then a minimum
78c87c5fbaSopenharmony_cirevision of GnuTLS 3.5.5 which supports CCM algorithms is required
79c87c5fbaSopenharmony_ciby TinyDTLS as TinyDTLS currently only supports CCM.
80c87c5fbaSopenharmony_ci
81c87c5fbaSopenharmony_ciNetwork traffic can be encrypted or un-encrypted with libcoap - how to set
82c87c5fbaSopenharmony_cithis up is described in *coap_context*(3).
83c87c5fbaSopenharmony_ci
84c87c5fbaSopenharmony_ciDue to the nature of TLS, there can be Callbacks that are invoked as the TLS
85c87c5fbaSopenharmony_cisession negotiates encryption algorithms, encryption keys etc.
86c87c5fbaSopenharmony_ciWhere possible, by default, the CoAP layer handles all this automatically.
87c87c5fbaSopenharmony_ciHowever, there is the flexibility of the Callbacks for imposing additional
88c87c5fbaSopenharmony_cisecurity checks etc. when PKI is being used.  These callbacks need to need to
89c87c5fbaSopenharmony_cimatch the TLS implementation type.
90c87c5fbaSopenharmony_ci
91c87c5fbaSopenharmony_ciFUNCTIONS
92c87c5fbaSopenharmony_ci---------
93c87c5fbaSopenharmony_ci
94c87c5fbaSopenharmony_ci*Function: coap_dtls_is_supported()*
95c87c5fbaSopenharmony_ci
96c87c5fbaSopenharmony_ciThe *coap_dtls_is_supported*() function returns 1 if support for DTLS is
97c87c5fbaSopenharmony_ciavailable, otherwise 0;
98c87c5fbaSopenharmony_ci
99c87c5fbaSopenharmony_ci*Function: coap_tls_is_supported()*
100c87c5fbaSopenharmony_ci
101c87c5fbaSopenharmony_ciThe *coap_tls_is_supported*() function returns 1 if support for TLS is
102c87c5fbaSopenharmony_ciavailable, otherwise 0;
103c87c5fbaSopenharmony_ci
104c87c5fbaSopenharmony_ci*Function: coap_dtls_psk_is_supported()*
105c87c5fbaSopenharmony_ci
106c87c5fbaSopenharmony_ciThe *coap_dtls_psk_is_supported*() function returns 1 if support for (D)TLS PSK
107c87c5fbaSopenharmony_ciis available, otherwise 0;
108c87c5fbaSopenharmony_ci
109c87c5fbaSopenharmony_ci*Function: coap_dtls_pki_is_supported()*
110c87c5fbaSopenharmony_ci
111c87c5fbaSopenharmony_ciThe *coap_dtls_pki_is_supported*() function returns 1 if support for (D)TLS PKI
112c87c5fbaSopenharmony_ciis available, otherwise 0;
113c87c5fbaSopenharmony_ci
114c87c5fbaSopenharmony_ci*Function: coap_dtls_pkcs11_is_supported()*
115c87c5fbaSopenharmony_ci
116c87c5fbaSopenharmony_ciThe *coap_dtls_pkcs11_is_supported*() function returns 1 if support for (D)TLS
117c87c5fbaSopenharmony_ciPKCS11 is available, otherwise 0;
118c87c5fbaSopenharmony_ci
119c87c5fbaSopenharmony_ci*Function: coap_dtls_rpk_is_supported()*
120c87c5fbaSopenharmony_ci
121c87c5fbaSopenharmony_ciThe *coap_dtls_rpk_is_supported*() function returns 1 if support for (D)TLS RPK
122c87c5fbaSopenharmony_ciis available, otherwise 0;
123c87c5fbaSopenharmony_ci
124c87c5fbaSopenharmony_ci*Function: coap_tcp_is_supported()*
125c87c5fbaSopenharmony_ci
126c87c5fbaSopenharmony_ciThe *coap_tcp_is_supported*() function returns 1 if support for TCP is
127c87c5fbaSopenharmony_ciavailable, otherwise 0.
128c87c5fbaSopenharmony_ci
129c87c5fbaSopenharmony_ci*Function: coap_get_tls_library_version()*
130c87c5fbaSopenharmony_ci
131c87c5fbaSopenharmony_ciThe *coap_get_tls_library_version*() function returns the TLS implementation
132c87c5fbaSopenharmony_citype and library version in a coap_tls_version_t* structure.
133c87c5fbaSopenharmony_ci
134c87c5fbaSopenharmony_ci[source, c]
135c87c5fbaSopenharmony_ci----
136c87c5fbaSopenharmony_citypedef enum coap_tls_library_t {
137c87c5fbaSopenharmony_ci  COAP_TLS_LIBRARY_NOTLS = 0, /* No DTLS library */
138c87c5fbaSopenharmony_ci  COAP_TLS_LIBRARY_TINYDTLS,  /* Using TinyDTLS library */
139c87c5fbaSopenharmony_ci  COAP_TLS_LIBRARY_OPENSSL,   /* Using OpenSSL library */
140c87c5fbaSopenharmony_ci  COAP_TLS_LIBRARY_GNUTLS,    /* Using GnuTLS library */
141c87c5fbaSopenharmony_ci  COAP_TLS_LIBRARY_MBEDTLS,   /* Using Mbed TLS library */
142c87c5fbaSopenharmony_ci} coap_tls_library_t;
143c87c5fbaSopenharmony_ci
144c87c5fbaSopenharmony_citypedef struct coap_tls_version_t {
145c87c5fbaSopenharmony_ci  uint64_t version;        /* (D)TLS runtime Library Version */
146c87c5fbaSopenharmony_ci  coap_tls_library_t type; /* Library type. One of COAP_TLS_LIBRARY_* */
147c87c5fbaSopenharmony_ci  uint64_t built_version;  /* (D)TLS Built against Library Version */
148c87c5fbaSopenharmony_ci}
149c87c5fbaSopenharmony_ci----
150c87c5fbaSopenharmony_ci
151c87c5fbaSopenharmony_ci*Function: coap_string_tls_support()*
152c87c5fbaSopenharmony_ci
153c87c5fbaSopenharmony_ciThe *coap_string_tls_support*() function is used to update the provided buffer
154c87c5fbaSopenharmony_ciwith ascii readable information about what type of PSK, PKI etc. keys the
155c87c5fbaSopenharmony_cicurrent (D)TLS library supports.
156c87c5fbaSopenharmony_ci_buffer_ defines the buffer to provide the information and _bufsize_ is the
157c87c5fbaSopenharmony_cisize of _buffer_.
158c87c5fbaSopenharmony_ci
159c87c5fbaSopenharmony_ci*Function: coap_string_tls_version()*
160c87c5fbaSopenharmony_ci
161c87c5fbaSopenharmony_ciThe *coap_string_tls_version*() function is used to update the provided buffer
162c87c5fbaSopenharmony_ciwith information about the current (D)TLS library that libcoap was built
163c87c5fbaSopenharmony_ciagainst, as well as the current linked version of the (D)TLS library.
164c87c5fbaSopenharmony_ci_buffer_ defines the buffer to provide the information and _bufsize_ is the
165c87c5fbaSopenharmony_cisize of _buffer_.
166c87c5fbaSopenharmony_ci
167c87c5fbaSopenharmony_ci*Function: coap_show_tls_version()*
168c87c5fbaSopenharmony_ci
169c87c5fbaSopenharmony_ciThe *coap_show_tls_version*() function is used log information about the
170c87c5fbaSopenharmony_cicurrent (D)TLS library that libcoap was built against, as well as the current
171c87c5fbaSopenharmony_cilinked version of the (D)TLS library. _level_ defines the minimum logging level
172c87c5fbaSopenharmony_cifor this information to be output using coap_log().
173c87c5fbaSopenharmony_ci
174c87c5fbaSopenharmony_ciRETURN VALUES
175c87c5fbaSopenharmony_ci-------------
176c87c5fbaSopenharmony_ci*coap_dtls_is_supported*(), *coap_tls_is_supported*(),
177c87c5fbaSopenharmony_ci*coap_dtls_psk_is_supported*(), *coap_dtls_pki_is_supported*(),
178c87c5fbaSopenharmony_ci*coap_dtls_pkcs11_is_supported*() and *coap_dtls_rpk_is_supported*()
179c87c5fbaSopenharmony_cireturn 0 if there is no support, 1 if support is available.
180c87c5fbaSopenharmony_ci
181c87c5fbaSopenharmony_ci*coap_get_tls_library_version*() returns the TLS implementation type
182c87c5fbaSopenharmony_ciand library version in a coap_tls_version_t* structure.
183c87c5fbaSopenharmony_ci
184c87c5fbaSopenharmony_ci*coap_tcp_is_supported*() returns 1 if support for TCP is
185c87c5fbaSopenharmony_ciavailable, otherwise 0.
186c87c5fbaSopenharmony_ci
187c87c5fbaSopenharmony_ci*coap_string_tls_version*() and *coap_string_tls_support*() return
188c87c5fbaSopenharmony_cia pointer to the provided buffer.
189c87c5fbaSopenharmony_ci
190c87c5fbaSopenharmony_ciSEE ALSO
191c87c5fbaSopenharmony_ci--------
192c87c5fbaSopenharmony_ci*coap_encryption*(3)
193c87c5fbaSopenharmony_ci
194c87c5fbaSopenharmony_ciFURTHER INFORMATION
195c87c5fbaSopenharmony_ci-------------------
196c87c5fbaSopenharmony_ciSee
197c87c5fbaSopenharmony_ci
198c87c5fbaSopenharmony_ci"https://rfc-editor.org/rfc/rfc7252[RFC7252: The Constrained Application Protocol (CoAP)]"
199c87c5fbaSopenharmony_ci
200c87c5fbaSopenharmony_ci"https://rfc-editor.org/rfc/rfc8323[RFC8323: CoAP (Constrained Application Protocol) over TCP, TLS, and WebSockets]"
201c87c5fbaSopenharmony_ci
202c87c5fbaSopenharmony_cifor further information.
203c87c5fbaSopenharmony_ci
204c87c5fbaSopenharmony_ciBUGS
205c87c5fbaSopenharmony_ci----
206c87c5fbaSopenharmony_ciPlease report bugs on the mailing list for libcoap:
207c87c5fbaSopenharmony_cilibcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
208c87c5fbaSopenharmony_cihttps://github.com/obgm/libcoap/issues
209c87c5fbaSopenharmony_ci
210c87c5fbaSopenharmony_ciAUTHORS
211c87c5fbaSopenharmony_ci-------
212c87c5fbaSopenharmony_ciThe libcoap project <libcoap-developers@lists.sourceforge.net>
213