From c089b700c677de107bebc44c5f5daf30d44a84ba Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Fri, 8 Jun 2018 16:18:06 -0700 Subject: chacha: fix build for mbedTLS Fix the build for mbedTLS: * set HAVE_CHACHA for non-mbedTLS builds * only compile chachapoly.c when HAVE_CHACHA * use empty CHACHA20 in src/kex.c unless HAVE_CHACHA Signed-off-by: Jon Simons Reviewed-by: Andreas Schneider --- ConfigureChecks.cmake | 3 ++- config.h.cmake | 3 +++ src/CMakeLists.txt | 8 +++++++- src/kex.c | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index fd8ff136..3bb4a5e0 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -138,7 +138,8 @@ endif () if (NOT WITH_MBEDTLS) set(HAVE_DSA 1) -endif() + set(HAVE_CHACHA 1) +endif (NOT WITH_MBEDTLS) # FUNCTIONS diff --git a/config.h.cmake b/config.h.cmake index 61d20acb..044e6032 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -89,6 +89,9 @@ /* Define to 1 if you have DSA */ #cmakedefine HAVE_DSA 1 +/* Define to 1 if you have chacha20-poly1305 */ +#cmakedefine HAVE_CHACHA 1 + /*************************** FUNCTIONS ***************************/ /* Define to 1 if you have the `EVP_aes128_ctr' function. */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90e44253..4edc59f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -122,7 +122,6 @@ set(libssh_SRCS bignum.c buffer.c callbacks.c - chachapoly.c channels.c client.c config.c @@ -167,6 +166,13 @@ set(libssh_SRCS external/sc25519.c ) +if (NOT WITH_MBEDTLS) + set(libssh_SRCS + ${libssh_SRCS} + chachapoly.c + ) +endif (NOT WITH_MBEDTLS) + if (WITH_GCRYPT) set(libssh_SRCS ${libssh_SRCS} diff --git a/src/kex.c b/src/kex.c index 00f4e00f..8c51566e 100644 --- a/src/kex.c +++ b/src/kex.c @@ -95,7 +95,11 @@ #define ECDH "" #endif +#ifdef HAVE_CHACHA #define CHACHA20 "chacha20-poly1305@openssh.com," +#else /* HAVE_CHACHA */ +#define CHACHA20 +#endif /* HAVE_CHACHA */ #define KEY_EXCHANGE CURVE25519 ECDH "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" #define KEX_METHODS_SIZE 10 -- cgit v1.2.3