aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/function/GpgKeyImportExportor.cpp
diff options
context:
space:
mode:
authorSaturn&Eric <[email protected]>2021-12-13 18:46:23 +0000
committerGitHub <[email protected]>2021-12-13 18:46:23 +0000
commit5d8e24b7ce4620164c3268b4f1de43a30df19a86 (patch)
tree6defd5d68468a95de980752ccf2c4ef8a0753617 /src/gpg/function/GpgKeyImportExportor.cpp
parentCreate SECURITY.md (diff)
parentUpdate Translations & README. (diff)
downloadGpgFrontend-5d8e24b7ce4620164c3268b4f1de43a30df19a86.tar.gz
GpgFrontend-5d8e24b7ce4620164c3268b4f1de43a30df19a86.zip
Merge pull request #32 from saturneric/developv2.0.2
v2.0.2-beta.2
Diffstat (limited to 'src/gpg/function/GpgKeyImportExportor.cpp')
-rw-r--r--src/gpg/function/GpgKeyImportExportor.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gpg/function/GpgKeyImportExportor.cpp b/src/gpg/function/GpgKeyImportExportor.cpp
index d8812839..89d3b002 100644
--- a/src/gpg/function/GpgKeyImportExportor.cpp
+++ b/src/gpg/function/GpgKeyImportExportor.cpp
@@ -130,3 +130,31 @@ bool GpgFrontend::GpgKeyImportExportor::ExportKey(
std::swap(out_buffer, temp_out_buffer);
return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
}
+
+bool GpgFrontend::GpgKeyImportExportor::ExportKeyOpenSSH(
+ const GpgFrontend::GpgKey& key,
+ GpgFrontend::ByteArrayPtr& out_buffer) const {
+ GpgData data_out;
+ auto err =
+ gpgme_op_export(ctx, key.id().c_str(), GPGME_EXPORT_MODE_SSH, data_out);
+
+ DLOG(INFO) << "read_bytes" << gpgme_data_seek(data_out, 0, SEEK_END);
+
+ auto temp_out_buffer = data_out.Read2Buffer();
+ std::swap(out_buffer, temp_out_buffer);
+ return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
+}
+
+bool GpgFrontend::GpgKeyImportExportor::ExportSecretKeyShortest(
+ const GpgFrontend::GpgKey& key,
+ GpgFrontend::ByteArrayPtr& out_buffer) const {
+ GpgData data_out;
+ auto err = gpgme_op_export(ctx, key.id().c_str(), GPGME_EXPORT_MODE_MINIMAL,
+ data_out);
+
+ DLOG(INFO) << "read_bytes" << gpgme_data_seek(data_out, 0, SEEK_END);
+
+ auto temp_out_buffer = data_out.Read2Buffer();
+ std::swap(out_buffer, temp_out_buffer);
+ return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
+}