'\" t .\" Title: coap_tls_library .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/28/2023 .\" Manual: libcoap Manual .\" Source: coap_tls_library 4.3.4 .\" Language: English .\" .TH "COAP_TLS_LIBRARY" "3" "10/28/2023" "coap_tls_library 4\&.3\&.4" "libcoap Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" coap_tls_library, coap_dtls_is_supported, coap_tls_is_supported, coap_dtls_psk_is_supported, coap_dtls_pki_is_supported, coap_dtls_pkcs11_is_supported, coap_dtls_rpk_is_supported, coap_tcp_is_supported, coap_get_tls_library_version, coap_string_tls_support, coap_string_tls_version, coap_show_tls_version \- Work with CoAP TLS libraries .SH "SYNOPSIS" .sp \fB#include \fR .sp \fBint coap_dtls_is_supported(void);\fR .sp \fBint coap_tls_is_supported(void);\fR .sp \fBint coap_dtls_psk_is_supported(void);\fR .sp \fBint coap_dtls_pki_is_supported(void);\fR .sp \fBint coap_dtls_pkcs11_is_supported(void);\fR .sp \fBint coap_dtls_rpk_is_supported(void);\fR .sp \fBint coap_tcp_is_supported(void);\fR .sp \fBcoap_tls_version_t *coap_get_tls_library_version(void);\fR .sp \fBchar *coap_string_tls_support(char *\fR\fB\fIbuffer\fR\fR\fB, size_t \fR\fB\fIbufsize\fR\fR\fB);\fR .sp \fBchar *coap_string_tls_version(char *\fR\fB\fIbuffer\fR\fR\fB, size_t \fR\fB\fIbufsize\fR\fR\fB);\fR .sp \fBvoid coap_show_tls_version(coap_log_t \fR\fB\fIlevel\fR\fR\fB);\fR .sp For specific (D)TLS library support, link with \fB\-lcoap\-3\-notls\fR, \fB\-lcoap\-3\-gnutls\fR, \fB\-lcoap\-3\-openssl\fR, \fB\-lcoap\-3\-mbedtls\fR or \fB\-lcoap\-3\-tinydtls\fR\&. Otherwise, link with \fB\-lcoap\-3\fR to get the default (D)TLS library support\&. .SH "DESCRIPTION" .sp When the libcoap library was built, it will have been compiled using a specific TLS implementation type (e\&.g\&. OpenSSL, GnuTLS, Mbed TLS, TinyDTLS or noTLS)\&. When the libcoap library is linked into an application, it is possible that the application needs to dynamically determine whether DTLS or TLS is supported, what type of TLS implementation libcoap was compiled with, as well as detect what is the version of the currently loaded TLS library is\&. .sp \fBNOTE:\fR If OpenSSL is being used, then the minimum OpenSSL library version is 1\&.1\&.0\&. .sp \fBNOTE:\fR If GnuTLS is being used, then the minimum GnuTLS library version is 3\&.3\&.0\&. .sp \fBNOTE:\fR If GnuTLS is going to interoperate with TinyDTLS, then a minimum revision of GnuTLS 3\&.5\&.5 which supports CCM algorithms is required by TinyDTLS as TinyDTLS currently only supports CCM\&. .sp Network traffic can be encrypted or un\-encrypted with libcoap \- how to set this up is described in \fBcoap_context\fR(3)\&. .sp Due to the nature of TLS, there can be Callbacks that are invoked as the TLS session negotiates encryption algorithms, encryption keys etc\&. Where possible, by default, the CoAP layer handles all this automatically\&. However, there is the flexibility of the Callbacks for imposing additional security checks etc\&. when PKI is being used\&. These callbacks need to need to match the TLS implementation type\&. .SH "FUNCTIONS" .sp \fBFunction: coap_dtls_is_supported()\fR .sp The \fBcoap_dtls_is_supported\fR() function returns 1 if support for DTLS is available, otherwise 0; .sp \fBFunction: coap_tls_is_supported()\fR .sp The \fBcoap_tls_is_supported\fR() function returns 1 if support for TLS is available, otherwise 0; .sp \fBFunction: coap_dtls_psk_is_supported()\fR .sp The \fBcoap_dtls_psk_is_supported\fR() function returns 1 if support for (D)TLS PSK is available, otherwise 0; .sp \fBFunction: coap_dtls_pki_is_supported()\fR .sp The \fBcoap_dtls_pki_is_supported\fR() function returns 1 if support for (D)TLS PKI is available, otherwise 0; .sp \fBFunction: coap_dtls_pkcs11_is_supported()\fR .sp The \fBcoap_dtls_pkcs11_is_supported\fR() function returns 1 if support for (D)TLS PKCS11 is available, otherwise 0; .sp \fBFunction: coap_dtls_rpk_is_supported()\fR .sp The \fBcoap_dtls_rpk_is_supported\fR() function returns 1 if support for (D)TLS RPK is available, otherwise 0; .sp \fBFunction: coap_tcp_is_supported()\fR .sp The \fBcoap_tcp_is_supported\fR() function returns 1 if support for TCP is available, otherwise 0\&. .sp \fBFunction: coap_get_tls_library_version()\fR .sp The \fBcoap_get_tls_library_version\fR() function returns the TLS implementation type and library version in a coap_tls_version_t* structure\&. .sp .if n \{\ .RS 4 .\} .nf typedef enum coap_tls_library_t { COAP_TLS_LIBRARY_NOTLS = 0, /* No DTLS library */ COAP_TLS_LIBRARY_TINYDTLS, /* Using TinyDTLS library */ COAP_TLS_LIBRARY_OPENSSL, /* Using OpenSSL library */ COAP_TLS_LIBRARY_GNUTLS, /* Using GnuTLS library */ COAP_TLS_LIBRARY_MBEDTLS, /* Using Mbed TLS library */ } coap_tls_library_t; typedef struct coap_tls_version_t { uint64_t version; /* (D)TLS runtime Library Version */ coap_tls_library_t type; /* Library type\&. One of COAP_TLS_LIBRARY_* */ uint64_t built_version; /* (D)TLS Built against Library Version */ } .fi .if n \{\ .RE .\} .sp \fBFunction: coap_string_tls_support()\fR .sp The \fBcoap_string_tls_support\fR() function is used to update the provided buffer with ascii readable information about what type of PSK, PKI etc\&. keys the current (D)TLS library supports\&. \fIbuffer\fR defines the buffer to provide the information and \fIbufsize\fR is the size of \fIbuffer\fR\&. .sp \fBFunction: coap_string_tls_version()\fR .sp The \fBcoap_string_tls_version\fR() function is used to update the provided buffer with information about the current (D)TLS library that libcoap was built against, as well as the current linked version of the (D)TLS library\&. \fIbuffer\fR defines the buffer to provide the information and \fIbufsize\fR is the size of \fIbuffer\fR\&. .sp \fBFunction: coap_show_tls_version()\fR .sp The \fBcoap_show_tls_version\fR() function is used log information about the current (D)TLS library that libcoap was built against, as well as the current linked version of the (D)TLS library\&. \fIlevel\fR defines the minimum logging level for this information to be output using coap_log()\&. .SH "RETURN VALUES" .sp \fBcoap_dtls_is_supported\fR(), \fBcoap_tls_is_supported\fR(), \fBcoap_dtls_psk_is_supported\fR(), \fBcoap_dtls_pki_is_supported\fR(), \fBcoap_dtls_pkcs11_is_supported\fR() and \fBcoap_dtls_rpk_is_supported\fR() return 0 if there is no support, 1 if support is available\&. .sp \fBcoap_get_tls_library_version\fR() returns the TLS implementation type and library version in a coap_tls_version_t* structure\&. .sp \fBcoap_tcp_is_supported\fR() returns 1 if support for TCP is available, otherwise 0\&. .sp \fBcoap_string_tls_version\fR() and \fBcoap_string_tls_support\fR() return a pointer to the provided buffer\&. .SH "SEE ALSO" .sp \fBcoap_encryption\fR(3) .SH "FURTHER INFORMATION" .sp See .sp "RFC7252: The Constrained Application Protocol (CoAP)" .sp "RFC8323: CoAP (Constrained Application Protocol) over TCP, TLS, and WebSockets" .sp for further information\&. .SH "BUGS" .sp Please report bugs on the mailing list for libcoap: libcoap\-developers@lists\&.sourceforge\&.net or raise an issue on GitHub at https://github\&.com/obgm/libcoap/issues .SH "AUTHORS" .sp The libcoap project