pgp.h 9.02 KB
Newer Older
Thomas Roessler's avatar
Thomas Roessler committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
/*
 * Copyright (C) 1996,1997 Michael R. Elkins <me@cs.hmc.edu>
 * 
 *     This program is free software; you can redistribute it and/or modify
 *     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.
 * 
 *     This program 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
 *     along with this program; if not, write to the Free Software
 *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */ 

#ifdef _PGPPATH

#define PGPENCRYPT 1
#define PGPSIGN    2
#define PGPKEY     4

#define KEYFLAG_CANSIGN (1 << 0)
#define KEYFLAG_CANENCRYPT (1 << 1)
#define KEYFLAG_EXPIRED (1 << 8)
#define KEYFLAG_REVOKED (1 << 9)
#define KEYFLAG_DISABLED (1 << 10)
#define KEYFLAG_SUBKEY (1 << 11)
#define KEYFLAG_CRITICAL (1 << 12)
#define KEYFLAG_PREFER_ENCRYPTION (1 << 13)
#define KEYFLAG_PREFER_SIGNING (1 << 14)

typedef struct keyinfo
{
  char *keyid;
  LIST *address;
  short flags;
  short keylen;
  unsigned long gen_time;
  const char *algorithm;
  struct keyinfo *mainkey;
  struct keyinfo *next;
} KEYINFO;

typedef struct pgp_uid
{
  char *addr;
  short trust;
} PGPUID;

enum pgp_version 
{
  PGP_V2, 
56 57
  PGP_V3,
  PGP_GPG,
Thomas Roessler's avatar
Thomas Roessler committed
58 59 60 61 62 63 64 65 66 67
  PGP_UNKNOWN
};

enum pgp_ops
{
  PGP_DECODE,		/* application/pgp */
  PGP_VERIFY,		/* PGP/MIME, signed */
  PGP_DECRYPT,		/* PGP/MIME, encrypted */
  PGP_SIGN,		/* sign data */
  PGP_ENCRYPT,		/* encrypt data */
68
  PGP_IMPORT,		/* extract keys from messages */
Thomas Roessler's avatar
Thomas Roessler committed
69
  PGP_VERIFY_KEY,	/* verify key when selecting */
70
  PGP_EXPORT,		/* extract keys from key ring */
Thomas Roessler's avatar
Thomas Roessler committed
71 72 73 74 75
  PGP_LAST_OP
};

struct pgp_vinfo
{
76 77 78
  
  /* data */
  
Thomas Roessler's avatar
Thomas Roessler committed
79 80 81 82 83 84
  enum pgp_version v;
  char *name;
  char **binary;
  char **pubring;
  char **secring;
  char **language;
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
  
  /* functions */
  
  KEYINFO * (*read_pubring)(struct pgp_vinfo *);
  KEYINFO * (*read_secring)(struct pgp_vinfo *);
  
  pid_t (*invoke_decode)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
		      int, int, int,
		      const char *, int);
  
  pid_t (*invoke_verify)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
		      int, int, int,
		      const char *, const char *);
  
  pid_t (*invoke_decrypt)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
		       int, int, int,
		       const char *);
  
  pid_t (*invoke_sign)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
		    int, int, int,
		    const char *);

  pid_t (*invoke_encrypt)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
		       int, int, int,
		       const char *, const char *, int);
  
  void (*invoke_import)(struct pgp_vinfo *, const char *);
  
  pid_t (*invoke_export)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
		      int, int, int,
		      const char *);
  
  pid_t (*invoke_verify_key)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
			  int, int, int,
			  const char *);
  
Thomas Roessler's avatar
Thomas Roessler committed
121 122 123 124 125 126 127 128 129 130 131 132 133
};


WHERE char *PgpV2;
WHERE char *PgpV2Language;
WHERE char *PgpV2Pubring;
WHERE char *PgpV2Secring;

WHERE char *PgpV3;
WHERE char *PgpV3Language;
WHERE char *PgpV3Pubring;
WHERE char *PgpV3Secring;

134 135 136 137 138 139 140 141 142
WHERE char *PgpGpg;
#if 0
WHERE char *PgpGpgLanguage;
WHERE char *PgpGpgPubring;
WHERE char *PgpGpgSecring;
#else
WHERE char *PgpGpgDummy;
#endif

Thomas Roessler's avatar
Thomas Roessler committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
WHERE char *PgpSendVersion;
WHERE char *PgpReceiveVersion;
WHERE char *PgpKeyVersion;
WHERE char *PgpDefaultVersion;

WHERE char *PgpSignAs;
WHERE char *PgpSignMicalg;

WHERE short PgpTimeout;



BODY *pgp_decrypt_part (BODY *, STATE *, FILE *);
BODY *pgp_make_key_attachment (char *);

const char *pgp_pkalg_to_mic(const char *);

160
char *pgp_ask_for_key (struct pgp_vinfo *, KEYINFO *, char *, char *, short, char **);
Thomas Roessler's avatar
Thomas Roessler committed
161 162 163 164 165 166 167 168
char *pgp_keyid(KEYINFO *);
char *_pgp_keyid(KEYINFO *);

struct pgp_vinfo *pgp_get_vinfo(enum pgp_ops);

int mutt_check_pgp (HEADER *h);
int mutt_parse_pgp_hdr (char *, int);

