Skip to content

Commit

Permalink
SSH Agent: Refactor encryption information
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexpFr committed May 1, 2024
1 parent cd9077e commit 82b479b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
12 changes: 4 additions & 8 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2540,10 +2540,6 @@ Disable safe saves and try again?</source>
<source>n/a</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(encrypted)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select private key</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -2653,10 +2649,6 @@ Would you like to correct it?</source>
<numerusform></numerusform>
</translation>
</message>
<message>
<source>(comment is encrypted)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditEntryWidgetAdvanced</name>
Expand Down Expand Up @@ -6192,6 +6184,10 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>Unexpected EOF when writing private key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(encrypted)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OpenSSHKeyGenDialog</name>
Expand Down
12 changes: 4 additions & 8 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,23 +661,19 @@ void EditEntryWidget::updateSSHAgentKeyInfo()
if (!key.fingerprint().isEmpty()) {
m_sshAgentUi->fingerprintTextLabel->setText(key.fingerprint(QCryptographicHash::Md5) + "\n"
+ key.fingerprint(QCryptographicHash::Sha256));
} else {
m_sshAgentUi->fingerprintTextLabel->setText(tr("(encrypted)"));
}

if (!key.comment().isEmpty()) {
m_sshAgentUi->commentTextLabel->setText(key.comment());
} else if (key.encrypted()) {
m_sshAgentUi->commentTextLabel->setText(tr("(encrypted)"));
}

if (key.encrypted()) {
m_sshAgentUi->decryptButton->setEnabled(true);
}

if (!key.publicKey().isEmpty() && !key.encrypted()) {
if (!key.publicKey().isEmpty()) {
m_sshAgentUi->publicKeyEdit->document()->setPlainText(key.publicKey());
m_sshAgentUi->copyToClipboardButton->setEnabled(true);
} else {
m_sshAgentUi->publicKeyEdit->document()->setPlainText(key.publicKey() + tr("(comment is encrypted)"));
m_sshAgentUi->copyToClipboardButton->setDisabled(true);
}

// enable agent buttons only if we have an agent running
Expand Down
4 changes: 2 additions & 2 deletions src/sshagent/KeeAgentSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,11 @@ bool KeeAgentSettings::toOpenSSHKey(const QString& username,
}
}

if (key.comment().isEmpty() && !key.encrypted()) {
if (key.comment().isEmpty()) {
key.setComment(username);
}

if (key.comment().isEmpty() && !key.encrypted()) {
if (key.comment().isEmpty()) {
key.setComment(fileName);
}

Expand Down
4 changes: 3 additions & 1 deletion src/sshagent/OpenSSHKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const QString OpenSSHKey::type() const
const QString OpenSSHKey::fingerprint(QCryptographicHash::Algorithm algo) const
{
if (m_rawPublicData.isEmpty()) {
return {};
return {tr("(encrypted)")};
}

QByteArray publicKey;
Expand Down Expand Up @@ -351,6 +351,8 @@ bool OpenSSHKey::parsePKCS1PEM(const QByteArray& in)
// load private if no encryption
if (!encrypted()) {
return openKey();
} else {
m_comment = tr("(encrypted)");
}

return true;
Expand Down

0 comments on commit 82b479b

Please sign in to comment.