2003-04-27  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Encrypting a Plaintext): Add info about
	GpgmeEncryptResult and gpgme_op_encrypt_result.

gpgme/
2003-04-27  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.h (GpgmeEncryptResult): New data type.
	(gpgme_op_encrypt_result): New prototype.
	* ops.h (_gpgme_op_encrypt_init_result): New prototype.
	(_gpgme_op_encrypt_status_handler): Fix prototype.
	* encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call
	_gpgme_op_encrypt_init_result.
	* encrypt.c: Do not include <stdio.h>, <assert.h>, "util.h" and
	"wait.h".  Include <errno.h> and "gpgme.h".
	(SKIP_TOKEN_OR_RETURN): Remove macro.
	(struct encrypt_result): Rename to ...
	(op_data_t): ... new data type.  Rewrite for user result data.
	(append_xml_encinfo): Remove function.
	(release_op_data): New function.
	(gpgme_op_encrypt_result): New function.
	(_gpgme_op_encrypt_status_handler): Change first argument to void *.
	Rewrite result parsing.
	(_gpgme_op_encrypt_sym_status_handler): Change first argument to
	void *.
	(_gpgme_op_encrypt_init_result): New function.
	(_gpgme_op_encrypt_start): Rename to ...
	(encrypt_start): ... this.
	(gpgme_op_encrypt_start): Use encrypt_start, not
	gpgme_op_encrypt_start.
	(gpgme_op_encrypt): Likewise.

tests/
2003-04-27  Marcus Brinkmann  <marcus@g10code.de>

	* gpg/t-sign.c: Rewritten.
	* gpgsm/t-sign.c: Rewritten.
	* gpg/t-encrypt.c: Check for invalid recipients.
	* gpgsm/t-encrypt.c: Likewise.
This commit is contained in:
Marcus Brinkmann 2003-04-27 22:24:37 +00:00
parent 2971894b27
commit 588c16d324
15 changed files with 541 additions and 488 deletions

6
NEWS
View File

@ -82,6 +82,10 @@ Noteworthy changes in version 0.4.1 (unreleased)
about the result of a signing operation in GpgmeSignResult, about the result of a signing operation in GpgmeSignResult,
GpgmeInvalidUserID and GpgmeNewSignature objects. GpgmeInvalidUserID and GpgmeNewSignature objects.
* The new gpgme_op_encrypt_result function provides detailed
information about the result of an encryption operation in
a GpgmeEncryptResult object.
* Interface changes relative to the 0.4.0 release: * Interface changes relative to the 0.4.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GpgmeIOCb CHANGED: Return type from void to GpgmeError. GpgmeIOCb CHANGED: Return type from void to GpgmeError.
@ -120,6 +124,8 @@ GpgmeSignResult NEW
gpgme_op_sign_result NEW gpgme_op_sign_result NEW
gpgme_pubkey_algo_name NEW gpgme_pubkey_algo_name NEW
gpgme_hash_algo_name NEW gpgme_hash_algo_name NEW
GpgmeEncryptResult NEW
gpgme_op_encrypt_result NEW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Noteworthy changes in version 0.4.0 (2002-12-23) Noteworthy changes in version 0.4.0 (2002-12-23)

View File

@ -1,5 +1,8 @@
2003-04-27 Marcus Brinkmann <marcus@g10code.de> 2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Encrypting a Plaintext): Add info about
GpgmeEncryptResult and gpgme_op_encrypt_result.
* gpgme.texi (Creating a Signature): Add info about * gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result. GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID. (Crypto Operations): Add GpgmeInvalidUserID.

View File

@ -3357,6 +3357,30 @@ started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
recipients. recipients.
@end deftypefun @end deftypefun
@deftp {Data type} {GpgmeEncryptResult}
This is a pointer to a structure used to store the result of a
@code{gpgme_op_encrypt} operation. After successfully encrypting
data, you can retrieve the pointer to the result with
@code{gpgme_op_encrypt_result}. The structure contains the following
members:
@table @code
@item GpgmeInvalidUserID invalid_recipients
A linked list with information about all invalid user IDs for which
the data could not be encrypted.
@end table
@end deftp
@deftypefun GpgmeEncryptResult gpgme_op_encrypt_result (@w{GpgmeCtx @var{ctx}})
The function @code{gpgme_op_encrypt_result} returns a
@code{GpgmeEncryptResult} pointer to a structure holding the result of
a @code{gpgme_op_encrypt} operation. The pointer is only valid if the
last operation on the context was a @code{gpgme_op_encrypt} or
@code{gpgme_op_encrypt_start} operation, and if this operation
finished successfully. The returned pointer is only valid until the
next operation is started on the context.
@end deftypefun
@deftypefun GpgmeError gpgme_op_encrypt_sign (@w{GpgmeCtx @var{ctx}}, @w{GpgmeRecipients @var{rset}}, @w{GpgmeData @var{plain}}, @w{GpgmeData @var{cipher}}) @deftypefun GpgmeError gpgme_op_encrypt_sign (@w{GpgmeCtx @var{ctx}}, @w{GpgmeRecipients @var{rset}}, @w{GpgmeData @var{plain}}, @w{GpgmeData @var{cipher}})
The function @code{gpgme_op_encrypt_sign} does a combined encrypt and The function @code{gpgme_op_encrypt_sign} does a combined encrypt and

