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 <boost/date_time.hpp>
33 #include <boost/date_time/posix_time/conversion.hpp>
34 
35 #include "GpgSubKey.h"
36 #include "GpgUID.h"
37 
38 namespace GpgFrontend {
39 
44 class GPGFRONTEND_CORE_EXPORT GpgKey {
45  public:
52  [[nodiscard]] bool IsGood() const;
53 
59  [[nodiscard]] std::string GetId() const;
60 
66  [[nodiscard]] std::string GetName() const;
67 
73  [[nodiscard]] std::string GetEmail() const;
74 
80  [[nodiscard]] std::string GetComment() const;
81 
87  [[nodiscard]] std::string GetFingerprint() const;
88 
94  [[nodiscard]] std::string GetProtocol() const;
95 
101  [[nodiscard]] std::string GetOwnerTrust() const;
102 
108  [[nodiscard]] std::string GetPublicKeyAlgo() const;
109 
115  [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const;
116 
122  [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
123 
129  [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
130 
136  [[nodiscard]] unsigned int GetPrimaryKeyLength() const;
137 
144  [[nodiscard]] bool IsHasEncryptionCapability() const;
145 
153  [[nodiscard]] bool IsHasActualEncryptionCapability() const;
154 
161  [[nodiscard]] bool IsHasSigningCapability() const;
162 
169  [[nodiscard]] bool IsHasActualSigningCapability() const;
170 
177  [[nodiscard]] bool IsHasCertificationCapability() const;
178 
185  [[nodiscard]] bool IsHasActualCertificationCapability() const;
186 
193  [[nodiscard]] bool IsHasAuthenticationCapability() const;
194 
201  [[nodiscard]] bool IsHasActualAuthenticationCapability() const;
202 
209  [[nodiscard]] bool IsHasCardKey() const;
210 
217  [[nodiscard]] bool IsPrivateKey() const;
218 
225  [[nodiscard]] bool IsExpired() const;
226 
233  [[nodiscard]] bool IsRevoked() const;
234 
241  [[nodiscard]] bool IsDisabled() const;
242 
249  [[nodiscard]] bool IsHasMasterKey() const;
250 
256  [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> GetSubKeys() const;
257 
263  [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> GetUIDs() const;
264 
269  GpgKey() = default;
270 
276  explicit GpgKey(gpgme_key_t&& key);
277 
282  ~GpgKey() = default;
283 
289  GpgKey(const gpgme_key_t& key) = delete;
290 
296  GpgKey(GpgKey&& k) noexcept;
297 
304  GpgKey& operator=(GpgKey&& k) noexcept;
305 
312  GpgKey& operator=(const gpgme_key_t& key) = delete;
313 
321  bool operator==(const GpgKey& o) const;
322 
330  bool operator<=(const GpgKey& o) const;
331 
337  explicit operator gpgme_key_t() const;
338 
344  [[nodiscard]] GpgKey Copy() const;
345 
346  private:
351  struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter {
352  void operator()(gpgme_key_t _key);
353  };
354 
355  using KeyRefHandler =
356  std::unique_ptr<struct _gpgme_key, _key_ref_deleter>;
357 
358  KeyRefHandler key_ref_ = nullptr;
359 };
360 
361 } // namespace GpgFrontend
362 
363 #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:351
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:44
GpgFrontend::GpgKey::GetName
std::string GetName() const
Definition: GpgKey.cpp:58