}
}
-static pgp_key_t parse_pub_line(char *buf, int *is_subkey, pgp_key_t k)
+static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKeyInfo *k)
{
pgp_uid_t *uid = NULL;
int field = 0, is_uid = 0;
char *pend = NULL, *p = NULL;
int trust = 0;
int flags = 0;
- struct pgp_keyinfo tmp;
+ struct PgpKeyInfo tmp;
*is_subkey = 0;
if (!*buf)
return NULL;
}
-pgp_key_t pgp_get_candidates(pgp_ring_t keyring, struct List *hints)
+struct PgpKeyInfo *pgp_get_candidates(pgp_ring_t keyring, struct List *hints)
{
FILE *fp = NULL;
pid_t thepid;
char buf[LONG_STRING];
- pgp_key_t db = NULL, *kend, k = NULL, kk, mainkey = NULL;
+ struct PgpKeyInfo *db = NULL, **kend, *k = NULL, *kk = NULL, *mainkey = NULL;
int is_sub;
int devnull;
};
typedef enum pgp_ring pgp_ring_t;
-
-struct pgp_keyinfo;
-typedef struct pgp_keyinfo *pgp_key_t;
-
/* Some prototypes -- old crypt.h. */
int mutt_protect(struct Header *msg, char *keylist);
return true;
}
-static pgp_key_t _pgp_parent(pgp_key_t k)
+static struct PgpKeyInfo *_pgp_parent(struct PgpKeyInfo *k)
{
if ((k->flags & KEYFLAG_SUBKEY) && k->parent && option(OPTPGPIGNORESUB))
k = k->parent;
return k;
}
-char *pgp_long_keyid(pgp_key_t k)
+char *pgp_long_keyid(struct PgpKeyInfo *k)
{
k = _pgp_parent(k);
return k->keyid;
}
-char *pgp_short_keyid(pgp_key_t k)
+char *pgp_short_keyid(struct PgpKeyInfo *k)
{
k = _pgp_parent(k);
return k->keyid + 8;
}
-char *pgp_keyid(pgp_key_t k)
+char *pgp_keyid(struct PgpKeyInfo *k)
{
k = _pgp_parent(k);
return _pgp_keyid(k);
}
-char *_pgp_keyid(pgp_key_t k)
+char *_pgp_keyid(struct PgpKeyInfo *k)
{
if (option(OPTPGPLONGIDS))
return k->keyid;
return (k->keyid + 8);
}
-static char *pgp_fingerprint(pgp_key_t k)
+static char *pgp_fingerprint(struct PgpKeyInfo *k)
{
k = _pgp_parent(k);
* The longest available should be used for internally identifying
* the key and for invoking pgp commands.
*/
-char *pgp_fpr_or_lkeyid(pgp_key_t k)
+char *pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
{
char *fingerprint = NULL;
size_t keylist_used = 0;
struct Address *addr = NULL;
struct Address *p = NULL, *q = NULL;
- pgp_key_t k_info = NULL;
+ struct PgpKeyInfo *k_info = NULL;
char buf[LONG_STRING];
int r;
int key_selected;
int pgp_send_menu(struct Header *msg)
{
- pgp_key_t p;
+ struct PgpKeyInfo *p = NULL;
char input_signas[SHORT_STRING];
char *prompt = NULL, *letters = NULL, *choices = NULL;
char promptbuf[LONG_STRING];
struct Body *pgp_make_key_attachment(char *tempf);
const char *pgp_micalg(const char *fname);
-char *_pgp_keyid(pgp_key_t);
-char *pgp_keyid(pgp_key_t);
-char *pgp_short_keyid(pgp_key_t k);
-char *pgp_long_keyid(pgp_key_t k);
-char *pgp_fpr_or_lkeyid(pgp_key_t k);
+char *_pgp_keyid(struct PgpKeyInfo *k);
+char *pgp_keyid(struct PgpKeyInfo *k);
+char *pgp_short_keyid(struct PgpKeyInfo *k);
+char *pgp_long_keyid(struct PgpKeyInfo *k);
+char *pgp_fpr_or_lkeyid(struct PgpKeyInfo *k);
int pgp_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
-pgp_key_t pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring);
-pgp_key_t pgp_get_candidates(pgp_ring_t keyring, struct List *hints);
-pgp_key_t pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode);
-pgp_key_t pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring);
+struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring);
+struct PgpKeyInfo *pgp_get_candidates(pgp_ring_t keyring, struct List *hints);
+struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode);
+struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring);
char *pgp_find_keys(struct Address *adrlist, int oppenc_mode);
return ' ';
}
-static pgp_key_t pgp_principal_key(pgp_key_t key)
+static struct PgpKeyInfo *pgp_principal_key(struct PgpKeyInfo *key)
{
if (key->flags & KEYFLAG_SUBKEY && key->parent)
return key->parent;
char fmt[16];
pgp_entry_t *entry = NULL;
pgp_uid_t *uid = NULL;
- pgp_key_t key, pkey;
+ struct PgpKeyInfo *key = NULL, *pkey = NULL;
int kflags = 0;
int optional = (flags & MUTT_FORMAT_OPTIONAL);
_pgp_compare_trust(a, b));
}
-static bool pgp_key_is_valid(pgp_key_t k)
+static bool pgp_key_is_valid(struct PgpKeyInfo *k)
{
- pgp_key_t pk = pgp_principal_key(k);
+ struct PgpKeyInfo *pk = pgp_principal_key(k);
if (k->flags & KEYFLAG_CANTUSE)
return false;
if (pk->flags & KEYFLAG_CANTUSE)
return rv;
}
-static pgp_key_t pgp_select_key(pgp_key_t keys, struct Address *p, const char *s)
+static struct PgpKeyInfo *pgp_select_key(struct PgpKeyInfo *keys, struct Address *p, const char *s)
{
int keymax;
pgp_uid_t **KeyTable;
char cmd[LONG_STRING], tempfile[_POSIX_PATH_MAX];
FILE *fp = NULL, *devnull = NULL;
pid_t thepid;
- pgp_key_t kp;
+ struct PgpKeyInfo *kp = NULL;
pgp_uid_t *a = NULL;
int (*f)(const void *, const void *);
return kp;
}
-pgp_key_t pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring)
+struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring)
{
- pgp_key_t key;
+ struct PgpKeyInfo *key = NULL;
char resp[SHORT_STRING];
struct pgp_cache *l = NULL;
FILE *devnull = NULL;
struct stat sb;
pid_t thepid;
- pgp_key_t key;
+ struct PgpKeyInfo *key = NULL;
unset_option(OPTPGPCHECKTRUST);
key = pgp_ask_for_key(_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
return hints;
}
-static pgp_key_t *pgp_get_lastp(pgp_key_t p)
+static struct PgpKeyInfo **pgp_get_lastp(struct PgpKeyInfo *p)
{
for (; p; p = p->next)
if (!p->next)
return NULL;
}
-pgp_key_t pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode)
+struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode)
{
struct Address *r = NULL, *p = NULL;
struct List *hints = NULL;
int multi = 0;
int match;
- pgp_key_t keys, k, kn;
- pgp_key_t the_strong_valid_key = NULL;
- pgp_key_t a_valid_addrmatch_key = NULL;
- pgp_key_t matches = NULL;
- pgp_key_t *last = &matches;
+ struct PgpKeyInfo *keys = NULL, *k = NULL, *kn = NULL;
+ struct PgpKeyInfo *the_strong_valid_key = NULL;
+ struct PgpKeyInfo *a_valid_addrmatch_key = NULL;
+ struct PgpKeyInfo *matches = NULL;
+ struct PgpKeyInfo **last = &matches;
pgp_uid_t *q = NULL;
if (a && a->mailbox)
return NULL;
}
-pgp_key_t pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring)
+struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring)
{
struct List *hints = NULL;
- pgp_key_t keys;
- pgp_key_t matches = NULL;
- pgp_key_t *last = &matches;
- pgp_key_t k, kn;
+ struct PgpKeyInfo *keys = NULL;
+ struct PgpKeyInfo *matches = NULL;
+ struct PgpKeyInfo **last = &matches;
+ struct PgpKeyInfo *k = NULL, *kn = NULL;
pgp_uid_t *a = NULL;
short match;
size_t l;
*upp = NULL;
}
-pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, pgp_key_t parent)
+pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, struct PgpKeyInfo *parent)
{
pgp_uid_t *l = NULL;
pgp_uid_t **lp = &l;
return l;
}
-static void _pgp_free_key(pgp_key_t *kpp)
+static void _pgp_free_key(struct PgpKeyInfo **kpp)
{
- pgp_key_t kp;
+ struct PgpKeyInfo *kp = NULL;
if (!kpp || !*kpp)
return;
pgp_free_uid(&kp->address);
FREE(&kp->keyid);
FREE(&kp->fingerprint);
- /* mutt_crypt.h: 'typedef struct pgp_keyinfo *pgp_key_t;' */
FREE(kpp);
}
-pgp_key_t pgp_remove_key(pgp_key_t *klist, pgp_key_t key)
+struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key)
{
- pgp_key_t *last = NULL;
- pgp_key_t p, q, r;
+ struct PgpKeyInfo **last = NULL;
+ struct PgpKeyInfo *p = NULL, *q = NULL, *r = NULL;
if (!klist || !*klist || !key)
return NULL;
return q;
}
-void pgp_free_key(pgp_key_t *kpp)
+void pgp_free_key(struct PgpKeyInfo **kpp)
{
- pgp_key_t p, q, r;
+ struct PgpKeyInfo *p = NULL, *q = NULL, *r = NULL;
if (!kpp || !*kpp)
return;
unsigned long sid2;
} pgp_sig_t;
-struct pgp_keyinfo
+struct PgpKeyInfo
{
char *keyid;
char *fingerprint;
time_t gen_time;
int numalg;
const char *algorithm;
- struct pgp_keyinfo *parent;
+ struct PgpKeyInfo *parent;
struct pgp_signature *sigs;
- struct pgp_keyinfo *next;
+ struct PgpKeyInfo *next;
};
-/* Note, that pgp_key_t is now pointer and declared in crypt.h */
typedef struct pgp_uid
{
char *addr;
short trust;
int flags;
- struct pgp_keyinfo *parent;
+ struct PgpKeyInfo *parent;
struct pgp_uid *next;
struct pgp_signature *sigs;
} pgp_uid_t;
const char *pgp_pkalgbytype(unsigned char type);
-pgp_key_t pgp_remove_key(pgp_key_t *klist, pgp_key_t key);
-pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, pgp_key_t parent);
+struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key);
+pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, struct PgpKeyInfo *parent);
bool pgp_canencrypt(unsigned char type);
bool pgp_cansign(unsigned char type);
short pgp_get_abilities(unsigned char type);
-void pgp_free_key(pgp_key_t *kpp);
+void pgp_free_key(struct PgpKeyInfo **kpp);
-static inline pgp_key_t pgp_new_keyinfo(void)
+static inline struct PgpKeyInfo *pgp_new_keyinfo(void)
{
- return safe_calloc(1, sizeof(*((pgp_key_t) 0)));
+ return safe_calloc(1, sizeof(struct PgpKeyInfo));
}
#endif /* CRYPT_BACKEND_CLASSIC_PGP */
}
}
-static void print_fingerprint(pgp_key_t p)
+static void print_fingerprint(struct PgpKeyInfo *p)
{
if (!p->fingerprint)
return;
}
}
-static void pgpring_dump_keyblock(pgp_key_t p)
+static void pgpring_dump_keyblock(struct PgpKeyInfo *p)
{
pgp_uid_t *uid = NULL;
short first;
return fingerprint;
}
-static pgp_key_t pgp_parse_pgp2_key(unsigned char *buff, size_t l)
+static struct PgpKeyInfo *pgp_parse_pgp2_key(unsigned char *buff, size_t l)
{
- pgp_key_t p;
+ struct PgpKeyInfo *p = NULL;
unsigned char alg;
unsigned char digest[MD5_DIGEST_LENGTH];
size_t expl;
*toff = j;
}
-static pgp_key_t pgp_parse_pgp3_key(unsigned char *buff, size_t l)
+static struct PgpKeyInfo *pgp_parse_pgp3_key(unsigned char *buff, size_t l)
{
- pgp_key_t p;
+ struct PgpKeyInfo *p = NULL;
unsigned char alg;
unsigned char digest[SHA_DIGEST_LENGTH];
unsigned char scratch[LONG_STRING];
return p;
}
-static pgp_key_t pgp_parse_keyinfo(unsigned char *buff, size_t l)
+static struct PgpKeyInfo *pgp_parse_keyinfo(unsigned char *buff, size_t l)
{
if (!buff || l < 2)
return NULL;
}
}
-static int pgp_parse_pgp2_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *s)
+static int pgp_parse_pgp2_sig(unsigned char *buff, size_t l, struct PgpKeyInfo *p, pgp_sig_t *s)
{
unsigned char sigtype;
time_t sig_gen_time;
return 0;
}
-static int pgp_parse_pgp3_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *s)
+static int pgp_parse_pgp3_sig(unsigned char *buff, size_t l, struct PgpKeyInfo *p, pgp_sig_t *s)
{
unsigned char sigtype;
unsigned char skt;
return 0;
}
-static int pgp_parse_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *sig)
+static int pgp_parse_sig(unsigned char *buff, size_t l, struct PgpKeyInfo *p, pgp_sig_t *sig)
{
if (!buff || l < 2 || !p)
return -1;
/* parse one key block, including all subkeys. */
-static pgp_key_t pgp_parse_keyblock(FILE *fp)
+static struct PgpKeyInfo *pgp_parse_keyblock(FILE *fp)
{
unsigned char *buff = NULL;
unsigned char pt = 0;
fpos_t pos;
- pgp_key_t root = NULL;
- pgp_key_t *last = &root;
- pgp_key_t p = NULL;
+ struct PgpKeyInfo *root = NULL;
+ struct PgpKeyInfo **last = &root;
+ struct PgpKeyInfo *p = NULL;
pgp_uid_t *uid = NULL;
pgp_uid_t **addr = NULL;
pgp_sig_t **lsig = NULL;
if (pgpring_string_matches_hint(tmp, hints, nhints))
{
- pgp_key_t p;
+ struct PgpKeyInfo *p = NULL;
fsetpos(rfp, &keypos);