aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp/src/context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lang/cpp/src/context.cpp')
-rw-r--r--lang/cpp/src/context.cpp64
1 files changed, 52 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));