diff options
author | Ingo Klöcker <[email protected]> | 2023-12-19 13:01:18 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2023-12-19 13:01:18 +0000 |
commit | 60c0fd7c955d6b8c1d0d7be3d3c65257c6418a26 (patch) | |
tree | 450f19fd9ab1672b4b169ea4c34497246fbb4ae0 | |
parent | core: Support writing the decrypt/verify output directly to a file (diff) | |
download | gpgme-60c0fd7c955d6b8c1d0d7be3d3c65257c6418a26.tar.gz gpgme-60c0fd7c955d6b8c1d0d7be3d3c65257c6418a26.zip |
cpp: Support new flags for direct signing/encryption of files
* lang/cpp/src/context.h (enum EncryptionFlags): Add constant
EncryptFile.
* lang/cpp/src/global.h (enum SignatureMode): Add constant SignFile.
* lang/cpp/src/context.cpp (sigflags2sigflags): Handle new flag
SignFile.
(encryptflags2encryptflags): Handle new flag EncryptFile.
(operator<<): Add new flags to the corresponding debug streams.
* lang/cpp/src/signingresult.cpp (CreatedSignature::mode): Handle
new flag SignFile (even if it cannot occur).
--
GnuPG-bug-id: 6550
-rw-r--r-- | lang/cpp/src/context.cpp | 8 | ||||
-rw-r--r-- | lang/cpp/src/context.h | 3 | ||||
-rw-r--r-- | lang/cpp/src/global.h | 1 | ||||
-rw-r--r-- | lang/cpp/src/signingresult.cpp | 1 |
4 files changed, 12 insertions, 1 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index bdcfabed..7d04e9cc 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -1301,6 +1301,9 @@ static gpgme_sig_mode_t sigflags2sigflags(SignatureMode flags) if (flags & SignatureMode::SignArchive) { result |= GPGME_SIG_MODE_ARCHIVE; } + if (flags & SignatureMode::SignFile) { + result |= GPGME_SIG_MODE_FILE; + } return static_cast<gpgme_sig_mode_t>(result); } @@ -1363,6 +1366,9 @@ static gpgme_encrypt_flags_t encryptflags2encryptflags(Context::EncryptionFlags if (flags & Context::EncryptArchive) { result |= GPGME_ENCRYPT_ARCHIVE; } + if (flags & Context::EncryptFile) { + result |= GPGME_ENCRYPT_FILE; + } return static_cast<gpgme_encrypt_flags_t>(result); } @@ -1927,6 +1933,7 @@ std::ostream &operator<<(std::ostream &os, SignatureMode mode) } #define CHECK( x ) if ( !(mode & (x)) ) {} else do { os << #x " "; } while (0) CHECK(SignArchive); + CHECK(SignFile); #undef CHECK return os << ')'; } @@ -1945,6 +1952,7 @@ std::ostream &operator<<(std::ostream &os, Context::EncryptionFlags flags) CHECK(EncryptWrap); CHECK(WantAddress); CHECK(EncryptArchive); + CHECK(EncryptFile); #undef CHECK return os << ')'; } diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h index 17a82de0..4d7fedf0 100644 --- a/lang/cpp/src/context.h +++ b/lang/cpp/src/context.h @@ -450,7 +450,8 @@ public: ThrowKeyIds = 64, EncryptWrap = 128, WantAddress = 256, - EncryptArchive = 512 + EncryptArchive = 512, + EncryptFile = 1024 }; EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags); GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText); diff --git a/lang/cpp/src/global.h b/lang/cpp/src/global.h index c9c65cdb..d297defc 100644 --- a/lang/cpp/src/global.h +++ b/lang/cpp/src/global.h @@ -79,6 +79,7 @@ enum SignatureMode { Detached = 1, Clearsigned = 2, SignArchive = 4, + SignFile = 8, }; enum class RevocationReason { diff --git a/lang/cpp/src/signingresult.cpp b/lang/cpp/src/signingresult.cpp index 06169cbc..c92a6e3e 100644 --- a/lang/cpp/src/signingresult.cpp +++ b/lang/cpp/src/signingresult.cpp @@ -200,6 +200,7 @@ GpgME::SignatureMode GpgME::CreatedSignature::mode() const case GPGME_SIG_MODE_DETACH: return Detached; case GPGME_SIG_MODE_CLEAR: return Clearsigned; case GPGME_SIG_MODE_ARCHIVE: return SignArchive; // cannot happen + case GPGME_SIG_MODE_FILE: return SignFile; // cannot happen } } |