aboutsummaryrefslogtreecommitdiff
path: root/libssh/wrapper.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-17 14:38:51 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-17 14:38:51 +0000
commit7e3307cb449527aa51a70c3eb608be7ea8d7ac6f (patch)
treec253f7a5e03ce80284a307d51cba64bc0040a9ee /libssh/wrapper.c
parentcf8e4447640375e2389518bab3e293164bb050ad (diff)
downloadlibssh-7e3307cb449527aa51a70c3eb608be7ea8d7ac6f.tar.gz
libssh-7e3307cb449527aa51a70c3eb608be7ea8d7ac6f.tar.xz
libssh-7e3307cb449527aa51a70c3eb608be7ea8d7ac6f.zip
Fix openSSL support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@524 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/wrapper.c')
-rw-r--r--libssh/wrapper.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/libssh/wrapper.c b/libssh/wrapper.c
index 7fa56e9b..905f7528 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;
}