mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
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
This commit is contained in:
@@ -255,7 +255,7 @@ static int privatekey_decrypt(int algo, int mode, unsigned int key_len,
|
|||||||
if (gcry_cipher_open(&cipher, algo, mode, 0)
|
if (gcry_cipher_open(&cipher, algo, mode, 0)
|
||||||
|| gcry_cipher_setkey(cipher, key, key_len)
|
|| gcry_cipher_setkey(cipher, key, key_len)
|
||||||
|| gcry_cipher_setiv(cipher, iv, iv_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),
|
|| gcry_cipher_decrypt(cipher, tmp, buffer_get_len(data),
|
||||||
buffer_get(data), buffer_get_len(data))) {
|
buffer_get(data), buffer_get_len(data))) {
|
||||||
gcry_cipher_close(cipher);
|
gcry_cipher_close(cipher);
|
||||||
@@ -560,14 +560,18 @@ PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if(type==TYPE_DSS){
|
if(type==TYPE_DSS){
|
||||||
if(!passphrase){
|
if (passphrase == NULL) {
|
||||||
if (session && session->options->auth_function) {
|
if (session->options->auth_function) {
|
||||||
auth_cb = session->options->auth_function;
|
auth_cb = session->options->auth_function;
|
||||||
if (session->options->auth_userdata) {
|
if (session->options->auth_userdata) {
|
||||||
auth_ud = session->options->auth_userdata;
|
auth_ud = session->options->auth_userdata;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
valid = read_dsa_privatekey(file,&dsa, auth_cb, auth_ud, "Passphrase for private key:");
|
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 {
|
} else {
|
||||||
valid = read_dsa_privatekey(file,&dsa, NULL, (void *) passphrase, NULL);
|
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){
|
else if (type==TYPE_RSA){
|
||||||
if(!passphrase){
|
if (passphrase == NULL) {
|
||||||
if(session && session->options->auth_function) {
|
if (session->options->auth_function) {
|
||||||
auth_cb = session->options->auth_function;
|
auth_cb = session->options->auth_function;
|
||||||
if (session->options->auth_userdata) {
|
if (session->options->auth_userdata) {
|
||||||
auth_ud = session->options->auth_userdata;
|
auth_ud = session->options->auth_userdata;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
valid = read_rsa_privatekey(file, &rsa, auth_cb, auth_ud, "Passphrase for private key:");
|
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 {
|
} else {
|
||||||
valid = read_rsa_privatekey(file, &rsa, NULL, (void *) passphrase, NULL);
|
valid = read_rsa_privatekey(file, &rsa, NULL, (void *) passphrase, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user