View File

@ -1,5 +1,30 @@
2003-04-27 Marcus Brinkmann <marcus@g10code.de> 2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmeEncryptResult): New data type.
(gpgme_op_encrypt_result): New prototype.
* ops.h (_gpgme_op_encrypt_init_result): New prototype.
(_gpgme_op_encrypt_status_handler): Fix prototype.
* encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call
_gpgme_op_encrypt_init_result.
* encrypt.c: Do not include <stdio.h>, <assert.h>, "util.h" and
"wait.h". Include <errno.h> and "gpgme.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct encrypt_result): Rename to ...
(op_data_t): ... new data type. Rewrite for user result data.
(append_xml_encinfo): Remove function.
(release_op_data): New function.
(gpgme_op_encrypt_result): New function.
(_gpgme_op_encrypt_status_handler): Change first argument to void *.
Rewrite result parsing.
(_gpgme_op_encrypt_sym_status_handler): Change first argument to
void *.
(_gpgme_op_encrypt_init_result): New function.
(_gpgme_op_encrypt_start): Rename to ...
(encrypt_start): ... this.
(gpgme_op_encrypt_start): Use encrypt_start, not
gpgme_op_encrypt_start.
(gpgme_op_encrypt): Likewise.
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID, * gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types. GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name, (gpgme_op_sign_result, gpgme_pubkey_algo_name,
@ -27,7 +52,6 @@
(sign_start): ... this. Call _gpgme_op_sign_init_result. (sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start. (gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise. (gpgme_op_sign): Likewise.
* encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call
_gpgme_op_sign_init_result. _gpgme_op_sign_init_result.

View File

@ -51,6 +51,10 @@ _gpgme_op_encrypt_sign_start (GpgmeCtx ctx, int synchronous,
if (err) if (err)
return err; return err;
err = _gpgme_op_encrypt_init_result (ctx);
if (err)
return err;
err = _gpgme_op_sign_init_result (ctx); err = _gpgme_op_sign_init_result (ctx);
if (err) if (err)
return err; return err;

View File

@ -1,4 +1,4 @@
/* encrypt.c - Encrypt functions. /* encrypt.c - Encrypt function.
Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003 g10 Code GmbH Copyright (C) 2001, 2002, 2003 g10 Code GmbH
@ -21,144 +21,119 @@
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <errno.h>
#include "util.h" #include "gpgme.h"
#include "context.h" #include "context.h"
#include "ops.h" #include "ops.h"
#include "wait.h"
#define SKIP_TOKEN_OR_RETURN(a) do { \
while (*(a) && *(a) != ' ') (a)++; \ typedef struct
while (*(a) == ' ') (a)++; \
if (!*(a)) \
return; /* oops */ \
} while (0)
struct encrypt_result
{ {
int no_valid_recipients; struct _gpgme_op_encrypt_result result;
int invalid_recipients;
GpgmeData xmlinfo; /* A pointer to the next pointer of the last invalid recipient in
}; the list. This makes appending new invalid recipients painless
typedef struct encrypt_result *EncryptResult; while preserving the order. */
GpgmeInvalidUserID *lastp;
} *op_data_t;
static void static void
release_encrypt_result (void *hook) release_op_data (void *hook)
{ {
EncryptResult result = (EncryptResult) hook; op_data_t opd = (op_data_t) hook;
GpgmeInvalidUserID invalid_recipient = opd->result.invalid_recipients;
gpgme_data_release (result->xmlinfo); while (invalid_recipient)
{
GpgmeInvalidUserID next = invalid_recipient->next;
free (invalid_recipient->id);
invalid_recipient = next;
}
} }
/* Parse the args and save the information in an XML structure. With GpgmeEncryptResult
args of NULL the xml structure is closed. */ gpgme_op_encrypt_result (GpgmeCtx ctx)
static void
append_xml_encinfo (GpgmeData *rdh, char *args)
{ {
GpgmeData dh; op_data_t opd;
char helpbuf[100]; GpgmeError err;
if (!*rdh) err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, (void **) &opd, -1, NULL);
{ if (err || !opd)
if (gpgme_data_new (rdh)) return NULL;
return; /* FIXME: We are ignoring out-of-core. */
dh = *rdh;
_gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
}
else
{
dh = *rdh;
_gpgme_data_append_string (dh, " </encryption>\n");
}
if (!args) return &opd->result;
{
/* Just close the XML containter. */
_gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
return;
}
_gpgme_data_append_string (dh, " <encryption>\n"
" <error>\n"
" <invalidRecipient/>\n");
sprintf (helpbuf, " <reason>%d</reason>\n", atoi (args));
_gpgme_data_append_string (dh, helpbuf);
SKIP_TOKEN_OR_RETURN (args);
_gpgme_data_append_string (dh, " <name>");
_gpgme_data_append_percentstring_for_xml (dh, args);
_gpgme_data_append_string (dh, "</name>\n"
" </error>\n");
} }
GpgmeError GpgmeError
_gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) _gpgme_encrypt_status_handler (void *priv, GpgmeStatusCode code, char *args)
{ {
GpgmeError err = 0; GpgmeCtx ctx = (GpgmeCtx) priv;
EncryptResult result; GpgmeError err;
op_data_t opd;
err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, (void **) &opd,
-1, NULL);
if (err)
return err;
switch (code) switch (code)
{ {
case GPGME_STATUS_EOF: case GPGME_STATUS_EOF:
err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, (void **) &result, if (opd->result.invalid_recipients)
-1, NULL); return GPGME_Invalid_UserID;
if (!err)
{
if (result && result->xmlinfo)
{
append_xml_encinfo (&result->xmlinfo, NULL);
_gpgme_set_op_info (ctx, result->xmlinfo);
result->xmlinfo = NULL;
}
if (result && result->no_valid_recipients)
return GPGME_No_UserID;
if (result && result->invalid_recipients)
return GPGME_Invalid_UserID;
}
break; break;
case GPGME_STATUS_INV_RECP: case GPGME_STATUS_INV_RECP:
err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, (void **) &result, err = _gpgme_parse_inv_userid (args, opd->lastp);
sizeof (*result), release_encrypt_result); if (err)
if (!err) return err;
{
result->invalid_recipients++; opd->lastp = &(*opd->lastp)->next;
append_xml_encinfo (&result->xmlinfo, args);
}
break; break;
case GPGME_STATUS_NO_RECP: case GPGME_STATUS_NO_RECP:
err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, (void **) &result, /* Should not happen, because we require at least one recipient. */
sizeof (*result), release_encrypt_result); return GPGME_No_UserID;
if (!err)
result->no_valid_recipients = 1;
break;
default: default:
break; break;
} }
return err; return 0;
} }
GpgmeError GpgmeError
_gpgme_encrypt_sym_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, _gpgme_encrypt_sym_status_handler (void *priv, GpgmeStatusCode code,
char *args) char *args)
{ {
return _gpgme_passphrase_status_handler (ctx, code, args); return _gpgme_passphrase_status_handler (priv, code, args);
}
GpgmeError
_gpgme_op_encrypt_init_result (GpgmeCtx ctx)
{
GpgmeError err;
op_data_t opd;
err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, (void **) &opd,
sizeof (*opd), release_op_data);
if (err)
return err;
opd->lastp = &opd->result.invalid_recipients;
return 0;
} }
static GpgmeError static GpgmeError
_gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous, encrypt_start (GpgmeCtx ctx, int synchronous, GpgmeRecipients recp,
GpgmeRecipients recp, GpgmeData plain, GpgmeData cipher) GpgmeData plain, GpgmeData cipher)
{ {
GpgmeError err; GpgmeError err;
int symmetric = 0; int symmetric = 0;
@ -167,6 +142,10 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous,
if (err) if (err)
return err; return err;
err = _gpgme_op_encrypt_init_result (ctx);
if (err)
return err;
if (!recp) if (!recp)
symmetric = 1; symmetric = 1;
else if (gpgme_recipients_count (recp) == 0) else if (gpgme_recipients_count (recp) == 0)
@ -200,30 +179,19 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous,
GpgmeError GpgmeError
gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData plain, gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData plain,
GpgmeData ciph) GpgmeData cipher)
{ {
return _gpgme_op_encrypt_start (ctx, 0, recp, plain, ciph); return encrypt_start (ctx, 0, recp, plain, cipher);
} }
/** /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
* gpgme_op_encrypt: store the resulting ciphertext in CIPHER. */
* @c: The context
* @recp: A set of recipients
* @in: plaintext input
* @out: ciphertext output
*
* This function encrypts @in to @out for all recipients from
* @recp. Other parameters are take from the context @c.
* The function does wait for the result.
*
* Return value: 0 on success or an errorcode.
**/
GpgmeError GpgmeError
gpgme_op_encrypt (GpgmeCtx ctx, GpgmeRecipients recp, gpgme_op_encrypt (GpgmeCtx ctx, GpgmeRecipients recp,
GpgmeData plain, GpgmeData cipher) GpgmeData plain, GpgmeData cipher)
{ {
int err = _gpgme_op_encrypt_start (ctx, 1, recp, plain, cipher); int err = encrypt_start (ctx, 1, recp, plain, cipher);
if (!err) if (!err)
err = _gpgme_wait_one (ctx); err = _gpgme_wait_one (ctx);
return err; return err;

View File

@ -767,6 +767,17 @@ struct _gpgme_invalid_user_id
typedef struct _gpgme_invalid_user_id *GpgmeInvalidUserID; typedef struct _gpgme_invalid_user_id *GpgmeInvalidUserID;
/* Encryption. */
struct _gpgme_op_encrypt_result
{
/* The list of invalid recipients. */
GpgmeInvalidUserID invalid_recipients;
};
typedef struct _gpgme_op_encrypt_result *GpgmeEncryptResult;
/* Retrieve a pointer to the result of the encrypt operation. */
GpgmeEncryptResult gpgme_op_encrypt_result (GpgmeCtx ctx);
/* Encrypt plaintext PLAIN within CTX for the recipients RECP and /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
store the resulting ciphertext in CIPHER. */ store the resulting ciphertext in CIPHER. */
GpgmeError gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeError gpgme_op_encrypt_start (GpgmeCtx ctx,
@ -786,6 +797,7 @@ GpgmeError gpgme_op_encrypt_sign (GpgmeCtx ctx,
GpgmeRecipients recp, GpgmeRecipients recp,
GpgmeData plain, GpgmeData cipher); GpgmeData plain, GpgmeData cipher);
/* Decrypt ciphertext CIPHER within CTX and store the resulting /* Decrypt ciphertext CIPHER within CTX and store the resulting
plaintext in PLAIN. */ plaintext in PLAIN. */
GpgmeError gpgme_op_decrypt_start (GpgmeCtx ctx, GpgmeError gpgme_op_decrypt_start (GpgmeCtx ctx,

View File

@ -96,10 +96,17 @@ GpgmeError _gpgme_sign_status_handler (void *priv, GpgmeStatusCode code,
char *args); char *args);
/*-- encrypt.c --*/ /* From encrypt.c. */
GpgmeError _gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgmeStatusCode code,
/* Create an initial op data object for encrypt. Needs to be called
once before calling _gpgme_encrypt_status_handler. */
GpgmeError _gpgme_op_encrypt_init_result (GpgmeCtx ctx);
/* Process a status line for encryption operations. */
GpgmeError _gpgme_encrypt_status_handler (void *priv, GpgmeStatusCode code,
char *args); char *args);
/*-- passphrase.c --*/ /*-- passphrase.c --*/
GpgmeError _gpgme_passphrase_status_handler (void *priv, GpgmeStatusCode code, GpgmeError _gpgme_passphrase_status_handler (void *priv, GpgmeStatusCode code,
char *args); char *args);

View File

@ -1,5 +1,10 @@
2003-04-27 Marcus Brinkmann <marcus@g10code.de> 2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpg/t-sign.c: Rewritten.
* gpgsm/t-sign.c: Rewritten.
* gpg/t-encrypt.c: Check for invalid recipients.
* gpgsm/t-encrypt.c: Likewise.
* gpg/t-import.c (check_result): Really use FPR. * gpg/t-import.c (check_result): Really use FPR.
* gpgsm/t-import.c (check_result): Rewritten. * gpgsm/t-import.c (check_result): Rewritten.

View File

@ -1,4 +1,4 @@
/* t-encrypt.c - regression test /* t-encrypt.c - Regression test.
Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003 g10 Code GmbH Copyright (C) 2001, 2002, 2003 g10 Code GmbH
@ -18,99 +18,89 @@
along with GPGME; if not, write to the Free Software Foundation, along with GPGME; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <gpgme.h> #include <gpgme.h>
#define fail_if_err(a) do { if(a) { \ #define fail_if_err(err) \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \ do \
__FILE__, __LINE__, gpgme_strerror(a)); \ { \
exit (1); } \ if (err) \
} while(0) { \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \
static void __FILE__, __LINE__, gpgme_strerror (err)); \
print_op_info (GpgmeCtx c) exit (1); \
{ } \
char *s = gpgme_get_op_info (c, 0); } \
while (0)
if (!s)
puts ("<!-- no operation info available -->");
else
{
puts (s);
free (s);
}
}
static void static void
print_data (GpgmeData dh) print_data (GpgmeData dh)
{ {
char buf[100]; #define BUF_SIZE 512
char buf[BUF_SIZE + 1];
int ret; int ret;
ret = gpgme_data_seek (dh, 0, SEEK_SET); ret = gpgme_data_seek (dh, 0, SEEK_SET);
if (ret) if (ret)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
while ((ret = gpgme_data_read (dh, buf, 100)) > 0) while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
fwrite (buf, ret, 1, stdout); fwrite (buf, ret, 1, stdout);
if (ret < 0) if (ret < 0)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
GpgmeCtx ctx; GpgmeCtx ctx;
GpgmeError err; GpgmeError err;
GpgmeData in, out; GpgmeData in, out;
GpgmeRecipients rset; GpgmeRecipients rset;
GpgmeEncryptResult result;
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP); err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
fail_if_err (err); fail_if_err (err);
err = gpgme_new (&ctx);
fail_if_err (err);
gpgme_set_armor (ctx, 1);
do { err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0);
err = gpgme_new (&ctx); fail_if_err (err);
fail_if_err (err);
gpgme_set_armor (ctx, 1);
err = gpgme_data_new_from_mem ( &in, "Hallo Leute\n", 12, 0 ); err = gpgme_data_new (&out);
fail_if_err (err); fail_if_err (err);
err = gpgme_recipients_new (&rset);
fail_if_err (err);
err = gpgme_recipients_add_name_with_validity (rset, "Bob",
GPGME_VALIDITY_FULL);
fail_if_err (err);
err = gpgme_recipients_add_name_with_validity (rset, "Alpha",
GPGME_VALIDITY_FULL);
fail_if_err (err);
err = gpgme_data_new ( &out ); err = gpgme_op_encrypt (ctx, rset, in, out);
fail_if_err (err); fail_if_err (err);
result = gpgme_op_encrypt_result (ctx);
if (result->invalid_recipients)
{
fprintf (stderr, "Invalid recipient encountered: %s\n",
result->invalid_recipients->id);
exit (1);
}
print_data (out);
err = gpgme_recipients_new (&rset); gpgme_recipients_release (rset);
fail_if_err (err); gpgme_data_release (in);
err = gpgme_recipients_add_name_with_validity (rset, "Bob", gpgme_data_release (out);
GPGME_VALIDITY_FULL); gpgme_release (ctx);
fail_if_err (err); return 0;
err = gpgme_recipients_add_name_with_validity (rset, "Alpha",
GPGME_VALIDITY_FULL);
fail_if_err (err);
err = gpgme_op_encrypt (ctx, rset, in, out );
print_op_info (ctx);
fail_if_err (err);
fflush (NULL);
fputs ("Begin Result:\n", stdout );
print_data (out);
fputs ("End Result.\n", stdout );
gpgme_recipients_release (rset);
gpgme_data_release (in);
gpgme_data_release (out);
gpgme_release (ctx);
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
return 0;
} }

View File

@ -1,4 +1,4 @@
/* t-genkey.c - regression test /* t-genkey.c - regression test
Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2003 g10 Code GmbH Copyright (C) 2001, 2003 g10 Code GmbH

View File

@ -1,62 +1,53 @@
/* t-sign.c - regression test /* t-sign.c - Regression test.
* Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
* Copyright (C) 2001, 2003 g10 Code GmbH Copyright (C) 2001, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <gpgme.h> #include <gpgme.h>
#define fail_if_err(a) do { if(a) { \ #define fail_if_err(err) \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \ do \
__FILE__, __LINE__, gpgme_strerror(a)); \ { \
exit (1); } \ if (err) \
} while(0) { \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \
static void __FILE__, __LINE__, gpgme_strerror (err)); \
print_op_info (GpgmeCtx ctx) exit (1); \
{ } \
char *str = gpgme_get_op_info (ctx, 0); } \
while (0)
if (!str)
puts ("<!-- no operation info available -->");
else
{
puts (str);
free (str);
}
}
static void static void
print_data (GpgmeData dh) print_data (GpgmeData dh)
{ {
char buf[100]; #define BUF_SIZE 512
char buf[BUF_SIZE + 1];
int ret; int ret;
ret = gpgme_data_seek (dh, 0, SEEK_SET); ret = gpgme_data_seek (dh, 0, SEEK_SET);
if (ret) if (ret)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
while ((ret = gpgme_data_read (dh, buf, 100)) > 0) while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
fwrite (buf, ret, 1, stdout); fwrite (buf, ret, 1, stdout);
if (ret < 0) if (ret < 0)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
@ -64,89 +55,121 @@ print_data (GpgmeData dh)
static GpgmeError static GpgmeError
passphrase_cb (void *opaque, const char *desc, passphrase_cb (void *opaque, const char *desc, void **hd, const char **result)
void **r_hd, const char **result)
{ {
/* Cleanup by looking at *hd. */
if (!desc) if (!desc)
/* Cleanup by looking at *r_hd. */
return 0; return 0;
*result = "abc"; *result = "abc";
fprintf (stderr, "%% requesting passphrase for `%s': ", desc);
fprintf (stderr, "sending `%s'\n", *result);
return 0; return 0;
} }
int static void
main (int argc, char **argv ) check_result (GpgmeSignResult result, GpgmeSigMode type)
{ {
GpgmeCtx ctx; if (result->invalid_signers)
GpgmeError err; {
GpgmeData in, out; fprintf (stderr, "Invalid signer found: %s\n",
char *p; result->invalid_signers->id);
exit (1);
}
if (!result->signatures || result->signatures->next)
{
fprintf (stderr, "Unexpected number of signatures created\n");
exit (1);
}
if (result->signatures->type != type)
{
fprintf (stderr, "Wrong type of signature created\n");
exit (1);
}
if (result->signatures->pubkey_algo != GPGME_PK_DSA)
{
fprintf (stderr, "Wrong pubkey algorithm reported: %i\n",
result->signatures->pubkey_algo);
exit (1);
}
if (result->signatures->hash_algo != GPGME_MD_SHA1)
{
fprintf (stderr, "Wrong hash algorithm reported: %i\n",
result->signatures->hash_algo);
exit (1);
}
if (result->signatures->class != 1)
{
fprintf (stderr, "Wrong signature class reported: %lu\n",
result->signatures->class);
exit (1);
}
if (strcmp ("A0FF4590BB6122EDEF6E3C542D727CC768697734",
result->signatures->fpr))
{
fprintf (stderr, "Wrong fingerprint reported: %s\n",
result->signatures->fpr);
exit (1);
}
}
do {
err = gpgme_new (&ctx);
fail_if_err (err);
p = getenv("GPG_AGENT_INFO"); int
if (!(p && strchr (p, ':'))) main (int argc, char **argv)
gpgme_set_passphrase_cb ( ctx, passphrase_cb, NULL ); {
GpgmeCtx ctx;
GpgmeError err;
GpgmeData in, out;
GpgmeSignResult result;
char *agent_info;
gpgme_set_textmode (ctx, 1); err = gpgme_new (&ctx);
gpgme_set_armor (ctx, 1); fail_if_err (err);
err = gpgme_data_new_from_mem ( &in, "Hallo Leute\n", 12, 0 ); agent_info = getenv("GPG_AGENT_INFO");
fail_if_err (err); if (!(agent_info && strchr (agent_info, ':')))
gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
/* first a normal signature */ gpgme_set_textmode (ctx, 1);
err = gpgme_data_new ( &out ); gpgme_set_armor (ctx, 1);
fail_if_err (err);
err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL ); err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0);
fail_if_err (err); fail_if_err (err);
fflush (NULL);
fputs ("Begin Result:\n", stdout ); /* First a normal signature. */
print_op_info (ctx); err = gpgme_data_new (&out);
print_data (out); fail_if_err (err);
fputs ("End Result.\n", stdout ); err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL);
gpgme_data_release (out); fail_if_err (err);
gpgme_data_rewind (in); result = gpgme_op_sign_result (ctx);
check_result (result, GPGME_SIG_MODE_NORMAL);
/* now a detached signature */ print_data (out);
err = gpgme_data_new ( &out ); gpgme_data_release (out);
fail_if_err (err);
err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH );
fail_if_err (err);
fflush (NULL);
print_op_info (ctx);
fputs ("Begin Result:\n", stdout );
print_data (out);
fputs ("End Result.\n", stdout );
gpgme_data_release (out);
gpgme_data_rewind (in);
/* Now a detached signature. */
gpgme_data_rewind (in);
err = gpgme_data_new (&out);
fail_if_err (err);
err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH);
fail_if_err (err);
result = gpgme_op_sign_result (ctx);
check_result (result, GPGME_SIG_MODE_DETACH);
print_data (out);
gpgme_data_release (out);
/* And finally a cleartext signature */ /* And finally a cleartext signature. */
err = gpgme_data_new ( &out ); gpgme_data_rewind (in);
fail_if_err (err); err = gpgme_data_new (&out);
err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_CLEAR ); fail_if_err (err);
fail_if_err (err); err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_CLEAR);
fflush (NULL); fail_if_err (err);
print_op_info (ctx); result = gpgme_op_sign_result (ctx);
fputs ("Begin Result:\n", stdout ); check_result (result, GPGME_SIG_MODE_CLEAR);
print_data (out); print_data (out);
fputs ("End Result.\n", stdout ); gpgme_data_release (out);
gpgme_data_release (out);
gpgme_data_rewind (in); gpgme_data_release (in);
gpgme_release (ctx);
/* ready */ return 0;
gpgme_data_release (in);
gpgme_release (ctx);
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
return 0;
} }

