13#include "kleo_export.h"
17#include <gpgme++/key.h>
26template<
typename KeyContainer>
27QStringList getFingerprints(
const KeyContainer &keys)
31 fingerprints.
reserve(keys.size());
32 std::transform(std::begin(keys), std::end(keys), std::back_inserter(fingerprints), [](
const auto &key) {
39KLEO_EXPORT std::set<QString> getMissingSignerKeyIds(
const std::vector<GpgME::UserID> &userIds);
41KLEO_EXPORT std::set<QString> getMissingSignerKeyIds(
const std::vector<GpgME::Key> &keys);
47KLEO_EXPORT
bool isRemoteKey(
const GpgME::Key &key);
49KLEO_EXPORT GpgME::UserID::Validity minimalValidityOfNotRevokedUserIDs(
const GpgME::Key &key);
51KLEO_EXPORT GpgME::UserID::Validity maximalValidityOfUserIDs(
const GpgME::Key &key);
54KLEO_EXPORT
bool allUserIDsHaveFullValidity(
const GpgME::Key &key);
56template<
typename RangeOfKeys>
57bool allKeysHaveProtocol(
const RangeOfKeys &keys, GpgME::Protocol protocol)
59 return std::all_of(std::begin(keys), std::end(keys), [protocol](
const auto &key) {
60 return key.protocol() == protocol;
64template<
typename RangeOfKeys>
65bool anyKeyHasProtocol(
const RangeOfKeys &keys, GpgME::Protocol protocol)
67 return std::any_of(std::begin(keys), std::end(keys), [protocol](
const auto &key) {
68 return key.protocol() == protocol;
73KLEO_EXPORT
bool isSelfSignature(
const GpgME::UserID::Signature &signature);
79KLEO_EXPORT
bool isRevokedOrExpired(
const GpgME::UserID &userId);
82KLEO_EXPORT
bool isExpired(
const GpgME::UserID &userId);
89KLEO_EXPORT
bool canCreateCertifications(
const GpgME::Key &key);
96KLEO_EXPORT
bool canBeCertified(
const GpgME::Key &key);
103KLEO_EXPORT
bool canBeUsedForEncryption(
const GpgME::Key &key);
110KLEO_EXPORT
bool canBeUsedForSigning(
const GpgME::Key &key);
120KLEO_EXPORT
bool canBeUsedForSecretKeyOperations(
const GpgME::Key &key);
126KLEO_EXPORT
bool canRevokeUserID(
const GpgME::UserID &userId);
132KLEO_EXPORT
bool isSecretKeyStoredInKeyRing(
const GpgME::Key &key);
140KLEO_EXPORT
bool userHasCertificationKey();
142enum CertificationRevocationFeasibility {
143 CertificationCanBeRevoked = 0,
144 CertificationNotMadeWithOwnKey,
145 CertificationIsSelfSignature,
146 CertificationIsRevocation,
147 CertificationIsExpired,
148 CertificationIsInvalid,
149 CertificationKeyNotAvailable,
155KLEO_EXPORT CertificationRevocationFeasibility userCanRevokeCertification(
const GpgME::UserID::Signature &certification);
162KLEO_EXPORT
bool userCanRevokeCertifications(
const GpgME::UserID &userId);
167KLEO_EXPORT
bool userIDBelongsToKey(
const GpgME::UserID &userID,
const GpgME::Key &key);
172inline auto userIDBelongsToKey(
const GpgME::Key &key)
174 return [key](
const GpgME::UserID &userID) {
175 return userIDBelongsToKey(userID, key);
186KLEO_EXPORT
bool userIDsAreEqual(
const GpgME::UserID &lhs,
const GpgME::UserID &rhs);
192KLEO_EXPORT
bool userIDIsCertifiedByUser(
const GpgME::UserID &userId);
194struct KLEO_EXPORT KeysByProtocol {
195 std::vector<GpgME::Key> openpgp;
196 std::vector<GpgME::Key> cms;
202template<
typename KeyContainer>
203KeysByProtocol partitionKeysByProtocol(
const KeyContainer &keys)
205 KeysByProtocol result;
206 std::partition_copy(std::begin(keys), std::end(keys), std::back_inserter(result.openpgp), std::back_inserter(result.cms), [](
const auto &key) {
207 return key.protocol() == GpgME::OpenPGP;
void reserve(qsizetype size)
QString fromLatin1(QByteArrayView str)