Questions about GPGME
Janico Greifenberg
jgre at tzi.de
Wed Feb 6 21:43:02 CET 2002
> No, currently the default keyrings of the crypto backend are used. We will
> need some way to list keys in a seperate file for some other project, but
> this is probably not what you mean. The question is of course what style
> of interface we choose for such configuration options of the crypto backend.
> I will think about it.
What I would like is are functions like
gpgme_set_pubkeyring(char *file);
gpgme_set_seckeyring(char *file);
gpgme_set_no_default_keyring(int );
or something like that simple setting the gpg options accordingly.
> After importing a key, you can get back some information about it with
> gpgme_op_info, I am not sure if that includes everything you need, please
> come back with more details if you tried it and need more.
I think that will work for me.
> For verify, there are two functions you can invoke after a successful
> verification, gpgme_get_sig_status and gpgme_get_sig_key.
This sound good, I just can't get the verify (or decrypt_verify) working. I'm
using the folling code:
void Crypto::Test(char *msg) {
size_t nread;
int ret,cnt=0;
char *buf_ptr;
char str_out[MAX_DATA];
GpgmeSigStat stat;
GpgmeData in, out, out2;
err = gpgme_data_new_from_mem(&in,msg,strlen(msg),0);
if (err) throw CoreError(gpgme_strerror(err));
err = gpgme_data_new ( &out );
if (err) throw CoreError(gpgme_strerror(err));
err = gpgme_op_sign (ctx,in,out,GPGME_SIG_MODE_NORMAL);
if (err) throw CoreError(gpgme_strerror(err));
fflush (NULL);
err = gpgme_data_rewind ( out );
if (err) throw CoreError(gpgme_strerror(err));
err = gpgme_data_read(out,str_out, MAX_DATA, &nread );
if(err) throw CoreError(gpgme_strerror(err));
gpgme_data_release (in);
gpgme_data_release (out);
cout<<str_out<<endl;
err = gpgme_data_new_from_mem(&in,str_out,strlen(str_out),1);
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);
if (err) throw CoreError(gpgme_strerror(err));
gpgme_data_release (in);
gpgme_data_release (out);
err = gpgme_data_rewind ( out2 );
if (err) throw CoreError(gpgme_strerror(err));
err = gpgme_data_read(out2,str_out, MAX_DATA, &nread );
if(err) throw CoreError(gpgme_strerror(err));
cout<<str_out;
}
When running it, I always get an No-Data-error from _op_verify(). But when
I give the signed output to gpg in the command line it's verifies correctly.
What am I doing wrong?
Thanks
Janico
--
Warning! Taking anyone (especially yourself) too serious will be harmful
More information about the Gnupg-devel
mailing list