View File

@ -1,4 +1,4 @@
/* t-encrypt.c - regression test /* t-encrypt.c - Regression test.
Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003 g10 Code GmbH Copyright (C) 2001, 2002, 2003 g10 Code GmbH
@ -18,44 +18,36 @@
along with GPGME; if not, write to the Free Software Foundation, along with GPGME; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <gpgme.h> #include <gpgme.h>
#define fail_if_err(a) do { if(a) { \ #define fail_if_err(err) \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \ do \
__FILE__, __LINE__, gpgme_strerror(a)); \ { \
exit (1); } \ if (err) \
} while(0) { \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \
static void __FILE__, __LINE__, gpgme_strerror (err)); \
print_op_info (GpgmeCtx ctx) exit (1); \
{ } \
char *str = gpgme_get_op_info (ctx, 0); } \
while (0)
if (!str)
puts ("<!-- no operation info available -->");
else
{
puts (str);
free (str);
}
}
static void static void
print_data (GpgmeData dh) print_data (GpgmeData dh)
{ {
char buf[100]; #define BUF_SIZE 512
char buf[BUF_SIZE + 1];
int ret; int ret;
ret = gpgme_data_seek (dh, 0, SEEK_SET); ret = gpgme_data_seek (dh, 0, SEEK_SET);
if (ret) if (ret)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
while ((ret = gpgme_data_read (dh, buf, 100)) > 0) while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
fwrite (buf, ret, 1, stdout); fwrite (buf, ret, 1, stdout);
if (ret < 0) if (ret < 0)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
@ -63,73 +55,48 @@ print_data (GpgmeData dh)
int int
main (int argc, char **argv ) main (int argc, char **argv)
{ {
GpgmeCtx ctx; GpgmeCtx ctx;
GpgmeError err; GpgmeError err;
GpgmeData in, out; GpgmeData in, out;
GpgmeRecipients rset; GpgmeRecipients rset;
int loop = 0; GpgmeEncryptResult result;
/* simple option parser; ignoring unknown options */ err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS);
if (argc) fail_if_err (err);
{
argc--;
argv++;
}
while (argc && **argv == '-' )
{
if (!strcmp (*argv, "--loop"))
loop++;
argc--; err = gpgme_new (&ctx);
argv++; fail_if_err (err);
if (!strcmp (argv[-1], "--")) gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
break; gpgme_set_armor (ctx, 1);
}
err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0);
fail_if_err (err);
err = gpgme_data_new (&out);
fail_if_err (err);
err = gpgme_recipients_new (&rset);
fail_if_err (err);
err = gpgme_recipients_add_name_with_validity (rset, "test cert 1",
GPGME_VALIDITY_FULL);
fail_if_err (err);
err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS); err = gpgme_op_encrypt (ctx, rset, in, out);
fail_if_err (err); fail_if_err (err);
result = gpgme_op_encrypt_result (ctx);
if (result->invalid_recipients)
{
fprintf (stderr, "Invalid recipient encountered: %s\n",
result->invalid_recipients->id);
exit (1);
}
print_data (out);
do { gpgme_recipients_release (rset);
err = gpgme_new (&ctx); gpgme_data_release (in);
fail_if_err (err); gpgme_data_release (out);
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); gpgme_release (ctx);
gpgme_set_armor (ctx, 1); return 0;
err = gpgme_data_new_from_mem ( &in, "Hallo Leute\n", 12, 0 );
fail_if_err (err);
err = gpgme_data_new ( &out );
fail_if_err (err);
err = gpgme_recipients_new (&rset);
fail_if_err (err);
if (argc)
err = gpgme_recipients_add_name_with_validity (rset, *argv,
GPGME_VALIDITY_FULL);
else
err = gpgme_recipients_add_name_with_validity (rset, "test cert 1",
GPGME_VALIDITY_FULL);
fail_if_err (err);
err = gpgme_op_encrypt (ctx, rset, in, out );
print_op_info (ctx);
fail_if_err (err);
fflush (NULL);
fputs ("Begin Result:\n", stdout );
print_data (out);
fputs ("End Result.\n", stdout );
gpgme_recipients_release (rset);
gpgme_data_release (in);
gpgme_data_release (out);
gpgme_release (ctx);
} while (loop);
return 0;
} }

