Problem with decrypt

Francis Le Roy thecissou98 at hotmail.fr
Sat Apr 16 10:37:13 CEST 2016


Hi, 
I am using the 
If(err) way to check if there is an error as GPG_ERR_NO_ERR is 0. But actually the gpgme_op_decrypt operation is successful. However, when I do something like : int len = gpgme_data_seek(plaintextdata, 0, SEEK_END); len is equal to zero. 
So I assume that the data haven't been decrypted or written to the buffer.

Thanks. 
F. 







Le 15 avr. 2016 19:05, à 19:05, Werner Koch <wk at gnupg.org> a écrit:
>On Thu, 14 Apr 2016 22:41, thecissou98 at hotmail.fr said:
>
>> I'm trying to decrypt a cipher using gpgme. I have a correct cipher
>and
>> have imported the private key but the plain result of
>gpgme_op_decrypt
>> is empty. The error returned is GPG_ERR_NO_ERROR...
>
>Which means success.  In general you test for an error this way:
>
>      err = gpgme_foo (&data);
>      if (err)
>
>Of course you could also do
>
>      if (err != 0)
>         report_error_foo (gpg_strerror (err));
>      else
>         process_returned_data (data);
>
>which is identical to the above or 
>
>      if (err != GPG_ERR_NO_ERROR)
>         report_error_foo (gpg_strerror (err));
>      else
>         process_returned_data (data);
>
>which is also identical because GPG_ERR_NO_ERROR expands to 0.  I would
>prefer the first becuase it is easier to read.
>
>If you need more help, I suggest to post a snippet of your code.
>
>
>Salam-Shalom,
>
>   Werner
>
>
>ps.
>And yes, some put the constant first like
>      if (0 == err)
>to detect an unintentional assignment to the lvalue.  However, modern
>compilers are pretty good in warning about unintentional assignments
>and
>thus _I_ do not use that.  Comparing false or true is anyway better
>done
>without an explicit compare operator - that pattern is easier to parse
>for the brain.
>
>-- 
>Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20160416/8064dc9a/attachment-0001.html>


More information about the Gnupg-users mailing list