Use p_new instead of xmalloc()
[apps/madmutt.git] / lib-crypt / pgplib.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996,1997 Michael R. Elkins <me@mutt.org>
4  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
5  *
6  * This file is part of mutt-ng, see http://www.muttng.org/.
7  * It's licensed under the GNU General Public License,
8  * please see the file GPL in the top level source directory.
9  */
10
11 #include "crypt.h"
12
13 typedef struct pgp_signature {
14   struct pgp_signature *next;
15   unsigned char sigtype;
16   unsigned long sid1;
17   unsigned long sid2;
18 } pgp_sig_t;
19
20 struct pgp_keyinfo {
21   char *keyid;
22   struct pgp_uid *address;
23   int flags;
24   short keylen;
25   time_t gen_time;
26   int numalg;
27   const char *algorithm;
28   struct pgp_keyinfo *parent;
29   struct pgp_signature *sigs;
30   struct pgp_keyinfo *next;
31
32   short fp_len;                 /* length of fingerprint.
33                                  * 20 for sha-1, 16 for md5.
34                                  */
35   unsigned char fingerprint[20];        /* large enough to hold SHA-1 and RIPEMD160
36                                            hashes (20 bytes), MD5 hashes just use the
37                                            first 16 bytes */
38 };
39
40 /* Note, that pgp_key_t is now pointer and declared in crypt.h */
41
42 typedef struct pgp_uid {
43   char *addr;
44   short trust;
45   int flags;
46   struct pgp_keyinfo *parent;
47   struct pgp_uid *next;
48   struct pgp_signature *sigs;
49 } pgp_uid_t;
50
51 enum pgp_version {
52   PGP_V2,
53   PGP_V3,
54   PGP_GPG,
55   PGP_UNKNOWN
56 };
57
58 /* prototypes */
59
60 const char *pgp_pkalgbytype (unsigned char);
61
62 pgp_key_t pgp_remove_key (pgp_key_t *, pgp_key_t);
63 pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t);
64
65 short pgp_canencrypt (unsigned char);
66 short pgp_cansign (unsigned char);
67 short pgp_get_abilities (unsigned char);
68
69 void pgp_free_key (pgp_key_t * kpp);
70
71 #define pgp_new_keyinfo() xmalloc(sizeof *((pgp_key_t)0))