Requests the passphrase with a popup. As from GPGME 1.15.0, the loopback pinentry is functional when exporting secret keys. It works fine when the exact passphrase is provided. If it's a wrong passphrase, GPGME does not generate an ::Error, but the app crashes with 'free(): double free detected in tcache 2'. Hence, this patch cannot be committed to master. Status : dangerous Result : works and works not Reason : a wrong passphrase means a crash
40 lines
864 B
C++
40 lines
864 B
C++
/*
|
|
* File: GpgMECWorker.cpp
|
|
* Author: SET - nmset@yandex.com
|
|
* License : LGPL v2.1
|
|
* Copyright SET - © 2019
|
|
*
|
|
* Created on 14 octobre 2019, 15:22
|
|
*/
|
|
|
|
#include "GpgMECWorker.h"
|
|
|
|
GpgMECWorker::GpgMECWorker()
|
|
{
|
|
gpgme_error_t c_err = gpgme_new(&c_ctx);
|
|
}
|
|
|
|
GpgMECWorker::~GpgMECWorker()
|
|
{
|
|
gpgme_release(c_ctx);
|
|
}
|
|
|
|
bool GpgMECWorker::DeleteKey(const char * fpr, bool secret, GpgME::Error& e)
|
|
{
|
|
gpgme_key_t c_key;
|
|
gpgme_error_t c_err = gpgme_get_key(c_ctx, fpr, &c_key, secret);
|
|
if (c_key == NULL)
|
|
{
|
|
e = GpgME::Error::fromCode(c_err);
|
|
return false;
|
|
}
|
|
int flags = secret ? GPGME_DELETE_ALLOW_SECRET | GPGME_DELETE_FORCE : GPGME_DELETE_FORCE;
|
|
c_err = gpgme_op_delete_ext(c_ctx, c_key, flags);
|
|
if (c_err != 0)
|
|
{
|
|
e = GpgME::Error::fromCode(c_err);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|