1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

build: drop crypto.c umbrella source

Instead build all crypto backend sources always, and exclude inactive
ones with guards.

To play better with code checkers and compilers that are blind to
included C sources, e.g. clang with certain compiler warnings and
clang-tidy.

We continue to include `blowfish.c`.

Follow-up to 4f0f4bff5a #941
Cherry-picked from #1561
This commit is contained in:
Viktor Szakats
2025-03-19 12:32:40 +01:00
parent ddc4cf34da
commit e0681cdba9
8 changed files with 31 additions and 43 deletions

View File

@ -33,16 +33,14 @@ LTLIBNEWNAME variable on success.
0.3) Add new header to src/Makefile.inc 0.3) Add new header to src/Makefile.inc
0.4) Include new source in src/crypto.c 0.4) Add a new block in configure.ac
0.5) Add a new block in configure.ac
``` ```
elif test "$found_crypto" = "newname"; then elif test "$found_crypto" = "newname"; then
LIBS="${LIBS} ${LTLIBNEWNAME}" LIBS="${LIBS} ${LTLIBNEWNAME}"
``` ```
0.6) Add CMake detection logic to CMakeLists.txt 0.5) Add CMake detection logic to CMakeLists.txt
1) Crypto library initialization/termination. 1) Crypto library initialization/termination.

View File

@ -3,19 +3,22 @@
CSOURCES = \ CSOURCES = \
agent.c \ agent.c \
bcrypt_pbkdf.c \ bcrypt_pbkdf.c \
channel.c \
comp.c \
chacha.c \ chacha.c \
channel.c \
cipher-chachapoly.c \ cipher-chachapoly.c \
comp.c \
crypt.c \ crypt.c \
crypto.c \
global.c \ global.c \
hostkey.c \ hostkey.c \
keepalive.c \ keepalive.c \
kex.c \ kex.c \
knownhost.c \ knownhost.c \
libgcrypt.c \
mac.c \ mac.c \
mbedtls.c \
misc.c \ misc.c \
openssl.c \
os400qc3.c \
packet.c \ packet.c \
pem.c \ pem.c \
poly1305.c \ poly1305.c \
@ -26,7 +29,8 @@ CSOURCES = \
transport.c \ transport.c \
userauth.c \ userauth.c \
userauth_kbd_packet.c \ userauth_kbd_packet.c \
version.c version.c \
wincng.c
HHEADERS = \ HHEADERS = \
chacha.h \ chacha.h \
@ -53,9 +57,4 @@ HHEADERS = \
wincng.h wincng.h
EXTRA_DIST = \ EXTRA_DIST = \
blowfish.c \ blowfish.c
libgcrypt.c \
mbedtls.c \
openssl.c \
os400qc3.c \
wincng.c

View File

@ -1,19 +0,0 @@
/* Copyright (C) Viktor Szakats
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#define LIBSSH2_CRYPTO_C
#include "libssh2_priv.h"
#if defined(LIBSSH2_OPENSSL) || defined(LIBSSH2_WOLFSSL)
#include "openssl.c"
#elif defined(LIBSSH2_LIBGCRYPT)
#include "libgcrypt.c"
#elif defined(LIBSSH2_MBEDTLS)
#include "mbedtls.c"
#elif defined(LIBSSH2_OS400QC3)
#include "os400qc3.c"
#elif defined(LIBSSH2_WINCNG)
#include "wincng.c"
#endif

View File

@ -38,7 +38,9 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #include "libssh2_priv.h"
#ifdef LIBSSH2_LIBGCRYPT
int _libssh2_hmac_ctx_init(libssh2_hmac_ctx *ctx) int _libssh2_hmac_ctx_init(libssh2_hmac_ctx *ctx)
{ {
@ -860,4 +862,4 @@ _libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
return NULL; return NULL;
} }
#endif /* LIBSSH2_CRYPTO_C */ #endif /* LIBSSH2_LIBGCRYPT */

View File

@ -37,7 +37,9 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #include "libssh2_priv.h"
#ifdef LIBSSH2_MBEDTLS
#include <stdlib.h> #include <stdlib.h>
@ -1532,4 +1534,4 @@ _libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
return NULL; return NULL;
} }
#endif /* LIBSSH2_CRYPTO_C */ #endif /* LIBSSH2_MBEDTLS */

View File

@ -39,7 +39,9 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #include "libssh2_priv.h"
#if defined(LIBSSH2_OPENSSL) || defined(LIBSSH2_WOLFSSL)
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -5237,4 +5239,4 @@ _libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
return NULL; return NULL;
} }
#endif /* LIBSSH2_CRYPTO_C */ #endif /* LIBSSH2_OPENSSL || LIBSSH2_WOLFSSL */

View File

@ -38,7 +38,9 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #include "libssh2_priv.h"
#ifdef LIBSSH2_OS400QC3
#include <stdlib.h> #include <stdlib.h>
@ -2530,6 +2532,6 @@ _libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
return NULL; return NULL;
} }
#endif /* LIBSSH2_CRYPTO_C */ #endif /* LIBSSH2_OS400QC3 */
/* vim: set expandtab ts=4 sw=4: */ /* vim: set expandtab ts=4 sw=4: */

View File

@ -38,7 +38,9 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #include "libssh2_priv.h"
#ifdef LIBSSH2_WINCNG
/* required for cross-compilation against the w64 mingw-runtime package */ /* required for cross-compilation against the w64 mingw-runtime package */
#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0600) #if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0600)
@ -4201,4 +4203,4 @@ _libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
return NULL; return NULL;
} }
#endif /* LIBSSH2_CRYPTO_C */ #endif /* LIBSSH2_WINCNG */