mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
Fix build with openssl.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@523 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -27,18 +27,13 @@
|
|||||||
* the filename would cause problems on most systems).
|
* the filename would cause problems on most systems).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef set_key
|
|
||||||
#undef set_key
|
|
||||||
#endif
|
|
||||||
#ifdef cbc_encrypt
|
#ifdef cbc_encrypt
|
||||||
#undef cbc_encrypt
|
#undef cbc_encrypt
|
||||||
#endif
|
#endif
|
||||||
#ifdef cbc_decrypt
|
#ifdef cbc_decrypt
|
||||||
#undef cbc_decrypt
|
#undef cbc_decrypt
|
||||||
#endif
|
#endif
|
||||||
#ifdef des_set_key
|
|
||||||
#undef des_set_key
|
|
||||||
#endif
|
|
||||||
#ifdef GCRYPT
|
#ifdef GCRYPT
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,12 +33,13 @@
|
|||||||
* are welcome.
|
* are welcome.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
|
||||||
#include "libssh/crypto.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/crypto.h"
|
||||||
|
|
||||||
static int alloc_key(struct crypto_struct *cipher) {
|
static int alloc_key(struct crypto_struct *cipher) {
|
||||||
cipher->key = malloc(cipher->keylen);
|
cipher->key = malloc(cipher->keylen);
|
||||||
if (cipher->key == NULL) {
|
if (cipher->key == NULL) {
|
||||||
@@ -383,7 +384,9 @@ static struct crypto_struct ssh_ciphertab[] = {
|
|||||||
.cbc_decrypt = NULL
|
.cbc_decrypt = NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
|
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
#include <openssl/dsa.h>
|
#include <openssl/dsa.h>
|
||||||
@@ -407,8 +410,15 @@ static struct crypto_struct ssh_ciphertab[] = {
|
|||||||
#define OLD_CRYPTO
|
#define OLD_CRYPTO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef cbc_encrypt
|
||||||
|
#undef cbc_encrypt
|
||||||
|
#endif
|
||||||
|
#ifdef cbc_decrypt
|
||||||
|
#undef cbc_decrypt
|
||||||
|
#endif
|
||||||
|
|
||||||
SHACTX sha1_init(void) {
|
SHACTX sha1_init(void) {
|
||||||
SHACTX ctx = malloc(sizeof(*c));
|
SHACTX c = malloc(sizeof(SHACTX));
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -494,24 +504,25 @@ void hmac_final(HMACCTX ctx, unsigned char *hashmacbuf, unsigned int *len) {
|
|||||||
|
|
||||||
#ifdef HAS_BLOWFISH
|
#ifdef HAS_BLOWFISH
|
||||||
/* the wrapper functions for blowfish */
|
/* the wrapper functions for blowfish */
|
||||||
static void blowfish_set_key(struct crypto_struct *cipher, void *key){
|
static int blowfish_set_key(struct crypto_struct *cipher, void *key){
|
||||||
if(!cipher->key){
|
if (cipher->key == NULL) {
|
||||||
/* TODO FIXME */
|
if (alloc_key(cipher) < 0) {
|
||||||
if (alloc_key(cipher) < 0) {
|
return -1;
|
||||||
return;
|
|
||||||
}
|
|
||||||
BF_set_key(cipher->key,16,key);
|
|
||||||
}
|
}
|
||||||
|
BF_set_key(cipher->key, 16, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blowfish_encrypt(struct crypto_struct *cipher, void *in,
|
static void blowfish_encrypt(struct crypto_struct *cipher, void *in,
|
||||||
void *out, unsigned long len, void *IV) {
|
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,
|
static void blowfish_decrypt(struct crypto_struct *cipher, void *in,
|
||||||
void *out, unsigned long len, void *IV) {
|
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 */
|
#endif /* HAS_BLOWFISH */
|
||||||
|
|
||||||
@@ -539,6 +550,8 @@ static int aes_set_decrypt_key(struct crypto_struct *cipher, void *key) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aes_encrypt(struct crypto_struct *cipher, void *in, void *out,
|
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);
|
ssh_print_hexa("Decrypt IV after", IV, 24);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAS_DES */
|
#endif /* HAS_DES */
|
||||||
|
|
||||||
/* the table of supported ciphers */
|
/* the table of supported ciphers */
|
||||||
@@ -633,7 +647,7 @@ static struct crypto_struct ssh_ciphertab[] = {
|
|||||||
.cbc_encrypt = blowfish_encrypt,
|
.cbc_encrypt = blowfish_encrypt,
|
||||||
.cbc_decrypt = blowfish_decrypt
|
.cbc_decrypt = blowfish_decrypt
|
||||||
},
|
},
|
||||||
#endif
|
#endif /* HAS_BLOWFISH */
|
||||||
#ifdef HAS_AES
|
#ifdef HAS_AES
|
||||||
{
|
{
|
||||||
.name = "aes128-cbc",
|
.name = "aes128-cbc",
|
||||||
@@ -668,7 +682,7 @@ static struct crypto_struct ssh_ciphertab[] = {
|
|||||||
.cbc_encrypt = aes_encrypt,
|
.cbc_encrypt = aes_encrypt,
|
||||||
.cbc_decrypt = aes_decrypt
|
.cbc_decrypt = aes_decrypt
|
||||||
},
|
},
|
||||||
#endif
|
#endif /* HAS_AES */
|
||||||
#ifdef HAS_DES
|
#ifdef HAS_DES
|
||||||
{
|
{
|
||||||
.name = "3des-cbc",
|
.name = "3des-cbc",
|
||||||
@@ -692,7 +706,7 @@ static struct crypto_struct ssh_ciphertab[] = {
|
|||||||
.cbc_encrypt = des3_1_encrypt,
|
.cbc_encrypt = des3_1_encrypt,
|
||||||
.cbc_decrypt = des3_1_decrypt
|
.cbc_decrypt = des3_1_decrypt
|
||||||
},
|
},
|
||||||
#endif
|
#endif /* HAS_DES */
|
||||||
{
|
{
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
.blocksize = 0,
|
.blocksize = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user