Verified Commit a0f79d1f authored by Ingo Klöcker's avatar Ingo Klöcker Committed by Ingo Klöcker
Browse files

Add possibility to require valid keys for a command

Some commands cannot be applied to revoked, expired, or otherwise "bad"
keys. Since this restriction is rather general I decided to add a flag
for this.

GnuPG-bug-id: 6155
parent c72081d7
......@@ -62,6 +62,8 @@ public:
MustBeTrustedRoot = 0x0400 | MustBeRoot,
MustBeUntrustedRoot = 0x0800 | MustBeRoot,
MustBeValid = 0x1000, //< key is neither revoked nor expired nor otherwise "bad"
_AllRestrictions_Helper,
AllRestrictions = 2 * (_AllRestrictions_Helper - 1) - 1
};
......
......@@ -58,6 +58,7 @@
#include "commands/exportpaperkeycommand.h"
#include "commands/revokekeycommand.h"
#include <Libkleo/Algorithm>
#include <Libkleo/KeyCache>
#include <Libkleo/KeyListModel>
#include <Libkleo/Formatting>
......@@ -795,6 +796,12 @@ Command::Restrictions KeyListController::Private::calculateRestrictionsMask(cons
result |= Command::MustBeCMS;
}
if (Kleo::all_of(keys, [](const auto &key) {
return !key.isBad();
})) {
result |= Command::MustBeValid;
}
if (all_secret_are_not_owner_trust_ultimate(keys)) {
result |= Command::MayOnlyBeSecretKeyIfOwnerTrustIsNotYetUltimate;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment