cpp: Support all encryption flags

* lang/cpp/src/context.h (WantAddress): New flag.
* lang/cpp/src/context.cpp (encryptflags2encryptflags): Convert
WantAddress to corresponding gpgme encrypt flags.
(operator<<): Add new flag to debug stream.
--

GnuPG-bug-id: 6359
This commit is contained in:
Ingo Klöcker 2023-01-26 11:59:50 +01:00
parent 70aaf05a6a
commit 3e31f648e5
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
3 changed files with 10 additions and 1 deletions

4
NEWS
View File

@ -7,6 +7,9 @@ Noteworthy changes in version 1.18.1 (unreleased)
* cpp: Handle error when trying to sign expired keys. [T6155] * cpp: Handle error when trying to sign expired keys. [T6155]
* cpp: Support encryption flags ThrowKeyIds, EncryptWrap, and WantAddress.
[T6359]
* cpp, qt: Fix building with C++11. [T6141] * cpp, qt: Fix building with C++11. [T6141]
* qt: Fix problem with expiration dates after 2038-01-19 on 32-bit systems * qt: Fix problem with expiration dates after 2038-01-19 on 32-bit systems
@ -26,6 +29,7 @@ Noteworthy changes in version 1.18.1 (unreleased)
gpgme_set_ctx_flag EXTENDED: New flag 'no-auto-check-trustdb'. gpgme_set_ctx_flag EXTENDED: New flag 'no-auto-check-trustdb'.
cpp: GpgGenCardKeyInteractor::Curve NEW. cpp: GpgGenCardKeyInteractor::Curve NEW.
cpp: GpgGenCardKeyInteractor::setCurve NEW. cpp: GpgGenCardKeyInteractor::setCurve NEW.
cpp: Context::WantAddress NEW.
qt: ListAllKeysJob::Option NEW. qt: ListAllKeysJob::Option NEW.
qt: ListAllKeysJob::Options NEW. qt: ListAllKeysJob::Options NEW.
qt: ListAllKeysJob::setOptions NEW. qt: ListAllKeysJob::setOptions NEW.

View File

@ -1341,6 +1341,9 @@ static gpgme_encrypt_flags_t encryptflags2encryptflags(Context::EncryptionFlags
if (flags & Context::EncryptWrap) { if (flags & Context::EncryptWrap) {
result |= GPGME_ENCRYPT_WRAP; result |= GPGME_ENCRYPT_WRAP;
} }
if (flags & Context::WantAddress) {
result |= GPGME_ENCRYPT_WANT_ADDRESS;
}
return static_cast<gpgme_encrypt_flags_t>(result); return static_cast<gpgme_encrypt_flags_t>(result);
} }
@ -1917,6 +1920,7 @@ std::ostream &operator<<(std::ostream &os, Context::EncryptionFlags flags)
CHECK(Symmetric); CHECK(Symmetric);
CHECK(ThrowKeyIds); CHECK(ThrowKeyIds);
CHECK(EncryptWrap); CHECK(EncryptWrap);
CHECK(WantAddress);
#undef CHECK #undef CHECK
return os << ')'; return os << ')';
} }

View File

@ -447,7 +447,8 @@ public:
NoCompress = 16, NoCompress = 16,
Symmetric = 32, Symmetric = 32,
ThrowKeyIds = 64, ThrowKeyIds = 64,
EncryptWrap = 128 EncryptWrap = 128,
WantAddress = 256,
}; };
EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags); EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText); GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText);