signing message problem
Hajdu Péter
hp489 at hszk.bme.hu
Tue Aug 8 22:38:17 CEST 2006
Hi!
I've got a problem while signing message with gpgme. I'm really new to
gpgme, so please be patient. Here is my code:
error = gpgme_data_new_from_file(&message,"./tempfile",1);
error = gpgme_new( &context );
gpgme_set_armor( context, 1);
error = gpgme_op_keylist_start(context,NULL,0);
gpgme_key_ref( key );
while ( !(error = gpgme_op_keylist_next (context, &key)) ) {
printf("%s\n",gpg_strerror(error));
uid = key->uids;
str = uid->uid;
printf("%s\n",str);
error = gpgme_signers_add( context, key);
printf("%s\n",gpg_strerror( error ));
gpgme_key_release( key );
}
gpgme_op_keylist_end( context );
memset(buf,0,sizeof(buf));
gpgme_data_new(&signature);
error = gpgme_op_sign( context, message, signature,
GPGME_SIG_MODE_NORMAL );
gpgme_data_release(message);
printf("%s\n",gpg_strerror( error ));
memset(buf,0,sizeof(buf));
printf("%d\n",gpgme_data_read( signature, buf, sizeof(buf) ));
printf("%s",buf);
gpgme_data_release(signature);
gpgme_release(context);
That's not the entire code, I've cut out error handling. At the end,
gpgme_data_read reads 0 data from signature, it looks like it's empty.
It reads in ./tempfile correctly, and it reads my keys too, and there
were no errors. I really don't know what's wrong.
Please help, and sorry for my bad english.
Peter Hajdu
More information about the Gnupg-devel
mailing list