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]] int GetOwnerTrustLevel() const;
108
114 [[nodiscard]] std::string GetPublicKeyAlgo() const;
115
121 [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const;
122
128 [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
129
135 [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
136
142 [[nodiscard]] unsigned int GetPrimaryKeyLength() const;
143
150 [[nodiscard]] bool IsHasEncryptionCapability() const;
151
159 [[nodiscard]] bool IsHasActualEncryptionCapability() const;
160
167 [[nodiscard]] bool IsHasSigningCapability() const;
168
175 [[nodiscard]] bool IsHasActualSigningCapability() const;
176
183 [[nodiscard]] bool IsHasCertificationCapability() const;
184
191 [[nodiscard]] bool IsHasActualCertificationCapability() const;
192
199 [[nodiscard]] bool IsHasAuthenticationCapability() const;
200
207 [[nodiscard]] bool IsHasActualAuthenticationCapability() const;
208
215 [[nodiscard]] bool IsHasCardKey() const;
216
223 [[nodiscard]] bool IsPrivateKey() const;
224
231 [[nodiscard]] bool IsExpired() const;
232
239 [[nodiscard]] bool IsRevoked() const;
240
247 [[nodiscard]] bool IsDisabled() const;
248
255 [[nodiscard]] bool IsHasMasterKey() const;
256
262 [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> GetSubKeys() const;
263
269 [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> GetUIDs() const;
270
275 GpgKey() = default;
276
282 explicit GpgKey(gpgme_key_t&& key);
283
288 ~GpgKey() = default;
289
295 GpgKey(const gpgme_key_t& key) = delete;
296
302 GpgKey(GpgKey&& k) noexcept;
303
310 GpgKey& operator=(GpgKey&& k) noexcept;
311
318 GpgKey& operator=(const gpgme_key_t& key) = delete;
319
327 bool operator==(const GpgKey& o) const;
328
336 bool operator<=(const GpgKey& o) const;
337
343 explicit operator gpgme_key_t() const;
344
350 [[nodiscard]] GpgKey Copy() const;
351
352 private:
357 struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter {
358 void operator()(gpgme_key_t _key);
359 };
360
361 using KeyRefHandler =
362 std::unique_ptr<struct _gpgme_key, _key_ref_deleter>;
363
364 KeyRefHandler key_ref_ = nullptr;
365
366 mutable std::mutex gpgme_key_opera_mutex; // mutex for gpgme key operations
367 };
368
369 } // namespace GpgFrontend
370
371 #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:357