From eb41a68ba063dd115ab5c1f39e1de3321c8b188e Mon Sep 17 00:00:00 2001
From: Alexandre Petit <62973006+AlexpFr@users.noreply.github.com>
Date: Wed, 1 May 2024 03:40:34 +0200
Subject: [PATCH] SSH Agent: Refactor encryption information
---
share/translations/keepassxc_en.ts | 12 ++++--------
src/gui/entry/EditEntryWidget.cpp | 12 ++++--------
src/sshagent/KeeAgentSettings.cpp | 4 ++--
src/sshagent/OpenSSHKey.cpp | 4 +++-
4 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts
index bff4663360..40ee9cd8d1 100644
--- a/share/translations/keepassxc_en.ts
+++ b/share/translations/keepassxc_en.ts
@@ -2556,10 +2556,6 @@ Disable safe saves and try again?
n/a
-
- (encrypted)
-
-
Select private key
@@ -2669,10 +2665,6 @@ Would you like to correct it?
-
- (comment is encrypted)
-
-
EditEntryWidgetAdvanced
@@ -6208,6 +6200,10 @@ We recommend you use the AppImage available on our downloads page.
Unexpected EOF when writing private key
+
+ (encrypted)
+
+
OpenSSHKeyGenDialog
diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp
index bdcbfe6c73..1de07638d0 100644
--- a/src/gui/entry/EditEntryWidget.cpp
+++ b/src/gui/entry/EditEntryWidget.cpp
@@ -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
diff --git a/src/sshagent/KeeAgentSettings.cpp b/src/sshagent/KeeAgentSettings.cpp
index 8393391525..272fb7edf7 100644
--- a/src/sshagent/KeeAgentSettings.cpp
+++ b/src/sshagent/KeeAgentSettings.cpp
@@ -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);
}
diff --git a/src/sshagent/OpenSSHKey.cpp b/src/sshagent/OpenSSHKey.cpp
index cdcc257013..7e1d12cd3f 100644
--- a/src/sshagent/OpenSSHKey.cpp
+++ b/src/sshagent/OpenSSHKey.cpp
@@ -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;
@@ -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;