mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Fix for bug 537
This commit is contained in:
parent
807cb227d1
commit
4b48bcacc9
111 changed files with 3111 additions and 2145 deletions
|
@ -1,3 +1,18 @@
|
|||
2006-10-02 Werner Koch <wk@g10code.com>
|
||||
|
||||
* encr-data.c (decrypt_data, mdc_decode_filter): Check the MDC
|
||||
right here and don't let parse-packet handle the MDC.
|
||||
|
||||
2006-09-29 Werner Koch <wk@g10code.com>
|
||||
|
||||
* compress.c (do_uncompress): Removed use of Z_PARTIAL_FLUSH.
|
||||
This is outdated and old zlib versions which still require it have
|
||||
security problems.
|
||||
|
||||
2006-09-27 Werner Koch <wk@g10code.com>
|
||||
|
||||
Replaced all STRLIST by strlist_t.
|
||||
|
||||
2006-09-21 Werner Koch <wk@g10code.com>
|
||||
|
||||
* signal.c (got_fatal_signal): Replaced readline stuff by a tty
|
||||
|
|
|
@ -992,7 +992,7 @@ armor_filter( void *opaque, int control,
|
|||
else if( control == IOBUFCTRL_FLUSH && !afx->cancel ) {
|
||||
if( !afx->status ) { /* write the header line */
|
||||
const char *s;
|
||||
STRLIST comment=opt.comments;
|
||||
strlist_t comment=opt.comments;
|
||||
|
||||
if( afx->what >= DIM(head_strings) )
|
||||
log_bug("afx->what=%d", afx->what);
|
||||
|
|
|
@ -1386,7 +1386,7 @@ card_edit_completion(const char *text, int start, int end)
|
|||
/* Menu to edit all user changeable values on an OpenPGP card. Only
|
||||
Key creation is not handled here. */
|
||||
void
|
||||
card_edit (STRLIST commands)
|
||||
card_edit (strlist_t commands)
|
||||
{
|
||||
enum cmdids cmd = cmdNOP;
|
||||
int have_commands = !!commands;
|
||||
|
|
|
@ -142,7 +142,7 @@ cipher_filter( void *opaque, int control,
|
|||
byte temp[22];
|
||||
|
||||
assert( hashlen == 20 );
|
||||
/* we must hash the prefix of the MDC packet here */
|
||||
/* We must hash the prefix of the MDC packet here. */
|
||||
temp[0] = 0xd3;
|
||||
temp[1] = 0x14;
|
||||
gcry_md_putc (cfx->mdc_hash, temp[0]);
|
||||
|
|
|
@ -45,6 +45,15 @@
|
|||
#include "main.h"
|
||||
#include "options.h"
|
||||
|
||||
|
||||
#ifdef __riscos__
|
||||
#define BYTEF_CAST(a) ((Bytef *)(a))
|
||||
#else
|
||||
#define BYTEF_CAST(a) (a)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int compress_filter_bz2( void *opaque, int control,
|
||||
IOBUF a, byte *buf, size_t *ret_len);
|
||||
|
||||
|
@ -92,11 +101,7 @@ do_compress( compress_filter_context_t *zfx, z_stream *zs, int flush, IOBUF a )
|
|||
unsigned n;
|
||||
|
||||
do {
|
||||
#ifndef __riscos__
|
||||
zs->next_out = zfx->outbuf;
|
||||
#else /* __riscos__ */
|
||||
zs->next_out = (Bytef *) zfx->outbuf;
|
||||
#endif /* __riscos__ */
|
||||
zs->next_out = BYTEF_CAST (zfx->outbuf);
|
||||
zs->avail_out = zfx->outbufsize;
|
||||
if( DBG_FILTER )
|
||||
log_debug("enter deflate: avail_in=%u, avail_out=%u, flush=%d\n",
|
||||
|
@ -171,11 +176,7 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
|
|||
if( zs->avail_in < zfx->inbufsize && refill ) {
|
||||
n = zs->avail_in;
|
||||
if( !n )
|
||||
#ifndef __riscos__
|
||||
zs->next_in = zfx->inbuf;
|
||||
#else /* __riscos__ */
|
||||
zs->next_in = (Bytef *) zfx->inbuf;
|
||||
#endif /* __riscos__ */
|
||||
zs->next_in = BYTEF_CAST (zfx->inbuf);
|
||||
count = zfx->inbufsize - n;
|
||||
nread = iobuf_read( a, zfx->inbuf + n, count );
|
||||
if( nread == -1 ) nread = 0;
|
||||
|
@ -194,11 +195,7 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
|
|||
if( DBG_FILTER )
|
||||
log_debug("enter inflate: avail_in=%u, avail_out=%u\n",
|
||||
(unsigned)zs->avail_in, (unsigned)zs->avail_out);
|
||||
#ifdef Z_SYNC_FLUSH
|
||||
zrc = inflate( zs, Z_SYNC_FLUSH );
|
||||
#else
|
||||
zrc = inflate( zs, Z_PARTIAL_FLUSH );
|
||||
#endif
|
||||
zrc = inflate ( zs, Z_SYNC_FLUSH );
|
||||
if( DBG_FILTER )
|
||||
log_debug("leave inflate: avail_in=%u, avail_out=%u, zrc=%d\n",
|
||||
(unsigned)zs->avail_in, (unsigned)zs->avail_out, zrc);
|
||||
|
@ -210,10 +207,12 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
|
|||
else
|
||||
log_fatal("zlib inflate problem: rc=%d\n", zrc );
|
||||
}
|
||||
} while( zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR );
|
||||
} while( zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR );
|
||||
|
||||
*ret_len = zfx->outbufsize - zs->avail_out;
|
||||
if( DBG_FILTER )
|
||||
log_debug("do_uncompress: returning %u bytes\n", (unsigned)*ret_len );
|
||||
log_debug("do_uncompress: returning %u bytes (%u ignored)\n",
|
||||
(unsigned int)*ret_len, (unsigned int)zs->avail_in );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -233,11 +232,7 @@ compress_filter( void *opaque, int control,
|
|||
zfx->status = 1;
|
||||
}
|
||||
|
||||
#ifndef __riscos__
|
||||
zs->next_out = buf;
|
||||
#else /* __riscos__ */
|
||||
zs->next_out = (Bytef *) buf;
|
||||
#endif /* __riscos__ */
|
||||
zs->next_out = BYTEF_CAST (buf);
|
||||
zs->avail_out = size;
|
||||
zfx->outbufsize = size; /* needed only for calculation */
|
||||
rc = do_uncompress( zfx, zs, a, ret_len );
|
||||
|
@ -262,11 +257,7 @@ compress_filter( void *opaque, int control,
|
|||
zfx->status = 2;
|
||||
}
|
||||
|
||||
#ifndef __riscos__
|
||||
zs->next_in = buf;
|
||||
#else /* __riscos__ */
|
||||
zs->next_in = (Bytef *) buf;
|
||||
#endif /* __riscos__ */
|
||||
zs->next_in = BYTEF_CAST (buf);
|
||||
zs->avail_in = size;
|
||||
rc = do_compress( zfx, zs, Z_NO_FLUSH, a );
|
||||
}
|
||||
|
@ -278,11 +269,7 @@ compress_filter( void *opaque, int control,
|
|||
xfree(zfx->outbuf); zfx->outbuf = NULL;
|
||||
}
|
||||
else if( zfx->status == 2 ) {
|
||||
#ifndef __riscos__
|
||||
zs->next_in = buf;
|
||||
#else /* __riscos__ */
|
||||
zs->next_in = (Bytef *) buf;
|
||||
#endif /* __riscos__ */
|
||||
zs->next_in = BYTEF_CAST (buf);
|
||||
zs->avail_in = 0;
|
||||
do_compress( zfx, zs, Z_FINISH, a );
|
||||
deflateEnd(zs);
|
||||
|
|
|
@ -186,7 +186,7 @@ do_delete_key( const char *username, int secret, int force, int *r_sec_avail )
|
|||
* Delete a public or secret key from a keyring.
|
||||
*/
|
||||
int
|
||||
delete_keys( STRLIST names, int secret, int allow_both )
|
||||
delete_keys( strlist_t names, int secret, int allow_both )
|
||||
{
|
||||
int rc, avail, force=(!allow_both && !secret && opt.expert);
|
||||
|
||||
|
|
|
@ -428,7 +428,7 @@ write_symkey_enc(STRING2KEY *symkey_s2k,DEK *symkey_dek,DEK *dek,IOBUF out)
|
|||
* is supplied).
|
||||
*/
|
||||
int
|
||||
encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
|
||||
encode_crypt( const char *filename, strlist_t remusr, int use_symkey )
|
||||
{
|
||||
IOBUF inp = NULL, out = NULL;
|
||||
PACKET pkt;
|
||||
|
@ -841,7 +841,7 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
|
|||
}
|
||||
|
||||
void
|
||||
encode_crypt_files(int nfiles, char **files, STRLIST remusr)
|
||||
encode_crypt_files(int nfiles, char **files, strlist_t remusr)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
419
g10/encr-data.c
419
g10/encr-data.c
|
@ -34,16 +34,16 @@
|
|||
#include "i18n.h"
|
||||
|
||||
|
||||
static int mdc_decode_filter( void *opaque, int control, IOBUF a,
|
||||
byte *buf, size_t *ret_len);
|
||||
static int decode_filter( void *opaque, int control, IOBUF a,
|
||||
static int mdc_decode_filter ( void *opaque, int control, IOBUF a,
|
||||
byte *buf, size_t *ret_len);
|
||||
static int decode_filter ( void *opaque, int control, IOBUF a,
|
||||
byte *buf, size_t *ret_len);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gcry_cipher_hd_t cipher_hd;
|
||||
gcry_md_hd_t mdc_hash;
|
||||
char defer[20];
|
||||
char defer[22];
|
||||
int defer_filled;
|
||||
int eof_seen;
|
||||
} decode_filter_ctx_t;
|
||||
|
@ -55,228 +55,271 @@ typedef struct
|
|||
int
|
||||
decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
|
||||
{
|
||||
decode_filter_ctx_t dfx;
|
||||
byte *p;
|
||||
int rc=0, c, i;
|
||||
byte temp[32];
|
||||
unsigned blocksize;
|
||||
unsigned nprefix;
|
||||
|
||||
memset( &dfx, 0, sizeof dfx );
|
||||
if( opt.verbose && !dek->algo_info_printed ) {
|
||||
const char *s = gcry_cipher_algo_name (dek->algo);
|
||||
if (s && *s)
|
||||
log_info(_("%s encrypted data\n"), s );
|
||||
else
|
||||
log_info(_("encrypted with unknown algorithm %d\n"), dek->algo );
|
||||
dek->algo_info_printed = 1;
|
||||
decode_filter_ctx_t dfx;
|
||||
byte *p;
|
||||
int rc=0, c, i;
|
||||
byte temp[32];
|
||||
unsigned blocksize;
|
||||
unsigned nprefix;
|
||||
|
||||
memset( &dfx, 0, sizeof dfx );
|
||||
if ( opt.verbose && !dek->algo_info_printed )
|
||||
{
|
||||
const char *s = gcry_cipher_algo_name (dek->algo);
|
||||
if (s && *s)
|
||||
log_info(_("%s encrypted data\n"), s );
|
||||
else
|
||||
log_info(_("encrypted with unknown algorithm %d\n"), dek->algo );
|
||||
dek->algo_info_printed = 1;
|
||||
}
|
||||
rc = openpgp_cipher_test_algo (dek->algo);
|
||||
if (rc)
|
||||
goto leave;
|
||||
blocksize = gcry_cipher_get_algo_blklen (dek->algo);
|
||||
if( !blocksize || blocksize > 16 )
|
||||
log_fatal("unsupported blocksize %u\n", blocksize );
|
||||
nprefix = blocksize;
|
||||
if( ed->len && ed->len < (nprefix+2) )
|
||||
BUG();
|
||||
rc = openpgp_cipher_test_algo (dek->algo);
|
||||
if (rc)
|
||||
goto leave;
|
||||
blocksize = gcry_cipher_get_algo_blklen (dek->algo);
|
||||
if ( !blocksize || blocksize > 16 )
|
||||
log_fatal("unsupported blocksize %u\n", blocksize );
|
||||
nprefix = blocksize;
|
||||
if ( ed->len && ed->len < (nprefix+2) )
|
||||
BUG();
|
||||
|
||||
if( ed->mdc_method ) {
|
||||
if (gcry_md_open (&dfx.mdc_hash, ed->mdc_method, 0 ))
|
||||
BUG ();
|
||||
if ( DBG_HASHING )
|
||||
gcry_md_start_debug (dfx.mdc_hash, "checkmdc");
|
||||
if ( ed->mdc_method )
|
||||
{
|
||||
if (gcry_md_open (&dfx.mdc_hash, ed->mdc_method, 0 ))
|
||||
BUG ();
|
||||
if ( DBG_HASHING )
|
||||
gcry_md_start_debug (dfx.mdc_hash, "checkmdc");
|
||||
}
|
||||
|
||||
rc = gcry_cipher_open (&dfx.cipher_hd, dek->algo,
|
||||
GCRY_CIPHER_MODE_CFB,
|
||||
(GCRY_CIPHER_SECURE
|
||||
| ((ed->mdc_method || dek->algo >= 100)?
|
||||
0 : GCRY_CIPHER_ENABLE_SYNC)));
|
||||
if (rc)
|
||||
{
|
||||
/* We should never get an error here cause we already checked
|
||||
* that the algorithm is available. */
|
||||
BUG();
|
||||
}
|
||||
|
||||
|
||||
/* log_hexdump( "thekey", dek->key, dek->keylen );*/
|
||||
rc = gcry_cipher_setkey (dfx.cipher_hd, dek->key, dek->keylen);
|
||||
if ( gpg_err_code (rc) == GPG_ERR_WEAK_KEY )
|
||||
{
|
||||
log_info(_("WARNING: message was encrypted with"
|
||||
" a weak key in the symmetric cipher.\n"));
|
||||
rc=0;
|
||||
}
|
||||
else if( rc )
|
||||
{
|
||||
log_error("key setup failed: %s\n", g10_errstr(rc) );
|
||||
goto leave;
|
||||
|
||||
}
|
||||
if (!ed->buf) {
|
||||
log_error(_("problem handling encrypted packet\n"));
|
||||
goto leave;
|
||||
rc = gcry_cipher_open (&dfx.cipher_hd, dek->algo,
|
||||
GCRY_CIPHER_MODE_CFB,
|
||||
(GCRY_CIPHER_SECURE
|
||||
| ((ed->mdc_method || dek->algo >= 100)?
|
||||
0 : GCRY_CIPHER_ENABLE_SYNC)));
|
||||
if (rc)
|
||||
{
|
||||
/* We should never get an error here cause we already checked
|
||||
* that the algorithm is available. */
|
||||
BUG();
|
||||
}
|
||||
|
||||
gcry_cipher_setiv (dfx.cipher_hd, NULL, 0);
|
||||
|
||||
if( ed->len ) {
|
||||
for(i=0; i < (nprefix+2) && ed->len; i++, ed->len-- ) {
|
||||
if( (c=iobuf_get(ed->buf)) == -1 )
|
||||
break;
|
||||
else
|
||||
temp[i] = c;
|
||||
}
|
||||
/* log_hexdump( "thekey", dek->key, dek->keylen );*/
|
||||
rc = gcry_cipher_setkey (dfx.cipher_hd, dek->key, dek->keylen);
|
||||
if ( gpg_err_code (rc) == GPG_ERR_WEAK_KEY )
|
||||
{
|
||||
log_info(_("WARNING: message was encrypted with"
|
||||
" a weak key in the symmetric cipher.\n"));
|
||||
rc=0;
|
||||
}
|
||||
else {
|
||||
for(i=0; i < (nprefix+2); i++ )
|
||||
if( (c=iobuf_get(ed->buf)) == -1 )
|
||||
break;
|
||||
else
|
||||
temp[i] = c;
|
||||
else if( rc )
|
||||
{
|
||||
log_error("key setup failed: %s\n", g10_errstr(rc) );
|
||||
goto leave;
|
||||
}
|
||||
|
||||
gcry_cipher_decrypt (dfx.cipher_hd, temp, nprefix+2, NULL, 0);
|
||||
gcry_cipher_sync (dfx.cipher_hd);
|
||||
p = temp;
|
||||
/* log_hexdump( "prefix", temp, nprefix+2 ); */
|
||||
if(dek->symmetric
|
||||
&& (p[nprefix-2] != p[nprefix] || p[nprefix-1] != p[nprefix+1]) )
|
||||
{
|
||||
rc = GPG_ERR_BAD_KEY;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if( dfx.mdc_hash )
|
||||
gcry_md_write (dfx.mdc_hash, temp, nprefix+2);
|
||||
|
||||
if( ed->mdc_method )
|
||||
iobuf_push_filter( ed->buf, mdc_decode_filter, &dfx );
|
||||
else
|
||||
iobuf_push_filter( ed->buf, decode_filter, &dfx );
|
||||
|
||||
proc_packets( procctx, ed->buf );
|
||||
ed->buf = NULL;
|
||||
if( ed->mdc_method && dfx.eof_seen == 2 )
|
||||
rc = gpg_error (GPG_ERR_INV_PACKET);
|
||||
else if( ed->mdc_method ) { /* check the mdc */
|
||||
int datalen = gcry_md_get_algo_dlen (ed->mdc_method);
|
||||
|
||||
gcry_cipher_decrypt (dfx.cipher_hd, dfx.defer, 20, NULL, 0);
|
||||
gcry_md_final (dfx.mdc_hash);
|
||||
if (datalen != 20
|
||||
|| memcmp (gcry_md_read( dfx.mdc_hash, 0 ), dfx.defer, datalen) )
|
||||
rc = gpg_error (GPG_ERR_BAD_SIGNATURE);
|
||||
/*log_hexdump("MDC calculated:", md_read( dfx.mdc_hash, 0), datalen);*/
|
||||
/*log_hexdump("MDC message :", dfx.defer, 20);*/
|
||||
if (!ed->buf)
|
||||
{
|
||||
log_error(_("problem handling encrypted packet\n"));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
||||
leave:
|
||||
gcry_cipher_close (dfx.cipher_hd);
|
||||
gcry_md_close (dfx.mdc_hash);
|
||||
return rc;
|
||||
gcry_cipher_setiv (dfx.cipher_hd, NULL, 0);
|
||||
|
||||
if ( ed->len )
|
||||
{
|
||||
for (i=0; i < (nprefix+2) && ed->len; i++, ed->len-- )
|
||||
{
|
||||
if ( (c=iobuf_get(ed->buf)) == -1 )
|
||||
break;
|
||||
else
|
||||
temp[i] = c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i < (nprefix+2); i++ )
|
||||
if ( (c=iobuf_get(ed->buf)) == -1 )
|
||||
break;
|
||||
else
|
||||
temp[i] = c;
|
||||
}
|
||||
|
||||
gcry_cipher_decrypt (dfx.cipher_hd, temp, nprefix+2, NULL, 0);
|
||||
gcry_cipher_sync (dfx.cipher_hd);
|
||||
p = temp;
|
||||
/* log_hexdump( "prefix", temp, nprefix+2 ); */
|
||||
if (dek->symmetric
|
||||
&& (p[nprefix-2] != p[nprefix] || p[nprefix-1] != p[nprefix+1]) )
|
||||
{
|
||||
rc = gpg_error (GPG_ERR_BAD_KEY);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if ( dfx.mdc_hash )
|
||||
gcry_md_write (dfx.mdc_hash, temp, nprefix+2);
|
||||
|
||||
if ( ed->mdc_method )
|
||||
iobuf_push_filter( ed->buf, mdc_decode_filter, &dfx );
|
||||
else
|
||||
iobuf_push_filter( ed->buf, decode_filter, &dfx );
|
||||
|
||||
proc_packets ( procctx, ed->buf );
|
||||
ed->buf = NULL;
|
||||
if ( ed->mdc_method && dfx.eof_seen == 2 )
|
||||
rc = gpg_error (GPG_ERR_INV_PACKET);
|
||||
else if ( ed->mdc_method )
|
||||
{
|
||||
/* We used to let parse-packet.c handle the MDC packet but this
|
||||
turned out to be a problem with compressed packets: With old
|
||||
style packets there is no length information available and
|
||||
the decompressor uses an implicit end. However we can't know
|
||||
this implicit end beforehand (:-) and thus may feed the
|
||||
decompressor with more bytes than actually needed. It would
|
||||
be possible to unread the extra bytes but due to our weird
|
||||
iobuf system any unread is non reliable due to filters
|
||||
already popped off. The easy and sane solution is to care
|
||||
about the MDC packet only here and never pass it to the
|
||||
packet parser. Fortunatley the OpenPGP spec requires a
|
||||
strict format for the MDC packet so that we know that 22
|
||||
bytes are appended. */
|
||||
int datalen = gcry_md_get_algo_dlen (ed->mdc_method);
|
||||
|
||||
gcry_cipher_decrypt (dfx.cipher_hd, dfx.defer, 22, NULL, 0);
|
||||
gcry_md_write (dfx.mdc_hash, dfx.defer, 2);
|
||||
gcry_md_final (dfx.mdc_hash);
|
||||
|
||||
if (dfx.defer[0] != '\xd3' || dfx.defer[1] != '\x14' )
|
||||
{
|
||||
log_error("mdc_packet with invalid encoding\n");
|
||||
rc = gpg_error (GPG_ERR_INV_PACKET);
|
||||
}
|
||||
else if (datalen != 20
|
||||
|| memcmp (gcry_md_read (dfx.mdc_hash, 0),dfx.defer+2,datalen))
|
||||
rc = gpg_error (GPG_ERR_BAD_SIGNATURE);
|
||||
/* log_printhex("MDC message:", dfx.defer, 22); */
|
||||
/* log_printhex("MDC calc:", gcry_md_read (dfx.mdc_hash,0), datalen); */
|
||||
}
|
||||
|
||||
|
||||
leave:
|
||||
gcry_cipher_close (dfx.cipher_hd);
|
||||
gcry_md_close (dfx.mdc_hash);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* I think we should merge this with cipher_filter */
|
||||
static int
|
||||
mdc_decode_filter( void *opaque, int control, IOBUF a,
|
||||
byte *buf, size_t *ret_len)
|
||||
mdc_decode_filter (void *opaque, int control, IOBUF a,
|
||||
byte *buf, size_t *ret_len)
|
||||
{
|
||||
decode_filter_ctx_t *dfx = opaque;
|
||||
size_t n, size = *ret_len;
|
||||
int rc = 0;
|
||||
int c;
|
||||
|
||||
if( control == IOBUFCTRL_UNDERFLOW && dfx->eof_seen ) {
|
||||
*ret_len = 0;
|
||||
rc = -1;
|
||||
decode_filter_ctx_t *dfx = opaque;
|
||||
size_t n, size = *ret_len;
|
||||
int rc = 0;
|
||||
int c;
|
||||
|
||||
if ( control == IOBUFCTRL_UNDERFLOW && dfx->eof_seen )
|
||||
{
|
||||
*ret_len = 0;
|
||||
rc = -1;
|
||||
}
|
||||
else if( control == IOBUFCTRL_UNDERFLOW ) {
|
||||
assert(a);
|
||||
assert( size > 40 );
|
||||
|
||||
/* get at least 20 bytes and put it somewhere ahead in the buffer */
|
||||
for(n=20; n < 40 ; n++ ) {
|
||||
if( (c = iobuf_get(a)) == -1 )
|
||||
break;
|
||||
buf[n] = c;
|
||||
else if( control == IOBUFCTRL_UNDERFLOW )
|
||||
{
|
||||
assert(a);
|
||||
assert( size > 44 );
|
||||
|
||||
/* Get at least 22 bytes and put it somewhere ahead in the buffer. */
|
||||
for(n=22; n < 44 ; n++ )
|
||||
{
|
||||
if( (c = iobuf_get(a)) == -1 )
|
||||
break;
|
||||
buf[n] = c;
|
||||
}
|
||||
if( n == 40 ) {
|
||||
/* we have enough stuff - flush the deferred stuff */
|
||||
/* (we have asserted that the buffer is large enough) */
|
||||
if( !dfx->defer_filled ) { /* the first time */
|
||||
memcpy(buf, buf+20, 20 );
|
||||
n = 20;
|
||||
if ( n == 44 )
|
||||
{
|
||||
/* We have enough stuff - flush the deferred stuff. */
|
||||
/* (we asserted that the buffer is large enough) */
|
||||
if ( !dfx->defer_filled ) /* First time. */
|
||||
{
|
||||
memcpy (buf, buf+22, 22 );
|
||||
n = 22;
|
||||
}
|
||||
else {
|
||||
memcpy(buf, dfx->defer, 20 );
|
||||
else
|
||||
{
|
||||
memcpy (buf, dfx->defer, 22 );
|
||||
}
|
||||
/* now fill up */
|
||||
for(; n < size; n++ ) {
|
||||
if( (c = iobuf_get(a)) == -1 )
|
||||
break;
|
||||
buf[n] = c;
|
||||
/* Now fill up. */
|
||||
for (; n < size; n++ )
|
||||
{
|
||||
if ( (c = iobuf_get(a)) == -1 )
|
||||
break;
|
||||
buf[n] = c;
|
||||
}
|
||||
/* move the last 20 bytes back to the defer buffer */
|
||||
/* (okay, we are wasting 20 bytes of supplied buffer) */
|
||||
n -= 20;
|
||||
memcpy( dfx->defer, buf+n, 20 );
|
||||
dfx->defer_filled = 1;
|
||||
/* Move the last 22 bytes back to the defer buffer. */
|
||||
/* (right, we are wasting 22 bytes of the supplied buffer.) */
|
||||
n -= 22;
|
||||
memcpy (dfx->defer, buf+n, 22 );
|
||||
dfx->defer_filled = 1;
|
||||
}
|
||||
else if( !dfx->defer_filled ) { /* eof seen buf empty defer */
|
||||
/* this is bad because there is an incomplete hash */
|
||||
n -= 20;
|
||||
memcpy(buf, buf+20, n );
|
||||
dfx->eof_seen = 2; /* eof with incomplete hash */
|
||||
else if ( !dfx->defer_filled ) /* EOF seen but empty defer buffer. */
|
||||
{
|
||||
/* This is bad because it means an incomplete hash. */
|
||||
n -= 22;
|
||||
memcpy (buf, buf+22, n );
|
||||
dfx->eof_seen = 2; /* EOF with incomplete hash. */
|
||||
}
|
||||
else { /* eof seen */
|
||||
memcpy(buf, dfx->defer, 20 );
|
||||
n -= 20;
|
||||
memcpy( dfx->defer, buf+n, 20 );
|
||||
dfx->eof_seen = 1; /* normal eof */
|
||||
else /* EOF seen (i.e. read less than 22 bytes). */
|
||||
{
|
||||
memcpy (buf, dfx->defer, 22 );
|
||||
n -= 22;
|
||||
memcpy (dfx->defer, buf+n, 22 );
|
||||
dfx->eof_seen = 1; /* Normal EOF. */
|
||||
}
|
||||
|
||||
if( n ) {
|
||||
gcry_cipher_decrypt (dfx->cipher_hd, buf, n, NULL, 0);
|
||||
gcry_md_write (dfx->mdc_hash, buf, n);
|
||||
if ( n )
|
||||
{
|
||||
gcry_cipher_decrypt (dfx->cipher_hd, buf, n, NULL, 0);
|
||||
gcry_md_write (dfx->mdc_hash, buf, n);
|
||||
}
|
||||
else {
|
||||
assert( dfx->eof_seen );
|
||||
rc = -1; /* eof */
|
||||
else
|
||||
{
|
||||
assert ( dfx->eof_seen );
|
||||
rc = -1; /* eof */
|
||||
}
|
||||
*ret_len = n;
|
||||
*ret_len = n;
|
||||
}
|
||||
else if( control == IOBUFCTRL_DESC ) {
|
||||
*(char**)buf = "mdc_decode_filter";
|
||||
else if ( control == IOBUFCTRL_DESC )
|
||||
{
|
||||
*(char**)buf = "mdc_decode_filter";
|
||||
}
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
decode_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len)
|
||||
{
|
||||
decode_filter_ctx_t *fc = opaque;
|
||||
size_t n, size = *ret_len;
|
||||
int rc = 0;
|
||||
|
||||
if( control == IOBUFCTRL_UNDERFLOW ) {
|
||||
assert(a);
|
||||
n = iobuf_read( a, buf, size );
|
||||
if( n == -1 ) n = 0;
|
||||
if( n )
|
||||
gcry_cipher_decrypt (fc->cipher_hd, buf, n, NULL, 0);
|
||||
else
|
||||
rc = -1; /* eof */
|
||||
*ret_len = n;
|
||||
decode_filter_ctx_t *fc = opaque;
|
||||
size_t n, size = *ret_len;
|
||||
int rc = 0;
|
||||
|
||||
if ( control == IOBUFCTRL_UNDERFLOW )
|
||||
{
|
||||
assert(a);
|
||||
n = iobuf_read ( a, buf, size );
|
||||
if ( n == -1 )
|
||||
n = 0;
|
||||
if ( n )
|
||||
gcry_cipher_decrypt (fc->cipher_hd, buf, n, NULL, 0);
|
||||
else
|
||||
rc = -1; /* EOF */
|
||||
*ret_len = n;
|
||||
}
|
||||
else if( control == IOBUFCTRL_DESC ) {
|
||||
*(char**)buf = "decode_filter";
|
||||
else if ( control == IOBUFCTRL_DESC )
|
||||
{
|
||||
*(char**)buf = "decode_filter";
|
||||
}
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
18
g10/export.c
18
g10/export.c
|
@ -47,8 +47,8 @@ struct subkey_list_s
|
|||
typedef struct subkey_list_s *subkey_list_t;
|
||||
|
||||
|
||||
static int do_export( STRLIST users, int secret, unsigned int options );
|
||||
static int do_export_stream( IOBUF out, STRLIST users, int secret,
|
||||
static int do_export( strlist_t users, int secret, unsigned int options );
|
||||
static int do_export_stream( IOBUF out, strlist_t users, int secret,
|
||||
KBNODE *keyblock_out, unsigned int options,
|
||||
int *any );
|
||||
static int build_sexp (iobuf_t out, PACKET *pkt, int *indent);
|
||||
|
@ -95,7 +95,7 @@ parse_export_options(char *str,unsigned int *options,int noisy)
|
|||
* options are defined in main.h.
|
||||
* If USERS is NULL, the complete ring will be exported. */
|
||||
int
|
||||
export_pubkeys( STRLIST users, unsigned int options )
|
||||
export_pubkeys( strlist_t users, unsigned int options )
|
||||
{
|
||||
return do_export( users, 0, options );
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ export_pubkeys( STRLIST users, unsigned int options )
|
|||
* been exported
|
||||
*/
|
||||
int
|
||||
export_pubkeys_stream( IOBUF out, STRLIST users,
|
||||
export_pubkeys_stream( IOBUF out, strlist_t users,
|
||||
KBNODE *keyblock_out, unsigned int options )
|
||||
{
|
||||
int any, rc;
|
||||
|
@ -117,7 +117,7 @@ export_pubkeys_stream( IOBUF out, STRLIST users,
|
|||
}
|
||||
|
||||
int
|
||||
export_seckeys( STRLIST users )
|
||||
export_seckeys( strlist_t users )
|
||||
{
|
||||
/* Use only relevant options for the secret key. */
|
||||
unsigned int options = (opt.export_options & EXPORT_SEXP_FORMAT);
|
||||
|
@ -125,7 +125,7 @@ export_seckeys( STRLIST users )
|
|||
}
|
||||
|
||||
int
|
||||
export_secsubkeys( STRLIST users )
|
||||
export_secsubkeys( strlist_t users )
|
||||
{
|
||||
/* Use only relevant options for the secret key. */
|
||||
unsigned int options = (opt.export_options & EXPORT_SEXP_FORMAT);
|
||||
|
@ -133,7 +133,7 @@ export_secsubkeys( STRLIST users )
|
|||
}
|
||||
|
||||
static int
|
||||
do_export( STRLIST users, int secret, unsigned int options )
|
||||
do_export( strlist_t users, int secret, unsigned int options )
|
||||
{
|
||||
IOBUF out = NULL;
|
||||
int any, rc;
|
||||
|
@ -290,7 +290,7 @@ exact_subkey_match_p (KEYDB_SEARCH_DESC *desc, KBNODE node)
|
|||
contains a pointer to the first keyblock found and exported. No
|
||||
other keyblocks are exported. The caller must free it. */
|
||||
static int
|
||||
do_export_stream( IOBUF out, STRLIST users, int secret,
|
||||
do_export_stream( IOBUF out, strlist_t users, int secret,
|
||||
KBNODE *keyblock_out, unsigned int options, int *any )
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -301,7 +301,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
|
|||
KEYDB_SEARCH_DESC *desc = NULL;
|
||||
subkey_list_t subkey_list = NULL; /* Track alreay processed subkeys. */
|
||||
KEYDB_HANDLE kdbhd;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
int indent = 0;
|
||||
|
||||
*any = 0;
|
||||
|
|
12
g10/getkey.c
12
g10/getkey.c
|
@ -808,14 +808,14 @@ skip_unusable(void *dummy,u32 *keyid,PKT_user_id *uid)
|
|||
*/
|
||||
|
||||
static int
|
||||
key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
||||
key_byname( GETKEY_CTX *retctx, strlist_t namelist,
|
||||
PKT_public_key *pk, PKT_secret_key *sk,
|
||||
int secmode, int include_unusable,
|
||||
KBNODE *ret_kb, KEYDB_HANDLE *ret_kdbhd )
|
||||
{
|
||||
int rc = 0;
|
||||
int n;
|
||||
STRLIST r;
|
||||
strlist_t r;
|
||||
GETKEY_CTX ctx;
|
||||
KBNODE help_kb = NULL;
|
||||
|
||||
|
@ -919,7 +919,7 @@ get_pubkey_byname (PKT_public_key *pk,
|
|||
KEYDB_HANDLE *ret_kdbhd, int include_unusable )
|
||||
{
|
||||
int rc;
|
||||
STRLIST namelist = NULL;
|
||||
strlist_t namelist = NULL;
|
||||
|
||||
add_to_strlist( &namelist, name );
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ get_pubkey_byname (PKT_public_key *pk,
|
|||
|
||||
int
|
||||
get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
STRLIST names, KBNODE *ret_keyblock )
|
||||
strlist_t names, KBNODE *ret_keyblock )
|
||||
{
|
||||
return key_byname( retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL);
|
||||
}
|
||||
|
@ -1195,7 +1195,7 @@ get_seckey_byname2( GETKEY_CTX *retctx,
|
|||
PKT_secret_key *sk, const char *name, int unprotect,
|
||||
KBNODE *retblock )
|
||||
{
|
||||
STRLIST namelist = NULL;
|
||||
strlist_t namelist = NULL;
|
||||
int rc,include_unusable=1;
|
||||
|
||||
/* If we have no name, try to use the default secret key. If we
|
||||
|
@ -1228,7 +1228,7 @@ get_seckey_byname( PKT_secret_key *sk, const char *name, int unlock )
|
|||
|
||||
int
|
||||
get_seckey_bynames( GETKEY_CTX *retctx, PKT_secret_key *sk,
|
||||
STRLIST names, KBNODE *ret_keyblock )
|
||||
strlist_t names, KBNODE *ret_keyblock )
|
||||
{
|
||||
return key_byname( retctx, names, NULL, sk, 1, 1, ret_keyblock, NULL );
|
||||
}
|
||||
|
|
10
g10/gpg.c
10
g10/gpg.c
|
@ -1371,7 +1371,7 @@ list_config(char *items)
|
|||
|
||||
for(iter=opt.grouplist;iter;iter=iter->next)
|
||||
{
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
printf("cfg:group:");
|
||||
print_string(stdout,iter->name,strlen(iter->name),':');
|
||||
|
@ -1728,8 +1728,8 @@ main (int argc, char **argv )
|
|||
const char *fname;
|
||||
char *username;
|
||||
int may_coredump;
|
||||
STRLIST sl, remusr= NULL, locusr=NULL;
|
||||
STRLIST nrings=NULL, sec_nrings=NULL;
|
||||
strlist_t sl, remusr= NULL, locusr=NULL;
|
||||
strlist_t nrings=NULL, sec_nrings=NULL;
|
||||
armor_filter_context_t afx;
|
||||
int detached_sig = 0;
|
||||
FILE *configfp = NULL;
|
||||
|
@ -4129,7 +4129,7 @@ static void
|
|||
add_policy_url( const char *string, int which )
|
||||
{
|
||||
unsigned int i,critical=0;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
if(*string=='!')
|
||||
{
|
||||
|
@ -4162,7 +4162,7 @@ static void
|
|||
add_keyserver_url( const char *string, int which )
|
||||
{
|
||||
unsigned int i,critical=0;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
if(*string=='!')
|
||||
{
|
||||
|
|
|
@ -131,8 +131,8 @@ main( int argc, char **argv )
|
|||
{
|
||||
ARGPARSE_ARGS pargs;
|
||||
int rc=0;
|
||||
STRLIST sl;
|
||||
STRLIST nrings=NULL;
|
||||
strlist_t sl;
|
||||
strlist_t nrings=NULL;
|
||||
unsigned configlineno;
|
||||
|
||||
set_strusage (my_strusage);
|
||||
|
@ -186,7 +186,7 @@ main( int argc, char **argv )
|
|||
for(sl = nrings; sl; sl = sl->next )
|
||||
keydb_add_resource (sl->d, 0, 0 );
|
||||
|
||||
FREE_STRLIST(nrings);
|
||||
FREE_STRLIST (nrings);
|
||||
|
||||
if( (rc = verify_signatures( argc, argv ) ))
|
||||
log_error("verify signatures failed: %s\n", g10_errstr(rc) );
|
||||
|
|
|
@ -647,7 +647,7 @@ check_prefs(KBNODE keyblock)
|
|||
|
||||
if(!opt.batch)
|
||||
{
|
||||
STRLIST sl=NULL,locusr=NULL;
|
||||
strlist_t sl=NULL,locusr=NULL;
|
||||
size_t fprlen=0;
|
||||
byte fpr[MAX_FINGERPRINT_LEN],*p;
|
||||
char username[(MAX_FINGERPRINT_LEN*2)+1];
|
||||
|
|
|
@ -182,7 +182,7 @@ int keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr);
|
|||
void show_revocation_reason( PKT_public_key *pk, int mode );
|
||||
int check_signatures_trust( PKT_signature *sig );
|
||||
void release_pk_list( PK_LIST pk_list );
|
||||
int build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use );
|
||||
int build_pk_list( strlist_t rcpts, PK_LIST *ret_pk_list, unsigned use );
|
||||
int algo_available( preftype_t preftype, int algo,
|
||||
const union pref_hint *hint );
|
||||
int select_algo_from_prefs( PK_LIST pk_list, int preftype,
|
||||
|
@ -192,7 +192,7 @@ int select_mdc_from_pklist (PK_LIST pk_list);
|
|||
/*-- skclist.c --*/
|
||||
int random_is_faked (void);
|
||||
void release_sk_list( SK_LIST sk_list );
|
||||
int build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
|
||||
int build_sk_list( strlist_t locusr, SK_LIST *ret_sk_list,
|
||||
int unlock, unsigned use );
|
||||
|
||||
/*-- passphrase.h --*/
|
||||
|
@ -225,7 +225,7 @@ int get_pubkey_byname( PKT_public_key *pk, const char *name,
|
|||
KBNODE *ret_keyblock, KEYDB_HANDLE *ret_kdbhd,
|
||||
int include_unusable );
|
||||
int get_pubkey_bynames( GETKEY_CTX *rx, PKT_public_key *pk,
|
||||
STRLIST names, KBNODE *ret_keyblock );
|
||||
strlist_t names, KBNODE *ret_keyblock );
|
||||
int get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock );
|
||||
void get_pubkey_end( GETKEY_CTX ctx );
|
||||
int get_seckey( PKT_secret_key *sk, u32 *keyid );
|
||||
|
@ -240,7 +240,7 @@ int get_keyblock_bylid( KBNODE *ret_keyblock, ulong lid );
|
|||
int seckey_available( u32 *keyid );
|
||||
int get_seckey_byname( PKT_secret_key *sk, const char *name, int unlock );
|
||||
int get_seckey_bynames( GETKEY_CTX *rx, PKT_secret_key *sk,
|
||||
STRLIST names, KBNODE *ret_keyblock );
|
||||
strlist_t names, KBNODE *ret_keyblock );
|
||||
int get_seckey_next (GETKEY_CTX ctx, PKT_secret_key *sk, KBNODE *ret_keyblock);
|
||||
void get_seckey_end( GETKEY_CTX ctx );
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
|
|||
* if some user_ids are marked those will be signed.
|
||||
*/
|
||||
static int
|
||||
sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
|
||||
sign_uids( KBNODE keyblock, strlist_t locusr, int *ret_modified,
|
||||
int local, int nonrevocable, int trust, int interactive )
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -1501,8 +1501,8 @@ keyedit_completion(const char *text, int start, int end)
|
|||
|
||||
|
||||
void
|
||||
keyedit_menu( const char *username, STRLIST locusr,
|
||||
STRLIST commands, int quiet, int seckey_check )
|
||||
keyedit_menu( const char *username, strlist_t locusr,
|
||||
strlist_t commands, int quiet, int seckey_check )
|
||||
{
|
||||
enum cmdids cmd = 0;
|
||||
int rc = 0;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "status.h"
|
||||
|
||||
static void list_all(int);
|
||||
static void list_one( STRLIST names, int secret);
|
||||
static void list_one( strlist_t names, int secret);
|
||||
static void print_card_serialno (PKT_secret_key *sk);
|
||||
|
||||
struct sig_stats
|
||||
|
@ -58,7 +58,7 @@ static FILE *attrib_fp=NULL;
|
|||
* If list is NULL, all available keys are listed
|
||||
*/
|
||||
void
|
||||
public_key_list( STRLIST list )
|
||||
public_key_list( strlist_t list )
|
||||
{
|
||||
if(opt.with_colons)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ public_key_list( STRLIST list )
|
|||
}
|
||||
|
||||
void
|
||||
secret_key_list( STRLIST list )
|
||||
secret_key_list( strlist_t list )
|
||||
{
|
||||
check_trustdb_stale ();
|
||||
|
||||
|
@ -462,7 +462,7 @@ list_all( int secret )
|
|||
|
||||
|
||||
static void
|
||||
list_one( STRLIST names, int secret )
|
||||
list_one( strlist_t names, int secret )
|
||||
{
|
||||
int rc = 0;
|
||||
KBNODE keyblock = NULL;
|
||||
|
|
|
@ -35,14 +35,14 @@ struct keyserver_spec *parse_keyserver_uri(const char *string,
|
|||
const char *configname,
|
||||
unsigned int configlineno);
|
||||
struct keyserver_spec *parse_preferred_keyserver(PKT_signature *sig);
|
||||
int keyserver_export(STRLIST users);
|
||||
int keyserver_import(STRLIST users);
|
||||
int keyserver_export(strlist_t users);
|
||||
int keyserver_import(strlist_t users);
|
||||
int keyserver_import_fprint(const byte *fprint,size_t fprint_len,
|
||||
struct keyserver_spec *keyserver);
|
||||
int keyserver_import_keyid(u32 *keyid,struct keyserver_spec *keyserver);
|
||||
int keyserver_refresh(STRLIST users);
|
||||
int keyserver_search(STRLIST tokens);
|
||||
int keyserver_fetch(STRLIST urilist);
|
||||
int keyserver_refresh(strlist_t users);
|
||||
int keyserver_search(strlist_t tokens);
|
||||
int keyserver_fetch(strlist_t urilist);
|
||||
int keyserver_import_cert(const char *name,
|
||||
unsigned char **fpr,size_t *fpr_len);
|
||||
int keyserver_import_pka(const char *name,unsigned char **fpr,size_t *fpr_len);
|
||||
|
|
|
@ -80,7 +80,7 @@ static struct parse_options keyserver_opts[]=
|
|||
{NULL,0,NULL,NULL}
|
||||
};
|
||||
|
||||
static int keyserver_work(enum ks_action action,STRLIST list,
|
||||
static int keyserver_work(enum ks_action action,strlist_t list,
|
||||
KEYDB_SEARCH_DESC *desc,int count,
|
||||
unsigned char **fpr,size_t *fpr_len,
|
||||
struct keyserver_spec *keyserver);
|
||||
|
@ -91,7 +91,7 @@ static int keyserver_work(enum ks_action action,STRLIST list,
|
|||
static size_t max_cert_size=DEFAULT_MAX_CERT_SIZE;
|
||||
|
||||
static void
|
||||
add_canonical_option(char *option,STRLIST *list)
|
||||
add_canonical_option(char *option,strlist_t *list)
|
||||
{
|
||||
char *arg=argsplit(option);
|
||||
|
||||
|
@ -952,12 +952,12 @@ direct_uri_map(const char *scheme,unsigned int is_direct)
|
|||
#define KEYSERVER_ARGS_NOKEEP " -o \"%o\" \"%i\""
|
||||
|
||||
static int
|
||||
keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
||||
keyserver_spawn(enum ks_action action,strlist_t list,KEYDB_SEARCH_DESC *desc,
|
||||
int count,int *prog,unsigned char **fpr,size_t *fpr_len,
|
||||
struct keyserver_spec *keyserver)
|
||||
{
|
||||
int ret=0,i,gotversion=0,outofband=0;
|
||||
STRLIST temp;
|
||||
strlist_t temp;
|
||||
unsigned int maxlen,buflen;
|
||||
char *command,*end,*searchstr=NULL;
|
||||
byte *line=NULL;
|
||||
|
@ -1167,7 +1167,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||
|
||||
case KS_GETNAME:
|
||||
{
|
||||
STRLIST key;
|
||||
strlist_t key;
|
||||
|
||||
fprintf(spawn->tochild,"COMMAND GETNAME\n\n");
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||
|
||||
case KS_SEND:
|
||||
{
|
||||
STRLIST key;
|
||||
strlist_t key;
|
||||
|
||||
/* Note the extra \n here to send an empty keylist block */
|
||||
fprintf(spawn->tochild,"COMMAND SEND\n\n\n");
|
||||
|
@ -1349,7 +1349,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||
|
||||
case KS_SEARCH:
|
||||
{
|
||||
STRLIST key;
|
||||
strlist_t key;
|
||||
|
||||
fprintf(spawn->tochild,"COMMAND SEARCH\n\n");
|
||||
|
||||
|
@ -1498,7 +1498,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||
}
|
||||
|
||||
static int
|
||||
keyserver_work(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
||||
keyserver_work(enum ks_action action,strlist_t list,KEYDB_SEARCH_DESC *desc,
|
||||
int count,unsigned char **fpr,size_t *fpr_len,
|
||||
struct keyserver_spec *keyserver)
|
||||
{
|
||||
|
@ -1568,9 +1568,9 @@ keyserver_work(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||
}
|
||||
|
||||
int
|
||||
keyserver_export(STRLIST users)
|
||||
keyserver_export(strlist_t users)
|
||||
{
|
||||
STRLIST sl=NULL;
|
||||
strlist_t sl=NULL;
|
||||
KEYDB_SEARCH_DESC desc;
|
||||
int rc=0;
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ keyserver_export(STRLIST users)
|
|||
}
|
||||
|
||||
int
|
||||
keyserver_import(STRLIST users)
|
||||
keyserver_import(strlist_t users)
|
||||
{
|
||||
KEYDB_SEARCH_DESC *desc;
|
||||
int num=100,count=0;
|
||||
|
@ -1675,13 +1675,13 @@ keyserver_import_keyid(u32 *keyid,struct keyserver_spec *keyserver)
|
|||
|
||||
/* code mostly stolen from do_export_stream */
|
||||
static int
|
||||
keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
|
||||
keyidlist(strlist_t users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
|
||||
{
|
||||
int rc=0,ndesc,num=100;
|
||||
KBNODE keyblock=NULL,node;
|
||||
KEYDB_HANDLE kdbhd;
|
||||
KEYDB_SEARCH_DESC *desc;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
*count=0;
|
||||
|
||||
|
@ -1831,7 +1831,7 @@ keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
|
|||
usernames to refresh only part of the keyring. */
|
||||
|
||||
int
|
||||
keyserver_refresh(STRLIST users)
|
||||
keyserver_refresh(strlist_t users)
|
||||
{
|
||||
int rc,count,numdesc,fakev3=0;
|
||||
KEYDB_SEARCH_DESC *desc;
|
||||
|
@ -1920,7 +1920,7 @@ keyserver_refresh(STRLIST users)
|
|||
}
|
||||
|
||||
int
|
||||
keyserver_search(STRLIST tokens)
|
||||
keyserver_search(strlist_t tokens)
|
||||
{
|
||||
if(tokens)
|
||||
return keyserver_work(KS_SEARCH,tokens,NULL,0,NULL,NULL,opt.keyserver);
|
||||
|
@ -1929,10 +1929,10 @@ keyserver_search(STRLIST tokens)
|
|||
}
|
||||
|
||||
int
|
||||
keyserver_fetch(STRLIST urilist)
|
||||
keyserver_fetch(strlist_t urilist)
|
||||
{
|
||||
KEYDB_SEARCH_DESC desc;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
unsigned int options=opt.keyserver_options.import_options;
|
||||
|
||||
/* Switch on fast-import, since fetch can handle more than one
|
||||
|
@ -2016,7 +2016,7 @@ keyserver_import_cert(const char *name,unsigned char **fpr,size_t *fpr_len)
|
|||
spec=parse_keyserver_uri(url,1,NULL,0);
|
||||
if(spec)
|
||||
{
|
||||
STRLIST list=NULL;
|
||||
strlist_t list=NULL;
|
||||
|
||||
add_to_strlist(&list,url);
|
||||
|
||||
|
@ -2083,7 +2083,7 @@ int
|
|||
keyserver_import_name(const char *name,unsigned char **fpr,size_t *fpr_len,
|
||||
struct keyserver_spec *keyserver)
|
||||
{
|
||||
STRLIST list=NULL;
|
||||
strlist_t list=NULL;
|
||||
int rc;
|
||||
|
||||
append_to_strlist(&list,name);
|
||||
|
@ -2102,7 +2102,7 @@ keyserver_import_ldap(const char *name,unsigned char **fpr,size_t *fpr_len)
|
|||
{
|
||||
char *domain;
|
||||
struct keyserver_spec *keyserver;
|
||||
STRLIST list=NULL;
|
||||
strlist_t list=NULL;
|
||||
int rc;
|
||||
|
||||
append_to_strlist(&list,name);
|
||||
|
|
38
g10/main.h
38
g10/main.h
|
@ -51,7 +51,7 @@ typedef struct
|
|||
struct groupitem
|
||||
{
|
||||
char *name;
|
||||
STRLIST values;
|
||||
strlist_t values;
|
||||
struct groupitem *next;
|
||||
};
|
||||
|
||||
|
@ -151,18 +151,18 @@ void display_online_help( const char *keyword );
|
|||
int setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek);
|
||||
int encode_symmetric( const char *filename );
|
||||
int encode_store( const char *filename );
|
||||
int encode_crypt( const char *filename, STRLIST remusr, int use_symkey );
|
||||
void encode_crypt_files(int nfiles, char **files, STRLIST remusr);
|
||||
int encode_crypt( const char *filename, strlist_t remusr, int use_symkey );
|
||||
void encode_crypt_files(int nfiles, char **files, strlist_t remusr);
|
||||
int encrypt_filter( void *opaque, int control,
|
||||
iobuf_t a, byte *buf, size_t *ret_len);
|
||||
|
||||
|
||||
/*-- sign.c --*/
|
||||
int complete_sig( PKT_signature *sig, PKT_secret_key *sk, gcry_md_hd_t md );
|
||||
int sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
||||
int do_encrypt, STRLIST remusr, const char *outfile );
|
||||
int clearsign_file( const char *fname, STRLIST locusr, const char *outfile );
|
||||
int sign_symencrypt_file (const char *fname, STRLIST locusr);
|
||||
int sign_file( strlist_t filenames, int detached, strlist_t locusr,
|
||||
int do_encrypt, strlist_t remusr, const char *outfile );
|
||||
int clearsign_file( const char *fname, strlist_t locusr, const char *outfile );
|
||||
int sign_symencrypt_file (const char *fname, strlist_t locusr);
|
||||
|
||||
/*-- sig-check.c --*/
|
||||
int check_revocation_keys (PKT_public_key *pk, PKT_signature *sig);
|
||||
|
@ -174,11 +174,11 @@ int check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk,
|
|||
u32 *r_expiredate, int *r_expired );
|
||||
|
||||
/*-- delkey.c --*/
|
||||
int delete_keys( STRLIST names, int secret, int allow_both );
|
||||
int delete_keys( strlist_t names, int secret, int allow_both );
|
||||
|
||||
/*-- keyedit.c --*/
|
||||
void keyedit_menu( const char *username, STRLIST locusr,
|
||||
STRLIST commands, int quiet, int seckey_check );
|
||||
void keyedit_menu( const char *username, strlist_t locusr,
|
||||
strlist_t commands, int quiet, int seckey_check );
|
||||
void show_basic_key_info (KBNODE keyblock);
|
||||
|
||||
/*-- keygen.c --*/
|
||||
|
@ -237,11 +237,11 @@ int auto_create_card_key_stub ( const char *serialnostr,
|
|||
|
||||
/*-- export.c --*/
|
||||
int parse_export_options(char *str,unsigned int *options,int noisy);
|
||||
int export_pubkeys( STRLIST users, unsigned int options );
|
||||
int export_pubkeys_stream( iobuf_t out, STRLIST users,
|
||||
int export_pubkeys( strlist_t users, unsigned int options );
|
||||
int export_pubkeys_stream( iobuf_t out, strlist_t users,
|
||||
KBNODE *keyblock_out, unsigned int options );
|
||||
int export_seckeys( STRLIST users );
|
||||
int export_secsubkeys( STRLIST users );
|
||||
int export_seckeys( strlist_t users );
|
||||
int export_secsubkeys( strlist_t users );
|
||||
|
||||
/* dearmor.c --*/
|
||||
int dearmor_file( const char *fname );
|
||||
|
@ -250,15 +250,15 @@ int enarmor_file( const char *fname );
|
|||
/*-- revoke.c --*/
|
||||
struct revocation_reason_info;
|
||||
int gen_revoke( const char *uname );
|
||||
int gen_desig_revoke( const char *uname, STRLIST locusr);
|
||||
int gen_desig_revoke( const char *uname, strlist_t locusr);
|
||||
int revocation_reason_build_cb( PKT_signature *sig, void *opaque );
|
||||
struct revocation_reason_info *
|
||||
ask_revocation_reason( int key_rev, int cert_rev, int hint );
|
||||
void release_revocation_reason_info( struct revocation_reason_info *reason );
|
||||
|
||||
/*-- keylist.c --*/
|
||||
void public_key_list( STRLIST list );
|
||||
void secret_key_list( STRLIST list );
|
||||
void public_key_list( strlist_t list );
|
||||
void secret_key_list( strlist_t list );
|
||||
void print_subpackets_colon(PKT_signature *sig);
|
||||
void reorder_keyblock (KBNODE keyblock);
|
||||
void list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque );
|
||||
|
@ -285,7 +285,7 @@ void decrypt_messages(int nfiles, char *files[]);
|
|||
|
||||
/*-- plaintext.c --*/
|
||||
int hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2,
|
||||
STRLIST files, const char *sigfilename, int textmode );
|
||||
strlist_t files, const char *sigfilename, int textmode );
|
||||
PKT_plaintext *setup_plaintext_name(const char *filename,IOBUF iobuf);
|
||||
|
||||
/*-- signal.c --*/
|
||||
|
@ -299,7 +299,7 @@ void unblock_all_signals(void);
|
|||
/*-- card-util.c --*/
|
||||
void change_pin (int no, int allow_admin);
|
||||
void card_status (FILE *fp, char *serialno, size_t serialnobuflen);
|
||||
void card_edit (STRLIST commands);
|
||||
void card_edit (strlist_t commands);
|
||||
int card_generate_subkey (KBNODE pub_keyblock, KBNODE sec_keyblock);
|
||||
int card_store_subkey (KBNODE node, int use);
|
||||
#endif
|
||||
|
|
|
@ -65,7 +65,7 @@ struct mainproc_context
|
|||
md_filter_context_t mfx;
|
||||
int sigs_only; /* Process only signatures and reject all other stuff. */
|
||||
int encrypt_only; /* Process only encryption messages. */
|
||||
STRLIST signed_data;
|
||||
strlist_t signed_data;
|
||||
const char *sigfilename;
|
||||
DEK *dek;
|
||||
int last_was_session_key;
|
||||
|
@ -1132,7 +1132,7 @@ proc_packets( void *anchor, IOBUF a )
|
|||
|
||||
int
|
||||
proc_signature_packets( void *anchor, IOBUF a,
|
||||
STRLIST signedfiles, const char *sigfilename )
|
||||
strlist_t signedfiles, const char *sigfilename )
|
||||
{
|
||||
CTX c = xmalloc_clear( sizeof *c );
|
||||
int rc;
|
||||
|
|
|
@ -114,7 +114,7 @@ struct
|
|||
int pgp2_workarounds;
|
||||
int shm_coprocess;
|
||||
const char *set_filename;
|
||||
STRLIST comments;
|
||||
strlist_t comments;
|
||||
int throw_keyid;
|
||||
const char *photo_viewer;
|
||||
int s2k_mode;
|
||||
|
@ -134,7 +134,7 @@ struct
|
|||
char *port;
|
||||
char *path;
|
||||
char *opaque;
|
||||
STRLIST options;
|
||||
strlist_t options;
|
||||
struct
|
||||
{
|
||||
unsigned int direct_uri:1;
|
||||
|
@ -146,7 +146,7 @@ struct
|
|||
unsigned int options;
|
||||
unsigned int import_options;
|
||||
unsigned int export_options;
|
||||
STRLIST other;
|
||||
strlist_t other;
|
||||
} keyserver_options;
|
||||
int exec_disable;
|
||||
int exec_path_set;
|
||||
|
@ -166,11 +166,11 @@ struct
|
|||
int interactive;
|
||||
struct notation *sig_notations;
|
||||
struct notation *cert_notations;
|
||||
STRLIST sig_policy_url;
|
||||
STRLIST cert_policy_url;
|
||||
STRLIST sig_keyserver_url;
|
||||
STRLIST cert_subpackets;
|
||||
STRLIST sig_subpackets;
|
||||
strlist_t sig_policy_url;
|
||||
strlist_t cert_policy_url;
|
||||
strlist_t sig_keyserver_url;
|
||||
strlist_t cert_subpackets;
|
||||
strlist_t sig_subpackets;
|
||||
int allow_non_selfsigned_uid;
|
||||
int allow_freeform_uid;
|
||||
int no_literal;
|
||||
|
|
|
@ -370,7 +370,7 @@ struct notation
|
|||
/*-- mainproc.c --*/
|
||||
int proc_packets( void *ctx, iobuf_t a );
|
||||
int proc_signature_packets( void *ctx, iobuf_t a,
|
||||
STRLIST signedfiles, const char *sigfile );
|
||||
strlist_t signedfiles, const char *sigfile );
|
||||
int proc_encryption_packets( void *ctx, iobuf_t a );
|
||||
int list_packets( iobuf_t a );
|
||||
|
||||
|
|
|
@ -2355,6 +2355,9 @@ parse_encrypted( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||
}
|
||||
|
||||
|
||||
/* Note, that this code is not anymore used in real life because now
|
||||
the MDC checking is done right after the encryption in
|
||||
decrypt_data. */
|
||||
static int
|
||||
parse_mdc( IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
PACKET *pkt, int new_ctb )
|
||||
|
@ -2363,7 +2366,7 @@ parse_mdc( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||
PKT_mdc *mdc;
|
||||
byte *p;
|
||||
|
||||
mdc = pkt->pkt.mdc= xmalloc(sizeof *pkt->pkt.mdc );
|
||||
mdc = pkt->pkt.mdc = xmalloc(sizeof *pkt->pkt.mdc );
|
||||
if( list_mode )
|
||||
fprintf (listfp, ":mdc packet: length=%lu\n", pktlen);
|
||||
if( !new_ctb || pktlen != 20 ) {
|
||||
|
|
|
@ -703,7 +703,7 @@ default_recipient(void)
|
|||
}
|
||||
|
||||
static int
|
||||
expand_id(const char *id,STRLIST *into,unsigned int flags)
|
||||
expand_id(const char *id,strlist_t *into,unsigned int flags)
|
||||
{
|
||||
struct groupitem *groups;
|
||||
int count=0;
|
||||
|
@ -713,7 +713,7 @@ expand_id(const char *id,STRLIST *into,unsigned int flags)
|
|||
/* need strcasecmp() here, as this should be localized */
|
||||
if(strcasecmp(groups->name,id)==0)
|
||||
{
|
||||
STRLIST each,sl;
|
||||
strlist_t each,sl;
|
||||
|
||||
/* this maintains the current utf8-ness */
|
||||
for(each=groups->values;each;each=each->next)
|
||||
|
@ -732,10 +732,10 @@ expand_id(const char *id,STRLIST *into,unsigned int flags)
|
|||
|
||||
/* For simplicity, and to avoid potential loops, we only expand once -
|
||||
you can't make an alias that points to an alias. */
|
||||
static STRLIST
|
||||
expand_group(STRLIST input)
|
||||
static strlist_t
|
||||
expand_group(strlist_t input)
|
||||
{
|
||||
STRLIST sl,output=NULL,rover;
|
||||
strlist_t sl,output=NULL,rover;
|
||||
|
||||
for(rover=input;rover;rover=rover->next)
|
||||
if(expand_id(rover->d,&output,rover->flags)==0)
|
||||
|
@ -771,13 +771,13 @@ expand_group(STRLIST input)
|
|||
not changed.
|
||||
*/
|
||||
int
|
||||
build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned int use )
|
||||
build_pk_list( strlist_t rcpts, PK_LIST *ret_pk_list, unsigned int use )
|
||||
{
|
||||
PK_LIST pk_list = NULL;
|
||||
PKT_public_key *pk=NULL;
|
||||
int rc=0;
|
||||
int any_recipients=0;
|
||||
STRLIST rov,remusr;
|
||||
strlist_t rov,remusr;
|
||||
char *def_rec = NULL;
|
||||
|
||||
/* Try to expand groups if any have been defined. */
|
||||
|
@ -875,7 +875,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned int use )
|
|||
{
|
||||
int have_def_rec;
|
||||
char *answer = NULL;
|
||||
STRLIST backlog = NULL;
|
||||
strlist_t backlog = NULL;
|
||||
|
||||
if (pk_list)
|
||||
any_recipients = 1;
|
||||
|
|
|
@ -515,12 +515,12 @@ ask_for_detached_datafile (gcry_md_hd_t md, gcry_md_hd_t md2,
|
|||
* If FILES is NULL, hash stdin.
|
||||
*/
|
||||
int
|
||||
hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2, STRLIST files,
|
||||
hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2, strlist_t files,
|
||||
const char *sigfilename, int textmode )
|
||||
{
|
||||
progress_filter_context_t pfx;
|
||||
IOBUF fp;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
if( !files ) {
|
||||
/* check whether we can open the signed material */
|
||||
|
|
|
@ -197,7 +197,7 @@ export_minimal_pk(IOBUF out,KBNODE keyblock,
|
|||
* Generate a revocation certificate for UNAME via a designated revoker
|
||||
*/
|
||||
int
|
||||
gen_desig_revoke( const char *uname, STRLIST locusr )
|
||||
gen_desig_revoke( const char *uname, strlist_t locusr )
|
||||
{
|
||||
int rc = 0;
|
||||
armor_filter_context_t afx;
|
||||
|
|
12
g10/sign.c
12
g10/sign.c
|
@ -66,7 +66,7 @@ mk_notation_policy_etc( PKT_signature *sig,
|
|||
{
|
||||
const char *string;
|
||||
char *s=NULL;
|
||||
STRLIST pu=NULL;
|
||||
strlist_t pu=NULL;
|
||||
struct notation *nd=NULL;
|
||||
struct expando_args args;
|
||||
|
||||
|
@ -735,8 +735,8 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, gcry_md_hd_t hash,
|
|||
* uncompressed, non-armored and in binary mode.
|
||||
*/
|
||||
int
|
||||
sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
||||
int encryptflag, STRLIST remusr, const char *outfile )
|
||||
sign_file( strlist_t filenames, int detached, strlist_t locusr,
|
||||
int encryptflag, strlist_t remusr, const char *outfile )
|
||||
{
|
||||
const char *fname;
|
||||
armor_filter_context_t afx;
|
||||
|
@ -987,7 +987,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
/* Setup the inner packet. */
|
||||
if( detached ) {
|
||||
if( multifile ) {
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
if( opt.verbose )
|
||||
log_info(_("signing:") );
|
||||
|
@ -1069,7 +1069,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
* make a clear signature. note that opt.armor is not needed
|
||||
*/
|
||||
int
|
||||
clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
|
||||
clearsign_file( const char *fname, strlist_t locusr, const char *outfile )
|
||||
{
|
||||
armor_filter_context_t afx;
|
||||
progress_filter_context_t pfx;
|
||||
|
@ -1223,7 +1223,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
|
|||
* FIXME: Far too much code is duplicated - revamp the whole file.
|
||||
*/
|
||||
int
|
||||
sign_symencrypt_file (const char *fname, STRLIST locusr)
|
||||
sign_symencrypt_file (const char *fname, strlist_t locusr)
|
||||
{
|
||||
armor_filter_context_t afx;
|
||||
progress_filter_context_t pfx;
|
||||
|
|
|
@ -115,7 +115,7 @@ key_present_in_sk_list(SK_LIST sk_list, PKT_secret_key *sk)
|
|||
}
|
||||
|
||||
static int
|
||||
is_duplicated_entry (STRLIST list, STRLIST item)
|
||||
is_duplicated_entry (strlist_t list, strlist_t item)
|
||||
{
|
||||
for(; list && list != item; list = list->next) {
|
||||
if ( !strcmp (list->d, item->d) )
|
||||
|
@ -126,7 +126,7 @@ is_duplicated_entry (STRLIST list, STRLIST item)
|
|||
|
||||
|
||||
int
|
||||
build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
|
||||
build_sk_list( strlist_t locusr, SK_LIST *ret_sk_list,
|
||||
int unlock, unsigned int use )
|
||||
{
|
||||
SK_LIST sk_list = NULL;
|
||||
|
@ -168,7 +168,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
|
|||
}
|
||||
}
|
||||
else {
|
||||
STRLIST locusr_orig = locusr;
|
||||
strlist_t locusr_orig = locusr;
|
||||
for(; locusr; locusr = locusr->next ) {
|
||||
PKT_secret_key *sk;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ verify_signatures( int nfiles, char **files )
|
|||
progress_filter_context_t pfx;
|
||||
const char *sigfile;
|
||||
int i, rc;
|
||||
STRLIST sl;
|
||||
strlist_t sl;
|
||||
|
||||
memset( &afx, 0, sizeof afx);
|
||||
/* decide whether we should handle a detached or a normal signature,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue