Add function to export public keys.
Expects a fingerprint to export a single public key in armor mode.
This commit is contained in:
@@ -280,3 +280,18 @@ const Error GpgMEWorker::ExportPrivateKey(const char * pattern, string& buffer,
|
|||||||
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -148,7 +148,13 @@ public:
|
|||||||
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