summaryrefslogtreecommitdiffstats
path: root/libssh/keyfiles.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-18 15:56:36 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-18 15:56:36 +0000
commitab8523a39119738658eb6c02696d89ed97e9212d (patch)
treee4f3d452fa3e22778bf625ffae5aec6bd46a6412 /libssh/keyfiles.c
parent460969a9cee11e2e37f5f387ad806ab4bbd58ede (diff)
downloadlibssh-ab8523a39119738658eb6c02696d89ed97e9212d.tar.gz
libssh-ab8523a39119738658eb6c02696d89ed97e9212d.tar.xz
libssh-ab8523a39119738658eb6c02696d89ed97e9212d.zip
Fix gcrypt error if no auth callback has been set.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@555 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r--libssh/keyfiles.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index 6a8b19d..0c2824e 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -255,7 +255,7 @@ static int privatekey_decrypt(int algo, int mode, unsigned int key_len,
if (gcry_cipher_open(&cipher, algo, mode, 0)
|| gcry_cipher_setkey(cipher, key, key_len)
|| gcry_cipher_setiv(cipher, iv, iv_len)
- || (tmp = malloc(buffer_get_len(data) * sizeof (char)) == NULL)
+ || (tmp = malloc(buffer_get_len(data) * sizeof (char))) == NULL
|| gcry_cipher_decrypt(cipher, tmp, buffer_get_len(data),
buffer_get(data), buffer_get_len(data))) {
gcry_cipher_close(cipher);
@@ -560,14 +560,18 @@ PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
return NULL;
}
if(type==TYPE_DSS){
- if(!passphrase){
- if (session && session->options->auth_function) {
+ if (passphrase == NULL) {
+ if (session->options->auth_function) {
auth_cb = session->options->auth_function;
if (session->options->auth_userdata) {
auth_ud = session->options->auth_userdata;
}
#ifdef HAVE_LIBGCRYPT
valid = read_dsa_privatekey(file,&dsa, auth_cb, auth_ud, "Passphrase for private key:");
+ } else {
+ ssh_log(session, SSH_LOG_RARE,
+ "No passphrase or authtentication callback specified.");
+ return NULL;
}
} else {
valid = read_dsa_privatekey(file,&dsa, NULL, (void *) passphrase, NULL);
@@ -592,14 +596,18 @@ PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
}
}
else if (type==TYPE_RSA){
- if(!passphrase){
- if(session && session->options->auth_function) {
+ if (passphrase == NULL) {
+ if (session->options->auth_function) {
auth_cb = session->options->auth_function;
if (session->options->auth_userdata) {
auth_ud = session->options->auth_userdata;
}
#ifdef HAVE_LIBGCRYPT
valid = read_rsa_privatekey(file, &rsa, auth_cb, auth_ud, "Passphrase for private key:");
+ } else {
+ ssh_log(session, SSH_LOG_RARE,
+ "No passphrase or authtentication callback specified.");
+ return NULL;
}
} else {
valid = read_rsa_privatekey(file, &rsa, NULL, (void *) passphrase, NULL);