Skip to content

Commit

Permalink
Use LIBSSH2_* instead of OPENSSL_NO_* (should ultimately be possible
Browse files Browse the repository at this point in the history
to chose by ./configure?).
  • Loading branch information
jas4711 committed Jan 17, 2007
1 parent 6873ada commit c090ac7
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 38 deletions.
44 changes: 22 additions & 22 deletions src/crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "libssh2_priv.h"
#include <openssl/evp.h>

#ifdef LIBSSH2_CRYPT_NONE
#if LIBSSH2_CRYPT_NONE
/* {{{ libssh2_crypt_none_crypt
* Minimalist cipher: VERY secure *wink*
*/
Expand All @@ -59,7 +59,7 @@ static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_none = {
libssh2_crypt_none_crypt,
NULL
};
#endif
#endif /* LIBSSH2_CRYPT_NONE */

#define MAKE_INIT(name, cipher) \
static int name (LIBSSH2_SESSION *session, \
Expand Down Expand Up @@ -127,7 +127,7 @@ static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_3des_cbc = {
&dtor
};

#if OPENSSL_VERSION_NUMBER >= 0x00907000L && !defined(OPENSSL_NO_AES)
#if LIBSSH2_AES
static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_aes128_cbc = {
"aes128-cbc",
16, /* blocksize */
Expand Down Expand Up @@ -172,9 +172,9 @@ static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_rijndael_cbc_lysator_liu_se = {
&crypt,
&dtor
};
#endif /* OPENSSL_VERSION_NUMBER >= 0x00907000L && !defined(OPENSSL_NO_AES)*/
#endif /* LIBSSH2_AES */

#ifndef OPENSSL_NO_BLOWFISH
#if LIBSSH2_BLOWFISH
static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_blowfish_cbc = {
"blowfish-cbc",
8, /* blocksize */
Expand All @@ -185,9 +185,9 @@ static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_blowfish_cbc = {
&crypt,
&dtor
};
#endif /* ! OPENSSL_NO_BLOWFISH */
#endif /* LIBSSH2_BLOWFISH */

#ifndef OPENSSL_NO_CAST
#if LIBSSH2_CAST
static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_cast128_cbc = {
"cast128-cbc",
8, /* blocksize */
Expand All @@ -198,9 +198,9 @@ static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_cast128_cbc = {
&crypt,
&dtor
};
#endif /* ! OPENSSL_NO_CAST */
#endif /* LIBSSH2_CAST */

#ifndef OPENSSL_NO_RC4
#if LIBSSH2_RC4
static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_arcfour = {
"arcfour",
8, /* blocksize */
Expand All @@ -211,29 +211,29 @@ static LIBSSH2_CRYPT_METHOD libssh2_crypt_method_arcfour = {
&crypt,
&dtor
};
#endif /* ! OPENSSL_NO_RC4 */
#endif /* LIBSSH2_RC4 */

static LIBSSH2_CRYPT_METHOD *_libssh2_crypt_methods[] = {
#if OPENSSL_VERSION_NUMBER >= 0x00907000L && !defined(OPENSSL_NO_AES)
#if LIBSSH2_AES
&libssh2_crypt_method_aes256_cbc,
&libssh2_crypt_method_rijndael_cbc_lysator_liu_se, /* == aes256-cbc */
&libssh2_crypt_method_aes192_cbc,
&libssh2_crypt_method_aes128_cbc,
#endif /* OPENSSL_VERSION_NUMBER >= 0x00907000L && !defined(OPENSSL_NO_AES) */
#ifndef OPENSSL_NO_BLOWFISH
#endif /* LIBSSH2_AES */
#if LIBSSH2_BLOWFISH
&libssh2_crypt_method_blowfish_cbc,
#endif /* ! OPENSSL_NO_BLOWFISH */
#ifndef OPENSSL_NO_RC4
#endif /* LIBSSH2_BLOWFISH */
#if LIBSSH2_RC4
&libssh2_crypt_method_arcfour,
#endif /* ! OPENSSL_NO_RC4 */
#ifndef OPENSSL_NO_CAST
#endif /* LIBSSH2_RC4 */
#if LIBSSH2_CAST
&libssh2_crypt_method_cast128_cbc,
#endif /* ! OPENSSL_NO_CAST */
#ifndef OPENSSL_NO_DES
#endif /* LIBSSH2_CAST */
#if LIBSSH2_3DES
&libssh2_crypt_method_3des_cbc,
#endif /* ! OPENSSL_NO_DES */
#ifdef LIBSSH2_CRYPT_NONE
&libssh2_crypt_method_none,
#endif /* LIBSSH2_DES */
#if LIBSSH2_CRYPT_NONE
&libssh2_crypt_method_none,
#endif
NULL
};
Expand Down
18 changes: 9 additions & 9 deletions src/hostkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include <sys/uio.h>
#endif

#ifndef OPENSSL_NO_RSA
#if LIBSSH2_RSA
/* ***********
* ssh-rsa *
*********** */
Expand Down Expand Up @@ -281,9 +281,9 @@ static LIBSSH2_HOSTKEY_METHOD libssh2_hostkey_method_ssh_rsa = {
NULL, /* encrypt */
libssh2_hostkey_method_ssh_rsa_dtor,
};
#endif /* ! OPENSSL_NO_RSA */
#endif /* LIBSSH2_RSA */

#ifndef OPENSSL_NO_DSA
#if LIBSSH2_DSA
/* ***********
* ssh-dss *
*********** */
Expand Down Expand Up @@ -526,15 +526,15 @@ static LIBSSH2_HOSTKEY_METHOD libssh2_hostkey_method_ssh_dss = {
NULL, /* encrypt */
libssh2_hostkey_method_ssh_dss_dtor,
};
#endif /* ! OPENSSL_NO_DSA */
#endif /* LIBSSH2_DSA */

static LIBSSH2_HOSTKEY_METHOD *_libssh2_hostkey_methods[] = {
#ifndef OPENSSL_NO_RSA
#if LIBSSH2_RSA
&libssh2_hostkey_method_ssh_rsa,
#endif /* ! OPENSSL_NO_RSA */
#ifndef OPENSSL_NO_DSA
#endif /* LIBSSH2_RSA */
#if LIBSSH2_DSA
&libssh2_hostkey_method_ssh_dss,
#endif /* ! OPENSSL_NO_DSA */
#endif /* LIBSSH2_DSA */
NULL
};

Expand All @@ -556,7 +556,7 @@ LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_
case LIBSSH2_HOSTKEY_HASH_MD5:
return (char *)session->server_hostkey_md5;
break;
#endif /* ! LIBSSH2_MD5 */
#endif /* LIBSSH2_MD5 */
case LIBSSH2_HOSTKEY_HASH_SHA1:
return (char *)session->server_hostkey_sha1;
break;
Expand Down
11 changes: 11 additions & 0 deletions src/libgcrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@

#define LIBSSH2_MD5 1

#define LIBSSH2_HMAC_RIPEMD 1

#define LIBSSH2_AES 1
#define LIBSSH2_BLOWFISH 1
#define LIBSSH2_RC4 1
#define LIBSSH2_CAST 1
#define LIBSSH2_3DES 1

#define LIBSSH2_RSA 1
#define LIBSSH2_DSA 1

#define MD5_DIGEST_LENGTH 16
#define SHA_DIGEST_LENGTH 20

Expand Down
12 changes: 6 additions & 6 deletions src/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "libssh2_priv.h"

#ifdef LIBSSH2_MAC_NONE
#if LIBSSH2_MAC_NONE
/* {{{ libssh2_mac_none_MAC
* Minimalist MAC: No MAC
*/
Expand Down Expand Up @@ -206,7 +206,7 @@ static LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_md5_96 = {
libssh2_mac_method_common_dtor,
};

#ifndef OPENSSL_NO_RIPEMD
#if LIBSSH2_HMAC_RIPEMD
/* {{{ libssh2_mac_method_hmac_ripemd160_hash
* Calculate hash using ripemd160 value
*/
Expand Down Expand Up @@ -249,18 +249,18 @@ static LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_ripemd160_openssh_com = {
libssh2_mac_method_hmac_ripemd160_hash,
libssh2_mac_method_common_dtor,
};
#endif /* ! OPENSSL_NO_RIPEMD */
#endif /* LIBSSH2_HMAC_RIPEMD */

static LIBSSH2_MAC_METHOD *_libssh2_mac_methods[] = {
&libssh2_mac_method_hmac_sha1,
&libssh2_mac_method_hmac_sha1_96,
&libssh2_mac_method_hmac_md5,
&libssh2_mac_method_hmac_md5_96,
#ifndef OPENSSL_NO_RIPEMD
#if LIBSSH2_HMAC_RIPEMD
&libssh2_mac_method_hmac_ripemd160,
&libssh2_mac_method_hmac_ripemd160_openssh_com,
#endif /* ! OPENSSL_NO_RIPEMD */
#ifdef LIBSSH2_MAC_NONE
#endif /* LIBSSH2_HMAC_RIPEMD */
#if LIBSSH2_MAC_NONE
&libssh2_mac_method_none,
#endif /* LIBSSH2_MAC_NONE */
NULL
Expand Down
51 changes: 50 additions & 1 deletion src/openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* OF SUCH DAMAGE.
*/

#include <openssl/opensslconf.h>
#include <openssl/sha.h>
#ifndef OPENSSL_NO_MD5
#include <openssl/md5.h>
Expand All @@ -44,12 +45,60 @@
#include <openssl/bn.h>
#include <openssl/pem.h>

#ifndef OPENSSL_NO_MD5
#ifdef OPENSSL_NO_RSA
# define LIBSSH2_RSA 0
#else
# define LIBSSH2_RSA 1
#endif

#ifdef OPENSSL_NO_DSA
# define LIBSSH2_DSA 0
#else
# define LIBSSH2_DSA 1
#endif

#ifdef OPENSSL_NO_MD5
# define LIBSSH2_MD5 0
#else
# define LIBSSH2_MD5 1
#endif

#ifdef OPENSSL_NO_RIPEMD
# define LIBSSH2_HMAC_RIPEMD 0
#else
# define LIBSSH2_HMAC_RIPEMD 1
#endif

#if OPENSSL_VERSION_NUMBER >= 0x00907000L && !defined(OPENSSL_NO_AES)
# define LIBSSH2_AES 1
#else
# define LIBSSH2_AES 0
#endif

#ifdef OPENSSL_NO_BLOWFISH
# define LIBSSH2_BLOWFISH 0
#else
# define LIBSSH2_BLOWFISH 1
#endif

#ifdef OPENSSL_NO_RC4
# define LIBSSH2_RC4 0
#else
# define LIBSSH2_RC4 1
#endif

#ifdef OPENSSL_NO_CAST
# define LIBSSH2_CAST 0
#else
# define LIBSSH2_CAST 1
#endif

#ifdef OPENSSL_NO_3DES
# define LIBSSH2_3DES 0
#else
# define LIBSSH2_3DES 1
#endif

#define libssh2_random(buf, len) \
RAND_bytes ((buf), (len))

Expand Down

0 comments on commit c090ac7

Please sign in to comment.