From 7e3307cb449527aa51a70c3eb608be7ea8d7ac6f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 17 Apr 2009 14:38:51 +0000 Subject: Fix openSSL support. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@524 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/wrapper.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'libssh/wrapper.c') diff --git a/libssh/wrapper.c b/libssh/wrapper.c index 7fa56e9..905f752 100644 --- a/libssh/wrapper.c +++ b/libssh/wrapper.c @@ -38,6 +38,10 @@ #include #include "libssh/priv.h" + +#ifdef HAVE_LIBGCRYPT +#include + #include "libssh/crypto.h" static int alloc_key(struct crypto_struct *cipher) { @@ -49,9 +53,6 @@ static int alloc_key(struct crypto_struct *cipher) { return 0; } -#ifdef HAVE_LIBGCRYPT -#include - SHACTX sha1_init(void) { SHACTX ctx = NULL; gcry_md_open(&ctx, GCRY_MD_SHA1, 0); @@ -410,15 +411,19 @@ static struct crypto_struct ssh_ciphertab[] = { #define OLD_CRYPTO #endif -#ifdef cbc_encrypt -#undef cbc_encrypt -#endif -#ifdef cbc_decrypt -#undef cbc_decrypt -#endif +#include "libssh/crypto.h" + +static int alloc_key(struct crypto_struct *cipher) { + cipher->key = malloc(cipher->keylen); + if (cipher->key == NULL) { + return -1; + } + + return 0; +} SHACTX sha1_init(void) { - SHACTX c = malloc(sizeof(SHACTX)); + SHACTX c = malloc(sizeof(*c)); if (c == NULL) { return NULL; } @@ -441,10 +446,11 @@ void sha1(unsigned char *digest, int len, unsigned char *hash) { } MD5CTX md5_init(void) { - MD5CTX c = malloc(sizeof(MD5CTX)); + MD5CTX c = malloc(sizeof(*c)); if (c == NULL) { return NULL; } + MD5_Init(c); return c; @@ -762,7 +768,7 @@ static void cipher_free(struct crypto_struct *cipher) { CRYPTO *crypto_new(void) { CRYPTO *crypto; - crypto = malloc(sizeof (CRYPTO)); + crypto = malloc(sizeof(CRYPTO)); if (crypto == NULL) { return NULL; } -- cgit