diff options
| author | Gregor Burger <gregor.burger@bhs-technologies.com> | 2018-11-20 11:48:03 +0100 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-11-22 12:28:27 -0800 |
| commit | d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50 (patch) | |
| tree | f081a6868a6c3d88b4df64ef20a38fb3e83925d1 /src/supplemental/tls | |
| parent | 8a9fd805d96201c780610b765f9e6dd9f2eda642 (diff) | |
| download | nng-d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50.tar.gz nng-d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50.tar.bz2 nng-d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50.zip | |
move all public headers to include/nng/ folder
This change makes embedding nng + nggpp (or other projects depending on
nng) in cmake easier. The header files are moved to a separate include
directory. This also makes installation of the headers easier, and
allows clearer identification of private vs public heade files.
Some additional cleanups were performed by @gedamore, but the main
credit for this change belongs with @gregorburger.
Diffstat (limited to 'src/supplemental/tls')
| -rw-r--r-- | src/supplemental/tls/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/supplemental/tls/mbedtls/tls.c | 2 | ||||
| -rw-r--r-- | src/supplemental/tls/none/tls.c | 2 | ||||
| -rw-r--r-- | src/supplemental/tls/tls.h | 112 |
4 files changed, 3 insertions, 118 deletions
diff --git a/src/supplemental/tls/CMakeLists.txt b/src/supplemental/tls/CMakeLists.txt index 111ff70f..8fed1df1 100644 --- a/src/supplemental/tls/CMakeLists.txt +++ b/src/supplemental/tls/CMakeLists.txt @@ -13,8 +13,7 @@ if (NNG_SUPP_TLS) set(_DEFS -DNNG_SUPP_TLS) endif() -set(_SRCS supplemental/tls/tls.h) -set(_HDRS supplemental/tls/tls.h) +set(_SRCS ${PROJECT_SOURCE_DIR}/include/nng/supplemental/tls/tls.h) # For now we only support the ARM mbedTLS library. if (NNG_SUPP_TLS_MBEDTLS) @@ -36,12 +35,10 @@ endif() list(APPEND NNG_DEFS ${_DEFS}) list(APPEND NNG_SRCS ${_SRCS}) -list(APPEND NNG_HDRS ${_HDRS}) list(APPEND NNG_LIBS ${_LIBS}) list(APPEND NNG_INCS ${_INCS}) set(NNG_DEFS ${NNG_DEFS} PARENT_SCOPE) set(NNG_SRCS ${NNG_SRCS} PARENT_SCOPE) -set(NNG_HDRS ${NNG_HDRS} PARENT_SCOPE) set(NNG_LIBS ${NNG_LIBS} PARENT_SCOPE) set(NNG_INCS ${NNG_INCS} PARENT_SCOPE) diff --git a/src/supplemental/tls/mbedtls/tls.c b/src/supplemental/tls/mbedtls/tls.c index f7431ac6..c01ff2ed 100644 --- a/src/supplemental/tls/mbedtls/tls.c +++ b/src/supplemental/tls/mbedtls/tls.c @@ -28,7 +28,7 @@ #include "core/nng_impl.h" -#include "supplemental/tls/tls.h" +#include "nng/supplemental/tls/tls.h" #include "supplemental/tls/tls_api.h" // Implementation note. This implementation buffers data between the TLS diff --git a/src/supplemental/tls/none/tls.c b/src/supplemental/tls/none/tls.c index d7968758..e9d84e19 100644 --- a/src/supplemental/tls/none/tls.c +++ b/src/supplemental/tls/none/tls.c @@ -17,7 +17,7 @@ // We provide stub functions only to satisfy linkage. #include "core/nng_impl.h" -#include "supplemental/tls/tls.h" +#include "nng/supplemental/tls/tls.h" #include "supplemental/tls/tls_api.h" void diff --git a/src/supplemental/tls/tls.h b/src/supplemental/tls/tls.h deleted file mode 100644 index 5983f3b6..00000000 --- a/src/supplemental/tls/tls.h +++ /dev/null @@ -1,112 +0,0 @@ -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This software is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -#ifndef NNG_SUPPLEMENTAL_TLS_TLS_H -#define NNG_SUPPLEMENTAL_TLS_TLS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stddef.h> -#include <stdint.h> - -// Note that TLS functions may be stubbed out if TLS is not enabled in -// the build. - -// For some transports, we need TLS configuration, including certificates -// and so forth. A TLS configuration cannot be changed once it is in use. -typedef struct nng_tls_config nng_tls_config; - -typedef enum nng_tls_mode { - NNG_TLS_MODE_CLIENT = 0, - NNG_TLS_MODE_SERVER = 1, -} nng_tls_mode; - -typedef enum nng_tls_auth_mode { - NNG_TLS_AUTH_MODE_NONE = 0, // No verification is performed - NNG_TLS_AUTH_MODE_OPTIONAL = 1, // Verify cert if presented - NNG_TLS_AUTH_MODE_REQUIRED = 2, // Verify cert, close if invalid -} nng_tls_auth_mode; - -// nng_tls_config_alloc creates a TLS configuration using -// reasonable defaults. This configuration can be shared -// with multiple pipes or services/servers. -NNG_DECL int nng_tls_config_alloc(nng_tls_config **, nng_tls_mode); - -// nng_tls_config_hold increments the reference count on the TLS -// configuration object. The hold can be dropped by calling -// nng_tls_config_free later. -NNG_DECL void nng_tls_config_hold(nng_tls_config *); - -// nng_tls_config_free drops the reference count on the TLS -// configuration object, and if zero, deallocates it. -NNG_DECL void nng_tls_config_free(nng_tls_config *); - -// nng_tls_config_server_name sets the server name. This is -// called by clients to set the name that the server supplied -// certificate should be matched against. This can also cause -// the SNI to be sent to the server to tell it which cert to -// use if it supports more than one. -NNG_DECL int nng_tls_config_server_name(nng_tls_config *, const char *); - -// nng_tls_config_ca_cert configures one or more CAs used for validation -// of peer certificates. Multiple CAs (and their chains) may be configured -// by either calling this multiple times, or by specifying a list of -// certificates as concatenated data. The final argument is an optional CRL -// (revokation list) for the CA, also in PEM. Both PEM strings are ASCIIZ -// format (except that the CRL may be NULL). -NNG_DECL int nng_tls_config_ca_chain( - nng_tls_config *, const char *, const char *); - -// nng_tls_config_own_cert is used to load our own certificate and public -// key. For servers, this may be called more than once to configure multiple -// different keys, for example with different algorithms depending on what -// the peer supports. On the client, only a single option is available. -// The first two arguments are the cert (or validation chain) and the -// key as PEM format ASCIIZ strings. The final argument is an optional -// password and may be NULL. -NNG_DECL int nng_tls_config_own_cert( - nng_tls_config *, const char *, const char *, const char *); - -// nng_tls_config_key is used to pass our own private key. -NNG_DECL int nng_tls_config_key(nng_tls_config *, const uint8_t *, size_t); - -// nng_tls_config_pass is used to pass a password used to decrypt -// private keys that are encrypted. -NNG_DECL int nng_tls_config_pass(nng_tls_config *, const char *); - -// nng_tls_config_auth_mode is used to configure the authentication mode use. -// The default is that servers have this off (i.e. no client authentication) -// and clients have it on (they verify the server), which matches typical -// practice. -NNG_DECL int nng_tls_config_auth_mode(nng_tls_config *, nng_tls_auth_mode); - -// nng_tls_config_ca_file is used to pass a CA chain and optional CRL -// via the filesystem. If CRL data is present, it must be contained -// in the file, along with the CA certificate data. The format is PEM. -// The path name must be a legal file name. -NNG_DECL int nng_tls_config_ca_file(nng_tls_config *, const char *); - -// nng_tls_config_cert_key_file is used to pass our own certificate and -// private key data via the filesystem. Both the key and certificate -// must be present as PEM blocks in the same file. A password is used to -// decrypt the private key if it is encrypted and the password supplied is not -// NULL. This may be called multiple times on servers, but only once on a -// client. (Servers can support multiple different certificates and keys for -// different cryptographic algorithms. Clients only get one.) -NNG_DECL int nng_tls_config_cert_key_file( - nng_tls_config *, const char *, const char *); - -#ifdef __cplusplus -} -#endif - -#endif // NNG_SUPPLEMENTAL_TLS_TLS_H |
