summaryrefslogtreecommitdiffstats
path: root/pgp.h
blob: 80af9915b0bf51d4a022e4d42f2217ae0c273d68 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * 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, 
  PGP_V3, 
  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 */
  PGP_EXTRACT,		/* extract keys from messages */
  PGP_VERIFY_KEY,	/* verify key when selecting */
  PGP_EXTRACT_KEY,	/* extract keys from key ring */
  PGP_LAST_OP
};

struct pgp_vinfo
{
  enum pgp_version v;
  char *name;
  char **binary;
  char **pubring;
  char **secring;
  char **language;
};


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

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

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 *);

char *pgp_ask_for_key (const char *, KEYINFO *, char *, char *, short, char **);

char *pgp_binary(enum pgp_ops);
char *pgp_getring (enum pgp_ops, int);
char *pgp_keyid(KEYINFO *);
char *_pgp_keyid(KEYINFO *);

enum pgp_version pgp_version(enum pgp_ops);
struct pgp_vinfo *pgp_get_vinfo(enum pgp_ops);

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

int pgp_protect (HEADER *);
int pgp_query (BODY *);
int pgp_valid_passphrase (void);

KEYINFO *ki_getkeybyaddr (ADDRESS *, KEYINFO *, short);
KEYINFO *ki_getkeybystr (char *, KEYINFO *, short);
KEYINFO *pgp_read_keyring(const char *);

void application_pgp_handler (BODY *, STATE *);
void mutt_forget_passphrase (void);
void pgp_closedb (KEYINFO *);
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);

#define pgp_secring(a) pgp_getring(a, 0)
#define pgp_pubring(a) pgp_getring(a, 1)


pid_t pgp_invoke_decode(FILE **, FILE **, FILE **, int, int, int, const char *, int);
pid_t pgp_invoke_verify(FILE **, FILE **, FILE **, int, int, int, const char *, const char *);
pid_t pgp_invoke_decrypt(FILE **, FILE **, FILE **, int, int, int, const char *);
pid_t pgp_invoke_sign(FILE **, FILE **, FILE **, int, int, int, const char *);
pid_t pgp_invoke_encrypt(FILE **, FILE **, FILE **, int, int, int, const char *, const char *, int);
void  pgp_invoke_extract(const char *);
pid_t pgp_invoke_verify_key(FILE **, FILE **, FILE **, int, int, int, const char *);
pid_t pgp_invoke_extract_key(FILE **, FILE **, FILE **, int, int, int, const char *);


#endif /* _PGPPATH */