summaryrefslogtreecommitdiff
path: root/lang/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'lang/cpp/src')
-rw-r--r--lang/cpp/src/Makefile.in4
-rw-r--r--lang/cpp/src/context.cpp30
-rw-r--r--lang/cpp/src/context.h14
-rw-r--r--lang/cpp/src/data.cpp5
-rw-r--r--lang/cpp/src/data.h3
-rw-r--r--lang/cpp/src/decryptionresult.cpp24
-rw-r--r--lang/cpp/src/decryptionresult.h6
-rw-r--r--lang/cpp/src/gpggencardkeyinteractor.cpp9
-rw-r--r--lang/cpp/src/key.cpp7
-rw-r--r--lang/cpp/src/verificationresult.cpp2
10 files changed, 96 insertions, 8 deletions
diff --git a/lang/cpp/src/Makefile.in b/lang/cpp/src/Makefile.in
index 21b259d..5ab55cc 100644
--- a/lang/cpp/src/Makefile.in
+++ b/lang/cpp/src/Makefile.in
@@ -123,7 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/build-aux/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_HEADER = $(top_builddir)/conf/config.h
CONFIG_CLEAN_FILES = GpgmeppConfig-w32.cmake.in GpgmeppConfig.cmake.in \
GpgmeppConfigVersion.cmake gpgmepp_version.h
CONFIG_CLEAN_VPATH_FILES =
@@ -195,7 +195,7 @@ AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/conf
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 135e4d5..1e4e549 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -1028,6 +1028,9 @@ unsigned int to_auditlog_flags(unsigned int flags)
if (flags & Context::AuditLogWithHelp) {
result |= GPGME_AUDITLOG_WITH_HELP;
}
+ if (flags & Context::DiagnosticAuditLog) {
+ result |= GPGME_AUDITLOG_DIAG;
+ }
return result;
}
@@ -1436,6 +1439,23 @@ Error Context::createKey (const char *userid,
flags));
}
+KeyGenerationResult Context::createKeyEx (const char *userid,
+ const char *algo,
+ unsigned long reserved,
+ unsigned long expires,
+ const Key &certkey,
+ unsigned int flags)
+{
+ d->lasterr = gpgme_op_createkey(d->ctx,
+ userid,
+ algo,
+ reserved,
+ expires,
+ certkey.impl(),
+ flags);
+ return KeyGenerationResult(d->ctx, Error(d->lasterr));
+}
+
Error Context::addUid(const Key &k, const char *userid)
{
return Error(d->lasterr = gpgme_op_adduid(d->ctx,
@@ -1478,6 +1498,16 @@ Error Context::startCreateSubkey(const Key &k, const char *algo,
k.impl(), algo, reserved, expires, flags));
}
+Error Context::setFlag(const char *name, const char *value)
+{
+ return Error(d->lasterr = gpgme_set_ctx_flag(d->ctx, name, value));
+}
+
+const char *Context::getFlag(const char *name) const
+{
+ return gpgme_get_ctx_flag(d->ctx, name);
+}
+
// Engine Spawn stuff
Error Context::spawn(const char *file, const char *argv[],
Data &input, Data &output, Data &err,
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index aff8e49..6e27daa 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -86,6 +86,9 @@ public:
void setOffline(bool useOfflineMode);
bool offline() const;
+ const char *getFlag(const char *name) const;
+ Error setFlag(const char *name, const char *value);
+
enum CertificateInclusion {
DefaultCertificates = -256,
AllCertificatesExceptRoot = -2,
@@ -231,6 +234,14 @@ public:
const Key &certkey,
unsigned int flags);
+ // Same as create key but returning a result
+ GpgME::KeyGenerationResult createKeyEx (const char *userid,
+ const char *algo,
+ unsigned long reserved,
+ unsigned long expires,
+ const Key &certkey,
+ unsigned int flags);
+
Error addUid(const Key &key, const char *userid);
Error startAddUid(const Key &key, const char *userid);
@@ -390,7 +401,9 @@ public:
//
//
enum AuditLogFlags {
+ DefaultAuditLog = 0,
HtmlAuditLog = 1,
+ DiagnosticAuditLog = 2,
AuditLogWithHelp = 128
};
GpgME::Error startGetAuditLog(Data &output, unsigned int flags = 0);
@@ -453,6 +466,7 @@ public:
{
return d;
}
+
private:
// Helper functions that need to be context because they rely
// on the "Friendlyness" of context to access the gpgme types.
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
index 52b8da2..2782aa7 100644
--- a/lang/cpp/src/data.cpp
+++ b/lang/cpp/src/data.cpp
@@ -232,6 +232,11 @@ off_t GpgME::Data::seek(off_t offset, int whence)
return gpgme_data_seek(d->data, offset, whence);
}
+GpgME::Error GpgME::Data::rewind()
+{
+ return Error(gpgme_data_rewind(d->data));
+}
+
std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
{
std::vector<GpgME::Key> ret;
diff --git a/lang/cpp/src/data.h b/lang/cpp/src/data.h
index 446f6fa..df8607e 100644
--- a/lang/cpp/src/data.h
+++ b/lang/cpp/src/data.h
@@ -110,6 +110,9 @@ public:
ssize_t write(const void *buffer, size_t length);
off_t seek(off_t offset, int whence);
+ /* Convenience function to do a seek (0, SEEK_SET). */
+ Error rewind();
+
/** Try to parse the data to a key object using the
* Protocol proto. Returns an empty list on error.*/
std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
diff --git a/lang/cpp/src/decryptionresult.cpp b/lang/cpp/src/decryptionresult.cpp
index 1e815cb..ea0a8a5 100644
--- a/lang/cpp/src/decryptionresult.cpp
+++ b/lang/cpp/src/decryptionresult.cpp
@@ -51,6 +51,9 @@ public:
if (res.file_name) {
res.file_name = strdup(res.file_name);
}
+ if (res.symkey_algo) {
+ res.symkey_algo = strdup(res.symkey_algo);
+ }
//FIXME: copying gpgme_recipient_t objects invalidates the keyid member,
//thus we use _keyid for now (internal API)
for (gpgme_recipient_t r = res.recipients ; r ; r = r->next) {
@@ -68,6 +71,10 @@ public:
std::free(res.file_name);
}
res.file_name = 0;
+ if (res.symkey_algo) {
+ std::free(res.symkey_algo);
+ }
+ res.symkey_algo = 0;
}
_gpgme_op_decrypt_result res;
@@ -155,6 +162,21 @@ std::vector<GpgME::DecryptionResult::Recipient> GpgME::DecryptionResult::recipie
return result;
}
+const char *GpgME::DecryptionResult::sessionKey() const
+{
+ return d ? d->res.session_key : nullptr;
+}
+
+const char *GpgME::DecryptionResult::symkeyAlgo() const
+{
+ return d ? d->res.symkey_algo : nullptr;
+}
+
+bool GpgME::DecryptionResult::isLegacyCipherNoMDC() const
+{
+ return d && d->res.legacy_cipher_nomdc;
+}
+
class GpgME::DecryptionResult::Recipient::Private : public _gpgme_recipient
{
public:
@@ -231,6 +253,8 @@ std::ostream &GpgME::operator<<(std::ostream &os, const DecryptionResult &result
<< "\n unsupportedAlgorithm: " << protect(result.unsupportedAlgorithm())
<< "\n isWrongKeyUsage: " << result.isWrongKeyUsage()
<< "\n isDeVs " << result.isDeVs()
+ << "\n legacyCipherNoMDC " << result.isLegacyCipherNoMDC()
+ << "\n symkeyAlgo: " << protect(result.symkeyAlgo())
<< "\n recipients:\n";
const std::vector<DecryptionResult::Recipient> recipients = result.recipients();
std::copy(recipients.begin(), recipients.end(),
diff --git a/lang/cpp/src/decryptionresult.h b/lang/cpp/src/decryptionresult.h
index 57705b4..e4d542d 100644
--- a/lang/cpp/src/decryptionresult.h
+++ b/lang/cpp/src/decryptionresult.h
@@ -77,12 +77,18 @@ public:
const char *fileName() const;
+ const char *sessionKey() const;
+
+ const char *symkeyAlgo() const;
+
class Recipient;
unsigned int numRecipients() const;
Recipient recipient(unsigned int idx) const;
std::vector<Recipient> recipients() const;
+ bool isLegacyCipherNoMDC() const;
+
private:
class Private;
void init(gpgme_ctx_t ctx);
diff --git a/lang/cpp/src/gpggencardkeyinteractor.cpp b/lang/cpp/src/gpggencardkeyinteractor.cpp
index 6f42e47..0ed6781 100644
--- a/lang/cpp/src/gpggencardkeyinteractor.cpp
+++ b/lang/cpp/src/gpggencardkeyinteractor.cpp
@@ -36,12 +36,11 @@ using namespace GpgME;
class GpgGenCardKeyInteractor::Private
{
public:
- Private() : keysize(2048), backup(false)
+ Private() : keysize("2048"), backup(false)
{
}
- std::string name, email, backupFileName, expiry, serial;
- int keysize;
+ std::string name, email, backupFileName, expiry, serial, keysize;
bool backup;
};
@@ -70,7 +69,7 @@ void GpgGenCardKeyInteractor::setDoBackup(bool value)
void GpgGenCardKeyInteractor::setKeySize(int value)
{
- d->keysize = value;
+ d->keysize = std::to_string(value);
}
void GpgGenCardKeyInteractor::setExpiry(const std::string &timeStr)
@@ -132,7 +131,7 @@ const char *GpgGenCardKeyInteractor::action(Error &err) const
case SIZE:
case SIZE2:
case SIZE3:
- return std::to_string(d->keysize).c_str();
+ return d->keysize.c_str();
case COMMENT:
return "";
case SAVE:
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 034286f..8fc266f 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -347,6 +347,9 @@ const Key &Key::mergeWith(const Key &other)
void Key::update()
{
+ if (isNull() || !primaryFingerprint()) {
+ return;
+ }
auto ctx = Context::createForProtocol(protocol());
if (!ctx) {
return;
@@ -1042,6 +1045,8 @@ std::ostream &operator<<(std::ostream &os, const UserID &uid)
<< "\n revoked: " << uid.isRevoked()
<< "\n invalid: " << uid.isInvalid()
<< "\n numsigs: " << uid.numSignatures()
+ << "\n origin: " << uid.origin()
+ << "\n updated: " << uid.lastUpdate()
<< "\n tofuinfo:\n" << uid.tofuInfo();
}
return os << ')';
@@ -1060,6 +1065,8 @@ std::ostream &operator<<(std::ostream &os, const Key &key)
<< "\n canEncrypt: " << key.canEncrypt()
<< "\n canCertify: " << key.canCertify()
<< "\n canAuth: " << key.canAuthenticate()
+ << "\n origin: " << key.origin()
+ << "\n updated: " << key.lastUpdate()
<< "\n uids:\n";
const std::vector<UserID> uids = key.userIDs();
std::copy(uids.begin(), uids.end(),
diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp
index 2c42d07..fa8237a 100644
--- a/lang/cpp/src/verificationresult.cpp
+++ b/lang/cpp/src/verificationresult.cpp
@@ -406,7 +406,7 @@ GpgME::Key GpgME::Signature::key(bool search, bool update) const
}
GpgME::Key ret = key();
- if (ret.isNull() && search) {
+ if (ret.isNull() && search && fingerprint ()) {
auto ctx = Context::createForProtocol (d->proto);
if (ctx) {
ctx->setKeyListMode(KeyListMode::Local |