aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2020-10-28 11:48:31 +0000
committerIngo Klöcker <[email protected]>2020-10-29 11:57:10 +0000
commit4166d263e421cb4f98c4ca6bef549613c35e149e (patch)
treead74e51e1fd4a1a810a628c071757c4cf56c5316 /lang/cpp
parentcore: New function gpgme_op_revsig. (diff)
downloadgpgme-4166d263e421cb4f98c4ca6bef549613c35e149e.tar.gz
gpgme-4166d263e421cb4f98c4ca6bef549613c35e149e.zip
cpp: Add support for gpgme_op_revsig
* lang/cpp/src/context.cpp, lang/cpp/src/context.h (Context::revokeSignature, Context::startRevokeSignature): New. * lang/cpp/src/context.cpp (getLFSeparatedListOfStrings, getLFSeparatedListOfUserIds): New. (getLFSeparatedListOfFingerprintsFromSubkeys): Extracted second part of function to getLFSeparatedListOfStrings. -- GnuPG-bug-id: 5094
Diffstat (limited to 'lang/cpp')
-rw-r--r--lang/cpp/src/context.cpp64
-rw-r--r--lang/cpp/src/context.h5
2 files changed, 57 insertions, 12 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index e868d387..44587a5f 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -1532,6 +1532,22 @@ Error Context::startCreateSubkey(const Key &k, const char *algo,
k.impl(), algo, reserved, expires, flags));
}
+static std::string getLFSeparatedListOfStrings(const std::vector<std::string> &strings)
+{
+ if (strings.empty()) {
+ return std::string();
+ }
+
+ return std::accumulate(
+ std::next(strings.begin()),
+ strings.end(),
+ strings[0],
+ [](const std::string &a, const std::string &b) {
+ return a + '\n' + b;
+ }
+ );
+}
+
static std::string getLFSeparatedListOfFingerprintsFromSubkeys(const std::vector<Subkey> &subkeys)
{
if (subkeys.empty()) {
@@ -1546,18 +1562,7 @@ static std::string getLFSeparatedListOfFingerprintsFromSubkeys(const std::vector
}
}
- if (fprs.empty()) {
- return std::string();
- }
-
- return std::accumulate(
- std::next(fprs.begin()),
- fprs.end(),
- fprs[0],
- [](const std::string &a, const std::string &b) {
- return a + '\n' + b;
- }
- );
+ return getLFSeparatedListOfStrings(fprs);
}
Error Context::setExpire(const Key &k, unsigned long expires,
@@ -1588,6 +1593,41 @@ Error Context::startSetExpire(const Key &k, unsigned long expires,
k.impl(), expires, subfprs.c_str(), 0));
}
+static std::string getLFSeparatedListOfUserIds(const std::vector<UserID> &userIds)
+{
+ if (userIds.empty()) {
+ return std::string();
+ }
+
+ std::vector<std::string> uids;
+ uids.reserve(userIds.size());
+ for (auto &userId : userIds) {
+ if (userId.id()) {
+ uids.push_back(std::string(userId.id()));
+ }
+ }
+
+ return getLFSeparatedListOfStrings(uids);
+}
+
+Error Context::revokeSignature(const Key &key, const Key &signingKey,
+ const std::vector<UserID> &userIds)
+{
+ const unsigned int flags = userIds.size() > 1 ? GPGME_REVSIG_LFSEP : 0;
+ const std::string uids = getLFSeparatedListOfUserIds(userIds);
+ return Error(d->lasterr = gpgme_op_revsig(d->ctx,
+ key.impl(), signingKey.impl(), uids.c_str(), flags));
+}
+
+Error Context::startRevokeSignature(const Key &key, const Key &signingKey,
+ const std::vector<UserID> &userIds)
+{
+ const unsigned int flags = userIds.size() > 1 ? GPGME_REVSIG_LFSEP : 0;
+ const std::string uids = getLFSeparatedListOfUserIds(userIds);
+ return Error(d->lasterr = gpgme_op_revsig_start(d->ctx,
+ key.impl(), signingKey.impl(), uids.c_str(), flags));
+}
+
Error Context::setFlag(const char *name, const char *value)
{
return Error(d->lasterr = gpgme_set_ctx_flag(d->ctx, name, value));
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index 4021aa97..bcb2017a 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -285,6 +285,11 @@ public:
const std::vector<Subkey> &subkeys = std::vector<Subkey>(),
const SetExpireFlags flags = SetExpireDefault);
+ Error revokeSignature(const Key &key, const Key &signingKey,
+ const std::vector<UserID> &userIds = std::vector<UserID>());
+ Error startRevokeSignature(const Key &key, const Key &signingKey,
+ const std::vector<UserID> &userIds = std::vector<UserID>());
+
// using TofuInfo::Policy
Error setTofuPolicy(const Key &k, unsigned int policy);
Error setTofuPolicyStart(const Key &k, unsigned int policy);