]> git.sthu.org Git - pgp-tools.git/blob - keyanalyze/pgpring/pgplib.h
* debian.control: added ${misc:Depends} as Depends for the keyanalyze
[pgp-tools.git] / keyanalyze / pgpring / pgplib.h
1 /*
2 * Copyright (C) 1996,1997 Michael R. Elkins <me@cs.hmc.edu>
3 * Copyright (C) 1999-2000 Thomas Roessler <roessler@guug.de>
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 HAVE_PGP
21
22 #define PGPENCRYPT (1 << 0)
23 #define PGPSIGN (1 << 1)
24 #define PGPKEY (1 << 2)
25 #define PGPGOODSIGN (1 << 3)
26
27 #define KEYFLAG_CANSIGN (1 << 0)
28 #define KEYFLAG_CANENCRYPT (1 << 1)
29 #define KEYFLAG_SECRET (1 << 7)
30 #define KEYFLAG_EXPIRED (1 << 8)
31 #define KEYFLAG_REVOKED (1 << 9)
32 #define KEYFLAG_DISABLED (1 << 10)
33 #define KEYFLAG_SUBKEY (1 << 11)
34 #define KEYFLAG_CRITICAL (1 << 12)
35 #define KEYFLAG_PREFER_ENCRYPTION (1 << 13)
36 #define KEYFLAG_PREFER_SIGNING (1 << 14)
37
38 #define KEYFLAG_CANTUSE (KEYFLAG_DISABLED|KEYFLAG_REVOKED|KEYFLAG_EXPIRED)
39 #define KEYFLAG_RESTRICTIONS (KEYFLAG_CANTUSE|KEYFLAG_CRITICAL)
40
41 #define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING)
42
43 typedef struct pgp_signature
44 {
45 struct pgp_signature *next;
46 unsigned char sigtype;
47 unsigned long sid1;
48 unsigned long sid2;
49 }
50 pgp_sig_t;
51
52 typedef struct pgp_keyinfo
53 {
54 char *keyid;
55 struct pgp_uid *address;
56 int flags;
57 short keylen;
58 time_t gen_time;
59 int numalg;
60 const char *algorithm;
61 struct pgp_keyinfo *parent;
62 struct pgp_signature *sigs;
63 struct pgp_keyinfo *next;
64 }
65 pgp_key_t;
66
67 typedef struct pgp_uid
68 {
69 char *addr;
70 short trust;
71 int flags;
72 struct pgp_keyinfo *parent;
73 struct pgp_uid *next;
74 struct pgp_signature *sigs;
75 }
76 pgp_uid_t;
77
78 enum pgp_version
79 {
80 PGP_V2,
81 PGP_V3,
82 PGP_GPG,
83 PGP_UNKNOWN
84 };
85
86 enum pgp_ring
87 {
88 PGP_PUBRING,
89 PGP_SECRING
90 };
91
92 typedef enum pgp_ring pgp_ring_t;
93
94 /* prototypes */
95
96 const char *pgp_pkalgbytype (unsigned char);
97
98 pgp_key_t *pgp_remove_key (pgp_key_t **, pgp_key_t *);
99 pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t *);
100
101 short pgp_canencrypt (unsigned char);
102 short pgp_cansign (unsigned char);
103 short pgp_get_abilities (unsigned char);
104
105 void pgp_free_key (pgp_key_t **kpp);
106
107 #define pgp_new_keyinfo() safe_calloc (sizeof (pgp_key_t), 1)
108
109 #endif /* HAVE_PGP */