mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 00:21:11 +02:00
Simplify openssl library detection and macros
This commit is contained in:
parent
f05c24b259
commit
433b14c52f
|
@ -39,11 +39,7 @@ AC_ARG_WITH([openssl],
|
||||||
[AS_HELP_STRING([--with-openssl], [enable support for OpenSSL])],
|
[AS_HELP_STRING([--with-openssl], [enable support for OpenSSL])],
|
||||||
[], [with_openssl=no])
|
[], [with_openssl=no])
|
||||||
AS_IF([test "x$with_openssl" != xno],
|
AS_IF([test "x$with_openssl" != xno],
|
||||||
[AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset],
|
[AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset],,
|
||||||
[
|
|
||||||
AC_DEFINE([HAVE_OPENSSL_1_1], [1], [OpenSSL 1.1 is present])
|
|
||||||
LIBS="-lcrypto ${LIBS}"
|
|
||||||
],
|
|
||||||
[AC_MSG_ERROR([openssl library not found])]
|
[AC_MSG_ERROR([openssl library not found])]
|
||||||
)],
|
)],
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#define AES128_KEY_BYTES (128/8)
|
#define AES128_KEY_BYTES (128/8)
|
||||||
|
|
||||||
|
|
||||||
#if defined (HAVE_OPENSSL_1_1) // openSSL 1.1 ---------------------------------------------------------------------
|
#ifdef HAVE_LIBCRYPTO // openSSL 1.1 ---------------------------------------------------------------------
|
||||||
|
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
|
@ -23,14 +23,14 @@
|
||||||
|
|
||||||
#include <stddef.h> // for size_t
|
#include <stddef.h> // for size_t
|
||||||
#include <stdint.h> // for uint32_t, uint8_t
|
#include <stdint.h> // for uint32_t, uint8_t
|
||||||
#include "config.h" // HAVE_OPENSSL_1_1
|
#include "config.h" // HAVE_LIBCRYPTO
|
||||||
|
|
||||||
|
|
||||||
#define CC20_IV_SIZE 16
|
#define CC20_IV_SIZE 16
|
||||||
#define CC20_KEY_BYTES (256/8)
|
#define CC20_KEY_BYTES (256/8)
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL_1_1 // openSSL 1.1 ----------------------------------------------------------------------------
|
#ifdef HAVE_LIBCRYPTO // openSSL 1.1 ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
#include <zstd.h>
|
#include <zstd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (HAVE_OPENSSL_1_1)
|
#ifdef HAVE_LIBCRYPTO
|
||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "portable_endian.h" // for be32toh, htobe32
|
#include "portable_endian.h" // for be32toh, htobe32
|
||||||
|
|
||||||
|
|
||||||
#if defined (HAVE_OPENSSL_1_1) // openSSL 1.1 ---------------------------------------------------------------------
|
#ifdef HAVE_LIBCRYPTO // openSSL 1.1 ---------------------------------------------------------------------
|
||||||
|
|
||||||
#include <openssl/err.h> // for ERR_print_errors
|
#include <openssl/err.h> // for ERR_print_errors
|
||||||
#include <openssl/evp.h> // for EVP_EncryptInit_ex, EVP_CIPHER_CTX_set_p...
|
#include <openssl/evp.h> // for EVP_EncryptInit_ex, EVP_CIPHER_CTX_set_p...
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
#include <stdlib.h> // for calloc, free, size_t
|
#include <stdlib.h> // for calloc, free, size_t
|
||||||
#include <string.h> // for memcpy
|
#include <string.h> // for memcpy
|
||||||
#include "cc20.h"
|
#include "cc20.h"
|
||||||
#include "config.h" // HAVE_OPENSSL_1_1
|
#include "config.h" // HAVE_LIBCRYPTO
|
||||||
#include "n2n.h" // for TRACE_ERROR, traceEvent
|
#include "n2n.h" // for TRACE_ERROR, traceEvent
|
||||||
#include "portable_endian.h" // for htole32
|
#include "portable_endian.h" // for htole32
|
||||||
|
|
||||||
|
|
||||||
#if defined (HAVE_OPENSSL_1_1) // openSSL 1.1 ---------------------------------------------------------------------
|
#ifdef HAVE_LIBCRYPTO // openSSL 1.1 ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// get any erorr message out of openssl
|
// get any erorr message out of openssl
|
||||||
|
@ -406,7 +406,7 @@ int cc20_init (const unsigned char *key, cc20_context_t **ctx) {
|
||||||
*ctx = (cc20_context_t*)calloc(1, sizeof(cc20_context_t));
|
*ctx = (cc20_context_t*)calloc(1, sizeof(cc20_context_t));
|
||||||
if(!(*ctx))
|
if(!(*ctx))
|
||||||
return -1;
|
return -1;
|
||||||
#if defined (HAVE_OPENSSL_1_1)
|
#ifdef HAVE_LIBCRYPTO
|
||||||
if(!((*ctx)->ctx = EVP_CIPHER_CTX_new())) {
|
if(!((*ctx)->ctx = EVP_CIPHER_CTX_new())) {
|
||||||
traceEvent(TRACE_ERROR, "cc20_init openssl's evp_* encryption context creation failed: %s",
|
traceEvent(TRACE_ERROR, "cc20_init openssl's evp_* encryption context creation failed: %s",
|
||||||
openssl_err_as_string());
|
openssl_err_as_string());
|
||||||
|
@ -423,7 +423,7 @@ int cc20_init (const unsigned char *key, cc20_context_t **ctx) {
|
||||||
|
|
||||||
int cc20_deinit (cc20_context_t *ctx) {
|
int cc20_deinit (cc20_context_t *ctx) {
|
||||||
|
|
||||||
#if defined (HAVE_OPENSSL_1_1)
|
#ifdef HAVE_LIBCRYPTO
|
||||||
if(ctx->ctx) EVP_CIPHER_CTX_free(ctx->ctx);
|
if(ctx->ctx) EVP_CIPHER_CTX_free(ctx->ctx);
|
||||||
#endif
|
#endif
|
||||||
free(ctx);
|
free(ctx);
|
||||||
|
|
|
@ -1109,7 +1109,7 @@ int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
traceEvent(TRACE_NORMAL, "starting n2n edge %s %s", PACKAGE_VERSION, PACKAGE_BUILDDATE);
|
traceEvent(TRACE_NORMAL, "starting n2n edge %s %s", PACKAGE_VERSION, PACKAGE_BUILDDATE);
|
||||||
|
|
||||||
#if defined(HAVE_OPENSSL_1_1)
|
#ifdef HAVE_LIBCRYPTO
|
||||||
traceEvent(TRACE_NORMAL, "using %s", OpenSSL_version(0));
|
traceEvent(TRACE_NORMAL, "using %s", OpenSSL_version(0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user