SSH Agent: Fix handling of encrypted RSA keys

Also fix multiple UI issues caused by said keys.

Fixes #1560
This commit is contained in:
Toni Spets 2018-03-01 18:27:53 +02:00 committed by Janek Bevendorff
parent 97a890e8a0
commit b0a61f437a
4 changed files with 52 additions and 26 deletions

View file

@ -94,6 +94,10 @@ int OpenSSHKey::keyLength() const
const QString OpenSSHKey::fingerprint() const
{
if (m_publicData.isEmpty()) {
return {};
}
QByteArray publicKey;
BinaryStream stream(&publicKey);
@ -115,6 +119,10 @@ const QString OpenSSHKey::comment() const
const QString OpenSSHKey::publicKey() const
{
if (m_publicData.isEmpty()) {
return {};
}
QByteArray publicKey;
BinaryStream stream(&publicKey);
@ -326,7 +334,7 @@ bool OpenSSHKey::openPrivateKey(const QString& passphrase)
return false;
}
if (passphrase.length() == 0) {
if (passphrase.isEmpty()) {
m_error = tr("Passphrase is required to decrypt this key");
return false;
}

View file

@ -260,6 +260,10 @@ void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode)
continue;
}
if (!key.openPrivateKey(e->password())) {
continue;
}
if (key.comment().isEmpty()) {
key.setComment(e->username());
}
@ -268,7 +272,7 @@ void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode)
removeIdentityAtLock(key, uuid);
}
if (settings.addAtDatabaseOpen() && key.openPrivateKey(e->password())) {
if (settings.addAtDatabaseOpen()) {
int lifetime = 0;
if (settings.useLifetimeConstraintWhenAdding()) {