1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-11 21:48:50 +01:00

* options.h, keylist.c (print_one_subpacket, print_subpackets_colon):

Print a spk record for each request subpacket. (list_keyblock_colon): Call
them here.

* g10.c (parse_subpacket_list, parse_list_options): New.  Make the list of
subpackets we are going to print. (main): Call them here.
This commit is contained in:
David Shaw 2004-09-12 15:27:38 +00:00
parent 45f99c58bb
commit e7c94128b2
4 changed files with 176 additions and 27 deletions

View File

@ -1,3 +1,14 @@
2004-09-12 David Shaw <dshaw@jabberwocky.com>
* options.h, keylist.c (print_one_subpacket,
print_subpackets_colon): Print a spk record for each request
subpacket.
(list_keyblock_colon): Call them here.
* g10.c (parse_subpacket_list, parse_list_options): New. Make the
list of subpackets we are going to print.
(main): Call them here.
2004-09-11 David Shaw <dshaw@jabberwocky.com> 2004-09-11 David Shaw <dshaw@jabberwocky.com>
* card-util.c (fetch_url, card_edit): Use the pubkey URL stored on * card-util.c (fetch_url, card_edit): Use the pubkey URL stored on

128
g10/g10.c
View File

@ -1358,6 +1358,113 @@ gpgconf_list (const char *configfile)
} }
static int
parse_subpacket_list(char *list)
{
char *tok;
byte subpackets[128],i;
int count=0;
if(!list)
{
/* No arguments means all subpackets */
memset(subpackets+1,1,sizeof(subpackets)-1);
count=127;
}
else
{
memset(subpackets,0,sizeof(subpackets));
/* Merge with earlier copy */
if(opt.show_subpackets)
{
byte *in;
for(in=opt.show_subpackets;*in;in++)
{
if(*in>127 || *in<1)
BUG();
if(!subpackets[*in])
count++;
subpackets[*in]=1;
}
}
while((tok=strsep(&list," ,")))
{
if(!*tok)
continue;
i=atoi(tok);
if(i>127 || i<1)
return 0;
if(!subpackets[i])
count++;
subpackets[i]=1;
}
}
m_free(opt.show_subpackets);
opt.show_subpackets=m_alloc(count+1);
opt.show_subpackets[count--]=0;
for(i=1;i<128 && count>=0;i++)
if(subpackets[i])
opt.show_subpackets[count--]=i;
return 1;
}
static int
parse_list_options(char *str)
{
char *subpackets=""; /* something that isn't NULL */
struct parse_options lopts[]=
{
{"show-photos",LIST_SHOW_PHOTOS,NULL},
{"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL},
{"show-notations",LIST_SHOW_NOTATIONS,NULL},
{"show-std-notations",LIST_SHOW_STD_NOTATIONS,NULL},
{"show-standard-notations",LIST_SHOW_STD_NOTATIONS,NULL},
{"show-user-notations",LIST_SHOW_USER_NOTATIONS,NULL},
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL},
{"show-uid-validity",LIST_SHOW_UID_VALIDITY,NULL},
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL},
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL},
{"show-keyring",LIST_SHOW_KEYRING,NULL},
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL},
{"show-sig-subpackets",LIST_SHOW_SIG_SUBPACKETS,&subpackets},
{NULL,0,NULL}
};
/* this is wrong since the show-sig-subpackets could have been set
from a previous incarnation of list-options */
if(parse_options(str,&opt.list_options,lopts,1))
{
if(opt.list_options&LIST_SHOW_SIG_SUBPACKETS)
{
/* Unset so users can pass multiple lists in. */
opt.list_options&=~LIST_SHOW_SIG_SUBPACKETS;
if(!parse_subpacket_list(subpackets))
return 0;
}
else if(subpackets==NULL && opt.show_subpackets)
{
/* User did 'no-show-subpackets' */
m_free(opt.show_subpackets);
opt.show_subpackets=NULL;
}
return 1;
}
else
return 0;
}
/* Collapses argc/argv into a single string that must be freed */ /* Collapses argc/argv into a single string that must be freed */
static char * static char *
@ -2150,25 +2257,7 @@ main( int argc, char **argv )
} }
break; break;
case oListOptions: case oListOptions:
{ if(!parse_list_options(pargs.r.ret_str))
struct parse_options lopts[]=
{
{"show-photos",LIST_SHOW_PHOTOS,NULL},
{"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL},
{"show-notations",LIST_SHOW_NOTATIONS,NULL},
{"show-std-notations",LIST_SHOW_STD_NOTATIONS,NULL},
{"show-standard-notations",LIST_SHOW_STD_NOTATIONS,NULL},
{"show-user-notations",LIST_SHOW_USER_NOTATIONS,NULL},
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL},
{"show-uid-validity",LIST_SHOW_UID_VALIDITY,NULL},
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL},
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL},
{"show-keyring",LIST_SHOW_KEYRING,NULL},
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL},
{NULL,0,NULL}
};
if(!parse_options(pargs.r.ret_str,&opt.list_options,lopts,1))
{ {
if(configname) if(configname)
log_error(_("%s:%d: invalid list options\n"), log_error(_("%s:%d: invalid list options\n"),
@ -2176,7 +2265,6 @@ main( int argc, char **argv )
else else
log_error(_("invalid list options\n")); log_error(_("invalid list options\n"));
} }
}
break; break;
case oVerifyOptions: case oVerifyOptions:
{ {

View File

@ -551,6 +551,51 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
putchar(':'); putchar(':');
} }
/* Flags = 0x01 hashed 0x02 critical */
static void
print_one_subpacket(sigsubpkttype_t type,size_t len,int flags,const byte *buf)
{
size_t i;
printf("spk:%d:%u:%u:",type,flags,len);
for(i=0;i<len;i++)
{
/* printable ascii other than : and % */
if(buf[i]>=32 && buf[i]<=126 && buf[i]!=':' && buf[i]!='%')
printf("%c",buf[i]);
else
printf("%%%02X",buf[i]);
}
printf("\n");
}
static void
print_subpackets_colon(PKT_signature *sig)
{
byte *i;
assert(opt.show_subpackets);
for(i=opt.show_subpackets;*i;i++)
{
const byte *p;
size_t len;
int seq,crit;
seq=0;
while((p=enum_sig_subpkt(sig->hashed,*i,&len,&seq,&crit)))
print_one_subpacket(*i,len,0x01|(crit?0x02:0),p);
seq=0;
while((p=enum_sig_subpkt(sig->unhashed,*i,&len,&seq,&crit)))
print_one_subpacket(*i,len,0x00|(crit?0x02:0),p);
}
}
void void
dump_attribs(const PKT_user_id *uid,PKT_public_key *pk,PKT_secret_key *sk) dump_attribs(const PKT_user_id *uid,PKT_public_key *pk,PKT_secret_key *sk)
{ {
@ -1232,6 +1277,9 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
printf("\n"); printf("\n");
if(opt.show_subpackets)
print_subpackets_colon(sig);
/* fixme: check or list other sigs here */ /* fixme: check or list other sigs here */
} }
} }

