GpgFrontend Project A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.

GpgKeyImportExporter.h
1
29 #ifndef _GPGKEYIMPORTEXPORTOR_H
30 #define _GPGKEYIMPORTEXPORTOR_H
31
32 #include <string>
33
34 #include "core/GpgConstants.h"
35 #include "core/GpgContext.h"
36 #include "core/GpgFunctionObject.h"
37 #include "core/GpgModel.h"
38
39 namespace GpgFrontend {
40
45 class GpgImportedKey {
46 public:
47 std::string fpr;
48 int import_status;
49 };
50
51 typedef std::list<GpgImportedKey> GpgImportedKeyList;
52
57 class GPGFRONTEND_CORE_EXPORT GpgImportInformation {
58 public:
59 GpgImportInformation();
60
66 explicit GpgImportInformation(gpgme_import_result_t result);
67
68 int considered = 0;
69 int no_user_id = 0;
70 int imported = 0;
71 int imported_rsa = 0;
72 int unchanged = 0;
73 int new_user_ids = 0;
74 int new_sub_keys = 0;
75 int new_signatures = 0;
76 int new_revocations = 0;
77 int secret_read = 0;
78 int secret_imported = 0;
79 int secret_unchanged = 0;
80 int not_imported = 0;
81
82 GpgImportedKeyList importedKeys;
83 };
84
89 class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter
90 : public SingletonFunctionObject<GpgKeyImportExporter> {
91 public:
97 explicit GpgKeyImportExporter(
98 int channel = SingletonFunctionObject::GetDefaultChannel());
99
106 GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer);
107
117 bool ExportKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer,
118 bool secret = false) const;
119
129 bool ExportKeys(const KeyArgsList& keys, ByteArrayPtr& outBuffer,
130 bool secret = false) const;
131
141 bool ExportAllKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer,
142 bool secret) const;
143
152 bool ExportKey(const GpgKey& key, ByteArrayPtr& out_buffer) const;
153
162 bool ExportKeyOpenSSH(const GpgKey& key, ByteArrayPtr& out_buffer) const;
163
172 bool ExportSecretKey(const GpgKey& key, ByteArrayPtr& outBuffer) const;
173
182 bool ExportSecretKeyShortest(const GpgKey& key,
183 ByteArrayPtr& outBuffer) const;
184
185 private:
186 GpgContext& ctx_ =
187 GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
188 };
189
190 } // namespace GpgFrontend
191
192 #endif // _GPGKEYIMPORTEXPORTOR_H
GpgFrontend::GpgContext
Definition: GpgContext.h:71
GpgFrontend::GpgImportInformation
Definition: GpgKeyImportExporter.h:57
GpgFrontend::GpgImportedKey
Definition: GpgKeyImportExporter.h:45
GpgFrontend::GpgKeyImportExporter
Definition: GpgKeyImportExporter.h:90
GpgFrontend::GpgKey
Definition: GpgKey.h:43
GpgFrontend::SingletonFunctionObject
Definition: GpgFunctionObject.h:150
GpgFrontend::SingletonFunctionObject::GetDefaultChannel
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:251
GpgFrontend::SingletonFunctionObject< GpgContext >::GetInstance
static GpgContext & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:172
GpgFrontend::SingletonFunctionObject::GetChannel
int GetChannel() const
Get the Channel object.
Definition: GpgFunctionObject.h:258
GpgFrontend
Definition: CoreCommonUtil.cpp:31