aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_key_server_sync/PKSInterface.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2026-08-03 15:40:32 +0200
committersaturneric <[email protected]>2026-08-03 15:40:32 +0200
commit4c8f8eeac158ba0a6b4dda02ca6972222357aa1c (patch)
tree0ed78c651c02b129a3d3e31831c3325c3bb7280a /src/m_key_server_sync/PKSInterface.cpp
parentfeat(key_server_sync): prefer VKS for sync and support v6 keys (diff)
downloadmodules-4c8f8eeac158ba0a6b4dda02ca6972222357aa1c.tar.gz
modules-4c8f8eeac158ba0a6b4dda02ca6972222357aa1c.zip
fix(pks): fix keyserver display for sizes, dates, and uids
- make key size output show curve names for ECC algorithms - parse numeric key_size and return "-" for missing/zero bits - avoid printing "0 bits" for fixed-param algos; show real bits - add FormatKeyServerDate to render timestamps and avoid 1970-01-01 - show "Unknown" / "Never" for absent creation/expiration dates - display "(no user ID published)" for empty or withheld uids
Diffstat (limited to 'src/m_key_server_sync/PKSInterface.cpp')
-rw-r--r--src/m_key_server_sync/PKSInterface.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/m_key_server_sync/PKSInterface.cpp b/src/m_key_server_sync/PKSInterface.cpp
index 066f86b..121bb39 100644
--- a/src/m_key_server_sync/PKSInterface.cpp
+++ b/src/m_key_server_sync/PKSInterface.cpp
@@ -67,15 +67,6 @@ auto GetAlgorithmName(const QString& algo_id) -> QString {
auto GetKeySizeDescription(const QString& algo_id, const QString& key_size)
-> QString {
- // These algorithms carry their parameters in the algorithm ID itself, so a
- // keyserver has no meaningful length to report — usually 0. Printing
- // "0 bits" would be worse than saying nothing.
- static const QSet<QString> kFixedParamAlgos = {
- "25", "26", "27", "28", "35", "36", "37", "38", "39", "40", "41"};
- if (kFixedParamAlgos.contains(algo_id)) return "-";
-
- if (key_size.isEmpty()) return "Unknown";
-
// For ECC algorithms, show curve instead of size
if (algo_id == "18" || algo_id == "19" || algo_id == "22") {
static const QMap<QString, QString> curve_map = {
@@ -85,10 +76,19 @@ auto GetKeySizeDescription(const QString& algo_id, const QString& key_size)
{"nistp384", "NIST P-384"}, {"nistp521", "NIST P-521"},
{"cv25519", "Curve25519"}, {"ed25519", "Ed25519"}};
- return curve_map.value(key_size, QString("%1 bits").arg(key_size));
+ const auto curve = curve_map.constFind(key_size);
+ if (curve != curve_map.constEnd()) return curve.value();
}
- return QString("%1 bits").arg(key_size);
+ // Algorithms that fix their parameters in the algorithm ID are reported
+ // inconsistently: keys.openpgp.org gives Ed448 its real 456, others send 0.
+ // Show a real figure when there is one, and a dash rather than "0 bits" —
+ // which reads as a broken key — when there is not.
+ bool ok = false;
+ const auto bits = key_size.toInt(&ok);
+ if (!ok || bits <= 0) return "-";
+
+ return QString("%1 bits").arg(bits);
}
auto GetFlagsDescription(const QString& flags) -> QString {