View File

@ -191,6 +191,7 @@ struct
int enable_progress_filter; int enable_progress_filter;
unsigned int screen_columns; unsigned int screen_columns;
unsigned int screen_lines; unsigned int screen_lines;
byte *show_subpackets;
#ifdef ENABLE_CARD_SUPPORT #ifdef ENABLE_CARD_SUPPORT
const char *ctapi_driver; /* Library to access the ctAPI. */ const char *ctapi_driver; /* Library to access the ctAPI. */
@ -264,6 +265,7 @@ struct {
#define LIST_SHOW_UNUSABLE_SUBKEYS (1<<7) #define LIST_SHOW_UNUSABLE_SUBKEYS (1<<7)
#define LIST_SHOW_KEYRING (1<<8) #define LIST_SHOW_KEYRING (1<<8)
#define LIST_SHOW_SIG_EXPIRE (1<<9) #define LIST_SHOW_SIG_EXPIRE (1<<9)
#define LIST_SHOW_SIG_SUBPACKETS (1<<10)
#define VERIFY_SHOW_PHOTOS (1<<0) #define VERIFY_SHOW_PHOTOS (1<<0)
#define VERIFY_SHOW_POLICY_URLS (1<<1) #define VERIFY_SHOW_POLICY_URLS (1<<1)