[Marcus.Brinkmann@ruhr-uni-bochum.de: Re: Questions about GPGME]

Marcus Brinkmann Marcus.Brinkmann at ruhr-uni-bochum.de
Thu Feb 7 14:48:01 CET 2002


Mmh, forgot to CC the list.  Sorry.

----- Forwarded message from Marcus Brinkmann <Marcus.Brinkmann at ruhr-uni-bochum.de> -----

From: Marcus Brinkmann <Marcus.Brinkmann at ruhr-uni-bochum.de>
To: Janico Greifenberg <jgre at tzi.de>
Subject: Re: Questions about GPGME

On Wed, Feb 06, 2002 at 09:40:04PM +0100, Janico Greifenberg wrote:
> This sound good, I just can't get the verify (or decrypt_verify) working. I'm
> using the folling code:

I can debug it, but please send in complete (but small) examples that compile
without changes (this time I pulled together my C++ knowledge and made it
compilable myself).

First, a general comment.  You might consider wrapping the GPGME data types
in C++ classes.  They should fall in the C++ style of programming quite
naturally.

>   err = gpgme_op_sign (ctx,in,out,GPGME_SIG_MODE_NORMAL);

gpgme_op_verify does only support detached signatures, so you must use
GPGME_SIG_MODE_DETACH if you want to verify it with gpgme afterwards. 
(Except if something is encrypted and signed, then you can use
decrypt_verify).

>   err = gpgme_data_read(out,str_out, MAX_DATA, &nread );

You should not use hard limits like that.  Avoid it by using
gpgme_data_release_and_get_mem, which returns a pointer to a buffer and its
size.

>   err = gpgme_data_new_from_mem(&in,str_out,strlen(str_out),1);

This is the next error.  The string consists of binary and might contain
binary zeroes.  So you should use the size returned by
gpgme_data_release_and_get_mem.

Alternatively, you can gpgme_data_read the buffer and calculat

>   bzero(str_out,sizeof(str_out));
>   if (err) throw CoreError(gpgme_strerror(err));
>   err = gpgme_data_new(&out2);
>   if (err) throw CoreError(gpgme_strerror(err));
>   err = gpgme_op_verify(ctx,in,out2,&stat);

gpgme_op_verify does not take an in and an out argument, but a sig and a
plain argument (signature and plaintext).  Please check out the
documentation in doc/gpgme.texi in the CVS repository.

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd at debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus at gnu.org
Marcus.Brinkmann at ruhr-uni-bochum.de
http://www.marcus-brinkmann.de

----- End forwarded message -----

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd at debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus at gnu.org
Marcus.Brinkmann at ruhr-uni-bochum.de
http://www.marcus-brinkmann.de




More information about the Gnupg-devel mailing list