diff options
author | Saturn&Eric <[email protected]> | 2021-12-13 14:50:57 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-13 14:50:57 +0000 |
commit | ee4752ed756e3114f740efddf63ce987ac154d03 (patch) | |
tree | 27653d56c88849c99c70b8fc7223f8ae98090f0b /src/gpg/function/GpgKeyImportExportor.cpp | |
parent | Update CI for Release and Debug. (diff) | |
parent | Added & Fixed (diff) | |
download | GpgFrontend-ee4752ed756e3114f740efddf63ce987ac154d03.tar.gz GpgFrontend-ee4752ed756e3114f740efddf63ce987ac154d03.zip |
Merge pull request #31 from saturneric/develop-ui
v2.0.2-beta.1
Diffstat (limited to 'src/gpg/function/GpgKeyImportExportor.cpp')
-rw-r--r-- | src/gpg/function/GpgKeyImportExportor.cpp | 28 |
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; +} |