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 "GpgSubKey.h"
33 #include "GpgUID.h"
34 
35 namespace GpgFrontend {
36 
41 class GPGFRONTEND_CORE_EXPORT GpgKey {
42  public:
49  [[nodiscard]] bool IsGood() const;
50 
56  [[nodiscard]] std::string GetId() const;
57 
63  [[nodiscard]] std::string GetName() const;
64 
70  [[nodiscard]] std::string GetEmail() const;
71 
77  [[nodiscard]] std::string GetComment() const;
78 
84  [[nodiscard]] std::string GetFingerprint() const;
85 
91  [[nodiscard]] std::string GetProtocol() const;
92 
98  [[nodiscard]] std::string GetOwnerTrust() const;
99 
105  [[nodiscard]] std::string GetPublicKeyAlgo() const;
106 
112  [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const;
113 
119  [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
120 
126  [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
127 
133  [[nodiscard]] unsigned int GetPrimaryKeyLength() const;
134 
141  [[nodiscard]] bool IsHasEncryptionCapability() const;
142 
150  [[nodiscard]] bool IsHasActualEncryptionCapability() const;
151 
158  [[nodiscard]] bool IsHasSigningCapability() const;
159 
166  [[nodiscard]] bool IsHasActualSigningCapability() const;
167 
174  [[nodiscard]] bool IsHasCertificationCapability() const;
175 
182  [[nodiscard]] bool IsHasActualCertificationCapability() const;
183 
190  [[nodiscard]] bool IsHasAuthenticationCapability() const;
191 
198  [[nodiscard]] bool IsHasActualAuthenticationCapability() const;
199 
206  [[nodiscard]] bool IsHasCardKey() const;
207 
214  [[nodiscard]] bool IsPrivateKey() const;
215 
222  [[nodiscard]] bool IsExpired() const;
223 
230  [[nodiscard]] bool IsRevoked() const;
231 
238  [[nodiscard]] bool IsDisabled() const;
239 
246  [[nodiscard]] bool IsHasMasterKey() const;
247 
253  [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> GetSubKeys() const;
254 
260  [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> GetUIDs() const;
261 
266  GpgKey() = default;
267 
273  explicit GpgKey(gpgme_key_t&& key);
274 
279  ~GpgKey() = default;
280 
286  GpgKey(const gpgme_key_t& key) = delete;
287 
293  GpgKey(GpgKey&& k) noexcept;
294 
301  GpgKey& operator=(GpgKey&& k) noexcept;
302 
309  GpgKey& operator=(const gpgme_key_t& key) = delete;
310 
318  bool operator==(const GpgKey& o) const;
319 
327  bool operator<=(const GpgKey& o) const;
328 
334  explicit operator gpgme_key_t() const;
335 
341  [[nodiscard]] GpgKey Copy() const;
342 
343  private:
348  struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter {
349  void operator()(gpgme_key_t _key);
350  };
351 
352  using KeyRefHandler =
353  std::unique_ptr<struct _gpgme_key, _key_ref_deleter>;
354 
355  KeyRefHandler key_ref_ = nullptr;
356 };
357 
358 } // namespace GpgFrontend
359 
360 #endif // GPGFRONTEND_GPGKEY_H
GpgFrontend::GpgKey::IsHasCardKey
bool IsHasCardKey() const
Definition: GpgKey.cpp:133
GpgFrontend::GpgKey::GpgKey
GpgKey()=default
Construct a new Gpg Key object.
GpgFrontend::GpgKey::operator=
GpgKey & operator=(GpgKey &&k) noexcept
Definition: GpgKey.cpp:35
GpgFrontend::GpgKey::GetId
std::string GetId() const
Definition: GpgKey.cpp:54
GpgFrontend::GpgKey::IsHasSigningCapability
bool IsHasSigningCapability() const
Definition: GpgKey.cpp:121
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::GpgKey::IsHasActualCertificationCapability
bool IsHasActualCertificationCapability() const
Definition: GpgKey.cpp:207
GpgFrontend::GpgKey::_key_ref_deleter
Definition: GpgKey.h:348
GpgFrontend::GpgKey::Copy
GpgKey Copy() const
Definition: GpgKey.cpp:230
GpgFrontend::GpgKey::GetComment
std::string GetComment() const
Definition: GpgKey.cpp:66
GpgFrontend::GpgKey::operator<=
bool operator<=(const GpgKey &o) const
Definition: GpgKey.cpp:44
GpgFrontend::GpgKey::GetEmail
std::string GetEmail() const
Definition: GpgKey.cpp:62
GpgFrontend::GpgKey::GetSubKeys
std::unique_ptr< std::vector< GpgSubKey > > GetSubKeys() const
Definition: GpgKey.cpp:153
GpgFrontend::GpgKey::GetOwnerTrust
std::string GetOwnerTrust() const
Definition: GpgKey.cpp:78
GpgFrontend::GpgKey::GetCreateTime
boost::posix_time::ptime GetCreateTime() const
Create a time object.
Definition: GpgKey.cpp:109
GpgFrontend::GpgKey::IsGood
bool IsGood() const
Definition: GpgKey.cpp:52
GpgFrontend::GpgKey::IsHasActualEncryptionCapability
bool IsHasActualEncryptionCapability() const
Definition: GpgKey.cpp:216
GpgFrontend::GpgKey::operator==
bool operator==(const GpgKey &o) const
Definition: GpgKey.cpp:40
GpgFrontend::GpgKey::IsHasActualSigningCapability
bool IsHasActualSigningCapability() const
Definition: GpgKey.cpp:174
GpgFrontend::GpgKey::IsHasActualAuthenticationCapability
bool IsHasActualAuthenticationCapability() const
Definition: GpgKey.cpp:188
GpgFrontend::GpgKey::IsPrivateKey
bool IsPrivateKey() const
Definition: GpgKey.cpp:140
GpgFrontend::GpgKey::GetPrimaryKeyLength
unsigned int GetPrimaryKeyLength() const
s
Definition: GpgKey.cpp:113
GpgFrontend::GpgKey::GetPublicKeyAlgo
std::string GetPublicKeyAlgo() const
Definition: GpgKey.cpp:96
GpgFrontend::GpgKey::GetExpireTime
boost::posix_time::ptime GetExpireTime() const
Definition: GpgKey.cpp:105
GpgFrontend::GpgKey::IsHasAuthenticationCapability
bool IsHasAuthenticationCapability() const
Definition: GpgKey.cpp:129
GpgFrontend::GpgKey::IsExpired
bool IsExpired() const
Definition: GpgKey.cpp:142
GpgFrontend::GpgSubKey
Definition: GpgSubKey.h:43
GpgFrontend::GpgKey::GetProtocol
std::string GetProtocol() const
Definition: GpgKey.cpp:74
GpgFrontend::GpgUID
Definition: GpgUID.h:40
GpgFrontend::GpgKey::IsRevoked
bool IsRevoked() const
Definition: GpgKey.cpp:144
GpgFrontend::GpgKey::GetUIDs
std::unique_ptr< std::vector< GpgUID > > GetUIDs() const
Definition: GpgKey.cpp:163
GpgFrontend::GpgKey::IsHasEncryptionCapability
bool IsHasEncryptionCapability() const
Definition: GpgKey.cpp:117
GpgFrontend::GpgKey::IsDisabled
bool IsDisabled() const
Definition: GpgKey.cpp:146
GpgFrontend::GpgKey::IsHasCertificationCapability
bool IsHasCertificationCapability() const
Definition: GpgKey.cpp:125
GpgFrontend::GpgKey::IsHasMasterKey
bool IsHasMasterKey() const
Definition: GpgKey.cpp:148
GpgFrontend::GpgKey::GetLastUpdateTime
boost::posix_time::ptime GetLastUpdateTime() const
Definition: GpgKey.cpp:100
GpgFrontend::GpgKey::GetFingerprint
std::string GetFingerprint() const
Definition: GpgKey.cpp:70
GpgFrontend::GpgKey
Definition: GpgKey.h:41
GpgFrontend::GpgKey::GetName
std::string GetName() const
Definition: GpgKey.cpp:58