1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00
gnupg/g10/filter.h

141 lines
4.2 KiB
C
Raw Normal View History

1997-11-18 14:06:00 +00:00
/* filter.h
* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
1997-11-18 14:06:00 +00:00
*
* This file is part of GnuPG.
1997-11-18 14:06:00 +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.
*
* 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
*/
#ifndef GPG_FILTER_H
#define GPG_FILTER_H
1997-11-18 14:06:00 +00:00
#include <gcrypt.h>
#include "basicdefs.h"
#include "iobuf.h"
1997-11-18 14:06:00 +00:00
typedef struct {
GCRY_MD_HD md; /* catch all */
GCRY_MD_HD 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 {
/* 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 */
/* these fileds must be initialized to zero */
int no_openpgp_data; /* output flag: "No valid OpenPGP data found" */
/* 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 */
int qp_detected;
int pgp2mode;
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];
int idx, idx2;
1997-11-21 14:53:57 +00:00
u32 crc;
int status; /* an internal state flag */
int cancel;
int any_data; /* any valid armored data seen */
int pending_lf; /* used together with faked */
1997-11-21 14:53:57 +00:00
} armor_filter_context_t;
1997-11-18 14:06:00 +00:00
1997-11-23 15:38:27 +00:00
typedef struct {
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 */
int algo1hack;
1997-11-23 15:38:27 +00:00
} compress_filter_context_t;
typedef struct {
DEK *dek;
u32 datalen;
GCRY_CIPHER_HD cipher_hd;
1997-11-23 15:38:27 +00:00
int header;
GCRY_MD_HD mdc_hash;
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;
typedef struct {
int header_okay;
PK_LIST pk_list;
cipher_filter_context_t cfx;
} encrypt_filter_context_t;
typedef struct {
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 */
int not_dash_escaped;
int escape_from;
GCRY_MD_HD md;
int pending_lf;
int pending_esc;
} text_filter_context_t;
1997-11-23 15:38:27 +00:00
1998-01-02 20:40:10 +00:00
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);
1997-11-23 15:38:27 +00:00
/*-- compress.c --*/
int compress_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len);
/*-- cipher.c --*/
int cipher_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len);
/*-- textfilter.c --*/
int text_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len);
int copy_clearsig_text( IOBUF out, IOBUF inp, GCRY_MD_HD md,
int escape_dash, int escape_from, int pgp2mode );
1997-11-23 15:38:27 +00:00
#endif /*GPG_FILTER_H*/