View File

@ -38,38 +38,25 @@
while (0) while (0)
void static void
dump_data (GpgmeData dh) print_data (GpgmeData dh)
{ {
#define BUF_SIZE 512 #define BUF_SIZE 512
char buffer[BUF_SIZE + 1]; char buf[BUF_SIZE + 1];
int bufread; int ret;
gpgme_data_rewind (dh); ret = gpgme_data_seek (dh, 0, SEEK_SET);
if (ret)
do fail_if_err (GPGME_File_Error);
{ while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
bufread = gpgme_data_read (dh, buffer, BUF_SIZE); fwrite (buf, ret, 1, stdout);
if (bufread > 0) if (ret < 0)
{ fail_if_err (GPGME_File_Error);
buffer[bufread] = '\0';
printf ("%s", buffer);
}
}
while (bufread > 0);
if (bufread < 0)
{
fprintf (stderr, "%s:%d: gpgme_data_read failed: %s\n",
__FILE__, __LINE__, strerror (errno));
exit (1);
}
printf ("\n");
} }
/* True if progress function printed something on the screen. */ /* True if progress function printed something on the screen. */
int progress_called; static int progress_called;
static void static void
progress (void *self, const char *what, int type, int current, int total) progress (void *self, const char *what, int type, int current, int total)
@ -156,7 +143,7 @@ main (int argc, char **argv)
} }
gpgme_release (ctx); gpgme_release (ctx);
dump_data (certreq); print_data (certreq);
gpgme_data_release (certreq); gpgme_data_release (certreq);
return 0; return 0;

