diff options
-rw-r--r-- | libssh/wrapper.c | 30 |
1 files changed, 18 insertions, 12 deletions
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 <string.h> #include "libssh/priv.h" + +#ifdef HAVE_LIBGCRYPT +#include <gcrypt.h> + #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 <gcrypt.h> - 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; } |