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

GpgKey.h
1
29 #ifndef GPGFRONTEND_GPGKEY_H
30 #define GPGFRONTEND_GPGKEY_H
31
32 #include <mutex>
33
34 #include "GpgSubKey.h"
35 #include "GpgUID.h"
36
37 namespace GpgFrontend {
38
43 class GPGFRONTEND_CORE_EXPORT GpgKey {
44 public:
51 [[nodiscard]] bool IsGood() const;
52
58 [[nodiscard]] std::string GetId() const;
59
65 [[nodiscard]] std::string GetName() const;
66
72 [[nodiscard]] std::string GetEmail() const;
73
79 [[nodiscard]] std::string GetComment() const;
80
86 [[nodiscard]] std::string GetFingerprint() const;
87
93 [[nodiscard]] std::string GetProtocol() const;
94
100 [[nodiscard]] std::string GetOwnerTrust() const;
101
107 [[nodiscard]] std::string GetPublicKeyAlgo() const;
108
114 [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const;
115
121 [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
122
128 [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
129
135 [[nodiscard]] unsigned int GetPrimaryKeyLength() const;
136
143 [[nodiscard]] bool IsHasEncryptionCapability() const;
144
152 [[nodiscard]] bool IsHasActualEncryptionCapability() const;
153
160 [[nodiscard]] bool IsHasSigningCapability() const;
161
168 [[nodiscard]] bool IsHasActualSigningCapability() const;
169
176 [[nodiscard]] bool IsHasCertificationCapability() const;
177
184 [[nodiscard]] bool IsHasActualCertificationCapability() const;
185
192 [[nodiscard]] bool IsHasAuthenticationCapability() const;
193
200 [[nodiscard]] bool IsHasActualAuthenticationCapability() const;
201
208 [[nodiscard]] bool IsHasCardKey() const;
209
216 [[nodiscard]] bool IsPrivateKey() const;
217
224 [[nodiscard]] bool IsExpired() const;
225
232 [[nodiscard]] bool IsRevoked() const;
233
240 [[nodiscard]] bool IsDisabled() const;
241
248 [[nodiscard]] bool IsHasMasterKey() const;
249
255 [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> GetSubKeys() const;
256
262 [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> GetUIDs() const;
263
268 GpgKey() = default;
269
275 explicit GpgKey(gpgme_key_t&& key);
276
281 ~GpgKey() = default;
282
288 GpgKey(const gpgme_key_t& key) = delete;
289
295 GpgKey(GpgKey&& k) noexcept;
296
303 GpgKey& operator=(GpgKey&& k) noexcept;
304
311 GpgKey& operator=(const gpgme_key_t& key) = delete;
312
320 bool operator==(const GpgKey& o) const;
321
329 bool operator<=(const GpgKey& o) const;
330
336 explicit operator gpgme_key_t() const;
337
343 [[nodiscard]] GpgKey Copy() const;
344
345 private:
350 struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter {
351 void operator()(gpgme_key_t _key);
352 };
353
354 using KeyRefHandler =
355 std::unique_ptr<struct _gpgme_key, _key_ref_deleter>;
356
357 KeyRefHandler key_ref_ = nullptr;
358
359 mutable std::mutex gpgme_key_opera_mutex; // mutex for gpgme key operations
360 };
361
362 } // namespace GpgFrontend
363
364 #endif // GPGFRONTEND_GPGKEY_H
GpgFrontend::GpgKey
Definition: GpgKey.h:43
GpgFrontend::GpgKey::GpgKey
GpgKey(const gpgme_key_t &key)=delete
Construct a new Gpg Key object.
GpgFrontend::GpgKey::~GpgKey
~GpgKey()=default
Destroy the Gpg Key objects.
GpgFrontend::GpgKey::GpgKey
GpgKey()=default
Construct a new Gpg Key object.
GpgFrontend::GpgKey::operator=
GpgKey & operator=(const gpgme_key_t &key)=delete
GpgFrontend
Definition: CoreCommonUtil.cpp:31
GpgFrontend::GpgKey::_key_ref_deleter
Definition: GpgKey.h:350