169 170
int pgp_get_keys (HEADER *, char **);
int pgp_protect (HEADER *, char *);
Thomas Roessler's avatar
Thomas Roessler committed
171 172 173
int pgp_query (BODY *);
int pgp_valid_passphrase (void);

174 175 176 177 178 179
KEYINFO *ki_getkeybyaddr (struct pgp_vinfo *pgp, ADDRESS *, KEYINFO *, short);
KEYINFO *ki_getkeybystr (struct pgp_vinfo *pgp, char *, KEYINFO *, short);
KEYINFO *pgp_read_pubring(struct pgp_vinfo *pgp);
KEYINFO *pgp_read_secring(struct pgp_vinfo *pgp);
KEYINFO *gpg_read_pubring(struct pgp_vinfo *pgp);
KEYINFO *gpg_read_secring(struct pgp_vinfo *pgp);
Thomas Roessler's avatar
Thomas Roessler committed
180 181 182

void application_pgp_handler (BODY *, STATE *);
void mutt_forget_passphrase (void);
183
void pgp_close_keydb (KEYINFO **);
Thomas Roessler's avatar
Thomas Roessler committed
184 185 186 187 188 189
void pgp_encrypted_handler (BODY *, STATE *);
void pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top);
void pgp_extract_keys_from_messages(HEADER *hdr);
void pgp_signed_handler (BODY *, STATE *);
void pgp_void_passphrase (void);

190 191 192 193 194
short pgp_canencrypt(unsigned char);
short pgp_cansign(unsigned char);
short pgp_get_abilities(unsigned char);
const char *pgp_pkalgbytype(unsigned char);

Thomas Roessler's avatar
Thomas Roessler committed
195 196 197
#define pgp_secring(a) pgp_getring(a, 0)
#define pgp_pubring(a) pgp_getring(a, 1)

198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
/* PGP V2 prototypes */


pid_t pgp_v2_invoke_decode(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, int);

pid_t pgp_v2_invoke_verify(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, const char *);


pid_t pgp_v2_invoke_decrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *);

pid_t pgp_v2_invoke_sign(struct pgp_vinfo *, 
			      FILE **, FILE **, FILE **,
			      int, int, int,
			      const char *);

pid_t pgp_v2_invoke_encrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *, const char *, int);

void pgp_v2_invoke_import(struct pgp_vinfo *, const char *);

pid_t pgp_v2_invoke_export(struct pgp_vinfo*, 
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *);

pid_t pgp_v2_invoke_verify_key(struct pgp_vinfo *,
				    FILE **, FILE **, FILE **,
				    int, int, int,
				    const char *);

/* PGP V3 prototypes */

pid_t pgp_v3_invoke_decode(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, int);

pid_t pgp_v3_invoke_verify(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, const char *);


pid_t pgp_v3_invoke_decrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *);

pid_t pgp_v3_invoke_sign(struct pgp_vinfo *, 
			      FILE **, FILE **, FILE **,
			      int, int, int,
			      const char *);

pid_t pgp_v3_invoke_encrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *, const char *, int);

void pgp_v3_invoke_import(struct pgp_vinfo *, const char *);

pid_t pgp_v3_invoke_export(struct pgp_vinfo*, 
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *);

pid_t pgp_v3_invoke_verify_key(struct pgp_vinfo *,
				    FILE **, FILE **, FILE **,
				    int, int, int,
				    const char *);

/* GNU Privacy Guard Prototypes */

pid_t pgp_gpg_invoke_decode(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, int);

pid_t pgp_gpg_invoke_verify(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, const char *);


pid_t pgp_gpg_invoke_decrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *);

pid_t pgp_gpg_invoke_sign(struct pgp_vinfo *, 
			      FILE **, FILE **, FILE **,
			      int, int, int,
			      const char *);

pid_t pgp_gpg_invoke_encrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *, const char *, int);

void pgp_gpg_invoke_import(struct pgp_vinfo *, const char *);

pid_t pgp_gpg_invoke_export(struct pgp_vinfo*, 
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *);

pid_t pgp_gpg_invoke_verify_key(struct pgp_vinfo *,
				    FILE **, FILE **, FILE **,
				    int, int, int,
				    const char *);




#if 0

/* use these as templates for your own prototypes */


pid_t pgp_VERSION_invoke_decode(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, int);

pid_t pgp_VERSION_invoke_verify(struct pgp_vinfo *,
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *, const char *);


pid_t pgp_VERSION_invoke_decrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *);

pid_t pgp_VERSION_invoke_sign(struct pgp_vinfo *, 
			      FILE **, FILE **, FILE **,
			      int, int, int,
			      const char *);

pid_t pgp_VERSION_invoke_encrypt(struct pgp_vinfo *,
				 FILE **, FILE **, FILE **,
				 int, int, int,
				 const char *, const char *, int);

void pgp_VERSION_invoke_import(struct pgp_vinfo *, const char *);

pid_t pgp_VERSION_invoke_export(struct pgp_vinfo*, 
				FILE **, FILE **, FILE **,
				int, int, int,
				const char *);
Thomas Roessler's avatar
Thomas Roessler committed
359

360 361 362 363
pid_t pgp_VERSION_invoke_verify_key(struct pgp_vinfo *,
				    FILE **, FILE **, FILE **,
				    int, int, int,
				    const char *);
Thomas Roessler's avatar
Thomas Roessler committed
364

365
#endif
Thomas Roessler's avatar
Thomas Roessler committed
366 367

#endif /* _PGPPATH */