2003-06-05 09:14:21 +02:00
|
|
|
/* filter.h
|
2006-04-19 13:26:11 +02:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
|
|
|
|
* 2005 Free Software Foundation, Inc.
|
2003-06-05 09:14:21 +02:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-04 21:49:40 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-05 09:14:21 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* 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
|
2007-07-04 21:49:40 +02:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2003-06-05 09:14:21 +02:00
|
|
|
*/
|
|
|
|
#ifndef G10_FILTER_H
|
|
|
|
#define G10_FILTER_H
|
|
|
|
|
|
|
|
#include "types.h"
|
gpg: Remove cipher.h and put algo ids into a common file.
* common/openpgpdefs.h (cipher_algo_t, pubkey_algo_t, digest_algo_t)
(compress_algo_t): New.
* agent/gpg-agent.c: Remove ../g10/cipher.h. Add openpgpdefs.h.
* g10/cipher.h (DEK): Move to ...
* g10/dek.h: new file.
* g10/cipher.h (is_RSA, is_ELGAMAL, is_DSA)
(PUBKEY_MAX_NPKEY, PUBKEY_MAX_NSKEY, PUBKEY_MAX_NSIG, PUBKEY_MAX_NENC)
(PUBKEY_USAGE_SIG, PUBKEY_USAGE_ENC, PUBKEY_USAGE_CERT)
(PUBKEY_USAGE_AUTH, PUBKEY_USAGE_NONE): Move to
* g10/packet.h: here.
* g10/cipher.h: Remove. Remove from all files.
* g10/filter.h, g10/packet.h: Include dek.h.
* g10/Makefile.am (common_source): Remove cipher.h. Add dek.h.
Signed-off-by: Werner Koch <wk@gnupg.org>
2014-01-29 20:35:05 +01:00
|
|
|
#include "dek.h"
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2006-04-19 13:26:11 +02:00
|
|
|
gcry_md_hd_t md; /* catch all */
|
|
|
|
gcry_md_hd_t md2; /* if we want to calculate an alternate hash */
|
2003-06-05 09:14:21 +02:00
|
|
|
size_t maxbuf_size;
|
|
|
|
} md_filter_context_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2006-12-06 11:16:50 +01:00
|
|
|
int refcount; /* Initialized to 1. */
|
|
|
|
|
2003-06-05 09:14:21 +02: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 */
|
|
|
|
|
2006-12-06 11:16:50 +01:00
|
|
|
/* these fields must be initialized to zero */
|
2003-06-05 09:14:21 +02:00
|
|
|
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;
|
2006-04-19 13:26:11 +02:00
|
|
|
byte eol[3]; /* The end of line characters as a
|
|
|
|
zero-terminated string. Defaults
|
|
|
|
(eol[0]=='\0') to whatever the local
|
|
|
|
platform uses. */
|
2003-06-05 09:14:21 +02: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 */
|
|
|
|
|
|
|
|
byte radbuf[4];
|
|
|
|
int idx, idx2;
|
|
|
|
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 */
|
|
|
|
} armor_filter_context_t;
|
|
|
|
|
|
|
|
struct unarmor_pump_s;
|
|
|
|
typedef struct unarmor_pump_s *UnarmorPump;
|
|
|
|
|
|
|
|
|
|
|
|
struct compress_filter_context_s {
|
|
|
|
int status;
|
|
|
|
void *opaque; /* (used for z_stream) */
|
|
|
|
byte *inbuf;
|
|
|
|
unsigned inbufsize;
|
|
|
|
byte *outbuf;
|
|
|
|
unsigned outbufsize;
|
|
|
|
int algo; /* compress algo */
|
|
|
|
int algo1hack;
|
|
|
|
int new_ctb;
|
|
|
|
void (*release)(struct compress_filter_context_s*);
|
|
|
|
};
|
|
|
|
typedef struct compress_filter_context_s compress_filter_context_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DEK *dek;
|
|
|
|
u32 datalen;
|
2006-04-19 13:26:11 +02:00
|
|
|
gcry_cipher_hd_t cipher_hd;
|
2003-06-05 09:14:21 +02:00
|
|
|
int header;
|
2006-04-19 13:26:11 +02:00
|
|
|
gcry_md_hd_t mdc_hash;
|
2003-06-05 09:14:21 +02:00
|
|
|
byte enchash[20];
|
|
|
|
int create_mdc; /* flag will be set by the cipher filter */
|
|
|
|
} cipher_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;
|
2006-04-19 13:26:11 +02:00
|
|
|
gcry_md_hd_t md;
|
2003-06-05 09:14:21 +02:00
|
|
|
int pending_lf;
|
|
|
|
int pending_esc;
|
|
|
|
} text_filter_context_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *what; /* description */
|
|
|
|
u32 last_time; /* last time reported */
|
|
|
|
unsigned long last; /* last amount reported */
|
|
|
|
unsigned long offset; /* current amount */
|
|
|
|
unsigned long total; /* total amount */
|
2011-02-04 12:57:53 +01:00
|
|
|
int refcount;
|
2003-06-05 09:14:21 +02:00
|
|
|
} progress_filter_context_t;
|
|
|
|
|
|
|
|
/* encrypt_filter_context_t defined in main.h */
|
|
|
|
|
|
|
|
/*-- mdfilter.c --*/
|
2006-04-19 15:24:36 +02:00
|
|
|
int md_filter( void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len);
|
2003-06-05 09:14:21 +02:00
|
|
|
void free_md_filter_context( md_filter_context_t *mfx );
|
|
|
|
|
|
|
|
/*-- armor.c --*/
|
2006-12-06 11:16:50 +01:00
|
|
|
armor_filter_context_t *new_armor_context (void);
|
|
|
|
void release_armor_context (armor_filter_context_t *afx);
|
|
|
|
int push_armor_filter (armor_filter_context_t *afx, iobuf_t iobuf);
|
2006-04-19 15:24:36 +02:00
|
|
|
int use_armor_filter( iobuf_t a );
|
2003-06-05 09:14:21 +02:00
|
|
|
UnarmorPump unarmor_pump_new (void);
|
|
|
|
void unarmor_pump_release (UnarmorPump x);
|
|
|
|
int unarmor_pump (UnarmorPump x, int c);
|
|
|
|
|
|
|
|
/*-- compress.c --*/
|
2006-04-19 15:24:36 +02:00
|
|
|
void push_compress_filter(iobuf_t out,compress_filter_context_t *zfx,int algo);
|
|
|
|
void push_compress_filter2(iobuf_t out,compress_filter_context_t *zfx,
|
2006-04-19 13:26:11 +02:00
|
|
|
int algo,int rel);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
/*-- cipher.c --*/
|
|
|
|
int cipher_filter( void *opaque, int control,
|
2006-04-19 15:24:36 +02:00
|
|
|
iobuf_t chain, byte *buf, size_t *ret_len);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
/*-- textfilter.c --*/
|
|
|
|
int text_filter( void *opaque, int control,
|
2006-04-19 15:24:36 +02:00
|
|
|
iobuf_t chain, byte *buf, size_t *ret_len);
|
|
|
|
int copy_clearsig_text (iobuf_t out, iobuf_t inp, gcry_md_hd_t md,
|
2006-04-19 13:26:11 +02:00
|
|
|
int escape_dash, int escape_from, int pgp2mode);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
/*-- progress.c --*/
|
2006-12-06 11:16:50 +01:00
|
|
|
progress_filter_context_t *new_progress_context (void);
|
|
|
|
void release_progress_context (progress_filter_context_t *pfx);
|
2003-06-05 09:14:21 +02:00
|
|
|
void handle_progress (progress_filter_context_t *pfx,
|
2006-04-19 15:24:36 +02:00
|
|
|
iobuf_t inp, const char *name);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
#endif /*G10_FILTER_H*/
|