1
1
Этот коммит содержится в:
Guenter Knauf 2010-12-22 14:27:55 +01:00
родитель fd691deb17
Коммит aa4f861643
7 изменённых файлов: 39 добавлений и 39 удалений

Просмотреть файл

@ -144,7 +144,7 @@ int main(int argc, char *argv[])
username, identity->comment); username, identity->comment);
break; break;
} }
prev_identity = identity; prev_identity = identity;
} }
if (rc) { if (rc) {
fprintf(stderr, "Couldn't continue authentication\n"); fprintf(stderr, "Couldn't continue authentication\n");

Просмотреть файл

@ -268,7 +268,7 @@ agent_connect_pageant(LIBSSH2_AGENT *agent)
HWND hwnd; HWND hwnd;
hwnd = FindWindow("Pageant", "Pageant"); hwnd = FindWindow("Pageant", "Pageant");
if (!hwnd) if (!hwnd)
return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL, return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL,
"failed connecting agent"); "failed connecting agent");
agent->fd = 0; /* Mark as the connection has been established */ agent->fd = 0; /* Mark as the connection has been established */
return LIBSSH2_ERROR_NONE; return LIBSSH2_ERROR_NONE;
@ -296,7 +296,7 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId()); sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId());
filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
0, PAGEANT_MAX_MSGLEN, mapname); 0, PAGEANT_MAX_MSGLEN, mapname);
if (filemap == NULL || filemap == INVALID_HANDLE_VALUE) if (filemap == NULL || filemap == INVALID_HANDLE_VALUE)
return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL, return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL,
@ -312,16 +312,16 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
id = SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) &cds); id = SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) &cds);
if (id > 0) { if (id > 0) {
transctx->response_len = _libssh2_ntohu32(p); transctx->response_len = _libssh2_ntohu32(p);
if (transctx->response_len > PAGEANT_MAX_MSGLEN) { if (transctx->response_len > PAGEANT_MAX_MSGLEN) {
UnmapViewOfFile(p); UnmapViewOfFile(p);
CloseHandle(filemap); CloseHandle(filemap);
return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL, return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL,
"agent setup fail"); "agent setup fail");
} }
transctx->response = LIBSSH2_ALLOC(agent->session, transctx->response = LIBSSH2_ALLOC(agent->session,
transctx->response_len); transctx->response_len);
if (!transctx->response) { if (!transctx->response) {
UnmapViewOfFile(p); UnmapViewOfFile(p);
CloseHandle(filemap); CloseHandle(filemap);
return _libssh2_error(agent->session, LIBSSH2_ERROR_ALLOC, return _libssh2_error(agent->session, LIBSSH2_ERROR_ALLOC,

Просмотреть файл

@ -242,13 +242,13 @@ crypt_init_arcfour128(LIBSSH2_SESSION * session,
int rc; int rc;
rc = crypt_init (session, method, iv, free_iv, secret, free_secret, rc = crypt_init (session, method, iv, free_iv, secret, free_secret,
encrypt, abstract); encrypt, abstract);
if (rc == 0) { if (rc == 0) {
struct crypt_ctx *cctx = *(struct crypt_ctx **) abstract; struct crypt_ctx *cctx = *(struct crypt_ctx **) abstract;
unsigned char block[8]; unsigned char block[8];
size_t discard = 1536; size_t discard = 1536;
for (; discard; discard -= 8) for (; discard; discard -= 8)
_libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block); _libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block);
} }
return rc; return rc;

Просмотреть файл

@ -1135,7 +1135,7 @@ static int kexinit(LIBSSH2_SESSION * session)
} else { } else {
data = session->kexinit_data; data = session->kexinit_data;
data_len = session->kexinit_data_len; data_len = session->kexinit_data_len;
/* zap the variables to ensure there is NOT a double free later */ /* zap the variables to ensure there is NOT a double free later */
session->kexinit_data = NULL; session->kexinit_data = NULL;
session->kexinit_data_len = 0; session->kexinit_data_len = 0;
} }

Просмотреть файл

@ -537,11 +537,11 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h,
if (mode != GCRY_CIPHER_MODE_STREAM) { if (mode != GCRY_CIPHER_MODE_STREAM) {
int blklen = gcry_cipher_get_algo_blklen(cipher); int blklen = gcry_cipher_get_algo_blklen(cipher);
if (mode == GCRY_CIPHER_MODE_CTR) if (mode == GCRY_CIPHER_MODE_CTR)
ret = gcry_cipher_setctr(*h, iv, blklen); ret = gcry_cipher_setctr(*h, iv, blklen);
else else
ret = gcry_cipher_setiv(*h, iv, blklen); ret = gcry_cipher_setiv(*h, iv, blklen);
if (ret) { if (ret) {
gcry_cipher_close(*h); gcry_cipher_close(*h);
return -1; return -1;
} }

Просмотреть файл

@ -110,25 +110,25 @@
#define _libssh2_gcry_cipher(c) (c >> 8) #define _libssh2_gcry_cipher(c) (c >> 8)
#define _libssh2_gcry_mode(m) (m & 0xFF) #define _libssh2_gcry_mode(m) (m & 0xFF)
#define _libssh2_cipher_aes256ctr \ #define _libssh2_cipher_aes256ctr \
_libssh2_gcry_ciphermode(GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CTR) _libssh2_gcry_ciphermode(GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CTR)
#define _libssh2_cipher_aes192ctr \ #define _libssh2_cipher_aes192ctr \
_libssh2_gcry_ciphermode(GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CTR) _libssh2_gcry_ciphermode(GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CTR)
#define _libssh2_cipher_aes128ctr \ #define _libssh2_cipher_aes128ctr \
_libssh2_gcry_ciphermode(GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR) _libssh2_gcry_ciphermode(GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR)
#define _libssh2_cipher_aes256 \ #define _libssh2_cipher_aes256 \
_libssh2_gcry_ciphermode(GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC) _libssh2_gcry_ciphermode(GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC)
#define _libssh2_cipher_aes192 \ #define _libssh2_cipher_aes192 \
_libssh2_gcry_ciphermode(GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CBC) _libssh2_gcry_ciphermode(GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CBC)
#define _libssh2_cipher_aes128 \ #define _libssh2_cipher_aes128 \
_libssh2_gcry_ciphermode(GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC) _libssh2_gcry_ciphermode(GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC)
#define _libssh2_cipher_blowfish \ #define _libssh2_cipher_blowfish \
_libssh2_gcry_ciphermode(GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CBC) _libssh2_gcry_ciphermode(GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CBC)
#define _libssh2_cipher_arcfour \ #define _libssh2_cipher_arcfour \
_libssh2_gcry_ciphermode(GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM) _libssh2_gcry_ciphermode(GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM)
#define _libssh2_cipher_cast5 \ #define _libssh2_cipher_cast5 \
_libssh2_gcry_ciphermode(GCRY_CIPHER_CAST5, GCRY_CIPHER_MODE_CBC) _libssh2_gcry_ciphermode(GCRY_CIPHER_CAST5, GCRY_CIPHER_MODE_CBC)
#define _libssh2_cipher_3des \ #define _libssh2_cipher_3des \
_libssh2_gcry_ciphermode(GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC) _libssh2_gcry_ciphermode(GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC)

Просмотреть файл

@ -215,14 +215,14 @@ typedef struct
static int static int
aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc) /* init key */ const unsigned char *iv, int enc) /* init key */
{ {
aes_ctr_ctx *c = malloc(sizeof(*c)); aes_ctr_ctx *c = malloc(sizeof(*c));
const EVP_CIPHER *aes_cipher; const EVP_CIPHER *aes_cipher;
(void) enc; (void) enc;
if (c == NULL) if (c == NULL)
return 0; return 0;
switch (ctx->key_len) { switch (ctx->key_len) {
case 16: case 16:
@ -239,7 +239,7 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
} }
c->aes_ctx = malloc(sizeof(EVP_CIPHER_CTX)); c->aes_ctx = malloc(sizeof(EVP_CIPHER_CTX));
if (c->aes_ctx == NULL) if (c->aes_ctx == NULL)
return 0; return 0;
if (EVP_EncryptInit(c->aes_ctx, aes_cipher, key, NULL) != 1) { if (EVP_EncryptInit(c->aes_ctx, aes_cipher, key, NULL) != 1) {
return 0; return 0;
@ -256,8 +256,8 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
static int static int
aes_ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, aes_ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, const unsigned char *in,
unsigned int inl) /* encrypt/decrypt data */ unsigned int inl) /* encrypt/decrypt data */
{ {
aes_ctr_ctx *c = EVP_CIPHER_CTX_get_app_data(ctx); aes_ctr_ctx *c = EVP_CIPHER_CTX_get_app_data(ctx);
unsigned char b1[AES_BLOCK_SIZE]; unsigned char b1[AES_BLOCK_SIZE];
@ -265,7 +265,7 @@ aes_ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
int outlen = 0; int outlen = 0;
if (inl != 16) /* libssh2 only ever encrypt one block */ if (inl != 16) /* libssh2 only ever encrypt one block */
return 0; return 0;
if (c == NULL) { if (c == NULL) {
return 0; return 0;
@ -283,13 +283,13 @@ aes_ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
} }
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
*out++ = *in++ ^ b1[i]; *out++ = *in++ ^ b1[i];
i = 15; i = 15;
while (c->ctr[i]++ == 0xFF) { while (c->ctr[i]++ == 0xFF) {
if (i == 0) if (i == 0)
break; break;
i--; i--;
} }
return 1; return 1;
@ -727,7 +727,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
const char *passphrase) const char *passphrase)
{ {
int st; int st;
BIO* bp; BIO* bp;
EVP_PKEY* pk; EVP_PKEY* pk;
_libssh2_debug(session, _libssh2_debug(session,