gpgme/
2002-10-08 Marcus Brinkmann <marcus@g10code.de> New data object component: * gpgme.h (GpgmeDataReadCb, GpgmeDataWriteCb, GpgmeDataSeekCb, GpgmeDataReleaseCb): New types. (struct GpgmeDataCbs): New structure. (gpgme_data_read): Changed prototype to match that of read() closely. (gpgme_data_write): Similar for write(). (gpgme_data_seek, gpgme_data_new_from_cbs, gpgme_data_new_from_fd, gpgme_data_new_from_stream): New prototypes. (gpgme_data_get_type, gpgme_check_engine): Prototype removed. * Makefile.am (libgpgme_la_SOURCES): Add data.h, data-fd.c, data-stream.c, data-mem.c, data-user.c and data-compat.c. * data.c: Reimplemented from scratch. * (data-compat.c, data-fd.c, data.h, data-mem.c, data-stream.c, data-user.c): New file. * context.h (struct gpgme_data_s): Removed. * conversion.c: Include <errno.h> and <sys/types.h>. (_gpgme_data_append): New function. * data.c (_gpgme_data_append_string): Move to ... * conversion.c (_gpgme_data_append_string): ... here. * data.c (_gpgme_data_append_for_xml): Move to ... * conversion.c (_gpgme_data_append_for_xml): ... here. * data.c (_gpgme_data_append_string_for_xml): Move to ... * conversion.c (_gpgme_data_append_string_for_xml): ... here. * data.c (_gpgme_data_append_percentstring_for_xml): Move to ... * conversion.c (_gpgme_data_append_percentstring_for_xml): ... here. * ops.h (_gpgme_data_get_mode, _gpgme_data_set_mode): Prototype removed. * types.h (GpgmeDataMode): Type removed. * decrypt.c (_gpgme_decrypt_start): Don't check data type or mode. * edit.c (_gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_op_encrypt_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * export.c (_gpgme_op_export_start): Likewise. * genkey.c (_gpgme_op_genkey_start): Likewise. * import.c (_gpgme_op_import_start): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * verify.c (_gpgme_op_verify_start): Likewise. * encrypt.c (gpgme_op_encrypt): Remove hack that returns invalid no recipient if no data was returned. * encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns no recipient if no data was returned. * encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns no recipient if no data was returned. * engine.c (_gpgme_engine_op_verify): Add new argument to differentiate detached from normal signatures. * engine.h (_gpgme_engine_op_verify): Likewise for prototype. * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise. Don't check mode of data argument. * engine-gpgsm.h (_gpgme_gpgsm_op_verify): Likewise for prototype. * gpgme.h (gpgme_op_verify_start): Likewise for prototype. (gpgme_op_verify): Likewise for prototype. * rungpg.c (_gpgme_gpg_op_verify): Likewise. * rungpg.h (_gpgme_gpg_op_verify): Likewise for prototype. * verify.c (_gpgme_op_verify_start): Likewise. (gpgme_op_verify_start): Likewise. (gpgme_op_verify): Likewise. * rungpg.c (struct arg_and_data_s): New member INBOUND to hold direction of data object. (_gpgme_gpg_add_data): Add new argument INBOUND. Use it to determine direction of data object. (_gpgme_gpg_add_pm_data, _gpgme_gpg_set_command_handler, _gpgme_gpg_op_decrypt, _gpgme_gpg_op_edit, _gpgme_gpg_op_encrypt, _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_sign, _gpgme_gpg_op_verify): Add new argument to _gpgme_gpg_add_data invocation. (build_argv): Use new member INBOUND to determine direction of file descriptor. Don't check the data type. * rungpg.h (_gpgme_gpg_add_data): Add new argument to prototype. * gpgme.c (gpgme_get_op_info): Don't call _gpgme_data_get_as_string if CTX->op_info is NULL. * version.c (gpgme_check_engine): Function removed. tests/ 2002-10-09 Marcus Brinkmann <marcus@g10code.de> * gpg/t-decrypt.c (print_data): Update to new gpgme_data_read interface, and use gpgme_engine_check_version instead gpgme_check_version. * gpg/t-decrypt-verify.c (print_data): Likewise. * gpg/t-edit.c (main): Likewise. * gpg/t-encrypt.c (print_data): Likewise. * gpg/t-encrypt-sign.c (print_data): Likewise. * gpg/t-encrypt-sym.c (print_data): Likewise. * gpg/t-eventloop.c (print_data): Likewise. * gpg/t-export.c (print_data): Likewise. * gpg/t-sign.c (print_data): Likewise. * gpg/t-signers.c (print_data): Likewise. * gpgsm/t-decrypt.c (print_data): Likewise. * gpgsm/t-encrypt.c (print_data): Likewise. * gpgsm/t-export.c (print_data): Likewise. * gpgsm/t-sign.c (print_data): Likewise. * gpg/t-verify.c (main): Likewise for gpgme_op_verify. * gpgsm/t-verify.c (main): Likewise for gpgme_op_verify. * t-data.c (read_once_test): Likewise. (write_test): Update for new behaviour of data objects. (main): Remove type test.
This commit is contained in:
parent
388b40bb88
commit
0447e0dd6d
22
NEWS
22
NEWS
@ -1,6 +1,28 @@
|
||||
Noteworthy changes in version 0.4.0 (unreleased)
|
||||
------------------------------------------------
|
||||
|
||||
* New data object interface, which is more flexible and transparent.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
GpgmeDataReadCb NEW
|
||||
GpgmeDataWriteCb NEW
|
||||
GpgmeDataSeekCb NEW
|
||||
GpgmeDataReleaseCb NEW
|
||||
GpgmeDataCbs NEW
|
||||
gpgme_data_read CHANGED: Match read() closely.
|
||||
gpgme_data_write CHANGED: Match write() closely.
|
||||
gpgme_data_seek NEW
|
||||
gpgme_data_from_fd NEW
|
||||
gpgme_data_from_stream NEW
|
||||
gpgme_data_from_cbs NEW
|
||||
gpgme_data_rewind DEPRECATED: Replaced by gpgme_data_seek().
|
||||
gpgme_data_new_from_read_cb DEPRECATED: Replaced by gpgme_data_from_cbs().
|
||||
gpgme_data_get_type REMOVED: No replacement.
|
||||
gpgme_op_verify CHANGED: Take different data objects for
|
||||
signed text and plain text.
|
||||
gpgme_op_verify_start CHANGED: See gpgme_op_verify.
|
||||
gpgme_check_engine REMOVED: Deprecated since 0.3.0.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Noteworthy changes in version 0.3.11 (2002-09-20)
|
||||
-------------------------------------------------
|
||||
|
4
TODO
4
TODO
@ -26,6 +26,8 @@ Hey Emacs, this is -*- outline -*- mode!
|
||||
** validity/trust
|
||||
|
||||
* Engines
|
||||
** Optimize the case where a data object has an underlying fd we can pass
|
||||
directly to the engine.
|
||||
** Move code common to all engines up from gpg to engine.
|
||||
** engine operations can return General Error on unknown protocol
|
||||
(it's an internal error, as select_protocol checks already).
|
||||
@ -37,7 +39,7 @@ Hey Emacs, this is -*- outline -*- mode!
|
||||
|
||||
* Operations
|
||||
** Passphrase callback should not copy password. !!!
|
||||
** Export status handler need much more work.
|
||||
** Export status handler need much more work. !!!
|
||||
** Import should return a useful error when one happened.
|
||||
** Genkey should return something more useful than General_Error.
|
||||
** Factor out common code in _op_*_start functions.
|
||||
|
@ -1,3 +1,88 @@
|
||||
2002-10-08 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
New data object component:
|
||||
|
||||
* gpgme.h (GpgmeDataReadCb, GpgmeDataWriteCb, GpgmeDataSeekCb,
|
||||
GpgmeDataReleaseCb): New types.
|
||||
(struct GpgmeDataCbs): New structure.
|
||||
(gpgme_data_read): Changed prototype to match that of read() closely.
|
||||
(gpgme_data_write): Similar for write().
|
||||
(gpgme_data_seek, gpgme_data_new_from_cbs, gpgme_data_new_from_fd,
|
||||
gpgme_data_new_from_stream): New prototypes.
|
||||
(gpgme_data_get_type, gpgme_check_engine): Prototype removed.
|
||||
|
||||
* Makefile.am (libgpgme_la_SOURCES): Add data.h, data-fd.c,
|
||||
data-stream.c, data-mem.c, data-user.c and data-compat.c.
|
||||
* data.c: Reimplemented from scratch.
|
||||
* (data-compat.c, data-fd.c, data.h, data-mem.c, data-stream.c,
|
||||
data-user.c): New file.
|
||||
* context.h (struct gpgme_data_s): Removed.
|
||||
* conversion.c: Include <errno.h> and <sys/types.h>.
|
||||
(_gpgme_data_append): New function.
|
||||
* data.c (_gpgme_data_append_string): Move to ...
|
||||
* conversion.c (_gpgme_data_append_string): ... here.
|
||||
* data.c (_gpgme_data_append_for_xml): Move to ...
|
||||
* conversion.c (_gpgme_data_append_for_xml): ... here.
|
||||
* data.c (_gpgme_data_append_string_for_xml): Move to ...
|
||||
* conversion.c (_gpgme_data_append_string_for_xml): ... here.
|
||||
* data.c (_gpgme_data_append_percentstring_for_xml): Move to ...
|
||||
* conversion.c (_gpgme_data_append_percentstring_for_xml): ... here.
|
||||
|
||||
* ops.h (_gpgme_data_get_mode, _gpgme_data_set_mode): Prototype
|
||||
removed.
|
||||
* types.h (GpgmeDataMode): Type removed.
|
||||
|
||||
* decrypt.c (_gpgme_decrypt_start): Don't check data type or mode.
|
||||
* edit.c (_gpgme_op_edit_start): Likewise.
|
||||
* encrypt.c (_gpgme_op_encrypt_start): Likewise.
|
||||
* encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise.
|
||||
* encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise.
|
||||
* export.c (_gpgme_op_export_start): Likewise.
|
||||
* genkey.c (_gpgme_op_genkey_start): Likewise.
|
||||
* import.c (_gpgme_op_import_start): Likewise.
|
||||
* sign.c (_gpgme_op_sign_start): Likewise.
|
||||
* verify.c (_gpgme_op_verify_start): Likewise.
|
||||
|
||||
* encrypt.c (gpgme_op_encrypt): Remove hack that returns invalid
|
||||
no recipient if no data was returned.
|
||||
* encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns
|
||||
no recipient if no data was returned.
|
||||
* encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns
|
||||
no recipient if no data was returned.
|
||||
|
||||
* engine.c (_gpgme_engine_op_verify): Add new argument to
|
||||
differentiate detached from normal signatures.
|
||||
* engine.h (_gpgme_engine_op_verify): Likewise for prototype.
|
||||
* engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise. Don't check
|
||||
mode of data argument.
|
||||
* engine-gpgsm.h (_gpgme_gpgsm_op_verify): Likewise for prototype.
|
||||
* gpgme.h (gpgme_op_verify_start): Likewise for prototype.
|
||||
(gpgme_op_verify): Likewise for prototype.
|
||||
* rungpg.c (_gpgme_gpg_op_verify): Likewise.
|
||||
* rungpg.h (_gpgme_gpg_op_verify): Likewise for prototype.
|
||||
* verify.c (_gpgme_op_verify_start): Likewise.
|
||||
(gpgme_op_verify_start): Likewise.
|
||||
(gpgme_op_verify): Likewise.
|
||||
|
||||
* rungpg.c (struct arg_and_data_s): New member INBOUND to hold
|
||||
direction of data object.
|
||||
(_gpgme_gpg_add_data): Add new argument INBOUND. Use it to
|
||||
determine direction of data object.
|
||||
(_gpgme_gpg_add_pm_data, _gpgme_gpg_set_command_handler,
|
||||
_gpgme_gpg_op_decrypt, _gpgme_gpg_op_edit, _gpgme_gpg_op_encrypt,
|
||||
_gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export,
|
||||
_gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_sign,
|
||||
_gpgme_gpg_op_verify): Add new argument to _gpgme_gpg_add_data
|
||||
invocation.
|
||||
(build_argv): Use new member INBOUND to determine direction of
|
||||
file descriptor. Don't check the data type.
|
||||
* rungpg.h (_gpgme_gpg_add_data): Add new argument to prototype.
|
||||
|
||||
* gpgme.c (gpgme_get_op_info): Don't call
|
||||
_gpgme_data_get_as_string if CTX->op_info is NULL.
|
||||
|
||||
* version.c (gpgme_check_engine): Function removed.
|
||||
|
||||
2002-09-30 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* keylist.c (keylist_colon_handler): Take care when printing a
|
||||
|
@ -57,7 +57,9 @@ endif
|
||||
|
||||
libgpgme_la_SOURCES = \
|
||||
gpgme.h types.h util.h util.c conversion.c context.h ops.h \
|
||||
data.c recipient.c signers.c wait.c wait.h op-support.c \
|
||||
data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \
|
||||
data-compat.c \
|
||||
recipient.c signers.c wait.c wait.h op-support.c \
|
||||
encrypt.c encrypt-sign.c decrypt.c decrypt-verify.c verify.c \
|
||||
sign.c passphrase.c progress.c \
|
||||
key.h key.c keylist.c trustlist.c \
|
||||
|
@ -41,11 +41,11 @@ struct trust_queue_item_s
|
||||
|
||||
|
||||
/* Currently we need it at several places, so we put the definition
|
||||
* into this header file */
|
||||
into this header file. */
|
||||
struct gpgme_context_s
|
||||
{
|
||||
int initialized;
|
||||
/* A gpg request is still pending. */
|
||||
/* An engine request is still pending. */
|
||||
int pending;
|
||||
|
||||
int use_cms;
|
||||
@ -112,44 +112,29 @@ struct gpgme_context_s
|
||||
GpgmeData help_data_1;
|
||||
};
|
||||
|
||||
|
||||
struct gpgme_data_s {
|
||||
size_t len;
|
||||
const char *data;
|
||||
GpgmeDataType type;
|
||||
GpgmeDataMode mode;
|
||||
GpgmeDataEncoding encoding;
|
||||
|
||||
int (*read_cb)( void *, char *, size_t, size_t *);
|
||||
void *read_cb_value;
|
||||
int read_cb_eof;
|
||||
|
||||
size_t readpos;
|
||||
size_t writepos;
|
||||
size_t private_len;
|
||||
char *private_buffer;
|
||||
};
|
||||
|
||||
/* Forward declaration of a structure to store certification
|
||||
signatures. */
|
||||
signatures. */
|
||||
struct certsig_s;
|
||||
|
||||
/* Structure to store user IDs. */
|
||||
struct user_id_s {
|
||||
struct user_id_s *next;
|
||||
unsigned int revoked:1;
|
||||
unsigned int invalid:1;
|
||||
GpgmeValidity validity;
|
||||
struct certsig_s *certsigs;
|
||||
const char *name_part; /* all 3 point into strings behind name */
|
||||
const char *email_part; /* or to read-only strings */
|
||||
const char *comment_part;
|
||||
char name[1];
|
||||
/* Structure to store user IDs. */
|
||||
struct user_id_s
|
||||
{
|
||||
struct user_id_s *next;
|
||||
unsigned int revoked : 1;
|
||||
unsigned int invalid : 1;
|
||||
GpgmeValidity validity;
|
||||
struct certsig_s *certsigs;
|
||||
const char *name_part; /* All 3 point into strings behind name */
|
||||
const char *email_part; /* or to read-only strings. */
|
||||
const char *comment_part;
|
||||
char name[1];
|
||||
};
|
||||
|
||||
struct gpgme_recipients_s {
|
||||
struct user_id_s *list;
|
||||
int checked; /* wether the recipients are all valid */
|
||||
|
||||
struct gpgme_recipients_s
|
||||
{
|
||||
struct user_id_s *list;
|
||||
int checked; /* Wether the recipients are all valid. */
|
||||
};
|
||||
|
||||
|
||||
@ -166,4 +151,4 @@ struct gpgme_recipients_s {
|
||||
gpgme_wait ((c), 1); \
|
||||
} while (0)
|
||||
|
||||
#endif /* CONTEXT_H */
|
||||
#endif /* CONTEXT_H */
|
||||
|
@ -24,7 +24,10 @@
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
|
||||
@ -138,3 +141,117 @@ _gpgme_decode_c_string (const char *src, char **destp)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GpgmeError
|
||||
_gpgme_data_append (GpgmeData dh, const char *buffer, size_t length)
|
||||
{
|
||||
if (!dh || !buffer)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
do
|
||||
{
|
||||
ssize_t amt = gpgme_data_write (dh, buffer, length);
|
||||
if (amt == 0 || (amt < 0 && errno != EINTR))
|
||||
return mk_error (File_Error);
|
||||
buffer += amt;
|
||||
length -= amt;
|
||||
}
|
||||
while (length > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GpgmeError
|
||||
_gpgme_data_append_string (GpgmeData dh, const char *str)
|
||||
{
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
return _gpgme_data_append (dh, str, strlen (str));
|
||||
}
|
||||
|
||||
|
||||
GpgmeError
|
||||
_gpgme_data_append_for_xml (GpgmeData dh, const char *buffer, size_t len)
|
||||
{
|
||||
const char *text, *str;
|
||||
size_t count;
|
||||
int err = 0;
|
||||
|
||||
if (!dh || !buffer)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
do
|
||||
{
|
||||
text = NULL;
|
||||
str = buffer;
|
||||
for (count = len; count && !text; str++, count--)
|
||||
{
|
||||
if (*str == '<')
|
||||
text = "<";
|
||||
else if (*str == '>')
|
||||
text = ">"; /* Not sure whether this is really needed. */
|
||||
else if (*str == '&')
|
||||
text = "&";
|
||||
else if (!*str)
|
||||
text = "�";
|
||||
}
|
||||
if (text)
|
||||
{
|
||||
str--;
|
||||
count++;
|
||||
}
|
||||
if (str != buffer)
|
||||
err = _gpgme_data_append (dh, buffer, str - buffer);
|
||||
if (!err && text)
|
||||
{
|
||||
err = _gpgme_data_append_string (dh, text);
|
||||
str++;
|
||||
count--;
|
||||
}
|
||||
buffer = str;
|
||||
len = count;
|
||||
}
|
||||
while (!err && len);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Append a string to DATA and convert it so that the result will be
|
||||
valid XML. */
|
||||
GpgmeError
|
||||
_gpgme_data_append_string_for_xml (GpgmeData dh, const char *str)
|
||||
{
|
||||
return _gpgme_data_append_for_xml (dh, str, strlen (str));
|
||||
}
|
||||
|
||||
|
||||
/* Append a string with percent style (%XX) escape characters as
|
||||
XML. */
|
||||
GpgmeError
|
||||
_gpgme_data_append_percentstring_for_xml (GpgmeData dh, const char *str)
|
||||
{
|
||||
const byte *src;
|
||||
byte *buf, *dst;
|
||||
int val;
|
||||
GpgmeError err;
|
||||
|
||||
buf = xtrymalloc (strlen (str));
|
||||
dst = buf;
|
||||
for (src = str; *src; src++)
|
||||
{
|
||||
if (*src == '%' && (val = _gpgme_hextobyte (src + 1)) != -1)
|
||||
{
|
||||
*dst++ = val;
|
||||
src += 2;
|
||||
}
|
||||
else
|
||||
*dst++ = *src;
|
||||
}
|
||||
|
||||
err = _gpgme_data_append_for_xml (dh, buf, dst - buf);
|
||||
xfree (buf);
|
||||
return err;
|
||||
}
|
||||
|
1056
gpgme/data.c
1056
gpgme/data.c
File diff suppressed because it is too large
Load Diff
@ -170,19 +170,16 @@ _gpgme_decrypt_start (GpgmeCtx ctx, int synchronous,
|
||||
goto leave;
|
||||
|
||||
/* Check the supplied data. */
|
||||
if (!ciph || gpgme_data_get_type (ciph) == GPGME_DATA_TYPE_NONE)
|
||||
if (!ciph)
|
||||
{
|
||||
err = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (ciph, GPGME_DATA_MODE_OUT);
|
||||
|
||||
if (gpgme_data_get_type (plain) != GPGME_DATA_TYPE_NONE)
|
||||
if (!plain)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (plain, GPGME_DATA_MODE_IN);
|
||||
|
||||
err = _gpgme_passphrase_start (ctx);
|
||||
if (err)
|
||||
|
@ -94,12 +94,11 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous,
|
||||
ctx->result.edit->fnc_value = fnc_value;
|
||||
|
||||
/* Check the supplied data. */
|
||||
if (!out || gpgme_data_get_type (out) != GPGME_DATA_TYPE_NONE)
|
||||
if (!out)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (out, GPGME_DATA_MODE_IN);
|
||||
|
||||
err = _gpgme_engine_set_command_handler (ctx->engine, command_handler,
|
||||
ctx, out);
|
||||
|
@ -61,18 +61,16 @@ _gpgme_op_encrypt_sign_start (GpgmeCtx ctx, int synchronous,
|
||||
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||
|
||||
/* Check the supplied data */
|
||||
if (gpgme_data_get_type (plain) == GPGME_DATA_TYPE_NONE)
|
||||
if (!plain)
|
||||
{
|
||||
err = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (plain, GPGME_DATA_MODE_OUT);
|
||||
if (!cipher || gpgme_data_get_type (cipher) != GPGME_DATA_TYPE_NONE)
|
||||
if (!cipher)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (cipher, GPGME_DATA_MODE_IN);
|
||||
|
||||
err = _gpgme_engine_op_encrypt_sign (ctx->engine, recp, plain, cipher,
|
||||
ctx->use_armor, ctx /* FIXME */);
|
||||
@ -116,17 +114,7 @@ gpgme_op_encrypt_sign (GpgmeCtx ctx, GpgmeRecipients recp,
|
||||
GpgmeData plain, GpgmeData cipher)
|
||||
{
|
||||
GpgmeError err = _gpgme_op_encrypt_sign_start (ctx, 1, recp, plain, cipher);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
err = _gpgme_wait_one (ctx);
|
||||
/* Old gpg versions don't return status info for invalid
|
||||
recipients, so we simply check whether we got any output at
|
||||
all, and if not we assume that we don't have valid
|
||||
recipients. */
|
||||
if (!ctx->error && gpgme_data_get_type (cipher) == GPGME_DATA_TYPE_NONE)
|
||||
ctx->error = mk_error (No_Recipients);
|
||||
err = ctx->error;
|
||||
}
|
||||
err = _gpgme_wait_one (ctx);
|
||||
return err;
|
||||
}
|
||||
|
@ -190,18 +190,16 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous,
|
||||
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||
|
||||
/* Check the supplied data */
|
||||
if (gpgme_data_get_type (plain) == GPGME_DATA_TYPE_NONE)
|
||||
if (!plain)
|
||||
{
|
||||
err = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (plain, GPGME_DATA_MODE_OUT);
|
||||
if (!ciph || gpgme_data_get_type (ciph) != GPGME_DATA_TYPE_NONE)
|
||||
if (!ciph)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (ciph, GPGME_DATA_MODE_IN);
|
||||
|
||||
err = _gpgme_engine_op_encrypt (ctx->engine, recp, plain, ciph, ctx->use_armor);
|
||||
|
||||
@ -247,15 +245,6 @@ gpgme_op_encrypt (GpgmeCtx ctx, GpgmeRecipients recp,
|
||||
{
|
||||
int err = _gpgme_op_encrypt_start (ctx, 1, recp, plain, cipher);
|
||||
if (!err)
|
||||
{
|
||||
err = _gpgme_wait_one (ctx);
|
||||
/* Old gpg versions don't return status info for invalid
|
||||
recipients, so we simply check whether we got any output at
|
||||
all, and if not we assume that we don't have valid
|
||||
recipients. */
|
||||
if (!ctx->error && gpgme_data_get_type (cipher) == GPGME_DATA_TYPE_NONE)
|
||||
ctx->error = mk_error (No_Recipients);
|
||||
err = ctx->error;
|
||||
}
|
||||
err = _gpgme_wait_one (ctx);
|
||||
return err;
|
||||
}
|
||||
|
@ -1146,7 +1146,8 @@ _gpgme_gpgsm_op_trustlist (GpgsmObject gpgsm, const char *pattern)
|
||||
|
||||
|
||||
GpgmeError
|
||||
_gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData text)
|
||||
_gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData signed_text,
|
||||
GpgmeData plaintext)
|
||||
{
|
||||
GpgmeError err;
|
||||
|
||||
@ -1162,10 +1163,10 @@ _gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData text)
|
||||
map_input_enc (gpgsm->input_cb.data));
|
||||
if (err)
|
||||
return err;
|
||||
if (_gpgme_data_get_mode (text) == GPGME_DATA_MODE_IN)
|
||||
if (plaintext)
|
||||
{
|
||||
/* Normal or cleartext signature. */
|
||||
gpgsm->output_cb.data = text;
|
||||
gpgsm->output_cb.data = plaintext;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,
|
||||
0);
|
||||
_gpgme_io_close (gpgsm->message_cb.fd);
|
||||
@ -1173,7 +1174,7 @@ _gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData text)
|
||||
else
|
||||
{
|
||||
/* Detached signature. */
|
||||
gpgsm->message_cb.data = text;
|
||||
gpgsm->message_cb.data = signed_text;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "MESSAGE",
|
||||
gpgsm->message_fd_server, 0);
|
||||
_gpgme_io_close (gpgsm->output_cb.fd);
|
||||
|
@ -61,7 +61,7 @@ GpgmeError _gpgme_gpgsm_op_sign (GpgsmObject gpgsm, GpgmeData in,
|
||||
GpgmeCtx ctx /* FIXME */);
|
||||
GpgmeError _gpgme_gpgsm_op_trustlist (GpgsmObject gpgsm, const char *pattern);
|
||||
GpgmeError _gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig,
|
||||
GpgmeData text);
|
||||
GpgmeData signed_text, GpgmeData plaintext);
|
||||
GpgmeError _gpgme_gpgsm_start (GpgsmObject gpgsm, void *opaque);
|
||||
void _gpgme_gpgsm_set_io_cbs (GpgsmObject gpgsm, struct GpgmeIOCbs *io_cbs);
|
||||
void _gpgme_gpgsm_io_event (GpgsmObject gpgsm, GpgmeEventIO type, void *type_data);
|
||||
|
@ -542,7 +542,8 @@ _gpgme_engine_op_trustlist (EngineObject engine, const char *pattern)
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
_gpgme_engine_op_verify (EngineObject engine, GpgmeData sig, GpgmeData text)
|
||||
_gpgme_engine_op_verify (EngineObject engine, GpgmeData sig,
|
||||
GpgmeData signed_text, GpgmeData plaintext)
|
||||
{
|
||||
if (!engine)
|
||||
return mk_error (Invalid_Value);
|
||||
@ -550,9 +551,11 @@ _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig, GpgmeData text)
|
||||
switch (engine->protocol)
|
||||
{
|
||||
case GPGME_PROTOCOL_OpenPGP:
|
||||
return _gpgme_gpg_op_verify (engine->engine.gpg, sig, text);
|
||||
return _gpgme_gpg_op_verify (engine->engine.gpg, sig,
|
||||
signed_text, plaintext);
|
||||
case GPGME_PROTOCOL_CMS:
|
||||
return _gpgme_gpgsm_op_verify (engine->engine.gpgsm, sig, text);
|
||||
return _gpgme_gpgsm_op_verify (engine->engine.gpgsm, sig,
|
||||
signed_text, plaintext);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ GpgmeError _gpgme_engine_op_sign (EngineObject engine, GpgmeData in,
|
||||
GpgmeError _gpgme_engine_op_trustlist (EngineObject engine,
|
||||
const char *pattern);
|
||||
GpgmeError _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig,
|
||||
GpgmeData text);
|
||||
GpgmeData signed_text, GpgmeData plaintext);
|
||||
GpgmeError _gpgme_engine_start (EngineObject engine, void *opaque);
|
||||
|
||||
void _gpgme_engine_set_io_cbs (EngineObject engine,
|
||||
|
@ -51,12 +51,11 @@ _gpgme_op_export_start (GpgmeCtx ctx, int synchronous,
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
if (!keydata || gpgme_data_get_type (keydata) != GPGME_DATA_TYPE_NONE)
|
||||
if (!keydata)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (keydata, GPGME_DATA_MODE_IN);
|
||||
|
||||
_gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
|
||||
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||
@ -99,12 +98,7 @@ gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recipients, GpgmeData keydata)
|
||||
{
|
||||
GpgmeError err = _gpgme_op_export_start (ctx, 1, recipients, keydata);
|
||||
if (!err)
|
||||
{
|
||||
err = _gpgme_wait_one (ctx);
|
||||
/* XXX We don't get status information. */
|
||||
if (!ctx->error && gpgme_data_get_type (keydata) == GPGME_DATA_TYPE_NONE)
|
||||
ctx->error = mk_error (No_Recipients);
|
||||
err = ctx->error;
|
||||
}
|
||||
err = _gpgme_wait_one (ctx);
|
||||
/* XXX We don't get enough status information. */
|
||||
return err;
|
||||
}
|
||||
|
@ -92,27 +92,6 @@ _gpgme_op_genkey_start (GpgmeCtx ctx, int synchronous, const char *parms,
|
||||
gpgme_data_release (ctx->help_data_1);
|
||||
ctx->help_data_1 = NULL;
|
||||
|
||||
if (!pubkey && !seckey)
|
||||
; /* okay: Add key to the keyrings */
|
||||
else if (pubkey && gpgme_data_get_type (pubkey) != GPGME_DATA_TYPE_NONE)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
else if (seckey && gpgme_data_get_type (seckey) != GPGME_DATA_TYPE_NONE)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (pubkey)
|
||||
/* FIXME: Need some more things here. */
|
||||
_gpgme_data_set_mode (pubkey, GPGME_DATA_MODE_IN);
|
||||
|
||||
if (seckey)
|
||||
/* FIXME: Need some more things here. */
|
||||
_gpgme_data_set_mode (seckey, GPGME_DATA_MODE_IN);
|
||||
|
||||
if ((parms = strstr (parms, "<GnupgKeyParms "))
|
||||
&& (s = strchr (parms, '>'))
|
||||
&& (sx = strstr (parms, "format=\"internal\""))
|
||||
@ -131,8 +110,6 @@ _gpgme_op_genkey_start (GpgmeCtx ctx, int synchronous, const char *parms,
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
_gpgme_data_set_mode (ctx->help_data_1, GPGME_DATA_MODE_OUT);
|
||||
|
||||
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
|
||||
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||
|
||||
|
@ -168,7 +168,7 @@ gpgme_get_notation (GpgmeCtx ctx)
|
||||
char *
|
||||
gpgme_get_op_info (GpgmeCtx ctx, int reserved)
|
||||
{
|
||||
if (!ctx || reserved)
|
||||
if (!ctx || reserved || !ctx->op_info)
|
||||
return NULL; /* Invalid value. */
|
||||
|
||||
return _gpgme_data_get_as_string (ctx->op_info);
|
||||
|
112
gpgme/gpgme.h
112
gpgme/gpgme.h
@ -507,9 +507,54 @@ GpgmeError gpgme_recipients_enum_close (const GpgmeRecipients rset,
|
||||
|
||||
/* Functions to handle data objects. */
|
||||
|
||||
/* Read up to SIZE bytes into buffer BUFFER from the data object with
|
||||
the handle HANDLE. Return the number of characters read, 0 on EOF
|
||||
and -1 on error. If an error occurs, errno is set. */
|
||||
typedef int (*GpgmeDataReadCb) (void *handle, void *buffer, size_t size);
|
||||
|
||||
/* Write up to SIZE bytes from buffer BUFFER to the data object with
|
||||
the handle HANDLE. Return the number of characters written, or -1
|
||||
on error. If an error occurs, errno is set. */
|
||||
typedef ssize_t (*GpgmeDataWriteCb) (void *handle, const void *buffer,
|
||||
size_t size);
|
||||
|
||||
/* Set the current position from where the next read or write starts
|
||||
in the data object with the handle HANDLE to OFFSET, relativ to
|
||||
WHENCE. */
|
||||
typedef int (*GpgmeDataSeekCb) (void *handle, off_t offset, int whence);
|
||||
|
||||
/* Close the data object with the handle DL. */
|
||||
typedef void (*GpgmeDataReleaseCb) (void *handle);
|
||||
|
||||
struct GpgmeDataCbs
|
||||
{
|
||||
GpgmeDataReadCb read;
|
||||
GpgmeDataWriteCb write;
|
||||
GpgmeDataSeekCb seek;
|
||||
GpgmeDataReleaseCb release;
|
||||
};
|
||||
|
||||
/* Read up to SIZE bytes into buffer BUFFER from the data object with
|
||||
the handle DH. Return the number of characters read, 0 on EOF and
|
||||
-1 on error. If an error occurs, errno is set. */
|
||||
int gpgme_data_read (GpgmeData dh, void *buffer, size_t size);
|
||||
|
||||
/* Write up to SIZE bytes from buffer BUFFER to the data object with
|
||||
the handle DH. Return the number of characters written, or -1 on
|
||||
error. If an error occurs, errno is set. */
|
||||
ssize_t gpgme_data_write (GpgmeData dh, const void *buffer, size_t size);
|
||||
|
||||
/* Set the current position from where the next read or write starts
|
||||
in the data object with the handle DH to OFFSET, relativ to
|
||||
WHENCE. */
|
||||
off_t gpgme_data_seek (GpgmeData dh, off_t offset, int whence);
|
||||
|
||||
/* Create a new data buffer and return it in R_DH. */
|
||||
GpgmeError gpgme_data_new (GpgmeData *r_dh);
|
||||
|
||||
/* Destroy the data buffer DH. */
|
||||
void gpgme_data_release (GpgmeData dh);
|
||||
|
||||
/* Create a new data buffer filled with SIZE bytes starting from
|
||||
BUFFER. If COPY is zero, copying is delayed until necessary, and
|
||||
the data is taken from the original location when needed. */
|
||||
@ -517,14 +562,37 @@ GpgmeError gpgme_data_new_from_mem (GpgmeData *r_dh,
|
||||
const char *buffer, size_t size,
|
||||
int copy);
|
||||
|
||||
/* Destroy the data buffer DH and return a pointer to its content.
|
||||
The memory has be to released with free by the user. It's size is
|
||||
returned in R_LEN. */
|
||||
char *gpgme_data_release_and_get_mem (GpgmeData dh, size_t *r_len);
|
||||
|
||||
GpgmeError gpgme_data_new_from_cbs (GpgmeData *dh,
|
||||
struct GpgmeDataCbs *cbs,
|
||||
void *handle);
|
||||
|
||||
GpgmeError gpgme_data_new_from_fd (GpgmeData *dh, int fd);
|
||||
|
||||
GpgmeError gpgme_data_new_from_stream (GpgmeData *dh, FILE *stream);
|
||||
|
||||
/* Return the encoding attribute of the data buffer DH */
|
||||
GpgmeDataEncoding gpgme_data_get_encoding (GpgmeData dh);
|
||||
|
||||
/* Set the encoding attribute of data buffer DH to ENC */
|
||||
GpgmeError gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc);
|
||||
|
||||
|
||||
|
||||
/* Create a new data buffer which retrieves the data from the callback
|
||||
function READ_CB. */
|
||||
function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
|
||||
instead. */
|
||||
GpgmeError gpgme_data_new_with_read_cb (GpgmeData *r_dh,
|
||||
int (*read_cb) (void*,char *,size_t,size_t*),
|
||||
void *read_cb_value);
|
||||
|
||||
/* Create a new data buffer filled with the content of file FNAME.
|
||||
COPY must be non-zero (delayed reads are not supported yet). */
|
||||
COPY must be non-zero. For delayed read, please use
|
||||
gpgme_data_new_from_fd or gpgme_data_new_from stream instead. */
|
||||
GpgmeError gpgme_data_new_from_file (GpgmeData *r_dh,
|
||||
const char *fname,
|
||||
int copy);
|
||||
@ -536,35 +604,10 @@ GpgmeError gpgme_data_new_from_filepart (GpgmeData *r_dh,
|
||||
const char *fname, FILE *fp,
|
||||
off_t offset, size_t length);
|
||||
|
||||
/* Destroy the data buffer DH. */
|
||||
void gpgme_data_release (GpgmeData dh);
|
||||
|
||||
/* Destroy the data buffer DH and return a pointer to its content.
|
||||
The memory has be to released with free by the user. It's size is
|
||||
returned in R_LEN. */
|
||||
char *gpgme_data_release_and_get_mem (GpgmeData dh, size_t *r_len);
|
||||
|
||||
/* Return the type of the data buffer DH. */
|
||||
GpgmeDataType gpgme_data_get_type (GpgmeData dh);
|
||||
|
||||
/* Return the encoding attribute of the data buffer DH */
|
||||
GpgmeDataEncoding gpgme_data_get_encoding (GpgmeData dh);
|
||||
|
||||
/* Set the encoding attribute of data buffer DH to ENC */
|
||||
GpgmeError gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc);
|
||||
|
||||
/* Reset the read pointer in DH. */
|
||||
/* Reset the read pointer in DH. Deprecated, please use
|
||||
gpgme_data_seek instead. */
|
||||
GpgmeError gpgme_data_rewind (GpgmeData dh);
|
||||
|
||||
/* Read LENGTH bytes from the data object DH and store them in the
|
||||
memory starting at BUFFER. The number of bytes actually read is
|
||||
returned in NREAD. */
|
||||
GpgmeError gpgme_data_read (GpgmeData dh, void *buffer,
|
||||
size_t length, size_t *nread);
|
||||
|
||||
/* Write LENGTH bytes starting from BUFFER into the data object DH. */
|
||||
GpgmeError gpgme_data_write (GpgmeData dh, const void *buffer, size_t length);
|
||||
|
||||
|
||||
/* Key and trust functions. */
|
||||
|
||||
@ -654,10 +697,10 @@ GpgmeError gpgme_op_sign (GpgmeCtx ctx,
|
||||
GpgmeSigMode mode);
|
||||
|
||||
/* Verify within CTX that SIG is a valid signature for TEXT. */
|
||||
GpgmeError gpgme_op_verify_start (GpgmeCtx ctx,
|
||||
GpgmeData sig, GpgmeData text);
|
||||
GpgmeError gpgme_op_verify (GpgmeCtx ctx,
|
||||
GpgmeData sig, GpgmeData text,
|
||||
GpgmeError gpgme_op_verify_start (GpgmeCtx ctx, GpgmeData sig,
|
||||
GpgmeData signed_text, GpgmeData plaintext);
|
||||
GpgmeError gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig,
|
||||
GpgmeData signed_text, GpgmeData plaintext,
|
||||
GpgmeSigStat *r_status);
|
||||
|
||||
/* Import the key in KEYDATA into the keyring. */
|
||||
@ -729,9 +772,6 @@ GpgmeError gpgme_op_trustlist_end (GpgmeCtx ctx);
|
||||
/* Check that the library fulfills the version requirement. */
|
||||
const char *gpgme_check_version (const char *req_version);
|
||||
|
||||
/* Check that the backend engine is available. DEPRECATED. */
|
||||
GpgmeError gpgme_check_engine (void);
|
||||
|
||||
/* Retrieve information about the backend engines. */
|
||||
const char *gpgme_get_engine_info (void);
|
||||
|
||||
|
@ -186,12 +186,11 @@ _gpgme_op_import_start (GpgmeCtx ctx, int synchronous, GpgmeData keydata)
|
||||
goto leave;
|
||||
|
||||
/* Check the supplied data */
|
||||
if (gpgme_data_get_type (keydata) == GPGME_DATA_TYPE_NONE)
|
||||
if (!keydata)
|
||||
{
|
||||
err = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (keydata, GPGME_DATA_MODE_OUT);
|
||||
|
||||
_gpgme_engine_set_status_handler (ctx->engine, import_status_handler, ctx);
|
||||
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||
|
@ -57,10 +57,8 @@ GpgmeError _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond);
|
||||
int _gpgme_recipients_all_valid ( const GpgmeRecipients rset );
|
||||
|
||||
|
||||
/*-- data.c --*/
|
||||
/*-- data.c and conversion.c --*/
|
||||
char * _gpgme_data_release_and_return_string ( GpgmeData dh );
|
||||
GpgmeDataMode _gpgme_data_get_mode ( GpgmeData dh );
|
||||
void _gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode );
|
||||
char * _gpgme_data_get_as_string ( GpgmeData dh );
|
||||
GpgmeError _gpgme_data_append ( GpgmeData dh,
|
||||
const char *buffer, size_t length );
|
||||
|
191
gpgme/rungpg.c
191
gpgme/rungpg.c
@ -44,14 +44,16 @@
|
||||
#include "status-table.h"
|
||||
|
||||
|
||||
/* This type is used to build a list of gpg arguments and
|
||||
* data sources/sinks */
|
||||
struct arg_and_data_s {
|
||||
struct arg_and_data_s *next;
|
||||
GpgmeData data; /* If this is not NULL .. */
|
||||
int dup_to;
|
||||
int print_fd; /* print the fd number and not the special form of it */
|
||||
char arg[1]; /* .. this is used */
|
||||
/* This type is used to build a list of gpg arguments and data
|
||||
sources/sinks. */
|
||||
struct arg_and_data_s
|
||||
{
|
||||
struct arg_and_data_s *next;
|
||||
GpgmeData data; /* If this is not NULL, use arg below. */
|
||||
int inbound; /* True if this is used for reading from gpg. */
|
||||
int dup_to;
|
||||
int print_fd; /* Print the fd number and not the special form of it. */
|
||||
char arg[1]; /* Used if data above is not used. */
|
||||
};
|
||||
|
||||
struct fd_data_map_s
|
||||
@ -378,33 +380,37 @@ _gpgme_gpg_add_arg ( GpgObject gpg, const char *arg )
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
_gpgme_gpg_add_data ( GpgObject gpg, GpgmeData data, int dup_to )
|
||||
_gpgme_gpg_add_data (GpgObject gpg, GpgmeData data, int dup_to, int inbound)
|
||||
{
|
||||
struct arg_and_data_s *a;
|
||||
struct arg_and_data_s *a;
|
||||
|
||||
assert (gpg);
|
||||
assert (data);
|
||||
if (gpg->pm.active)
|
||||
return 0;
|
||||
|
||||
a = xtrymalloc ( sizeof *a - 1 );
|
||||
if ( !a ) {
|
||||
gpg->arg_error = 1;
|
||||
return mk_error(Out_Of_Core);
|
||||
}
|
||||
a->next = NULL;
|
||||
a->data = data;
|
||||
if ( dup_to == -2 ) {
|
||||
a->print_fd = 1;
|
||||
a->dup_to = -1;
|
||||
}
|
||||
else {
|
||||
a->print_fd = 0;
|
||||
a->dup_to = dup_to;
|
||||
}
|
||||
*gpg->argtail = a;
|
||||
gpg->argtail = &a->next;
|
||||
assert (gpg);
|
||||
assert (data);
|
||||
if (gpg->pm.active)
|
||||
return 0;
|
||||
|
||||
a = xtrymalloc (sizeof *a - 1);
|
||||
if (!a)
|
||||
{
|
||||
gpg->arg_error = 1;
|
||||
return mk_error(Out_Of_Core);
|
||||
}
|
||||
a->next = NULL;
|
||||
a->data = data;
|
||||
a->inbound = inbound;
|
||||
if (dup_to == -2)
|
||||
{
|
||||
a->print_fd = 1;
|
||||
a->dup_to = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
a->print_fd = 0;
|
||||
a->dup_to = dup_to;
|
||||
}
|
||||
*gpg->argtail = a;
|
||||
gpg->argtail = &a->next;
|
||||
return 0;
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
@ -435,7 +441,7 @@ _gpgme_gpg_add_pm_data ( GpgObject gpg, GpgmeData data, int what )
|
||||
|
||||
rc = gpgme_data_new_with_read_cb ( &tmp, pipemode_cb, gpg );
|
||||
if (!rc )
|
||||
rc = _gpgme_gpg_add_data (gpg, tmp, 0);
|
||||
rc = _gpgme_gpg_add_data (gpg, tmp, 0, 0);
|
||||
}
|
||||
if ( !rc ) {
|
||||
/* here we can reset the handler stuff */
|
||||
@ -532,8 +538,8 @@ _gpgme_gpg_set_command_handler (GpgObject gpg,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
_gpgme_gpg_add_arg ( gpg, "--command-fd" );
|
||||
_gpgme_gpg_add_data (gpg, tmp, -2);
|
||||
_gpgme_gpg_add_arg (gpg, "--command-fd");
|
||||
_gpgme_gpg_add_data (gpg, tmp, -2, 0);
|
||||
gpg->cmd.cb_data = tmp;
|
||||
gpg->cmd.fnc = fnc;
|
||||
gpg->cmd.fnc_value = fnc_value;
|
||||
@ -696,40 +702,8 @@ build_argv (GpgObject gpg)
|
||||
{
|
||||
if (a->data)
|
||||
{
|
||||
switch (_gpgme_data_get_mode (a->data))
|
||||
{
|
||||
case GPGME_DATA_MODE_NONE:
|
||||
case GPGME_DATA_MODE_INOUT:
|
||||
xfree (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Invalid_Mode);
|
||||
case GPGME_DATA_MODE_IN:
|
||||
/* Create a pipe to read from gpg. */
|
||||
fd_data_map[datac].inbound = 1;
|
||||
break;
|
||||
case GPGME_DATA_MODE_OUT:
|
||||
/* Create a pipe to pass it down to gpg. */
|
||||
fd_data_map[datac].inbound = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (gpgme_data_get_type (a->data))
|
||||
{
|
||||
case GPGME_DATA_TYPE_NONE:
|
||||
if (fd_data_map[datac].inbound)
|
||||
break; /* Allowed. */
|
||||
xfree (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Invalid_Type);
|
||||
case GPGME_DATA_TYPE_MEM:
|
||||
case GPGME_DATA_TYPE_CB:
|
||||
break;
|
||||
case GPGME_DATA_TYPE_FD:
|
||||
case GPGME_DATA_TYPE_FILE:
|
||||
xfree (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Not_Implemented);
|
||||
}
|
||||
/* Create a pipe to pass it down to gpg. */
|
||||
fd_data_map[datac].inbound = a->inbound;
|
||||
|
||||
/* Create a pipe. */
|
||||
{
|
||||
@ -1256,29 +1230,30 @@ read_colon_line ( GpgObject gpg )
|
||||
}
|
||||
|
||||
static GpgmeError
|
||||
pipemode_copy (char *buffer, size_t length, size_t *nread, GpgmeData data )
|
||||
pipemode_copy (char *buffer, size_t length, size_t *nread, GpgmeData data)
|
||||
{
|
||||
GpgmeError err;
|
||||
size_t nbytes;
|
||||
char tmp[1000], *s, *d;
|
||||
size_t nbytes;
|
||||
char tmp[1000], *src, *dst;
|
||||
|
||||
/* we can optimize this whole thing but for now we just
|
||||
* return after each escape character */
|
||||
if (length > 990)
|
||||
length = 990;
|
||||
/* We can optimize this whole thing but for now we just return after
|
||||
each escape character. */
|
||||
if (length > 990)
|
||||
length = 990;
|
||||
|
||||
err = gpgme_data_read ( data, tmp, length, &nbytes );
|
||||
if (err)
|
||||
return err;
|
||||
for (s=tmp, d=buffer; nbytes; s++, nbytes--) {
|
||||
*d++ = *s;
|
||||
if (*s == '@' ) {
|
||||
*d++ = '@';
|
||||
break;
|
||||
}
|
||||
nbytes = gpgme_data_read (data, tmp, length);
|
||||
if (nbytes < 0)
|
||||
return mk_error (File_Error);
|
||||
for (src = tmp, dst = buffer; nbytes; src++, nbytes--)
|
||||
{
|
||||
*dst++ = *src;
|
||||
if (*src == '@')
|
||||
{
|
||||
*dst++ = '@';
|
||||
break;
|
||||
}
|
||||
}
|
||||
*nread = d - buffer;
|
||||
return 0;
|
||||
*nread = dst - buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1409,9 +1384,9 @@ _gpgme_gpg_op_decrypt (GpgObject gpg, GpgmeData ciph, GpgmeData plain)
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "-");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, plain, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, plain, 1, 1);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, ciph, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, ciph, 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1477,7 +1452,7 @@ _gpgme_gpg_op_edit (GpgObject gpg, GpgmeKey key, GpgmeData out,
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--edit-key");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, out, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, out, 1, 1);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--");
|
||||
if (!err)
|
||||
@ -1542,11 +1517,11 @@ _gpgme_gpg_op_encrypt (GpgObject gpg, GpgmeRecipients recp,
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "-");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, ciph, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, ciph, 1, 1);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, plain, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, plain, 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1581,11 +1556,11 @@ _gpgme_gpg_op_encrypt_sign (GpgObject gpg, GpgmeRecipients recp,
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "-");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, ciph, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, ciph, 1, 1);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, plain, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, plain, 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1600,7 +1575,7 @@ _gpgme_gpg_op_export (GpgObject gpg, GpgmeRecipients recp,
|
||||
if (!err && use_armor)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--armor");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, keydata, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, keydata, 1, 1);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--");
|
||||
|
||||
@ -1639,7 +1614,7 @@ _gpgme_gpg_op_genkey (GpgObject gpg, GpgmeData help_data, int use_armor,
|
||||
if (!err && use_armor)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--armor");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, help_data, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, help_data, 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1651,7 +1626,7 @@ _gpgme_gpg_op_import (GpgObject gpg, GpgmeData keydata)
|
||||
|
||||
err = _gpgme_gpg_add_arg (gpg, "--import");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, keydata, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, keydata, 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1741,9 +1716,9 @@ _gpgme_gpg_op_sign (GpgObject gpg, GpgmeData in, GpgmeData out,
|
||||
|
||||
/* Tell the gpg object about the data. */
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, in, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, in, 0, 0);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, out, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, out, 1, 1);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1767,11 +1742,11 @@ _gpgme_gpg_op_trustlist (GpgObject gpg, const char *pattern)
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
_gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData text)
|
||||
_gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData signed_text, GpgmeData plaintext)
|
||||
{
|
||||
GpgmeError err = 0;
|
||||
|
||||
if (_gpgme_data_get_mode (text) == GPGME_DATA_MODE_IN)
|
||||
if (plaintext)
|
||||
{
|
||||
/* Normal or cleartext signature. */
|
||||
|
||||
@ -1781,9 +1756,9 @@ _gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData text)
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, sig, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, sig, 0, 0);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, text, 1);
|
||||
err = _gpgme_gpg_add_data (gpg, plaintext, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1795,7 +1770,7 @@ _gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData text)
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_pm_data (gpg, sig, 0);
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_pm_data (gpg, text, 1);
|
||||
err = _gpgme_gpg_add_pm_data (gpg, signed_text, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1803,13 +1778,13 @@ _gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData text)
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "--");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, sig, -1);
|
||||
if (text)
|
||||
err = _gpgme_gpg_add_data (gpg, sig, -1, 0);
|
||||
if (signed_text)
|
||||
{
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_arg (gpg, "-");
|
||||
if (!err)
|
||||
err = _gpgme_gpg_add_data (gpg, text, 0);
|
||||
err = _gpgme_gpg_add_data (gpg, signed_text, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ void _gpgme_gpg_release ( GpgObject gpg );
|
||||
void _gpgme_gpg_housecleaning (void);
|
||||
void _gpgme_gpg_enable_pipemode ( GpgObject gpg );
|
||||
GpgmeError _gpgme_gpg_add_arg ( GpgObject gpg, const char *arg );
|
||||
GpgmeError _gpgme_gpg_add_data ( GpgObject gpg, GpgmeData data, int dup_to );
|
||||
GpgmeError _gpgme_gpg_add_data (GpgObject gpg, GpgmeData data, int dup_to, int inbound);
|
||||
GpgmeError _gpgme_gpg_add_pm_data ( GpgObject gpg, GpgmeData data, int what );
|
||||
void _gpgme_gpg_set_status_handler (GpgObject gpg,
|
||||
GpgStatusHandler fnc,
|
||||
@ -79,7 +79,9 @@ GpgmeError _gpgme_gpg_op_sign (GpgObject gpg, GpgmeData in, GpgmeData out,
|
||||
GpgmeSigMode mode, int use_armor,
|
||||
int use_textmode, GpgmeCtx ctx /* FIXME */);
|
||||
GpgmeError _gpgme_gpg_op_trustlist (GpgObject gpg, const char *pattern);
|
||||
GpgmeError _gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData text);
|
||||
GpgmeError _gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig,
|
||||
GpgmeData signed_text,
|
||||
GpgmeData plaintext);
|
||||
GpgmeError _gpgme_gpg_spawn (GpgObject gpg, void *opaque);
|
||||
void _gpgme_gpg_set_io_cbs (GpgObject gpg, struct GpgmeIOCbs *io_cbs);
|
||||
void _gpgme_gpg_io_event (GpgObject gpg, GpgmeEventIO type, void *type_data);
|
||||
|
@ -185,18 +185,16 @@ _gpgme_op_sign_start (GpgmeCtx ctx, int synchronous,
|
||||
goto leave;
|
||||
|
||||
/* Check the supplied data. */
|
||||
if (gpgme_data_get_type (in) == GPGME_DATA_TYPE_NONE)
|
||||
if (!in)
|
||||
{
|
||||
err = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (in, GPGME_DATA_MODE_OUT);
|
||||
if (!out || gpgme_data_get_type (out) != GPGME_DATA_TYPE_NONE)
|
||||
if (!out)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (out, GPGME_DATA_MODE_IN);
|
||||
|
||||
err = _gpgme_passphrase_start (ctx);
|
||||
if (err)
|
||||
|
@ -32,14 +32,6 @@ typedef unsigned long ulong;
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum {
|
||||
GPGME_DATA_MODE_NONE = 0,
|
||||
GPGME_DATA_MODE_IN = 1,
|
||||
GPGME_DATA_MODE_OUT = 2,
|
||||
GPGME_DATA_MODE_INOUT = 3
|
||||
} GpgmeDataMode;
|
||||
|
||||
|
||||
/*
|
||||
* Declaration of internal objects
|
||||
*/
|
||||
|
@ -359,7 +359,7 @@ _gpgme_verify_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
|
||||
|
||||
static GpgmeError
|
||||
_gpgme_op_verify_start (GpgmeCtx ctx, int synchronous,
|
||||
GpgmeData sig, GpgmeData text)
|
||||
GpgmeData sig, GpgmeData signed_text, GpgmeData plaintext)
|
||||
{
|
||||
int err = 0;
|
||||
int pipemode = 0; /* !!text; use pipemode for detached sigs. */
|
||||
@ -382,25 +382,17 @@ _gpgme_op_verify_start (GpgmeCtx ctx, int synchronous,
|
||||
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||
|
||||
/* Check the supplied data. */
|
||||
if (gpgme_data_get_type (sig) == GPGME_DATA_TYPE_NONE)
|
||||
if (!sig)
|
||||
{
|
||||
err = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
if (!text)
|
||||
if (!signed_text && !plaintext)
|
||||
{
|
||||
err = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_data_set_mode (sig, GPGME_DATA_MODE_OUT);
|
||||
if (gpgme_data_get_type (text) == GPGME_DATA_TYPE_NONE)
|
||||
/* Normal or cleartext signature. */
|
||||
_gpgme_data_set_mode (text, GPGME_DATA_MODE_IN);
|
||||
else
|
||||
/* Detached signature. */
|
||||
_gpgme_data_set_mode (text, GPGME_DATA_MODE_OUT);
|
||||
|
||||
err = _gpgme_engine_op_verify (ctx->engine, sig, text);
|
||||
err = _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext);
|
||||
if (!err) /* And kick off the process. */
|
||||
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||
|
||||
@ -415,9 +407,10 @@ _gpgme_op_verify_start (GpgmeCtx ctx, int synchronous,
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
gpgme_op_verify_start (GpgmeCtx ctx, GpgmeData sig, GpgmeData text)
|
||||
gpgme_op_verify_start (GpgmeCtx ctx, GpgmeData sig, GpgmeData signed_text,
|
||||
GpgmeData plaintext)
|
||||
{
|
||||
return _gpgme_op_verify_start (ctx, 0, sig, text);
|
||||
return _gpgme_op_verify_start (ctx, 0, sig, signed_text, plaintext);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -469,8 +462,8 @@ _gpgme_intersect_stati (VerifyResult result)
|
||||
* the signature itself did go wrong.
|
||||
**/
|
||||
GpgmeError
|
||||
gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig, GpgmeData text,
|
||||
GpgmeSigStat *r_stat)
|
||||
gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig, GpgmeData signed_text,
|
||||
GpgmeData plaintext, GpgmeSigStat *r_stat)
|
||||
{
|
||||
GpgmeError err;
|
||||
|
||||
@ -481,7 +474,7 @@ gpgme_op_verify (GpgmeCtx ctx, GpgmeData sig, GpgmeData text,
|
||||
ctx->notation = NULL;
|
||||
|
||||
*r_stat = GPGME_SIG_STAT_NONE;
|
||||
err = _gpgme_op_verify_start (ctx, 1, sig, text);
|
||||
err = _gpgme_op_verify_start (ctx, 1, sig, signed_text, plaintext);
|
||||
if (!err)
|
||||
{
|
||||
err = _gpgme_wait_one (ctx);
|
||||
|
@ -193,22 +193,6 @@ gpgme_get_engine_info ()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gpgme_check_engine:
|
||||
*
|
||||
* Check whether the installed crypto engine for the OpenPGP protocol
|
||||
* matches the requirement of GPGME. This function is deprecated,
|
||||
* instead use gpgme_engine_get_info() with the specific protocol you
|
||||
* need.
|
||||
*
|
||||
* Return value: 0 or an error code.
|
||||
**/
|
||||
GpgmeError
|
||||
gpgme_check_engine ()
|
||||
{
|
||||
return gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||
}
|
||||
|
||||
|
||||
#define LINELENGTH 80
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-10-09 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* gpg/t-decrypt.c (print_data): Update to new gpgme_data_read
|
||||
interface, and use gpgme_engine_check_version instead
|
||||
gpgme_check_version.
|
||||
* gpg/t-decrypt-verify.c (print_data): Likewise.
|
||||
* gpg/t-edit.c (main): Likewise.
|
||||
* gpg/t-encrypt.c (print_data): Likewise.
|
||||
* gpg/t-encrypt-sign.c (print_data): Likewise.
|
||||
* gpg/t-encrypt-sym.c (print_data): Likewise.
|
||||
* gpg/t-eventloop.c (print_data): Likewise.
|
||||
* gpg/t-export.c (print_data): Likewise.
|
||||
* gpg/t-sign.c (print_data): Likewise.
|
||||
* gpg/t-signers.c (print_data): Likewise.
|
||||
* gpgsm/t-decrypt.c (print_data): Likewise.
|
||||
* gpgsm/t-encrypt.c (print_data): Likewise.
|
||||
* gpgsm/t-export.c (print_data): Likewise.
|
||||
* gpgsm/t-sign.c (print_data): Likewise.
|
||||
* gpg/t-verify.c (main): Likewise for gpgme_op_verify.
|
||||
* gpgsm/t-verify.c (main): Likewise for gpgme_op_verify.
|
||||
* t-data.c (read_once_test): Likewise.
|
||||
(write_test): Update for new behaviour of data objects.
|
||||
(main): Remove type test.
|
||||
|
||||
2002-09-30 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpgsm/t-keylist.c (doit): Add arg SECRET.
|
||||
|
@ -42,21 +42,23 @@ struct passphrase_cb_info_s
|
||||
exit (1); } \
|
||||
} while(0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind (dh);
|
||||
fail_if_err (err);
|
||||
while (!(err = gpgme_data_read (dh, buf, 100, &nread)))
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
passphrase_cb (void *opaque, const char *desc, void **r_hd)
|
||||
{
|
||||
|
@ -42,19 +42,33 @@ struct passphrase_cb_info_s {
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,13 +45,15 @@ static void
|
||||
flush_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
int ret;
|
||||
|
||||
while (!(err = gpgme_data_read (dh, buf, 100, &nread)))
|
||||
fwrite (buf, nread, 1, stdout);
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,33 +33,33 @@
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else {
|
||||
puts (s);
|
||||
free (s);
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ main (int argc, char **argv )
|
||||
GpgmeRecipients rset;
|
||||
char *p;
|
||||
|
||||
err = gpgme_check_engine ();
|
||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||
fail_if_err (err);
|
||||
puts ( gpgme_get_engine_info() );
|
||||
|
||||
|
@ -36,15 +36,15 @@ static void
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind (dh);
|
||||
fail_if_err (err);
|
||||
while (!(err = gpgme_data_read (dh, buf, 100, &nread)))
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ main (int argc, char **argv)
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
err = gpgme_check_engine ();
|
||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||
fail_if_err (err);
|
||||
|
||||
do
|
||||
|
@ -35,44 +35,44 @@
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else {
|
||||
puts (s);
|
||||
free (s);
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (s);
|
||||
free (s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GpgmeCtx ctx;
|
||||
GpgmeError err;
|
||||
GpgmeData in, out;
|
||||
GpgmeRecipients rset;
|
||||
|
||||
err = gpgme_check_engine ();
|
||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||
fail_if_err (err);
|
||||
puts ( gpgme_get_engine_info() );
|
||||
|
||||
|
@ -37,14 +37,14 @@
|
||||
static void
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char *s = gpgme_get_op_info (ctx, 0);
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
if (!s)
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (s);
|
||||
free (s);
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,15 +53,15 @@ static void
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind (dh);
|
||||
fail_if_err (err);
|
||||
while (!(err = gpgme_data_read (dh, buf, 100, &nread)))
|
||||
fwrite (buf, nread, 1, stdout);
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ main (int argc, char *argv[])
|
||||
for (i = 0; i < FDLIST_MAX; i++)
|
||||
fdlist[i].fd = -1;
|
||||
|
||||
err = gpgme_check_engine ();
|
||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||
fail_if_err (err);
|
||||
puts (gpgme_get_engine_info ());
|
||||
|
||||
|
@ -32,24 +32,22 @@
|
||||
exit (1); } \
|
||||
} while(0)
|
||||
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
pattern = argc? *argv : NULL;
|
||||
|
||||
err = gpgme_check_engine();
|
||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_new (&ctx);
|
||||
|
@ -33,34 +33,36 @@
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else {
|
||||
puts (s);
|
||||
free (s);
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
passphrase_cb ( void *opaque, const char *desc, void **r_hd )
|
||||
{
|
||||
|
@ -33,34 +33,36 @@
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
if (!s)
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (s);
|
||||
free (s);
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind (dh);
|
||||
fail_if_err (err);
|
||||
while (!(err = gpgme_data_read (dh, buf, 100, &nread)))
|
||||
fwrite (buf, nread, 1, stdout);
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
passphrase_cb (void *opaque, const char *desc, void **r_hd)
|
||||
{
|
||||
|
@ -188,25 +188,25 @@ main (int argc, char **argv )
|
||||
fail_if_err (err);
|
||||
|
||||
puts ("checking a valid message:\n");
|
||||
err = gpgme_op_verify (ctx, sig, text, &status );
|
||||
err = gpgme_op_verify (ctx, sig, text, NULL, &status);
|
||||
fail_if_err (err);
|
||||
print_sig_stat ( ctx, status );
|
||||
print_sig_stat (ctx, status);
|
||||
if (status != GPGME_SIG_STAT_GOOD)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: Wrong sig stat\n", __FILE__, __LINE__);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ( (nota=gpgme_get_notation (ctx)) )
|
||||
if ((nota = gpgme_get_notation (ctx)))
|
||||
printf ("---Begin Notation---\n%s---End Notation---\n", nota );
|
||||
|
||||
puts ("checking a manipulated message:\n");
|
||||
gpgme_data_release (text);
|
||||
err = gpgme_data_new_from_mem ( &text,
|
||||
test_text1f, strlen (test_text1f), 0 );
|
||||
err = gpgme_data_new_from_mem (&text,
|
||||
test_text1f, strlen (test_text1f), 0);
|
||||
fail_if_err (err);
|
||||
gpgme_data_rewind ( sig );
|
||||
err = gpgme_op_verify (ctx, sig, text, &status );
|
||||
gpgme_data_rewind (sig);
|
||||
err = gpgme_op_verify (ctx, sig, text, NULL, &status);
|
||||
fail_if_err (err);
|
||||
|
||||
print_sig_stat (ctx, status);
|
||||
@ -215,17 +215,17 @@ main (int argc, char **argv )
|
||||
fprintf (stderr, "%s:%d: Wrong sig stat\n", __FILE__, __LINE__);
|
||||
exit (1);
|
||||
}
|
||||
if ( (nota=gpgme_get_notation (ctx)) )
|
||||
if ((nota = gpgme_get_notation (ctx)))
|
||||
printf ("---Begin Notation---\n%s---End Notation---\n", nota );
|
||||
|
||||
puts ("checking a normal signature:");
|
||||
gpgme_data_release (sig);
|
||||
gpgme_data_release (text);
|
||||
err = gpgme_data_new_from_mem (&sig, test_sig2, strlen (test_sig2), 0);
|
||||
err = gpgme_data_new_from_mem (&sig, test_sig2, strlen (test_sig2), 0);
|
||||
fail_if_err (err);
|
||||
err = gpgme_data_new (&text);
|
||||
fail_if_err (err);
|
||||
err = gpgme_op_verify (ctx, sig, text, &status);
|
||||
err = gpgme_op_verify (ctx, sig, NULL, text, &status);
|
||||
fail_if_err (err);
|
||||
|
||||
nota = gpgme_data_release_and_get_mem (text, &len);
|
||||
|
@ -49,21 +49,21 @@ static const char test_cip1[] =
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
{
|
||||
|
@ -33,37 +33,36 @@
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else {
|
||||
puts (s);
|
||||
free (s);
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
{
|
||||
|
@ -33,23 +33,21 @@
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
{
|
||||
|
@ -33,36 +33,38 @@
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
print_op_info (GpgmeCtx ctx)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
char *str = gpgme_get_op_info (ctx, 0);
|
||||
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else {
|
||||
puts (s);
|
||||
free (s);
|
||||
if (!str)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_data ( GpgmeData dh )
|
||||
print_data (GpgmeData dh)
|
||||
{
|
||||
char buf[100];
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
fail_if_err (err);
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GpgmeCtx ctx;
|
||||
GpgmeError err;
|
||||
|
@ -186,33 +186,33 @@ main (int argc, char **argv )
|
||||
fail_if_err (err);
|
||||
|
||||
puts ("checking a valid message:\n");
|
||||
err = gpgme_op_verify (ctx, sig, text, &status );
|
||||
print_sig_stat ( ctx, status );
|
||||
print_sig_stat ( ctx, status );
|
||||
print_sig_stat ( ctx, status );
|
||||
print_sig_stat ( ctx, status );
|
||||
err = gpgme_op_verify (ctx, sig, text, NULL, &status);
|
||||
print_sig_stat (ctx, status);
|
||||
print_sig_stat (ctx, status);
|
||||
print_sig_stat (ctx, status);
|
||||
print_sig_stat (ctx, status);
|
||||
fail_if_err (err);
|
||||
|
||||
if ( (nota=gpgme_get_notation (ctx)) )
|
||||
printf ("---Begin Notation---\n%s---End Notation---\n", nota );
|
||||
printf ("---Begin Notation---\n%s---End Notation---\n", nota);
|
||||
|
||||
puts ("checking a manipulated message:\n");
|
||||
gpgme_data_release (text);
|
||||
err = gpgme_data_new_from_mem ( &text,
|
||||
test_text1f, strlen (test_text1f), 0 );
|
||||
test_text1f, strlen (test_text1f), 0);
|
||||
fail_if_err (err);
|
||||
gpgme_data_rewind ( sig );
|
||||
err = gpgme_op_verify (ctx, sig, text, &status );
|
||||
err = gpgme_op_verify (ctx, sig, text, NULL, &status);
|
||||
|
||||
print_sig_stat ( ctx, status );
|
||||
print_sig_stat (ctx, status);
|
||||
fail_if_err (err);
|
||||
if ( (nota=gpgme_get_notation (ctx)) )
|
||||
printf ("---Begin Notation---\n%s---End Notation---\n", nota );
|
||||
if ((nota=gpgme_get_notation (ctx)))
|
||||
printf ("---Begin Notation---\n%s---End Notation---\n", nota);
|
||||
|
||||
gpgme_data_release (sig);
|
||||
gpgme_data_release (text);
|
||||
|
||||
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) && ++n < 20 );
|
||||
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) && ++n < 20 );
|
||||
gpgme_release (ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -106,12 +106,10 @@ read_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
|
||||
void
|
||||
read_once_test (round_t round, GpgmeData data)
|
||||
{
|
||||
GpgmeError err;
|
||||
char buffer[1024];
|
||||
size_t read;
|
||||
|
||||
err = gpgme_data_read (data, buffer, sizeof (buffer), &read);
|
||||
fail_if_err (err);
|
||||
read = gpgme_data_read (data, buffer, sizeof (buffer));
|
||||
|
||||
if (read != strlen (text) || strncmp (buffer, text, strlen (text)))
|
||||
{
|
||||
@ -120,8 +118,8 @@ read_once_test (round_t round, GpgmeData data)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
err = gpgme_data_read (data, buffer, sizeof (buffer), &read);
|
||||
if (err != GPGME_EOF)
|
||||
read = gpgme_data_read (data, buffer, sizeof (buffer));
|
||||
if (read)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: (%i) gpgme_data_read did not signal EOF\n",
|
||||
__FILE__, __LINE__, round);
|
||||
@ -138,8 +136,8 @@ read_test (round_t round, GpgmeData data)
|
||||
|
||||
if (round == TEST_INOUT_NONE)
|
||||
{
|
||||
err = gpgme_data_read (data, buffer, sizeof (buffer), &read);
|
||||
if (!err)
|
||||
read = gpgme_data_read (data, buffer, sizeof (buffer));
|
||||
if (read > 0)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: (%i) gpgme_data_read succeded unexpectedly\n",
|
||||
__FILE__, __LINE__, round);
|
||||
@ -159,12 +157,12 @@ write_test (round_t round, GpgmeData data)
|
||||
{
|
||||
GpgmeError err;
|
||||
char buffer[1024];
|
||||
size_t read;
|
||||
size_t amt;
|
||||
|
||||
err = gpgme_data_write (data, text, strlen (text));
|
||||
fail_if_err (err);
|
||||
amt = gpgme_data_write (data, text, strlen (text));
|
||||
if (amt != strlen (text))
|
||||
fail_if_err (GPGME_File_Error);
|
||||
|
||||
read_once_test (round, data);
|
||||
err = gpgme_data_rewind (data);
|
||||
fail_if_err (err);
|
||||
|
||||
@ -172,18 +170,17 @@ write_test (round_t round, GpgmeData data)
|
||||
read_once_test (round, data);
|
||||
else
|
||||
{
|
||||
err = gpgme_data_read (data, buffer, sizeof (buffer), &read);
|
||||
fail_if_err (err);
|
||||
amt = gpgme_data_read (data, buffer, sizeof (buffer));
|
||||
|
||||
if (read != strlen (text2) || strncmp (buffer, text2, strlen (text2)))
|
||||
if (amt != strlen (text2) || strncmp (buffer, text2, strlen (text2)))
|
||||
{
|
||||
fprintf (stderr, "%s:%d: (%i) gpgme_data_read returned wrong data\n",
|
||||
__FILE__, __LINE__, round);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
err = gpgme_data_read (data, buffer, sizeof (buffer), &read);
|
||||
if (err != GPGME_EOF)
|
||||
amt = gpgme_data_read (data, buffer, sizeof (buffer));
|
||||
if (amt)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: (%i) gpgme_data_read did not signal EOF\n",
|
||||
__FILE__, __LINE__, round);
|
||||
@ -193,7 +190,7 @@ write_test (round_t round, GpgmeData data)
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv )
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
round_t round = TEST_INITIALIZER;
|
||||
const char *text_filename = make_filename ("t-data-1.txt");
|
||||
@ -214,12 +211,6 @@ main (int argc, char **argv )
|
||||
"unexpectedly\n", __FILE__, __LINE__);
|
||||
exit (1);
|
||||
}
|
||||
if (gpgme_data_get_type (NULL) != GPGME_DATA_TYPE_NONE)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: gpgme_data_get_type on NULL incorrect\n",
|
||||
__FILE__, __LINE__);
|
||||
exit (1);
|
||||
}
|
||||
continue;
|
||||
case TEST_INOUT_NONE:
|
||||
err = gpgme_data_new (&data);
|
||||
@ -245,7 +236,7 @@ main (int argc, char **argv )
|
||||
case TEST_INOUT_MEM_FROM_FILE_NO_COPY:
|
||||
err = gpgme_data_new_from_file (&data, text_filename, 0);
|
||||
/* This is not implemented yet. */
|
||||
if (err == GPGME_Not_Implemented)
|
||||
if (err == GPGME_Not_Implemented || err == GPGME_Invalid_Value)
|
||||
continue;
|
||||
break;
|
||||
case TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME:
|
||||
@ -287,34 +278,6 @@ main (int argc, char **argv )
|
||||
}
|
||||
fail_if_err (err);
|
||||
|
||||
switch (round)
|
||||
{
|
||||
case TEST_INOUT_NONE:
|
||||
if (gpgme_data_get_type (data) != GPGME_DATA_TYPE_NONE)
|
||||
err = GPGME_Invalid_Type;
|
||||
break;
|
||||
case TEST_INOUT_MEM_NO_COPY:
|
||||
case TEST_INOUT_MEM_COPY:
|
||||
case TEST_INOUT_MEM_FROM_FILE_COPY:
|
||||
case TEST_INOUT_MEM_FROM_FILE_NO_COPY:
|
||||
case TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME:
|
||||
case TEST_INOUT_MEM_FROM_FILE_PART_BY_FP:
|
||||
if (gpgme_data_get_type (data) != GPGME_DATA_TYPE_MEM)
|
||||
err = GPGME_Invalid_Type;
|
||||
break;
|
||||
case TEST_OUT_CB:
|
||||
if (gpgme_data_get_type (data) != GPGME_DATA_TYPE_CB)
|
||||
err = GPGME_Invalid_Type;
|
||||
break;
|
||||
case TEST_INITIALIZER:
|
||||
case TEST_INVALID_ARGUMENT:
|
||||
case TEST_INOUT_MEM_FROM_INEXISTANT_FILE:
|
||||
case TEST_INOUT_MEM_FROM_INEXISTANT_FILE_PART:
|
||||
case TEST_END:
|
||||
/* Shouldn't happen. */
|
||||
fprintf (stderr, "%s:%d: impossible condition\n", __FILE__, __LINE__);
|
||||
exit (1);
|
||||
}
|
||||
read_test (round, data);
|
||||
if (round != TEST_OUT_CB)
|
||||
write_test (round, data);
|
||||
|
Loading…
Reference in New Issue
Block a user