aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gpg/function/GpgCommandExecutor.h17
-rw-r--r--src/gpg/function/GpgFileOpera.h72
-rw-r--r--src/gpg/function/GpgKeyGetter.h48
-rw-r--r--src/gpg/function/GpgKeyImportExporter.h114
4 files changed, 227 insertions, 24 deletions
diff --git a/src/gpg/function/GpgCommandExecutor.h b/src/gpg/function/GpgCommandExecutor.h
index 6979d5f6..5e8c19c1 100644
--- a/src/gpg/function/GpgCommandExecutor.h
+++ b/src/gpg/function/GpgCommandExecutor.h
@@ -35,11 +35,16 @@
namespace GpgFrontend {
/**
- * @brief
+ * @brief Extra commands related to GPG
*
*/
class GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
public:
+ /**
+ * @brief Construct a new Gpg Command Executor object
+ *
+ * @param channel Corresponding context
+ */
explicit GpgCommandExecutor(
int channel = SingletonFunctionObject::GetDefaultChannel())
: SingletonFunctionObject<GpgCommandExecutor>(channel) {}
@@ -47,10 +52,10 @@ class GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
#ifndef WINDOWS
/**
- * @brief
+ * @brief Excuting an order
*
- * @param arguments
- * @param interact_func
+ * @param arguments Command parameters
+ * @param interact_func Command answering function
*/
void Execute(StringArgsRef arguments,
const std::function<void(boost::process::async_pipe &in,
@@ -59,8 +64,8 @@ class GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
#endif
private:
- GpgContext &ctx =
- GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
+ GpgContext &ctx = GpgContext::GetInstance(
+ SingletonFunctionObject::GetChannel()); ///< Corresponding context
};
} // namespace GpgFrontend
diff --git a/src/gpg/function/GpgFileOpera.h b/src/gpg/function/GpgFileOpera.h
index f4508f42..e08c9ba6 100644
--- a/src/gpg/function/GpgFileOpera.h
+++ b/src/gpg/function/GpgFileOpera.h
@@ -31,34 +31,97 @@
namespace GpgFrontend {
+/**
+ * @brief Executive files related to the basic operations that are provided by
+ * BasicOperator
+ * @class class: BasicOperator
+ */
class GpgFileOpera : public SingletonFunctionObject<GpgFileOpera> {
public:
explicit GpgFileOpera(
int channel = SingletonFunctionObject::GetDefaultChannel())
: SingletonFunctionObject<GpgFileOpera>(channel) {}
+ /**
+ * @brief Encrypted file
+ *
+ * @param keys Used public key
+ * @param in_path The path where the enter file is located
+ * @param out_path The path where the output file is located
+ * @param result Encrypted results
+ * @param _channel Channel in context
+ * @return unsigned int error code
+ */
static unsigned int EncryptFile(KeyListPtr keys, const std::string& in_path,
const std::string& out_path,
GpgEncrResult& result,
int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
+ /**
+ * @brief 运用对称加密算法加密文件
+ *
+ * @param in_path
+ * @param out_path
+ * @param result
+ * @param _channel
+ * @return unsigned int
+ */
static unsigned int EncryptFileSymmetric(
const std::string& in_path, const std::string& out_path,
GpgEncrResult& result, int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
+ /**
+ * @brief
+ *
+ * @param in_path
+ * @param out_path
+ * @param result
+ * @return GpgError
+ */
static GpgError DecryptFile(const std::string& in_path,
const std::string& out_path,
GpgDecrResult& result);
+ /**
+ * @brief
+ *
+ * @param keys
+ * @param in_path
+ * @param out_path
+ * @param result
+ * @param _channel
+ * @return GpgError
+ */
static GpgError SignFile(KeyListPtr keys, const std::string& in_path,
const std::string& out_path, GpgSignResult& result,
int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
+ /**
+ * @brief
+ *
+ * @param data_path
+ * @param sign_path
+ * @param result
+ * @param _channel
+ * @return GpgError
+ */
static GpgError VerifyFile(const std::string& data_path,
const std::string& sign_path,
GpgVerifyResult& result,
int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
+ /**
+ * @brief
+ *
+ * @param keys
+ * @param signer_keys
+ * @param in_path
+ * @param out_path
+ * @param encr_res
+ * @param sign_res
+ * @param _channel
+ * @return GpgError
+ */
static GpgError EncryptSignFile(KeyListPtr keys, KeyListPtr signer_keys,
const std::string& in_path,
const std::string& out_path,
@@ -66,6 +129,15 @@ class GpgFileOpera : public SingletonFunctionObject<GpgFileOpera> {
GpgSignResult& sign_res,
int _channel = GPGFRONTEND_DEFAULT_CHANNEL);
+ /**
+ * @brief
+ *
+ * @param in_path
+ * @param out_path
+ * @param decr_res
+ * @param verify_res
+ * @return GpgError
+ */
static GpgError DecryptVerifyFile(const std::string& in_path,
const std::string& out_path,
GpgDecrResult& decr_res,
diff --git a/src/gpg/function/GpgKeyGetter.h b/src/gpg/function/GpgKeyGetter.h
index fcd518d3..e4700d5a 100644
--- a/src/gpg/function/GpgKeyGetter.h
+++ b/src/gpg/function/GpgKeyGetter.h
@@ -31,25 +31,73 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class GpgKeyGetter : public SingletonFunctionObject<GpgKeyGetter> {
public:
+ /**
+ * @brief Construct a new Gpg Key Getter object
+ *
+ * @param channel
+ */
explicit GpgKeyGetter(
int channel = SingletonFunctionObject::GetDefaultChannel())
: SingletonFunctionObject<GpgKeyGetter>(channel) {}
+ /**
+ * @brief Get the Key object
+ *
+ * @param fpr
+ * @return GpgKey
+ */
GpgKey GetKey(const std::string& fpr);
+ /**
+ * @brief Get the Keys object
+ *
+ * @param ids
+ * @return KeyListPtr
+ */
KeyListPtr GetKeys(const KeyIdArgsListPtr& ids);
+ /**
+ * @brief Get the Pubkey object
+ *
+ * @param fpr
+ * @return GpgKey
+ */
GpgKey GetPubkey(const std::string& fpr);
+ /**
+ * @brief
+ *
+ * @return KeyLinkListPtr
+ */
KeyLinkListPtr FetchKey();
+ /**
+ * @brief Get the Keys Copy object
+ *
+ * @param keys
+ * @return KeyListPtr
+ */
static KeyListPtr GetKeysCopy(const KeyListPtr& keys);
+ /**
+ * @brief Get the Keys Copy object
+ *
+ * @param keys
+ * @return KeyLinkListPtr
+ */
static KeyLinkListPtr GetKeysCopy(const KeyLinkListPtr& keys);
private:
+ /**
+ * @brief
+ *
+ */
GpgContext& ctx =
GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
};
diff --git a/src/gpg/function/GpgKeyImportExporter.h b/src/gpg/function/GpgKeyImportExporter.h
index 64b3b8a9..52de8091 100644
--- a/src/gpg/function/GpgKeyImportExporter.h
+++ b/src/gpg/function/GpgKeyImportExporter.h
@@ -34,18 +34,31 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class GpgImportedKey {
public:
- std::string fpr;
- int import_status;
+ std::string fpr; ///<
+ int import_status; ///<
};
-typedef std::list<GpgImportedKey> GpgImportedKeyList;
+typedef std::list<GpgImportedKey> GpgImportedKeyList; ///<
+/**
+ * @brief
+ *
+ */
class GpgImportInformation {
public:
GpgImportInformation() = default;
+ /**
+ * @brief Construct a new Gpg Import Information object/**
+ *
+ * @param result
+ */
explicit GpgImportInformation(gpgme_import_result_t result) {
if (result->unchanged) unchanged = result->unchanged;
if (result->considered) considered = result->considered;
@@ -63,49 +76,114 @@ class GpgImportInformation {
if (result->not_imported) not_imported = result->not_imported;
}
- int considered = 0;
- int no_user_id = 0;
- int imported = 0;
- int imported_rsa = 0;
- int unchanged = 0;
- int new_user_ids = 0;
- int new_sub_keys = 0;
- int new_signatures = 0;
- int new_revocations = 0;
- int secret_read = 0;
- int secret_imported = 0;
- int secret_unchanged = 0;
- int not_imported = 0;
- GpgImportedKeyList importedKeys;
+ int considered = 0; ///<
+ int no_user_id = 0; ///<
+ int imported = 0; ///<
+ int imported_rsa = 0; ///<
+ int unchanged = 0; ///<
+ int new_user_ids = 0; ///<
+ int new_sub_keys = 0; ///<
+ int new_signatures = 0; ///<
+ int new_revocations = 0; ///<
+ int secret_read = 0; ///<
+ int secret_imported = 0; ///<
+ int secret_unchanged = 0; ///<
+ int not_imported = 0; ///<
+ GpgImportedKeyList importedKeys; ///<
};
+/**
+ * @brief
+ *
+ */
class GpgKeyImportExporter
: public SingletonFunctionObject<GpgKeyImportExporter> {
public:
+ /**
+ * @brief Construct a new Gpg Key Import Exporter object
+ *
+ * @param channel
+ */
explicit GpgKeyImportExporter(
int channel = SingletonFunctionObject::GetDefaultChannel())
: SingletonFunctionObject<GpgKeyImportExporter>(channel) {}
+ /**
+ * @brief
+ *
+ * @param inBuffer
+ * @return GpgImportInformation
+ */
GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer);
+ /**
+ * @brief
+ *
+ * @param uid_list
+ * @param out_buffer
+ * @param secret
+ * @return true
+ * @return false
+ */
bool ExportKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer,
bool secret = false) const;
+ /**
+ * @brief
+ *
+ * @param keys
+ * @param outBuffer
+ * @param secret
+ * @return true
+ * @return false
+ */
bool ExportKeys(const KeyArgsList& keys, ByteArrayPtr& outBuffer,
bool secret = false) const;
+ /**
+ * @brief
+ *
+ * @param key
+ * @param out_buffer
+ * @return true
+ * @return false
+ */
bool ExportKey(const GpgKey& key, ByteArrayPtr& out_buffer) const;
+ /**
+ * @brief
+ *
+ * @param key
+ * @param out_buffer
+ * @return true
+ * @return false
+ */
bool ExportKeyOpenSSH(const GpgKey& key, ByteArrayPtr& out_buffer) const;
+ /**
+ * @brief
+ *
+ * @param key
+ * @param outBuffer
+ * @return true
+ * @return false
+ */
bool ExportSecretKey(const GpgKey& key, ByteArrayPtr& outBuffer) const;
+ /**
+ * @brief
+ *
+ * @param key
+ * @param outBuffer
+ * @return true
+ * @return false
+ */
bool ExportSecretKeyShortest(const GpgKey& key,
ByteArrayPtr& outBuffer) const;
private:
GpgContext& ctx =
- GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
+ GpgContext::GetInstance(SingletonFunctionObject::GetChannel()); ///<
};
} // namespace GpgFrontend