Encrypting with gnupg (gpgme library)

Matthijs Mohlmann matthijs at cacholong.nl
Wed Apr 27 23:59:31 CEST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm still busy with the gaim plugin.

Still thanks for pointing me to the tests in the gpgme source directory,
stupid that i didn't checked that one.

Well i try to understand the: tests/gpg/t-encrypt.c test program.

There are 2 calls:
err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
         &key[0], 0);
err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2",
         &key[1], 0);

Here we get the public keys. But then suddenly there is an encrypt
operation. Where o where do I need to set the secret key. When having
multiple secret keys, I have to select the key. What i can get from the
seahorse source is that it's added to the end of the key array. Should
it be there and where can i find more documentation about that ?

And then do the encrypt...
err = gpgme_op_encrypt (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);

After doing this and do the following:
result = gpgme_op_encrypt_result(ctx);
if (result->invalid_recipients) {
  printf("Hmm invalid recipients!!\n");
}
Nothing printed, that's ok.

After that:
#define BUF_SIZE 512
char buf[BUF_SIZE + 1];
int ret;
ret = gpgme_data_seek(out, 0, SEEK_SET);
printf("Print data: (gpgme_data_seek) %i\n", ret);

Now i get a -1 while i expect a value >= 0

When i return the error value, i get:
printf("Hmm what error: %s\n",
gpgme_strerror(gpgme_error_from_errno(errno)));

Hmm what error: Invalid argument

Where did i make the fault ?

Regards,

Matthijs Mohlmann

PS: Now i am subscribed to the list.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCcAtD2n1ROIkXqbARAgMWAJ96+cDJf4TMc9CbgK+rvRbR92uyOwCgmknd
alZShqDxTxJ6Dquwnw9eSro=
=btPM
-----END PGP SIGNATURE-----



More information about the Gnupg-users mailing list