diff --git a/src/hostkey.c b/src/hostkey.c index 4058c64..a07a442 100644 --- a/src/hostkey.c +++ b/src/hostkey.c @@ -552,11 +552,11 @@ LIBSSH2_HOSTKEY_METHOD **libssh2_hostkey_methods(void) LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type) { switch (hash_type) { -#ifndef OPENSSL_NO_MD5 +#if LIBSSH2_MD5 case LIBSSH2_HOSTKEY_HASH_MD5: return (char *)session->server_hostkey_md5; break; -#endif /* ! OPENSSL_NO_MD5 */ +#endif /* ! LIBSSH2_MD5 */ case LIBSSH2_HOSTKEY_HASH_SHA1: return (char *)session->server_hostkey_sha1; break; diff --git a/src/kex.c b/src/kex.c index b7ce801..b773ff2 100644 --- a/src/kex.c +++ b/src/kex.c @@ -155,7 +155,7 @@ static int libssh2_kex_method_diffie_hellman_groupGP_sha1_key_exchange(LIBSSH2_S memcpy(session->server_hostkey, s, session->server_hostkey_len); s += session->server_hostkey_len; -#ifndef OPENSSL_NO_MD5 +#if LIBSSH2_MD5 { libssh2_md5_ctx fingerprint_ctx; @@ -174,7 +174,7 @@ static int libssh2_kex_method_diffie_hellman_groupGP_sha1_key_exchange(LIBSSH2_S _libssh2_debug(session, LIBSSH2_DBG_KEX, "Server's MD5 Fingerprint: %s", fingerprint); } #endif /* LIBSSH2_DEBUG_KEX */ -#endif /* ! OPENSSL_NO_MD5 */ +#endif /* ! LIBSSH2_MD5 */ { libssh2_sha1_ctx fingerprint_ctx; diff --git a/src/libgcrypt.h b/src/libgcrypt.h index 551113b..c75593b 100644 --- a/src/libgcrypt.h +++ b/src/libgcrypt.h @@ -37,6 +37,8 @@ #include +#define LIBSSH2_MD5 1 + #define MD5_DIGEST_LENGTH 16 #define SHA_DIGEST_LENGTH 20 diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index 7759352..55043d5 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -208,9 +208,9 @@ struct _LIBSSH2_SESSION { */ unsigned char *server_hostkey; unsigned long server_hostkey_len; -#ifndef OPENSSL_NO_MD5 +#if LIBSSH2_MD5 unsigned char server_hostkey_md5[MD5_DIGEST_LENGTH]; -#endif /* ! OPENSSL_NO_MD5 */ +#endif /* ! LIBSSH2_MD5 */ unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH]; /* (remote as source of data -- packet_read ) */ diff --git a/src/openssl.h b/src/openssl.h index a17af88..85edb8e 100644 --- a/src/openssl.h +++ b/src/openssl.h @@ -44,6 +44,12 @@ #include #include +#ifndef OPENSSL_NO_MD5 +# define LIBSSH2_MD5 0 +#else +# define LIBSSH2_MD5 1 +#endif + #define libssh2_random(buf, len) \ RAND_bytes ((buf), (len))