Add function to export public keys.

Expects a fingerprint to export a single public key in armor mode.
This commit is contained in:
SET
2020-11-15 11:58:07 +01:00
parent e944da9eda
commit 7633ef9d60
2 changed files with 24 additions and 3 deletions

View File

@@ -273,10 +273,25 @@ const Error GpgMEWorker::ExportPrivateKey(const char * pattern, string& buffer,
Error e = ctx->exportPublicKeys(pattern, kData, flags); Error e = ctx->exportPublicKeys(pattern, kData, flags);
buffer = kData.toString(); // Empty buffer = kData.toString(); // Empty
delete ppp; delete ppp;
delete ctx; delete ctx;
return e; return e;
} }
#endif #endif
const Error GpgMEWorker::ExportPublicKey(const char* pattern, string& buffer)
{
GpgME::Data kData;
Context * ctx = Context::createForProtocol(Protocol::OpenPGP);
ctx->setArmor(true);
uint flags = Context::ExportDefault;
Error e = ctx->exportPublicKeys(pattern, kData, flags);
buffer = kData.toString();
delete ctx;
return e;
}

View File

@@ -146,9 +146,15 @@ public:
* @return * @return
*/ */
const Error ExportPrivateKey(const char * pattern, string& buffer, const Error ExportPrivateKey(const char * pattern, string& buffer,
const string& passphrase = ""); const string& passphrase = "");
#endif #endif
/**
* Export a public key.
* @param pattern : a key fingerprint
* @param buffer : returns data in armor mode
* @return
*/
const Error ExportPublicKey(const char * pattern, string& buffer);
private: private:
Context * m_ctx; Context * m_ctx;
// GPG will fetch a password here. // GPG will fetch a password here.