pgppubring.c.
#include "mutt.h"
#include "pgp.h"
-static const char *
-pkalgbytype(unsigned char type)
-{
- switch(type)
- {
- case 1:
- case 2:
- case 3: return "RSA";
- case 16: /* encrypt only */
- case 20: return "ElG";
- case 17: return "DSA";
- default: return "unk";
- }
-}
-
-static short canencrypt(unsigned char type)
-{
- switch(type)
- {
- case 1:
- case 2:
- case 16:
- case 20:
- return 1;
- default:
- return 0;
- }
-}
-
-static short cansign(unsigned char type)
-{
- switch(type)
- {
- case 1:
- case 3:
- case 16: /* hmmm: this one can only sign if used in a v3 packet */
- case 17:
- case 20:
- return 1;
- default:
- return 0;
- }
-}
-/* return values:
- *
- * 1 = sign only
- * 2 = encrypt only
- * 3 = both
- */
-
-static short get_abilities(unsigned char type)
-{
- return (canencrypt(type) << 1) | cansign(type);
-}
/****************
* Read the GNUPG keys. For now we read the complete keyring by
* - signature class
*/
-static KEYINFO *
-parse_pub_line( char *buf, int *is_subkey )
+static KEYINFO *parse_pub_line( char *buf, int *is_subkey )
{
KEYINFO *k=NULL;
PGPUID *uid = NULL;
k->keylen = atoi(p); /* fixme: add validation checks */
break;
case 4: /* pubkey algo */
- k->algorithm = pkalgbytype(atoi(p));
- k->flags |= get_abilities(atoi(p));
+ k->algorithm = pgp_pkalgbytype(atoi(p));
+ k->flags |= pgp_get_abilities(atoi(p));
break;
case 5: /* 16 hex digits with the long keyid. */
/* We really should do a check here */
pgpinfd, pgpoutfd, pgperrfd);
}
-static KEYINFO *
-read_ring(struct pgp_vinfo *pgp, int secret )
+static KEYINFO *read_ring(struct pgp_vinfo *pgp, int secret )
{
FILE *fp;
pid_t thepid;
void pgp_signed_handler (BODY *, STATE *);
void pgp_void_passphrase (void);
+short pgp_canencrypt(unsigned char);
+short pgp_cansign(unsigned char);
+short pgp_get_abilities(unsigned char);
+const char *pgp_pkalgbytype(unsigned char);
+
#define pgp_secring(a) pgp_getring(a, 0)
#define pgp_pubring(a) pgp_getring(a, 1)
"Comment Packet"
};
-static const char *pkalgbytype(unsigned char type)
+const char *pgp_pkalgbytype(unsigned char type)
{
switch(type)
{
#endif
-static short canencrypt(unsigned char type)
+short pgp_canencrypt(unsigned char type)
{
switch(type)
{
}
}
-static short cansign(unsigned char type)
+short pgp_cansign(unsigned char type)
{
switch(type)
{
case 1:
case 3:
+ case 16:
case 17:
case 20:
return 1;
* 3 = both
*/
-static short get_abilities(unsigned char type)
+short pgp_get_abilities(unsigned char type)
{
- return (canencrypt(type) << 1) | cansign(type);
+ return (pgp_canencrypt(type) << 1) | pgp_cansign(type);
}
static int read_material(size_t material, size_t *used, FILE *fp)
alg = buff[j++];
- p->algorithm = pkalgbytype(alg);
- p->flags |= get_abilities(alg);
+ p->algorithm = pgp_pkalgbytype(alg);
+ p->flags |= pgp_get_abilities(alg);
expl = 0;
for(i = 0; i < 2; i++)
alg = buff[j++];
- p->algorithm = pkalgbytype(alg);
- p->flags |= get_abilities(alg);
+ p->algorithm = pgp_pkalgbytype(alg);
+ p->flags |= pgp_get_abilities(alg);
if (alg == 17)
skip_bignum(buff, l, j, &j, 3);