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
38namespace GpgFrontend {
39
44class 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
Definition: GpgKey.h:44
GpgKey(const gpgme_key_t &key)=delete
Construct a new Gpg Key object.
~GpgKey()=default
Destroy the Gpg Key objects.
GpgKey()=default
Construct a new Gpg Key object.
GpgKey & operator=(const gpgme_key_t &key)=delete
Definition: CoreCommonUtil.cpp:29