Add function to export public keys.
Expects a fingerprint to export a single public key in armor mode.
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user