Andreas Krennmair:
[apps/madmutt.git] / pgplib.h
1 /*
2  * Copyright (C) 1996,1997 Michael R. Elkins <me@mutt.org>
3  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
4  *
5  *     This program is free software; you can redistribute it and/or modify
6  *     it under the terms of the GNU General Public License as published by
7  *     the Free Software Foundation; either version 2 of the License, or
8  *     (at your option) any later version.
9  * 
10  *     This program is distributed in the hope that it will be useful,
11  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *     GNU General Public License for more details.
14  * 
15  *     You should have received a copy of the GNU General Public License
16  *     along with this program; if not, write to the Free Software
17  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
18  */
19
20 #ifdef CRYPT_BACKEND_CLASSIC_PGP
21
22 #include "mutt_crypt.h"
23
24
25 typedef struct pgp_signature {
26   struct pgp_signature *next;
27   unsigned char sigtype;
28   unsigned long sid1;
29   unsigned long sid2;
30 } pgp_sig_t;
31
32 struct pgp_keyinfo {
33   char *keyid;
34   struct pgp_uid *address;
35   int flags;
36   short keylen;
37   time_t gen_time;
38   int numalg;
39   const char *algorithm;
40   struct pgp_keyinfo *parent;
41   struct pgp_signature *sigs;
42   struct pgp_keyinfo *next;
43
44   short fp_len;                 /* length of fingerprint.
45                                  * 20 for sha-1, 16 for md5.
46                                  */
47   unsigned char fingerprint[20];        /* large enough to hold SHA-1 and RIPEMD160
48                                            hashes (20 bytes), MD5 hashes just use the
49                                            first 16 bytes */
50 };
51
52 /* Note, that pgp_key_t is now pointer and declared in crypt.h */
53
54 typedef struct pgp_uid {
55   char *addr;
56   short trust;
57   int flags;
58   struct pgp_keyinfo *parent;
59   struct pgp_uid *next;
60   struct pgp_signature *sigs;
61 } pgp_uid_t;
62
63 enum pgp_version {
64   PGP_V2,
65   PGP_V3,
66   PGP_GPG,
67   PGP_UNKNOWN
68 };
69
70 /* prototypes */
71
72 const char *pgp_pkalgbytype (unsigned char);
73
74 pgp_key_t pgp_remove_key (pgp_key_t *, pgp_key_t);
75 pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t);
76
77 short pgp_canencrypt (unsigned char);
78 short pgp_cansign (unsigned char);
79 short pgp_get_abilities (unsigned char);
80
81 void pgp_free_key (pgp_key_t * kpp);
82
83 #define pgp_new_keyinfo() safe_calloc (sizeof *((pgp_key_t)0), 1)
84
85 #endif /* CRYPT_BACKEND_CLASSIC_PGP */