1997-11-18 14:06:00 +00:00
|
|
|
/* filter.h
|
2005-01-06 16:23:47 +00:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
|
|
|
|
* 2005 Free Software Foundation, Inc.
|
1997-11-18 14:06:00 +00:00
|
|
|
*
|
1998-12-23 12:41:40 +00:00
|
|
|
* This file is part of GnuPG.
|
1997-11-18 14:06:00 +00:00
|
|
|
*
|
1998-12-23 12:41:40 +00:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
1997-11-18 14:06:00 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
1998-12-23 12:41:40 +00:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
1997-11-18 14:06:00 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
2002-06-29 13:46:34 +00:00
|
|
|
#ifndef G10_FILTER_H
|
|
|
|
#define G10_FILTER_H
|
1999-10-26 12:14:37 +00:00
|
|
|
|
2002-06-29 13:46:34 +00:00
|
|
|
#include "types.h"
|
|
|
|
#include "cipher.h"
|
1999-10-26 12:14:37 +00:00
|
|
|
|
1997-11-18 14:06:00 +00:00
|
|
|
typedef struct {
|
2002-06-29 13:46:34 +00:00
|
|
|
MD_HANDLE md; /* catch all */
|
|
|
|
MD_HANDLE md2; /* if we want to calculate an alternate hash */
|
1997-11-18 14:06:00 +00:00
|
|
|
size_t maxbuf_size;
|
|
|
|
} md_filter_context_t;
|
|
|
|
|
1997-11-21 14:53:57 +00:00
|
|
|
typedef struct {
|
1999-01-07 17:05:48 +00:00
|
|
|
/* these fields may be initialized */
|
|
|
|
int what; /* what kind of armor headers to write */
|
|
|
|
int only_keyblocks; /* skip all headers but ".... key block" */
|
|
|
|
const char *hdrlines; /* write these headerlines */
|
|
|
|
|
2000-07-14 17:34:53 +00:00
|
|
|
/* these fileds must be initialized to zero */
|
|
|
|
int no_openpgp_data; /* output flag: "No valid OpenPGP data found" */
|
|
|
|
|
1999-01-07 17:05:48 +00:00
|
|
|
/* the following fields must be initialized to zero */
|
|
|
|
int inp_checked; /* set if the input has been checked */
|
|
|
|
int inp_bypass; /* set if the input is not armored */
|
|
|
|
int in_cleartext; /* clear text message */
|
|
|
|
int not_dash_escaped; /* clear text is not dash escaped */
|
|
|
|
int hashes; /* detected hash algorithms */
|
|
|
|
int faked; /* we are faking a literal data packet */
|
|
|
|
int truncated; /* number of truncated lines */
|
1999-01-13 13:12:50 +00:00
|
|
|
int qp_detected;
|
1999-05-20 12:11:41 +00:00
|
|
|
int pgp2mode;
|
2005-01-06 16:23:47 +00:00
|
|
|
byte eol[3]; /* The end of line characters as a
|
|
|
|
zero-terminated string. Defaults
|
|
|
|
(eol[0]=='\0') to whatever the local
|
|
|
|
platform uses. */
|
1999-01-07 17:05:48 +00:00
|
|
|
|
|
|
|
byte *buffer; /* malloced buffer */
|
|
|
|
unsigned buffer_size; /* and size of this buffer */
|
|
|
|
unsigned buffer_len; /* used length of the buffer */
|
|
|
|
unsigned buffer_pos; /* read position */
|
|
|
|
|
1997-11-21 14:53:57 +00:00
|
|
|
byte radbuf[4];
|
1999-01-07 17:05:48 +00:00
|
|
|
int idx, idx2;
|
1997-11-21 14:53:57 +00:00
|
|
|
u32 crc;
|
1999-01-07 17:05:48 +00:00
|
|
|
|
|
|
|
int status; /* an internal state flag */
|
2000-07-14 17:34:53 +00:00
|
|
|
int cancel;
|
1999-01-07 17:05:48 +00:00
|
|
|
int any_data; /* any valid armored data seen */
|
1999-02-19 14:54:00 +00:00
|
|
|
int pending_lf; /* used together with faked */
|
1997-11-21 14:53:57 +00:00
|
|
|
} armor_filter_context_t;
|
|
|
|
|
2002-06-29 13:46:34 +00:00
|
|
|
struct unarmor_pump_s;
|
|
|
|
typedef struct unarmor_pump_s *UnarmorPump;
|
1997-11-18 14:06:00 +00:00
|
|
|
|
2002-06-29 13:46:34 +00:00
|
|
|
|
|
|
|
struct compress_filter_context_s {
|
1997-11-23 15:38:27 +00:00
|
|
|
int status;
|
|
|
|
void *opaque; /* (used for z_stream) */
|
|
|
|
byte *inbuf;
|
|
|
|
unsigned inbufsize;
|
|
|
|
byte *outbuf;
|
|
|
|
unsigned outbufsize;
|
1998-05-15 18:49:19 +00:00
|
|
|
int algo; /* compress algo */
|
1999-01-19 18:37:41 +00:00
|
|
|
int algo1hack;
|
2002-08-30 16:34:13 +00:00
|
|
|
int new_ctb;
|
2002-06-29 13:46:34 +00:00
|
|
|
void (*release)(struct compress_filter_context_s*);
|
|
|
|
};
|
|
|
|
typedef struct compress_filter_context_s compress_filter_context_t;
|
1997-11-23 15:38:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DEK *dek;
|
|
|
|
u32 datalen;
|
2002-06-29 13:46:34 +00:00
|
|
|
CIPHER_HANDLE cipher_hd;
|
1997-11-23 15:38:27 +00:00
|
|
|
int header;
|
2002-06-29 13:46:34 +00:00
|
|
|
MD_HANDLE mdc_hash;
|
2000-07-14 17:34:53 +00:00
|
|
|
byte enchash[20];
|
|
|
|
int create_mdc; /* flag will be set by the cipher filter */
|
1997-11-23 15:38:27 +00:00
|
|
|
} cipher_filter_context_t;
|
|
|
|
|
|
|
|
|
1999-10-26 12:14:37 +00:00
|
|
|
|
1997-12-23 17:30:18 +00:00
|
|
|
typedef struct {
|
1999-01-17 10:06:03 +00:00
|
|
|
byte *buffer; /* malloced buffer */
|
|
|
|
unsigned buffer_size; /* and size of this buffer */
|
|
|
|
unsigned buffer_len; /* used length of the buffer */
|
|
|
|
unsigned buffer_pos; /* read position */
|
|
|
|
int truncated; /* number of truncated lines */
|
1999-01-20 18:10:35 +00:00
|
|
|
int not_dash_escaped;
|
|
|
|
int escape_from;
|
2002-06-29 13:46:34 +00:00
|
|
|
MD_HANDLE md;
|
1999-01-20 18:10:35 +00:00
|
|
|
int pending_lf;
|
|
|
|
int pending_esc;
|
1997-12-23 17:30:18 +00:00
|
|
|
} text_filter_context_t;
|
1997-11-23 15:38:27 +00:00
|
|
|
|
1998-01-02 20:40:10 +00:00
|
|
|
|
2003-04-15 15:46:13 +00:00
|
|
|
typedef struct {
|
2003-05-26 13:21:12 +00:00
|
|
|
char *what; /* description */
|
2003-04-15 15:46:13 +00:00
|
|
|
u32 last_time; /* last time reported */
|
|
|
|
unsigned long last; /* last amount reported */
|
|
|
|
unsigned long offset; /* current amount */
|
|
|
|
unsigned long total; /* total amount */
|
|
|
|
} progress_filter_context_t;
|
|
|
|
|
2002-06-29 13:46:34 +00:00
|
|
|
/* encrypt_filter_context_t defined in main.h */
|
|
|
|
|
1997-11-18 14:06:00 +00:00
|
|
|
/*-- mdfilter.c --*/
|
|
|
|
int md_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len);
|
1997-11-24 11:04:11 +00:00
|
|
|
void free_md_filter_context( md_filter_context_t *mfx );
|
1997-11-18 14:06:00 +00:00
|
|
|
|
1997-11-21 14:53:57 +00:00
|
|
|
/*-- armor.c --*/
|
1998-02-16 20:05:02 +00:00
|
|
|
int use_armor_filter( IOBUF a );
|
1997-11-21 14:53:57 +00:00
|
|
|
int armor_filter( void *opaque, int control,
|
|
|
|
IOBUF chain, byte *buf, size_t *ret_len);
|
2002-06-29 13:46:34 +00:00
|
|
|
UnarmorPump unarmor_pump_new (void);
|
|
|
|
void unarmor_pump_release (UnarmorPump x);
|
|
|
|
int unarmor_pump (UnarmorPump x, int c);
|
1997-11-21 14:53:57 +00:00
|
|
|
|
1997-11-23 15:38:27 +00:00
|
|
|
/*-- compress.c --*/
|
* misc.c (compress_algo_to_string, string_to_compress_algo,
check_compress_algo): Add bzip2.
* compress.c (compress_filter): Make static to help force the use of
push_compress_filter. Remove default algorithm setting since that is done
in push_compress_filter now.
* main.h: Use named algorithm.
* filter.h, compress.c (push_compress_filter, push_compress_filter2): New.
Figure out which is the appropriate compression filter to use, and push it
into place.
* compress.c (handle_compressed), encode.c (encode_simple, encode_crypt),
sign.c (sign_file, sign_symencrypt_file), import.c (read_block), export.c
(do_export): Use push_compress_filter instead of pushing the compression
filter ourselves.
* compress-bz2.c: New. Bzlib versions of the compression filter routines.
* Makefile.am: Include compress-bz2.c if bz2lib is available.
2003-10-31 05:39:02 +00:00
|
|
|
void push_compress_filter(IOBUF out,compress_filter_context_t *zfx,int algo);
|
|
|
|
void push_compress_filter2(IOBUF out,compress_filter_context_t *zfx,
|
|
|
|
int algo,int rel);
|
1997-11-23 15:38:27 +00:00
|
|
|
|
|
|
|
/*-- cipher.c --*/
|
|
|
|
int cipher_filter( void *opaque, int control,
|
|
|
|
IOBUF chain, byte *buf, size_t *ret_len);
|
|
|
|
|
1997-12-23 17:30:18 +00:00
|
|
|
/*-- textfilter.c --*/
|
|
|
|
int text_filter( void *opaque, int control,
|
|
|
|
IOBUF chain, byte *buf, size_t *ret_len);
|
2002-06-29 13:46:34 +00:00
|
|
|
int copy_clearsig_text( IOBUF out, IOBUF inp, MD_HANDLE md,
|
1999-05-20 12:11:41 +00:00
|
|
|
int escape_dash, int escape_from, int pgp2mode );
|
1997-12-23 17:30:18 +00:00
|
|
|
|
2003-04-15 15:46:13 +00:00
|
|
|
/*-- progress.c --*/
|
|
|
|
int progress_filter (void *opaque, int control,
|
|
|
|
IOBUF a, byte *buf, size_t *ret_len);
|
|
|
|
void handle_progress (progress_filter_context_t *pfx,
|
2003-04-23 21:18:39 +00:00
|
|
|
IOBUF inp, const char *name);
|
1997-11-23 15:38:27 +00:00
|
|
|
|
2002-06-29 13:46:34 +00:00
|
|
|
#endif /*G10_FILTER_H*/
|