137
142
print_pubkey_info (FILE *fp, PKT_public_key *pk)
143
keyid_from_pk (pk, pk_keyid);
147
keyid_from_pk (pk, keyid);
149
/* If the pk was chosen by a particular user ID, that is the one to
152
p=utf8_to_native(pk->user_id->name,pk->user_id->len,0);
154
p=get_user_id_native(keyid);
145
fprintf (fp, "pub %4u%c/%08lX %s ",
157
fprintf (fp, "pub %4u%c/%s %s %s\n",
146
158
nbits_from_pk (pk),
147
159
pubkey_letter (pk->pubkey_algo),
148
(ulong)pk_keyid[1], datestr_from_pk (pk));
160
keystr(keyid), datestr_from_pk (pk), p);
150
tty_printf ("\npub %4u%c/%08lX %s ",
152
pubkey_letter (pk->pubkey_algo),
153
(ulong)pk_keyid[1], datestr_from_pk (pk));
162
tty_printf ("\npub %4u%c/%s %s %s\n",
163
nbits_from_pk (pk), pubkey_letter (pk->pubkey_algo),
164
keystr(keyid), datestr_from_pk (pk), p);
155
p = get_user_id (pk_keyid, &n);
157
print_utf8_string2 (fp, p, n, '\n');
159
tty_print_utf8_string (p, n);
170
/* Print basic information of a secret key including the card serial
171
number information. */
173
print_card_key_info (FILE *fp, KBNODE keyblock)
178
for (node = keyblock; node; node = node->next )
180
if (node->pkt->pkttype == PKT_SECRET_KEY
181
|| (node->pkt->pkttype == PKT_SECRET_SUBKEY) )
183
PKT_secret_key *sk = node->pkt->pkt.secret_key;
185
tty_fprintf (fp, "%s%c %4u%c/%s ",
186
node->pkt->pkttype == PKT_SECRET_KEY? "sec":"ssb",
187
(sk->protect.s2k.mode==1001)?'#':
188
(sk->protect.s2k.mode==1002)?'>':' ',
190
pubkey_letter (sk->pubkey_algo),
192
tty_fprintf (fp, _("created: %s"), datestr_from_sk (sk));
193
tty_fprintf (fp, " ");
194
tty_fprintf (fp, _("expires: %s"), expirestr_from_sk (sk));
195
if (sk->is_protected && sk->protect.s2k.mode == 1002)
197
tty_fprintf (fp, "\n ");
198
tty_fprintf (fp, _("card-no: "));
199
if (sk->protect.ivlen == 16
200
&& !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6))
202
/* This is an OpenPGP card. */
203
for (i=8; i < 14; i++)
206
tty_fprintf (fp, " ");
207
tty_fprintf (fp, "%02X", sk->protect.iv[i]);
211
{ /* Something is wrong: Print all. */
212
for (i=0; i < sk->protect.ivlen; i++)
213
tty_fprintf (fp, "%02X", sk->protect.iv[i]);
216
tty_fprintf (fp, "\n");
223
/* Flags = 0x01 hashed 0x02 critical */
225
status_one_subpacket(sigsubpkttype_t type,size_t len,int flags,const byte *buf)
229
/* Don't print these. */
233
sprintf(status,"%d %u %u ",type,flags,(unsigned int)len);
235
write_status_text_and_buffer(STATUS_SIG_SUBPACKET,status,buf,len,0);
243
312
fprintf(fp,"\n");
246
/* TODO: put in a status-fd tag for preferred keyservers */
316
status_one_subpacket(SIGSUBPKT_PREF_KS,len,(crit?0x02:0)|0x01,p);
252
321
mode=0 for stdout.
253
322
mode=1 for log_info + status messages
254
323
mode=2 for status messages only
326
1 == standard notations
258
show_notation(PKT_signature *sig,int indent,int mode)
331
show_notation(PKT_signature *sig,int indent,int mode,int which)
263
333
FILE *fp=mode?log_get_stream():stdout;
334
struct notation *nd,*notations;
339
notations=sig_to_notation(sig);
265
341
/* There may be multiple notations in the same sig. */
267
while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_NOTATION,&len,&seq,&crit)))
277
log_info(_("WARNING: invalid notation data found\n"));
286
for(i=0;i<indent;i++)
291
str=_("Critical signature notation: ");
293
str=_("Signature notation: ");
298
print_utf8_string(fp,p+8,n1);
302
print_utf8_string(fp,p+8+n1,n2);
304
fprintf(fp,"[ %s ]",_("not human readable"));
311
write_status_buffer ( STATUS_NOTATION_NAME, p+8 , n1, 0 );
312
write_status_buffer ( STATUS_NOTATION_DATA, p+8+n1, n2, 50 );
316
log_info(_("WARNING: invalid notation data found\n"));
342
for(nd=notations;nd;nd=nd->next)
346
int has_at=!!strchr(nd->name,'@');
348
if((which&1 && !has_at) || (which&2 && has_at))
353
for(i=0;i<indent;i++)
356
if(nd->flags.critical)
357
str=_("Critical signature notation: ");
359
str=_("Signature notation: ");
364
/* This is all UTF8 */
365
print_utf8_string(fp,nd->name,strlen(nd->name));
367
print_utf8_string(fp,nd->value,strlen(nd->value));
374
write_status_buffer(STATUS_NOTATION_NAME,
375
nd->name,strlen(nd->name),0);
376
write_status_buffer(STATUS_NOTATION_DATA,
377
nd->value,strlen(nd->value),50);
381
free_notation(notations);
623
730
sk = node->pkt->pkt.secret_key;
624
keyid_from_sk( sk, keyid );
626
printf("sec%c %4u%c/",(sk->protect.s2k.mode==1001)?'#':' ',
627
nbits_from_sk( sk ),pubkey_letter( sk->pubkey_algo ));
629
if(opt.list_options&LIST_SHOW_LONG_KEYID)
630
printf("%08lX%08lX",(ulong)keyid[0],(ulong)keyid[1]);
632
printf("%08lX",(ulong)keyid[1]);
634
printf(" %s%s",datestr_from_sk( sk ),newformat?"":" " );
636
if(newformat && sk->expiredate )
637
printf(_(" [expires: %s]"), expirestr_from_sk( sk ) );
732
printf("sec%c %4u%c/%s %s",(sk->protect.s2k.mode==1001)?'#':
733
(sk->protect.s2k.mode==1002)?'>':' ',
734
nbits_from_sk( sk ),pubkey_letter( sk->pubkey_algo ),
735
keystr_from_sk(sk),datestr_from_sk( sk ));
740
printf(_("expired: %s"),expirestr_from_sk(sk));
743
else if(sk->expiredate )
746
printf(_("expires: %s"),expirestr_from_sk(sk));
642
754
pk = node->pkt->pkt.public_key;
644
keyid_from_pk( pk, keyid );
646
validity=get_validity(pk,NULL);
649
nbits_from_pk(pk),pubkey_letter(pk->pubkey_algo));
651
if(opt.list_options&LIST_SHOW_LONG_KEYID)
652
printf("%08lX%08lX",(ulong)keyid[0],(ulong)keyid[1]);
654
printf("%08lX",(ulong)keyid[1]);
656
printf(" %s%s",datestr_from_pk( pk ),newformat?"":" " );
757
check_trustdb_stale();
759
printf("pub %4u%c/%s %s",
760
nbits_from_pk(pk),pubkey_letter(pk->pubkey_algo),
761
keystr_from_pk(pk),datestr_from_pk( pk ));
658
763
/* We didn't include this before in the key listing, but there
659
764
is room in the new format, so why not? */
660
if(newformat && pk->expiredate)
661
printf(_(" [expires: %s]"), expirestr_from_pk( pk ) );
769
printf(_("revoked: %s"),revokestr_from_pk(pk));
772
else if(pk->has_expired)
775
printf(_("expired: %s"),expirestr_from_pk(pk));
778
else if(pk->expiredate)
781
printf(_("expires: %s"),expirestr_from_pk(pk));
786
/* I need to think about this some more. It's easy enough to
787
include, but it looks sort of confusing in the
663
789
if(opt.list_options&LIST_SHOW_VALIDITY)
664
printf(" [%s]",trust_value_to_string(validity));
791
int validity=get_validity(pk,NULL);
792
printf(" [%s]",trust_value_to_string(validity));
800
print_fingerprint( pk, sk, 0 );
801
print_card_serialno (sk);
802
if( opt.with_key_data )
803
print_key_data( pk );
667
805
for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
668
806
if( node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode ) {
670
/* don't list revoked or expired UIDS unless we are in
671
* verbose mode and signature listing has not been
673
if ( !opt.verbose && !opt.list_sigs &&
674
(node->pkt->pkt.user_id->is_revoked ||
675
node->pkt->pkt.user_id->is_expired ))
678
if(attrib_fp && node->pkt->pkt.user_id->attrib_data!=NULL)
679
dump_attribs(node->pkt->pkt.user_id,pk,sk);
681
if(!any && newformat)
684
if((opt.list_options&LIST_SHOW_VALIDITY) && pk)
686
const char *validity=
687
trust_value_to_string(get_validity(pk,node->pkt->pkt.user_id));
689
/* Includes the 3 spaces for [, ], and " ". */
690
indent=((opt.list_options&LIST_SHOW_LONG_KEYID)?23:15)
807
PKT_user_id *uid=node->pkt->pkt.user_id;
809
if(pk && (uid->is_expired || uid->is_revoked)
810
&& !(opt.list_options&LIST_SHOW_UNUSABLE_UIDS))
818
if(attrib_fp && uid->attrib_data!=NULL)
819
dump_attribs(uid,pk,sk);
821
if((uid->is_revoked || uid->is_expired)
822
|| ((opt.list_options&LIST_SHOW_UID_VALIDITY) && pk))
824
const char *validity;
827
validity=uid_trust_string_fixed(pk,uid);
828
indent=(keystrlen()+9)-atoi(uid_trust_string_fixed(NULL,NULL));
830
if(indent<0 || indent>40)
696
printf("uid%*s[%s] ",indent,"",validity);
833
printf("uid%*s%s ",indent,"",validity);
699
printf("uid%*s",26,"");
701
printf("uid%*s",29,"");
703
if ( node->pkt->pkt.user_id->is_revoked )
704
fputs ("[revoked] ", stdout);
705
if ( node->pkt->pkt.user_id->is_expired )
706
fputs ("[expired] ", stdout);
708
print_utf8_string( stdout, node->pkt->pkt.user_id->name,
709
node->pkt->pkt.user_id->len );
836
printf("uid%*s", (int)keystrlen()+10,"");
838
print_utf8_string( stdout, uid->name, uid->len );
713
print_fingerprint( pk, sk, 0 );
714
print_card_serialno (sk);
715
if( opt.with_key_data )
716
print_key_data( pk, keyid );
720
if((opt.list_options&LIST_SHOW_PHOTOS)
721
&& node->pkt->pkt.user_id->attribs!=NULL)
722
show_photos(node->pkt->pkt.user_id->attribs,
723
node->pkt->pkt.user_id->numattribs,pk,sk);
841
if((opt.list_options&LIST_SHOW_PHOTOS) && uid->attribs!=NULL)
842
show_photos(uid->attribs,uid->numattribs,pk,sk);
725
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
844
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
727
846
PKT_public_key *pk2 = node->pkt->pkt.public_key;
732
print_fingerprint( pk, sk, 0 ); /* of the main key */
736
keyid_from_pk( pk2, keyid2 );
738
nbits_from_pk( pk2 ),pubkey_letter( pk2->pubkey_algo ));
739
if(opt.list_options&LIST_SHOW_LONG_KEYID)
740
printf("%08lX%08lX",(ulong)keyid2[0],(ulong)keyid2[1]);
848
if((pk2->is_revoked || pk2->has_expired)
849
&& !(opt.list_options&LIST_SHOW_UNUSABLE_SUBKEYS))
742
printf("%08lX",(ulong)keyid2[1]);
743
printf(" %s",datestr_from_pk(pk2));
744
if( pk2->expiredate )
745
printf(_(" [expires: %s]"), expirestr_from_pk( pk2 ) );
857
printf("sub %4u%c/%s %s",
858
nbits_from_pk( pk2 ),pubkey_letter( pk2->pubkey_algo ),
859
keystr_from_pk(pk2),datestr_from_pk(pk2));
860
if( pk2->is_revoked )
863
printf(_("revoked: %s"),revokestr_from_pk(pk2));
866
else if( pk2->has_expired )
869
printf(_("expired: %s"),expirestr_from_pk(pk2));
872
else if( pk2->expiredate )
875
printf(_("expires: %s"),expirestr_from_pk(pk2));
748
print_fingerprint( pk2, NULL, 0 );
880
print_fingerprint( pk2, NULL, 0 );
749
881
if( opt.with_key_data )
750
print_key_data( pk2, keyid2 );
752
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
882
print_key_data( pk2 );
884
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY )
754
886
PKT_secret_key *sk2 = node->pkt->pkt.secret_key;
759
print_fingerprint( pk, sk, 0 ); /* of the main key */
760
print_card_serialno (sk);
764
keyid_from_sk( sk2, keyid2 );
766
nbits_from_sk( sk2 ),pubkey_letter( sk2->pubkey_algo ));
767
if(opt.list_options&LIST_SHOW_LONG_KEYID)
768
printf("%08lX%08lX",(ulong)keyid2[0],(ulong)keyid2[1]);
770
printf("%08lX",(ulong)keyid2[1]);
771
printf(" %s",datestr_from_sk( sk2 ) );
888
printf("ssb%c %4u%c/%s %s",
889
(sk2->protect.s2k.mode==1001)?'#':
890
(sk2->protect.s2k.mode==1002)?'>':' ',
891
nbits_from_sk( sk2 ),pubkey_letter( sk2->pubkey_algo ),
892
keystr_from_sk(sk2),datestr_from_sk( sk2 ) );
772
893
if( sk2->expiredate )
773
printf(_(" [expires: %s]"), expirestr_from_sk( sk2 ) );
896
printf(_("expires: %s"),expirestr_from_sk(sk2));
777
print_fingerprint( NULL, sk2, 0 );
778
print_card_serialno (sk);
902
print_fingerprint( NULL, sk2, 0 );
903
print_card_serialno (sk2);
781
else if( opt.list_sigs && node->pkt->pkttype == PKT_SIGNATURE ) {
906
else if( opt.list_sigs
907
&& node->pkt->pkttype == PKT_SIGNATURE
782
909
PKT_signature *sig = node->pkt->pkt.signature;
848
956
sig->flags.notation?'N':' ',
849
957
sig->flags.expired?'X':' ',
850
958
(sig->trust_depth>9)?'T':
851
(sig->trust_depth>0)?'0'+sig->trust_depth:' ');
852
if(opt.list_options&LIST_SHOW_LONG_KEYID)
853
printf("%08lX%08lX",(ulong)sig->keyid[0],(ulong)sig->keyid[1]);
855
printf("%08lX",(ulong)sig->keyid[1]);
856
printf(" %s ", datestr_from_sig(sig));
959
(sig->trust_depth>0)?'0'+sig->trust_depth:' ',
960
keystr(sig->keyid),datestr_from_sig(sig));
961
if(opt.list_options&LIST_SHOW_SIG_EXPIRE)
962
printf(" %s", expirestr_from_sig(sig));
857
964
if( sigrc == '%' )
858
printf("[%s] ", gpg_strerror (rc) );
965
printf("[%s] ", g10_errstr(rc) );
859
966
else if( sigrc == '?' )
861
968
else if ( !opt.fast_list_mode ) {
863
970
char *p = get_user_id( sig->keyid, &n );
864
971
print_utf8_string( stdout, p, n );
869
if(sig->flags.policy_url && (opt.list_options&LIST_SHOW_POLICY))
976
if(sig->flags.policy_url
977
&& (opt.list_options&LIST_SHOW_POLICY_URLS))
870
978
show_policy_url(sig,3,0);
872
if(sig->flags.notation && (opt.list_options&LIST_SHOW_NOTATION))
873
show_notation(sig,3,0);
980
if(sig->flags.notation && (opt.list_options&LIST_SHOW_NOTATIONS))
981
show_notation(sig,3,0,
982
((opt.list_options&LIST_SHOW_STD_NOTATIONS)?1:0)+
983
((opt.list_options&LIST_SHOW_USER_NOTATIONS)?2:0));
875
if(sig->flags.pref_ks && (opt.list_options&LIST_SHOW_KEYSERVER))
985
if(sig->flags.pref_ks
986
&& (opt.list_options&LIST_SHOW_KEYSERVER_URLS))
876
987
show_keyserver_url(sig,3,0);
878
989
/* fixme: check or list other sigs here */