getting signed text in plain

Mario Lenz m at
Sat Jun 30 20:24:19 CEST 2007

Hi @all!
I'm trying to get the "plaintext" out of a signature, but without any
success :-/

Here's a little bit of code to show you what I mean (I used a keyring
without a password for testing so I don't need to

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gpgme.h>

main (int argc, char *argv[])
  gpgme_ctx_t ctx;
  gpgme_error_t err;
  gpgme_data_t plain, signed_text;
  char *agent_info, buffer[100];
  ssize_t size;

  gpgme_check_version (NULL);
  err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
  if (err)
    exit (1);

  err = gpgme_new (&ctx);
  if (err)
    exit (2);

  err = gpgme_data_new_from_mem (&plain, "Hallo Leute\n", 13, 0);
  if (err)
    exit (3);
  err = gpgme_data_new (&signed_text);
  if (err)
    exit (4);

  err = gpgme_op_sign (ctx, plain, signed_text, GPGME_SIG_MODE_NORMAL);
  if (err)
    exit (5);

  gpgme_data_release (plain);
  err = gpgme_data_new (&plain);
  if (err)
    exit (6);

  gpgme_data_seek (signed_text, 0, SEEK_SET);

  err = gpgme_op_verify (ctx, signed_text, NULL, plain);
  if (err)
    exit (7);

  gpgme_data_seek (plain, 0, SEEK_SET);
  size = gpgme_data_read (plain, buffer, 100);
  if (size > 0)
    printf ("%s\n", buffer);
    printf ("failed with size %d\n", size);

  gpgme_data_release (plain);
  gpgme_data_release (signed_text);
  gpgme_release (ctx);
  return 0;

Although verification doesn't fail, I'm unable to get the signed text
out of plain. I've been trying this for some time now and wasn't able to
make it work. Could you please help me?


I'm working on Debian Etch, but I linked the program above also against
the latest gpgme version (1.1.4) and the problem stays.

Rule One: Do not act incautiously when confronting little bald wrinkly
smiling men.

More information about the Gnupg-users mailing list