aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-17 14:13:38 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-17 14:13:38 +0000
commitcf8e4447640375e2389518bab3e293164bb050ad (patch)
tree7579807014fdebcc24d6a1788df6ff240442d51a /libssh
parent109c10bdfd0e46f1a537d2766f3731164d94f28c (diff)
downloadlibssh-cf8e4447640375e2389518bab3e293164bb050ad.tar.gz
libssh-cf8e4447640375e2389518bab3e293164bb050ad.tar.xz
libssh-cf8e4447640375e2389518bab3e293164bb050ad.zip
Fix build with openssl.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@523 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r--libssh/wrapper.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/libssh/wrapper.c b/libssh/wrapper.c
index a825f3ba..7fa56e9b 100644
--- a/libssh/wrapper.c
+++ b/libssh/wrapper.c
@@ -33,12 +33,13 @@
* are welcome.
*/
-#include "libssh/priv.h"
-#include "libssh/crypto.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "libssh/priv.h"
+#include "libssh/crypto.h"
+
static int alloc_key(struct crypto_struct *cipher) {
cipher->key = malloc(cipher->keylen);
if (cipher->key == NULL) {
@@ -383,7 +384,9 @@ static struct crypto_struct ssh_ciphertab[] = {
.cbc_decrypt = NULL
}
};
+
#elif defined HAVE_LIBCRYPTO
+
#include <openssl/sha.h>
#include <openssl/md5.h>
#include <openssl/dsa.h>
@@ -407,8 +410,15 @@ static struct crypto_struct ssh_ciphertab[] = {
#define OLD_CRYPTO
#endif
+#ifdef cbc_encrypt
+#undef cbc_encrypt
+#endif
+#ifdef cbc_decrypt
+#undef cbc_decrypt
+#endif
+
SHACTX sha1_init(void) {
- SHACTX ctx = malloc(sizeof(*c));
+ SHACTX c = malloc(sizeof(SHACTX));
if (c == NULL) {
return NULL;
}
@@ -494,24 +504,25 @@ void hmac_final(HMACCTX ctx, unsigned char *hashmacbuf, unsigned int *len) {
#ifdef HAS_BLOWFISH
/* the wrapper functions for blowfish */
-static void blowfish_set_key(struct crypto_struct *cipher, void *key){
- if(!cipher->key){
- /* TODO FIXME */
- if (alloc_key(cipher) < 0) {
- return;
- }
- BF_set_key(cipher->key,16,key);
+static int blowfish_set_key(struct crypto_struct *cipher, void *key){
+ if (cipher->key == NULL) {
+ if (alloc_key(cipher) < 0) {
+ return -1;
}
+ BF_set_key(cipher->key, 16, key);
+ }
+
+ return 0;
}
static void blowfish_encrypt(struct crypto_struct *cipher, void *in,
void *out, unsigned long len, void *IV) {
- BF_cbc_encrypt(in,out,len,cipher->key,IV,BF_ENCRYPT);
+ BF_cbc_encrypt(in, out, len, cipher->key, IV, BF_ENCRYPT);
}
static void blowfish_decrypt(struct crypto_struct *cipher, void *in,
void *out, unsigned long len, void *IV) {
- BF_cbc_encrypt(in,out,len,cipher->key,IV,BF_DECRYPT);
+ BF_cbc_encrypt(in, out, len, cipher->key, IV, BF_DECRYPT);
}
#endif /* HAS_BLOWFISH */
@@ -539,6 +550,8 @@ static int aes_set_decrypt_key(struct crypto_struct *cipher, void *key) {
return -1;
}
}
+
+ return 0;
}
static void aes_encrypt(struct crypto_struct *cipher, void *in, void *out,
@@ -617,6 +630,7 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
ssh_print_hexa("Decrypt IV after", IV, 24);
#endif
}
+
#endif /* HAS_DES */
/* the table of supported ciphers */
@@ -633,7 +647,7 @@ static struct crypto_struct ssh_ciphertab[] = {
.cbc_encrypt = blowfish_encrypt,
.cbc_decrypt = blowfish_decrypt
},
-#endif
+#endif /* HAS_BLOWFISH */
#ifdef HAS_AES
{
.name = "aes128-cbc",
@@ -668,7 +682,7 @@ static struct crypto_struct ssh_ciphertab[] = {
.cbc_encrypt = aes_encrypt,
.cbc_decrypt = aes_decrypt
},
-#endif
+#endif /* HAS_AES */
#ifdef HAS_DES
{
.name = "3des-cbc",
@@ -692,7 +706,7 @@ static struct crypto_struct ssh_ciphertab[] = {
.cbc_encrypt = des3_1_encrypt,
.cbc_decrypt = des3_1_decrypt
},
-#endif
+#endif /* HAS_DES */
{
.name = NULL,
.blocksize = 0,