View File

@ -1,118 +1,151 @@
/* t-sign.c - regression test /* t-sign.c - Regression test.
* Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
* Copyright (C) 2001 g10 Code GmbH Copyright (C) 2001, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <gpgme.h> #include <gpgme.h>
#define fail_if_err(a) do { if(a) { \ #define fail_if_err(err) \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \ do \
__FILE__, __LINE__, gpgme_strerror(a)); \ { \
exit (1); } \ if (err) \
} while(0) { \
fprintf (stderr, "%s:%d: GpgmeError %s\n", \
static void __FILE__, __LINE__, gpgme_strerror (err)); \
print_op_info (GpgmeCtx ctx) exit (1); \
{ } \
char *str = gpgme_get_op_info (ctx, 0); } \
while (0)
if (!str)
puts ("<!-- no operation info available -->");
else
{
puts (str);
free (str);
}
}
static void static void
print_data (GpgmeData dh) print_data (GpgmeData dh)
{ {
char buf[100]; #define BUF_SIZE 512
char buf[BUF_SIZE + 1];
int ret; int ret;
ret = gpgme_data_seek (dh, 0, SEEK_SET); ret = gpgme_data_seek (dh, 0, SEEK_SET);
if (ret) if (ret)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
while ((ret = gpgme_data_read (dh, buf, 100)) > 0) while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
fwrite (buf, ret, 1, stdout); fwrite (buf, ret, 1, stdout);
if (ret < 0) if (ret < 0)
fail_if_err (GPGME_File_Error); fail_if_err (GPGME_File_Error);
} }
static void
check_result (GpgmeSignResult result, GpgmeSigMode type)
{
if (result->invalid_signers)
{
fprintf (stderr, "Invalid signer found: %s\n",
result->invalid_signers->id);
exit (1);
}
if (!result->signatures || result->signatures->next)
{
fprintf (stderr, "Unexpected number of signatures created\n");
exit (1);
}
if (result->signatures->type != type)
{
fprintf (stderr, "Wrong type of signature created\n");
exit (1);
}
if (result->signatures->pubkey_algo != GPGME_PK_RSA)
{
fprintf (stderr, "Wrong pubkey algorithm reported: %i\n",
result->signatures->pubkey_algo);
exit (1);
}
if (result->signatures->hash_algo != GPGME_MD_SHA1)
{
fprintf (stderr, "Wrong hash algorithm reported: %i\n",
result->signatures->hash_algo);
exit (1);
}
if (result->signatures->class != 0)
{
fprintf (stderr, "Wrong signature class reported: %lu\n",
result->signatures->class);
exit (1);
}
if (strcmp ("3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
result->signatures->fpr))
{
fprintf (stderr, "Wrong fingerprint reported: %s\n",
result->signatures->fpr);
exit (1);
}
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
GpgmeCtx ctx; GpgmeCtx ctx;
GpgmeError err; GpgmeError err;
GpgmeData in, out; GpgmeData in, out;
GpgmeSignResult result;
do { err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS);
err = gpgme_new (&ctx); fail_if_err (err);
fail_if_err (err);
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
gpgme_set_textmode (ctx, 1);
gpgme_set_armor (ctx, 1);
err = gpgme_data_new_from_mem ( &in, "Hallo Leute!\n", 13, 0 ); err = gpgme_new (&ctx);
fail_if_err (err); fail_if_err (err);
/* first a normal signature */ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
err = gpgme_data_new ( &out ); gpgme_set_textmode (ctx, 1);
fail_if_err (err); gpgme_set_armor (ctx, 1);
err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL );
fail_if_err (err); err = gpgme_data_new_from_mem (&in, "Hallo Leute!\n", 13, 0);
fflush (NULL); fail_if_err (err);
fputs ("Begin Result:\n", stdout );
print_op_info (ctx); /* First a normal signature. */
print_data (out); err = gpgme_data_new (&out);
fputs ("End Result.\n", stdout ); fail_if_err (err);
gpgme_data_release (out); err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL);
gpgme_data_rewind (in); fail_if_err (err);
result = gpgme_op_sign_result (ctx);
check_result (result, GPGME_SIG_MODE_NORMAL);
print_data (out);
gpgme_data_release (out);
/* now a detached signature */ /* Now a detached signature. */
err = gpgme_data_new ( &out ); gpgme_data_rewind (in);
fail_if_err (err); err = gpgme_data_new (&out);
err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH ); fail_if_err (err);
fail_if_err (err); err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH);
fflush (NULL); fail_if_err (err);
print_op_info (ctx); result = gpgme_op_sign_result (ctx);
fputs ("Begin Result:\n", stdout ); check_result (result, GPGME_SIG_MODE_DETACH);
print_data (out); print_data (out);
fputs ("End Result.\n", stdout ); gpgme_data_release (out);
gpgme_data_release (out);
gpgme_data_rewind (in); gpgme_data_release (in);
gpgme_release (ctx);
return 0;
/* ready */
gpgme_data_release (in);
gpgme_release (ctx);
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
return 0;
} }