[GPGME] Repeated decrypt fails
Randy Trinh
trinh.randy at gmail.com
Thu May 17 20:48:01 CEST 2018
On Thu, May 17, 2018 at 11:35 AM, Ben McGinnes <ben at adversary.org> wrote:
>
> > Does the website encrypt the file uploaded by (eventually) some end
> > user or do they encrypt the file first and then upload that which your
> > code subsequently decrypts?
The file is encrypted first by the user and then uploaded to which my code
subsequently decrypts it.
>
> Yeah, this is strange, but we'll need more info to work out what's
> > going on. Are you able to share the code for what's happening here
> > and, if the website also encrypts the uploaded data, that bit too?
>
Certainly! I've provided the entire GPGME portion of the function below,
I'm not entirely certain if this is acceptable to call every time my
program decides to attempt a decrypt though (Feel free to highlight my
errors):
gpgme_check_version(NULL);
setlocale (LC_ALL, "");
gpgme_error_t err, stat;
gpgme_ctx_t ctx;
gpgme_decrypt_result_t decResult;
gpgme_data_t fileEncrypted, fileDecrypted, keydata;
int systemVal;
std::string tempFile = "TemporaryFile";
std::string newFileName = "Decrypted";
std::string newFileNameExt = newFileName + ".tar.gz";
const char* name = newFileNameExt.c_str();
err = gpgme_new(&ctx);
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
if (boost::filesystem::exists(tempFile))
{
boost::filesystem::remove_all(tempFile);
}
boost::filesystem::create_directory(tempFile);
int fdEncrypt = open(fileName, O_RDONLY);
int fdDecrypt = open(name, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
err = gpgme_data_new_from_fd(&fileEncrypted, fdEncrypt);
err = gpgme_data_new_from_fd(&fileDecrypted, fdDecrypt);
err = gpgme_op_decrypt_start(ctx, fileEncrypted, fileDecrypted);
ctx = gpgme_wait(ctx, &stat, 1);
std::cout << "Decrypt Status: " << gpgme_strerror(err) << std::endl;
gpgme_decrypt_result_t dResult = gpgme_op_decrypt_result(ctx);
if (dResult->unsupported_algorithm)
{
std::cout << "invalid decrypt" << std::endl;
}
close(fdEncrypt);
close(fdDecrypt);
gpgme_release(ctx);
> > No, that's not normal and I'm wondering how it happened, but there are
> > some functions which might do it and it may also depend on which
> > version(s) of GPG and GPGME you're using. Which are they, by the way?
>
The version of GPG I am using is 2.0.22 (or 1.4.16) I have both installed
but I'm actually not entirely confident which one is being used by GPGME.
As for GPGME, I am using Ver 1.11.1.
Thanks for the reply! 😉
Cheers,
Randy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20180517/4b883f45/attachment.html>
More information about the Gnupg-users
mailing list