mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-10-30 12:05:34 +03:00 
			
		
		
		
	Clean up crypto library abstraction in build system and source code
libssh2 used to explicitly check for libgcrypt and default to OpenSSL. Now all possible crypto libraries are checked for explicitly, making the addition of further crypto libraries both simpler and cleaner.
This commit is contained in:
		
							
								
								
									
										19
									
								
								Makefile.inc
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								Makefile.inc
									
									
									
									
									
								
							| @@ -1,7 +1,18 @@ | ||||
| CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \ | ||||
|  packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \ | ||||
|  version.c knownhost.c agent.c openssl.c libgcrypt.c pem.c keepalive.c \ | ||||
|  global.c | ||||
|  version.c knownhost.c agent.c pem.c keepalive.c global.c | ||||
| if OPENSSL | ||||
| CSOURCES += openssl.c | ||||
| endif | ||||
| if LIBGCRYPT | ||||
| CSOURCES += libgcrypt.c | ||||
| endif | ||||
|  | ||||
| HHEADERS = libssh2_priv.h openssl.h libgcrypt.h transport.h channel.h \ | ||||
|  comp.h mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h | ||||
| HHEADERS = libssh2_priv.h transport.h channel.h comp.h mac.h misc.h \ | ||||
|  packet.h userauth.h session.h sftp.h crypto.h | ||||
| if OPENSSL | ||||
| HHEADERS += openssl.h | ||||
| endif | ||||
| if LIBGCRYPT | ||||
| HHEADERS += libgcrypt.h | ||||
| endif | ||||
|   | ||||
| @@ -93,7 +93,7 @@ AC_ARG_WITH(libz, | ||||
|   AC_HELP_STRING([--with-libz],[Use Libz for compression]), | ||||
|   use_libz=$withval,use_libz=auto) | ||||
|  | ||||
| # Look for OpenSSL (default) | ||||
| # Look for OpenSSL | ||||
| if test "$use_openssl" != "no" && test "$use_libgcrypt" != "yes"; then | ||||
|   AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>]) | ||||
|   LIBSREQUIRED=libssl,libcrypto | ||||
| @@ -110,6 +110,11 @@ if test "$ac_cv_libssl" != "yes" && test "$ac_cv_libgcrypt" != "yes"; then | ||||
| try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH]) | ||||
| fi | ||||
|  | ||||
| if test "$ac_cv_libssl" = "yes"; then | ||||
|   AC_DEFINE(LIBSSH2_OPENSSL, 1, [Use OpenSSL]) | ||||
| fi | ||||
| AM_CONDITIONAL(OPENSSL, test "$ac_cv_libssl" = "yes") | ||||
|  | ||||
| if test "$ac_cv_libgcrypt" = "yes"; then | ||||
|   AC_DEFINE(LIBSSH2_LIBGCRYPT, 1, [Use libgcrypt]) | ||||
| fi | ||||
|   | ||||
| @@ -38,10 +38,12 @@ | ||||
| #ifndef LIBSSH2_CRYPTO_H | ||||
| #define LIBSSH2_CRYPTO_H | ||||
|  | ||||
| #ifdef LIBSSH2_OPENSSL | ||||
| #include "openssl.h" | ||||
| #endif | ||||
|  | ||||
| #ifdef LIBSSH2_LIBGCRYPT | ||||
| #include "libgcrypt.h" | ||||
| #else | ||||
| #include "openssl.h" | ||||
| #endif | ||||
|  | ||||
| int _libssh2_rsa_new(libssh2_rsa_ctx ** rsa, | ||||
|   | ||||
| @@ -40,8 +40,6 @@ | ||||
|  | ||||
| #include "libssh2_priv.h" | ||||
|  | ||||
| #ifndef LIBSSH2_LIBGCRYPT /* compile only if we build with OpenSSL */ | ||||
|  | ||||
| #include <string.h> | ||||
|  | ||||
| #ifndef EVP_MAX_BLOCK_LENGTH | ||||
| @@ -800,5 +798,3 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session, | ||||
|     EVP_PKEY_free(pk); | ||||
|     return st; | ||||
| } | ||||
|  | ||||
| #endif /* !LIBSSH2_LIBGCRYPT */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user