Encrypting with gnupg (gpgme library)
Matthijs Mohlmann
matthijs at cacholong.nl
Thu Apr 28 15:15:56 CEST 2005
Matthijs Mohlmann wrote:
> 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
>
Finally found the problem.
Compiling with: -D_FILE_OFFSET_BITS=64 did the trick.
Thanks.
> Where did i make the fault ?
>
> Regards,
>
> Matthijs Mohlmann
>
> PS: Now i am subscribed to the list.
_______________________________________________
Gnupg-users mailing list
Gnupg-users at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : /pipermail/attachments/20050428/3c2ca686/signature.pgp
More information about the Gnupg-users
mailing list