aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/gpg')
-rw-r--r--src/core/function/gpg/GpgKeyImportExporter.cpp21
-rw-r--r--src/core/function/gpg/GpgKeyImportExporter.h12
2 files changed, 33 insertions, 0 deletions
diff --git a/src/core/function/gpg/GpgKeyImportExporter.cpp b/src/core/function/gpg/GpgKeyImportExporter.cpp
index dc744e09..8c66ebe2 100644
--- a/src/core/function/gpg/GpgKeyImportExporter.cpp
+++ b/src/core/function/gpg/GpgKeyImportExporter.cpp
@@ -28,6 +28,8 @@
#include "GpgKeyImportExporter.h"
+#include <memory>
+
#include "GpgConstants.h"
#include "GpgKeyGetter.h"
@@ -116,6 +118,25 @@ bool GpgFrontend::GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys,
}
/**
+ * Export all the keys both private and public keys
+ * @param uid_list key ids
+ * @param out_buffer output byte array
+ * @return if success
+ */
+bool GpgFrontend::GpgKeyImportExporter::ExportAllKeys(
+ KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer, bool secret) const {
+ bool result = true;
+ result = ExportKeys(uid_list, out_buffer, false) & result;
+
+ ByteArrayPtr temp_buffer;
+ if (secret) {
+ result = ExportKeys(uid_list, temp_buffer, true) & result;
+ }
+ out_buffer->append(*temp_buffer);
+ return true;
+}
+
+/**
* Export the secret key of a key pair(including subkeys)
* @param key target key pair
* @param outBuffer output byte array
diff --git a/src/core/function/gpg/GpgKeyImportExporter.h b/src/core/function/gpg/GpgKeyImportExporter.h
index 7603c17d..6e90f436 100644
--- a/src/core/function/gpg/GpgKeyImportExporter.h
+++ b/src/core/function/gpg/GpgKeyImportExporter.h
@@ -132,6 +132,18 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter
/**
* @brief
*
+ * @param keys
+ * @param outBuffer
+ * @param secret
+ * @return true
+ * @return false
+ */
+ bool ExportAllKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer,
+ bool secret) const;
+
+ /**
+ * @brief
+ *
* @param key
* @param out_buffer
* @return true