mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
Fix segfault with gcrypt.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@542 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
@@ -39,9 +40,12 @@
|
|||||||
#include <openssl/dsa.h>
|
#include <openssl/dsa.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
#endif
|
#endif /* HAVE_LIBCRYPTO */
|
||||||
|
|
||||||
#define MAXLINESIZE 80
|
#define MAXLINESIZE 80
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
|
|
||||||
#define MAX_KEY_SIZE 32
|
#define MAX_KEY_SIZE 32
|
||||||
#define MAX_PASSPHRASE_SIZE 1024
|
#define MAX_PASSPHRASE_SIZE 1024
|
||||||
#define RSA_HEADER_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
|
#define RSA_HEADER_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
|
||||||
@@ -462,7 +466,7 @@ static int read_dsa_privatekey(FILE *fp, gcry_sexp_t *r, ssh_auth_callback cb,
|
|||||||
free(v);
|
free(v);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif /* GCRYPT */
|
#endif /* HAVE_LIBGCRYPT */
|
||||||
|
|
||||||
#ifdef HAVE_LIBCRYPTO
|
#ifdef HAVE_LIBCRYPTO
|
||||||
static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
|
static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
|
||||||
|
|||||||
@@ -626,7 +626,6 @@ static int rsa_public_to_string(RSA *key, BUFFER *buffer) {
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
string_fill(e, (char *) tmp, size);
|
string_fill(e, (char *) tmp, size);
|
||||||
gcry_sexp_release(sexp);
|
|
||||||
|
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
e = make_bignum_string(key->e);
|
e = make_bignum_string(key->e);
|
||||||
@@ -676,16 +675,20 @@ STRING *publickey_to_string(PUBLIC_KEY *key) {
|
|||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
buffer_add_ssh_string(buf, type);
|
|
||||||
|
if (buffer_add_ssh_string(buf, type) < 0) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
switch(key->type){
|
switch(key->type){
|
||||||
case TYPE_DSS:
|
case TYPE_DSS:
|
||||||
if (dsa_public_to_string(key->dsa_pub,buf) < 0) {
|
if (dsa_public_to_string(key->dsa_pub, buf) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TYPE_RSA:
|
case TYPE_RSA:
|
||||||
case TYPE_RSA1:
|
case TYPE_RSA1:
|
||||||
if (rsa_public_to_string(key->rsa_pub,buf) < 0) {
|
if (rsa_public_to_string(key->rsa_pub, buf) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1257,7 +1260,7 @@ STRING *ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf,
|
|||||||
STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key) {
|
STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key) {
|
||||||
STRING *str = NULL;
|
STRING *str = NULL;
|
||||||
size_t len = string_len(data);
|
size_t len = string_len(data);
|
||||||
int size = 0;
|
size_t size = 0;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
const char *tmp = NULL;
|
const char *tmp = NULL;
|
||||||
gcry_sexp_t ret_sexp;
|
gcry_sexp_t ret_sexp;
|
||||||
|
|||||||
Reference in New Issue
Block a user