diff options
author | Saturneric <[email protected]> | 2021-07-01 18:07:42 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-07-01 18:07:42 +0000 |
commit | bf033884a652f32c207046b0f3dcdcc0d225150c (patch) | |
tree | 8c89d964c51cebc7333e6cbe829dc343425958ca /src/gpg/GpgContext.cpp | |
parent | Merge branch 'develop-ci' (diff) | |
download | GpgFrontend-bf033884a652f32c207046b0f3dcdcc0d225150c.tar.gz GpgFrontend-bf033884a652f32c207046b0f3dcdcc0d225150c.zip |
Export Secret Key Fixed.
Start Wizard Modified.
Another Bugs Fixed.
Diffstat (limited to '')
-rw-r--r-- | src/gpg/GpgContext.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index 603ad90b..67bae907 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -653,22 +653,27 @@ namespace GpgME { return QString::fromUtf8(gpgme_strerror(err)); } -/** export private key, TODO errohandling, e.g. like in seahorse (seahorse-gpg-op.c) **/ - - void GpgContext::exportSecretKey(const QString &uid, QByteArray *outBuffer) { - qDebug() << *outBuffer; + bool GpgContext::exportSecretKey(const GpgKey &key, QByteArray *outBuffer) { + qDebug() << "Export Secret Key" << key.id; + gpgme_key_t target_key[2] = { + key.key_refer, + nullptr + }; + + gpgme_data_t dataOut; + gpgme_data_new(&dataOut); // export private key to outBuffer - QStringList arguments; - arguments << "--armor" << "--export-secret-key" << uid; - auto *p_errArray = new QByteArray(); - executeGpgCommand(arguments, outBuffer, p_errArray); - - // append public key to outBuffer - auto *pubKey = new QByteArray(); - QStringList keyList; - keyList.append(uid); - exportKeys(&keyList, pubKey); - outBuffer->append(*pubKey); + gpgme_error_t error = gpgme_op_export_keys(mCtx, target_key,GPGME_EXPORT_MODE_SECRET, dataOut); + + if(gpgme_err_code(error) != GPG_ERR_NO_ERROR) { + checkErr(error); + gpgme_data_release(dataOut); + return false; + } + + readToBuffer(dataOut, outBuffer); + gpgme_data_release(dataOut); + return true; } /** return type should be gpgme_error_t*/ @@ -1241,4 +1246,4 @@ namespace GpgME { } return true; } -}
\ No newline at end of file +} |