mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-05-17 19:21:11 +03:00
Fix build with MSVC.
This commit is contained in:
parent
94a57df0c9
commit
766bae9d76
@ -29,6 +29,13 @@
|
|||||||
|
|
||||||
#ifndef _LIBSSH_PRIV_H
|
#ifndef _LIBSSH_PRIV_H
|
||||||
#define _LIBSSH_PRIV_H
|
#define _LIBSSH_PRIV_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
|
|
||||||
@ -172,13 +179,19 @@ void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
|
|||||||
|
|
||||||
/* strings and buffers */
|
/* strings and buffers */
|
||||||
/* must be 32 bits number + immediatly our data */
|
/* must be 32 bits number + immediatly our data */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(1)
|
||||||
|
#endif
|
||||||
struct ssh_string_struct {
|
struct ssh_string_struct {
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
unsigned char string[MAX_PACKET_LEN];
|
unsigned char string[MAX_PACKET_LEN];
|
||||||
}
|
}
|
||||||
#if !defined(__SUNPRO_C)
|
#if !defined(__SUNPRO_C) && !defined(_MSC_VER)
|
||||||
__attribute__ ((packed))
|
__attribute__ ((packed))
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack()
|
||||||
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
/** Describes a buffer state at a moment
|
/** Describes a buffer state at a moment
|
||||||
|
@ -38,7 +38,11 @@
|
|||||||
|
|
||||||
#ifndef SFTP_H
|
#ifndef SFTP_H
|
||||||
#define SFTP_H
|
#define SFTP_H
|
||||||
#include <libssh/libssh.h>
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "libssh.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -51,11 +55,19 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef uid_t
|
#ifndef uid_t
|
||||||
typedef long uid_t;
|
typedef uint32_t uid_t;
|
||||||
#endif /* uid_t */
|
#endif /* uid_t */
|
||||||
#ifndef gid_t
|
#ifndef gid_t
|
||||||
typedef long gid_t;
|
typedef uint32_t gid_t;
|
||||||
#endif /* gid_t */
|
#endif /* gid_t */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#ifndef mode_t
|
||||||
|
typedef uint32_t mode_t;
|
||||||
|
#endif /* mode_t */
|
||||||
|
#ifndef ssize_t
|
||||||
|
typedef _W64 signed int ssize_t;
|
||||||
|
#endif /* ssize_t */
|
||||||
|
#endif /* _MSC_VER */
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
typedef struct sftp_ext_struct *sftp_ext;
|
typedef struct sftp_ext_struct *sftp_ext;
|
||||||
|
@ -750,6 +750,22 @@ error:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
static const char privKey_1[] = "%s/.ssh/identity";
|
||||||
|
static const char pubKey_1[] = "%s/.ssh/identity.pub";
|
||||||
|
static const char privKey_2[] = "%s/.ssh/id_dsa";
|
||||||
|
static const char pubKey_2[] = "%s/.ssh/id_dsa.pub";
|
||||||
|
static const char privKey_3[] = "%s/.ssh/id_rsa";
|
||||||
|
static const char pubKey_3[] = "%s/.ssh/id_rsa.pub";
|
||||||
|
/** Used different var to allow const char[] declaration */
|
||||||
|
static struct ssh_keys_struct keytab[] = {
|
||||||
|
{ privKey_1, pubKey_1},
|
||||||
|
{ privKey_2, pubKey_2},
|
||||||
|
{ privKey_3, pubKey_3},
|
||||||
|
{0}
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
/* This requires GCC extensions */
|
||||||
static struct ssh_keys_struct keytab[] = {
|
static struct ssh_keys_struct keytab[] = {
|
||||||
{
|
{
|
||||||
.privatekey = "%s/.ssh/identity",
|
.privatekey = "%s/.ssh/identity",
|
||||||
@ -768,9 +784,7 @@ static struct ssh_keys_struct keytab[] = {
|
|||||||
.publickey = NULL
|
.publickey = NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
/* this function initialy was in the client */
|
|
||||||
/* but the fools are the ones who never change mind */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tries to automaticaly authenticate with public key and "none"
|
* @brief Tries to automaticaly authenticate with public key and "none"
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -929,7 +928,7 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
|
|
||||||
channel->remote_window -= effectivelen;
|
channel->remote_window -= effectivelen;
|
||||||
len -= effectivelen;
|
len -= effectivelen;
|
||||||
data += effectivelen;
|
data = ((uint8_t*)data + effectivelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_function();
|
leave_function();
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* getaddrinfo, freeaddrinfo, getnameinfo */
|
/* getaddrinfo, freeaddrinfo, getnameinfo */
|
||||||
@ -93,6 +92,7 @@ static void sock_set_nonblocking(socket_t sock) {
|
|||||||
static void sock_set_blocking(socket_t sock) {
|
static void sock_set_blocking(socket_t sock) {
|
||||||
fcntl(sock, F_SETFL, 0);
|
fcntl(sock, F_SETFL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#ifdef HAVE_REGCOMP
|
#ifdef HAVE_REGCOMP
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
* MA 02111-1307, USA.
|
* MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -33,8 +32,8 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define _WIN32_IE 0x0400 //SHGetSpecialFolderPath
|
#define _WIN32_IE 0x0400 //SHGetSpecialFolderPath
|
||||||
|
#include <winsock2.h> // Must be the first to include
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <winsock2.h>
|
|
||||||
#else
|
#else
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -67,7 +66,6 @@
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
char *ssh_get_user_home_dir(void) {
|
char *ssh_get_user_home_dir(void) {
|
||||||
static char szPath[MAX_PATH] = {0};
|
static char szPath[MAX_PATH] = {0};
|
||||||
|
|
||||||
@ -87,7 +85,6 @@ char *ssh_get_user_home_dir(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
|
|
||||||
char *ssh_get_user_home_dir(void) {
|
char *ssh_get_user_home_dir(void) {
|
||||||
static char szPath[PATH_MAX] = {0};
|
static char szPath[PATH_MAX] = {0};
|
||||||
struct passwd *pwd = NULL;
|
struct passwd *pwd = NULL;
|
||||||
@ -102,8 +99,6 @@ char *ssh_get_user_home_dir(void) {
|
|||||||
return szPath;
|
return szPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* we have read access on file */
|
/* we have read access on file */
|
||||||
int ssh_file_readaccess_ok(const char *file) {
|
int ssh_file_readaccess_ok(const char *file) {
|
||||||
if (access(file, R_OK) < 0) {
|
if (access(file, R_OK) < 0) {
|
||||||
@ -112,13 +107,14 @@ int ssh_file_readaccess_ok(const char *file) {
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t ntohll(uint64_t a) {
|
uint64_t ntohll(uint64_t a) {
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
return a;
|
return a;
|
||||||
#else
|
#else
|
||||||
uint32_t low = a & 0xffffffff;
|
uint32_t low = (uint32_t)(a & 0xffffffff);
|
||||||
uint32_t high = a >> 32 ;
|
uint32_t high = (uint32_t)(a >> 32);
|
||||||
low = ntohl(low);
|
low = ntohl(low);
|
||||||
high = ntohl(high);
|
high = ntohl(high);
|
||||||
|
|
||||||
|
@ -24,10 +24,11 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#else
|
||||||
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
@ -589,6 +590,7 @@ int ssh_options_default_username(SSH_OPTIONS *opt) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
{
|
||||||
DWORD Size = 0;
|
DWORD Size = 0;
|
||||||
GetUserName(NULL, &Size); //Get Size
|
GetUserName(NULL, &Size); //Get Size
|
||||||
user = malloc(Size);
|
user = malloc(Size);
|
||||||
@ -601,6 +603,7 @@ int ssh_options_default_username(SSH_OPTIONS *opt) {
|
|||||||
} else {
|
} else {
|
||||||
SAFE_FREE(user);
|
SAFE_FREE(user);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -836,7 +839,10 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv) {
|
|||||||
int ssh1 = 0;
|
int ssh1 = 0;
|
||||||
#endif
|
#endif
|
||||||
int ssh2 = 1;
|
int ssh2 = 1;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
/* Not supported with a Microsoft compiler */
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
int saveoptind = optind; /* need to save 'em */
|
int saveoptind = optind; /* need to save 'em */
|
||||||
int saveopterr = opterr;
|
int saveopterr = opterr;
|
||||||
|
|
||||||
@ -985,6 +991,7 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -148,7 +147,7 @@ static int packet_read2(SSH_SESSION *session) {
|
|||||||
* have been decrypted)
|
* have been decrypted)
|
||||||
*/
|
*/
|
||||||
if (packet_decrypt(session,
|
if (packet_decrypt(session,
|
||||||
buffer_get(session->in_buffer) + blocksize,
|
((uint8_t*)buffer_get(session->in_buffer) + blocksize),
|
||||||
buffer_get_len(session->in_buffer) - blocksize) < 0) {
|
buffer_get_len(session->in_buffer) - blocksize) < 0) {
|
||||||
ssh_set_error(session, SSH_FATAL, "Decrypt error");
|
ssh_set_error(session, SSH_FATAL, "Decrypt error");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -81,6 +81,7 @@ int ssh_poll(pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
static int poll_rest (HANDLE *handles, int nhandles,
|
static int poll_rest (HANDLE *handles, int nhandles,
|
||||||
pollfd_t *fds, nfds_t nfds, int timeout) {
|
pollfd_t *fds, nfds_t nfds, int timeout) {
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
@ -45,7 +44,7 @@
|
|||||||
#define SOCKOPT_TYPE_ARG4 char
|
#define SOCKOPT_TYPE_ARG4 char
|
||||||
|
|
||||||
/* We need to provide hstrerror. Not we can't call the parameter h_errno because it's #defined */
|
/* We need to provide hstrerror. Not we can't call the parameter h_errno because it's #defined */
|
||||||
inline char *hstrerror(int h_errno_val) {
|
static char *hstrerror(int h_errno_val) {
|
||||||
static char text[50] = {0};
|
static char text[50] = {0};
|
||||||
|
|
||||||
snprintf(text, sizeof(text), "gethostbyname error %d\n", h_errno_val);
|
snprintf(text, sizeof(text), "gethostbyname error %d\n", h_errno_val);
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
* MA 02111-1307, USA.
|
* MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
* MA 02111-1307, USA.
|
* MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -264,7 +263,7 @@ int ssh_socket_completeread(struct socket *s, void *buffer, uint32_t len) {
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while((r = ssh_socket_unbuffered_read(s, buffer + total, toread))) {
|
while((r = ssh_socket_unbuffered_read(s, ((uint8_t*)buffer + total), toread))) {
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
@ -303,7 +302,7 @@ int ssh_socket_completewrite(struct socket *s, const void *buffer, uint32_t len)
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
len -= written;
|
len -= written;
|
||||||
buffer += written;
|
buffer = ((uint8_t*)buffer + written);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_function();
|
leave_function();
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
165
libssh/wrapper.c
165
libssh/wrapper.c
@ -577,11 +577,11 @@ static int des3_set_key(struct crypto_struct *cipher, void *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DES_set_odd_parity(key);
|
DES_set_odd_parity(key);
|
||||||
DES_set_odd_parity(key + 8);
|
DES_set_odd_parity((void*)((uint8_t*)key + 8));
|
||||||
DES_set_odd_parity(key + 16);
|
DES_set_odd_parity((void*)((uint8_t*)key + 16));
|
||||||
DES_set_key_unchecked(key, cipher->key);
|
DES_set_key_unchecked(key, cipher->key);
|
||||||
DES_set_key_unchecked(key + 8, cipher->key + sizeof(DES_key_schedule));
|
DES_set_key_unchecked((void*)((uint8_t*)key + 8), (void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)));
|
||||||
DES_set_key_unchecked(key + 16, cipher->key + 2 * sizeof(DES_key_schedule));
|
DES_set_key_unchecked((void*)((uint8_t*)key + 16), (void*)((uint8_t*)cipher->key + 2 * sizeof(DES_key_schedule)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -590,16 +590,16 @@ static int des3_set_key(struct crypto_struct *cipher, void *key) {
|
|||||||
static void des3_encrypt(struct crypto_struct *cipher, void *in,
|
static void des3_encrypt(struct crypto_struct *cipher, void *in,
|
||||||
void *out, unsigned long len, void *IV) {
|
void *out, unsigned long len, void *IV) {
|
||||||
DES_ede3_cbc_encrypt(in, out, len, cipher->key,
|
DES_ede3_cbc_encrypt(in, out, len, cipher->key,
|
||||||
cipher->key + sizeof(DES_key_schedule),
|
(void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)),
|
||||||
cipher->key + 2 * sizeof(DES_key_schedule),
|
(void*)((uint8_t*)cipher->key + 2 * sizeof(DES_key_schedule)),
|
||||||
IV, 1);
|
IV, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des3_decrypt(struct crypto_struct *cipher, void *in,
|
static void des3_decrypt(struct crypto_struct *cipher, void *in,
|
||||||
void *out, unsigned long len, void *IV) {
|
void *out, unsigned long len, void *IV) {
|
||||||
DES_ede3_cbc_encrypt(in, out, len, cipher->key,
|
DES_ede3_cbc_encrypt(in, out, len, cipher->key,
|
||||||
cipher->key + sizeof(DES_key_schedule),
|
(void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)),
|
||||||
cipher->key + 2 * sizeof(DES_key_schedule),
|
(void*)((uint8_t*)cipher->key + 2 * sizeof(DES_key_schedule)),
|
||||||
IV, 0);
|
IV, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,10 +609,10 @@ static void des3_1_encrypt(struct crypto_struct *cipher, void *in,
|
|||||||
ssh_print_hexa("Encrypt IV before", IV, 24);
|
ssh_print_hexa("Encrypt IV before", IV, 24);
|
||||||
#endif
|
#endif
|
||||||
DES_ncbc_encrypt(in, out, len, cipher->key, IV, 1);
|
DES_ncbc_encrypt(in, out, len, cipher->key, IV, 1);
|
||||||
DES_ncbc_encrypt(out, in, len, cipher->key + sizeof(DES_key_schedule),
|
DES_ncbc_encrypt(out, in, len, (void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)),
|
||||||
IV + 8, 0);
|
(void*)((uint8_t*)IV + 8), 0);
|
||||||
DES_ncbc_encrypt(in, out, len, cipher->key + 2 * sizeof(DES_key_schedule),
|
DES_ncbc_encrypt(in, out, len, (void*)((uint8_t*)cipher->key + 2 * sizeof(DES_key_schedule)),
|
||||||
IV + 16, 1);
|
(void*)((uint8_t*)IV + 16), 1);
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("Encrypt IV after", IV, 24);
|
ssh_print_hexa("Encrypt IV after", IV, 24);
|
||||||
#endif
|
#endif
|
||||||
@ -624,11 +624,11 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
|
|||||||
ssh_print_hexa("Decrypt IV before", IV, 24);
|
ssh_print_hexa("Decrypt IV before", IV, 24);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DES_ncbc_encrypt(in, out, len, cipher->key + 2 * sizeof(DES_key_schedule),
|
DES_ncbc_encrypt(in, out, len, (void*)((uint8_t*)cipher->key + 2 * sizeof(DES_key_schedule)),
|
||||||
IV, 0);
|
IV, 0);
|
||||||
DES_ncbc_encrypt(out, in, len, cipher->key + sizeof(DES_key_schedule),
|
DES_ncbc_encrypt(out, in, len, (void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)),
|
||||||
IV + 8, 1);
|
(void*)((uint8_t*)IV + 8), 1);
|
||||||
DES_ncbc_encrypt(in, out, len, cipher->key, IV + 16, 0);
|
DES_ncbc_encrypt(in, out, len, cipher->key, (void*)((uint8_t*)IV + 16), 0);
|
||||||
|
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("Decrypt IV after", IV, 24);
|
ssh_print_hexa("Decrypt IV after", IV, 24);
|
||||||
@ -637,90 +637,95 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
|
|||||||
|
|
||||||
#endif /* HAS_DES */
|
#endif /* HAS_DES */
|
||||||
|
|
||||||
/* the table of supported ciphers */
|
/*
|
||||||
|
* The table of supported ciphers
|
||||||
|
*
|
||||||
|
* WARNING: If you modify crypto_struct, you must make sure the order is
|
||||||
|
* correct!
|
||||||
|
*/
|
||||||
static struct crypto_struct ssh_ciphertab[] = {
|
static struct crypto_struct ssh_ciphertab[] = {
|
||||||
#ifdef HAS_BLOWFISH
|
#ifdef HAS_BLOWFISH
|
||||||
{
|
{
|
||||||
.name = "blowfish-cbc",
|
"blowfish-cbc",
|
||||||
.blocksize = 8,
|
8,
|
||||||
.keylen = sizeof (BF_KEY),
|
sizeof (BF_KEY),
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 128,
|
128,
|
||||||
.set_encrypt_key = blowfish_set_key,
|
blowfish_set_key,
|
||||||
.set_decrypt_key = blowfish_set_key,
|
blowfish_set_key,
|
||||||
.cbc_encrypt = blowfish_encrypt,
|
blowfish_encrypt,
|
||||||
.cbc_decrypt = blowfish_decrypt
|
blowfish_decrypt
|
||||||
},
|
},
|
||||||
#endif /* HAS_BLOWFISH */
|
#endif /* HAS_BLOWFISH */
|
||||||
#ifdef HAS_AES
|
#ifdef HAS_AES
|
||||||
{
|
{
|
||||||
.name = "aes128-cbc",
|
"aes128-cbc",
|
||||||
.blocksize = 16,
|
16,
|
||||||
.keylen = sizeof(AES_KEY),
|
sizeof(AES_KEY),
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 128,
|
128,
|
||||||
.set_encrypt_key = aes_set_encrypt_key,
|
aes_set_encrypt_key,
|
||||||
.set_decrypt_key = aes_set_decrypt_key,
|
aes_set_decrypt_key,
|
||||||
.cbc_encrypt = aes_encrypt,
|
aes_encrypt,
|
||||||
.cbc_decrypt = aes_decrypt
|
aes_decrypt
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "aes192-cbc",
|
"aes192-cbc",
|
||||||
.blocksize = 16,
|
16,
|
||||||
.keylen = sizeof(AES_KEY),
|
sizeof(AES_KEY),
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 192,
|
192,
|
||||||
.set_encrypt_key = aes_set_encrypt_key,
|
aes_set_encrypt_key,
|
||||||
.set_decrypt_key = aes_set_decrypt_key,
|
aes_set_decrypt_key,
|
||||||
.cbc_encrypt = aes_encrypt,
|
aes_encrypt,
|
||||||
.cbc_decrypt = aes_decrypt
|
aes_decrypt
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "aes256-cbc",
|
"aes256-cbc",
|
||||||
.blocksize = 16,
|
16,
|
||||||
.keylen = sizeof(AES_KEY),
|
sizeof(AES_KEY),
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 256,
|
256,
|
||||||
.set_encrypt_key = aes_set_encrypt_key,
|
aes_set_encrypt_key,
|
||||||
.set_decrypt_key = aes_set_decrypt_key,
|
aes_set_decrypt_key,
|
||||||
.cbc_encrypt = aes_encrypt,
|
aes_encrypt,
|
||||||
.cbc_decrypt = aes_decrypt
|
aes_decrypt
|
||||||
},
|
},
|
||||||
#endif /* HAS_AES */
|
#endif /* HAS_AES */
|
||||||
#ifdef HAS_DES
|
#ifdef HAS_DES
|
||||||
{
|
{
|
||||||
.name = "3des-cbc",
|
"3des-cbc",
|
||||||
.blocksize = 8,
|
8,
|
||||||
.keylen = sizeof(DES_key_schedule) * 3,
|
sizeof(DES_key_schedule) * 3,
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 192,
|
192,
|
||||||
.set_encrypt_key = des3_set_key,
|
des3_set_key,
|
||||||
.set_decrypt_key = des3_set_key,
|
des3_set_key,
|
||||||
.cbc_encrypt = des3_encrypt,
|
des3_encrypt,
|
||||||
.cbc_decrypt = des3_decrypt
|
des3_decrypt
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "3des-cbc-ssh1",
|
"3des-cbc-ssh1",
|
||||||
.blocksize = 8,
|
8,
|
||||||
.keylen = sizeof(DES_key_schedule) * 3,
|
sizeof(DES_key_schedule) * 3,
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 192,
|
192,
|
||||||
.set_encrypt_key = des3_set_key,
|
des3_set_key,
|
||||||
.set_decrypt_key = des3_set_key,
|
des3_set_key,
|
||||||
.cbc_encrypt = des3_1_encrypt,
|
des3_1_encrypt,
|
||||||
.cbc_decrypt = des3_1_decrypt
|
des3_1_decrypt
|
||||||
},
|
},
|
||||||
#endif /* HAS_DES */
|
#endif /* HAS_DES */
|
||||||
{
|
{
|
||||||
.name = NULL,
|
NULL,
|
||||||
.blocksize = 0,
|
0,
|
||||||
.keylen = 0,
|
0,
|
||||||
.key = NULL,
|
NULL,
|
||||||
.keysize = 0,
|
0,
|
||||||
.set_encrypt_key = NULL,
|
NULL,
|
||||||
.set_decrypt_key = NULL,
|
NULL,
|
||||||
.cbc_encrypt = NULL,
|
NULL,
|
||||||
.cbc_decrypt = NULL
|
NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif /* OPENSSL_CRYPTO */
|
#endif /* OPENSSL_CRYPTO */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user