1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-02 10:53:16 +03:00

Use LIBSSH2_* instead of OPENSSL_NO_* (should ultimately be possible

to chose by ./configure?).
This commit is contained in:
Simon Josefsson
2007-01-17 14:41:06 +00:00
parent 5c904b112e
commit 6873ada0b7
5 changed files with 14 additions and 6 deletions

View File

@@ -552,11 +552,11 @@ LIBSSH2_HOSTKEY_METHOD **libssh2_hostkey_methods(void)
LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type) LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type)
{ {
switch (hash_type) { switch (hash_type) {
#ifndef OPENSSL_NO_MD5 #if LIBSSH2_MD5
case LIBSSH2_HOSTKEY_HASH_MD5: case LIBSSH2_HOSTKEY_HASH_MD5:
return (char *)session->server_hostkey_md5; return (char *)session->server_hostkey_md5;
break; break;
#endif /* ! OPENSSL_NO_MD5 */ #endif /* ! LIBSSH2_MD5 */
case LIBSSH2_HOSTKEY_HASH_SHA1: case LIBSSH2_HOSTKEY_HASH_SHA1:
return (char *)session->server_hostkey_sha1; return (char *)session->server_hostkey_sha1;
break; break;

View File

@@ -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); memcpy(session->server_hostkey, s, session->server_hostkey_len);
s += session->server_hostkey_len; s += session->server_hostkey_len;
#ifndef OPENSSL_NO_MD5 #if LIBSSH2_MD5
{ {
libssh2_md5_ctx fingerprint_ctx; 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); _libssh2_debug(session, LIBSSH2_DBG_KEX, "Server's MD5 Fingerprint: %s", fingerprint);
} }
#endif /* LIBSSH2_DEBUG_KEX */ #endif /* LIBSSH2_DEBUG_KEX */
#endif /* ! OPENSSL_NO_MD5 */ #endif /* ! LIBSSH2_MD5 */
{ {
libssh2_sha1_ctx fingerprint_ctx; libssh2_sha1_ctx fingerprint_ctx;

View File

@@ -37,6 +37,8 @@
#include <gcrypt.h> #include <gcrypt.h>
#define LIBSSH2_MD5 1
#define MD5_DIGEST_LENGTH 16 #define MD5_DIGEST_LENGTH 16
#define SHA_DIGEST_LENGTH 20 #define SHA_DIGEST_LENGTH 20

View File

@@ -208,9 +208,9 @@ struct _LIBSSH2_SESSION {
*/ */
unsigned char *server_hostkey; unsigned char *server_hostkey;
unsigned long server_hostkey_len; unsigned long server_hostkey_len;
#ifndef OPENSSL_NO_MD5 #if LIBSSH2_MD5
unsigned char server_hostkey_md5[MD5_DIGEST_LENGTH]; unsigned char server_hostkey_md5[MD5_DIGEST_LENGTH];
#endif /* ! OPENSSL_NO_MD5 */ #endif /* ! LIBSSH2_MD5 */
unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH]; unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH];
/* (remote as source of data -- packet_read ) */ /* (remote as source of data -- packet_read ) */

View File

@@ -44,6 +44,12 @@
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#ifndef OPENSSL_NO_MD5
# define LIBSSH2_MD5 0
#else
# define LIBSSH2_MD5 1
#endif
#define libssh2_random(buf, len) \ #define libssh2_random(buf, len) \
RAND_bytes ((buf), (len)) RAND_bytes ((buf), (len))