* gpgme.h (GpgmeData_Encoding): New.

* data.c (gpgme_data_get_encoding,gpgme_data_set_encoding): New.
* engine-gpgsm.c (map_input_enc): New. Use it in all local
functions where the INPUT command gets send.
This commit is contained in:
Werner Koch 2002-04-27 12:16:48 +00:00
parent 40717c3184
commit 1ac21c55c8
7 changed files with 73 additions and 7 deletions

3
NEWS
View File

@ -6,6 +6,9 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_get_passphrase_cb NEW gpgme_get_passphrase_cb NEW
gpgme_get_progress_cb NEW gpgme_get_progress_cb NEW
GpgmeDataEncoding NEW
gpgme_data_set_encoding NEW
gpgme_data_get_encoding NEW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Noteworthy changes in version 0.3.5 (2002-04-01) Noteworthy changes in version 0.3.5 (2002-04-01)

View File

@ -1,3 +1,10 @@
2002-04-27 Werner Koch <wk@gnupg.org>
* gpgme.h (GpgmeData_Encoding): New.
* data.c (gpgme_data_get_encoding,gpgme_data_set_encoding): New.
* engine-gpgsm.c (map_input_enc): New. Use it in all local
functions where the INPUT command gets send.
2002-04-27 Marcus Brinkmann <marcus@g10code.de> 2002-04-27 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_op_verify): Close the output * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Close the output

View File

@ -107,6 +107,7 @@ struct gpgme_data_s {
const char *data; const char *data;
GpgmeDataType type; GpgmeDataType type;
GpgmeDataMode mode; GpgmeDataMode mode;
GpgmeDataEncoding encoding;
int (*read_cb)( void *, char *, size_t, size_t *); int (*read_cb)( void *, char *, size_t, size_t *);
void *read_cb_value; void *read_cb_value;

View File

@ -465,6 +465,24 @@ gpgme_data_get_type (GpgmeData dh)
return dh->type; return dh->type;
} }
/* Get the current encoding meta information. */
GpgmeDataEncoding
gpgme_data_get_encoding (GpgmeData dh)
{
return dh? dh->encoding : GPGME_DATA_ENCODING_NONE;
}
/* Set the encoding meta information for DB to ENC */
GpgmeError
gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc)
{
if (!dh)
return GPGME_Invalid_Value;
if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR)
return GPGME_Invalid_Value;
dh->encoding = enc;
return 0;
}
void void
_gpgme_data_set_mode (GpgmeData dh, GpgmeDataMode mode) _gpgme_data_set_mode (GpgmeData dh, GpgmeDataMode mode)

View File

@ -503,6 +503,21 @@ gpgsm_set_fd (ASSUAN_CONTEXT ctx, const char *which, int fd, const char *opt)
} }
static const char *
map_input_enc (GpgmeData d)
{
switch (gpgme_data_get_encoding (d))
{
case GPGME_DATA_ENCODING_NONE: break;
case GPGME_DATA_ENCODING_BINARY: return "--binary";
case GPGME_DATA_ENCODING_BASE64: return "--base64";
case GPGME_DATA_ENCODING_ARMOR: return "--armor";
}
return NULL;
}
GpgmeError GpgmeError
_gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain) _gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain)
{ {
@ -516,7 +531,8 @@ _gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain)
return mk_error (Out_Of_Core); return mk_error (Out_Of_Core);
gpgsm->input_data = ciph; gpgsm->input_data = ciph;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_data));
if (err) if (err)
return mk_error (General_Error); /* FIXME */ return mk_error (General_Error); /* FIXME */
gpgsm->output_data = plain; gpgsm->output_data = plain;
@ -607,7 +623,8 @@ _gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp,
return mk_error (Out_Of_Core); return mk_error (Out_Of_Core);
gpgsm->input_data = plain; gpgsm->input_data = plain;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_data));
if (err) if (err)
return err; return err;
gpgsm->output_data = ciph; gpgsm->output_data = ciph;
@ -648,7 +665,8 @@ _gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor,
return mk_error (Out_Of_Core); return mk_error (Out_Of_Core);
gpgsm->input_data = help_data; gpgsm->input_data = help_data;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_data));
if (err) if (err)
return err; return err;
gpgsm->output_data = pubkey; gpgsm->output_data = pubkey;
@ -675,7 +693,8 @@ _gpgme_gpgsm_op_import (GpgsmObject gpgsm, GpgmeData keydata)
return mk_error (Out_Of_Core); return mk_error (Out_Of_Core);
gpgsm->input_data = keydata; gpgsm->input_data = keydata;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_data));
if (err) if (err)
return err; return err;
_gpgme_io_close (gpgsm->output_fd); _gpgme_io_close (gpgsm->output_fd);
@ -834,7 +853,8 @@ _gpgme_gpgsm_op_sign (GpgsmObject gpgsm, GpgmeData in, GpgmeData out,
return err; return err;
gpgsm->input_data = in; gpgsm->input_data = in;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_data));
if (err) if (err)
return err; return err;
gpgsm->output_data = out; gpgsm->output_data = out;
@ -869,7 +889,8 @@ _gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData text)
return mk_error (Out_Of_Core); return mk_error (Out_Of_Core);
gpgsm->input_data = sig; gpgsm->input_data = sig;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_data));
if (err) if (err)
return err; return err;
if (_gpgme_data_get_mode (text) == GPGME_DATA_MODE_IN) if (_gpgme_data_get_mode (text) == GPGME_DATA_MODE_IN)

View File

@ -140,7 +140,7 @@ gpgme_get_notation (GpgmeCtx ctx)
* @c: the context * @c: the context
* @reserved: * @reserved:
* *
* Return information about the last information. The caller has to * Return information about the last operation. The caller has to
* free the string. NULL is returned if there is not previous * free the string. NULL is returned if there is not previous
* operation available or the operation has not yet finished. * operation available or the operation has not yet finished.
* *

View File

@ -112,6 +112,16 @@ typedef enum
} }
GpgmeDataType; GpgmeDataType;
/* The possible encoding mode of GpgmeData objects. */
typedef enum
{
GPGME_DATA_ENCODING_NONE = 0, /* i.e. not specified */
GPGME_DATA_ENCODING_BINARY = 1,
GPGME_DATA_ENCODING_BASE64 = 2,
GPGME_DATA_ENCODING_ARMOR = 3 /* Either PEM or OpenPGP Armor */
}
GpgmeDataEncoding;
/* The possible signature stati. */ /* The possible signature stati. */
typedef enum typedef enum
{ {
@ -374,6 +384,12 @@ char *gpgme_data_release_and_get_mem (GpgmeData dh, size_t *r_len);
/* Return the type of the data buffer DH. */ /* Return the type of the data buffer DH. */
GpgmeDataType gpgme_data_get_type (GpgmeData 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. */
GpgmeError gpgme_data_rewind (GpgmeData dh); GpgmeError gpgme_data_rewind (GpgmeData dh);