1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-01 16:33:02 +01:00

Re-indent

This commit is contained in:
Werner Koch 2010-01-09 19:00:46 +00:00
parent be45bf3d54
commit ff147275c3
4 changed files with 3370 additions and 3131 deletions

View File

@ -1,3 +1,7 @@
2010-01-09 Werner Koch <wk@g10code.com>
* getkey.c, keylist.c: Re-indent.
2010-01-08 Werner Koch <wk@g10code.com>
* cpr.c (write_status_error): Rename to write_status_errcode.
@ -11003,7 +11007,7 @@ Thu Feb 12 22:24:42 1998 Werner Koch (wk@frodo)
Copyright 1998,1999,2000,2001,2002,2003,2004,2005,
2006,2007,2008,2009 Free Software Foundation, Inc.
2006,2007,2008,2009,2010 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without

File diff suppressed because it is too large Load Diff

View File

@ -353,6 +353,8 @@ keydb_new (int secret)
KEYDB_HANDLE hd;
int i, j;
if (secret)
log_debug ("FIXME: keydb_new called for secret keys\n");
hd = xmalloc_clear (sizeof *hd);
hd->found = -1;

View File

@ -1,6 +1,6 @@
/* keylist.c - print keys
/* keylist.c - Print information about OpenPGP keys
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
* 2008 Free Software Foundation, Inc.
* 2008, 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -56,10 +56,10 @@ struct sig_stats
/* The stream used to write attribute packets to. */
static FILE *attrib_fp = NULL;
/****************
* List the keys
* If list is NULL, all available keys are listed
*/
/* List the keys. If list is NULL, all available keys are listed.
With LOCATE_MODE set the locate algorithm is used to find a
key. */
void
public_key_list (strlist_t list, int locate_mode)
{
@ -195,8 +195,7 @@ print_card_key_info (FILE *fp, KBNODE keyblock)
(sk->protect.s2k.mode == 1001) ? '#' :
(sk->protect.s2k.mode == 1002) ? '>' : ' ',
nbits_from_sk (sk),
pubkey_letter (sk->pubkey_algo),
keystr_from_sk(sk));
pubkey_letter (sk->pubkey_algo), keystr_from_sk (sk));
tty_fprintf (fp, _("created: %s"), datestr_from_sk (sk));
tty_fprintf (fp, " ");
tty_fprintf (fp, _("expires: %s"), expirestr_from_sk (sk));
@ -216,7 +215,8 @@ print_card_key_info (FILE *fp, KBNODE keyblock)
}
}
else
{ /* Something is wrong: Print all. */
{
/* Something is wrong: Print all. */
for (i = 0; i < sk->protect.ivlen; i++)
tty_fprintf (fp, "%02X", sk->protect.iv[i]);
}
@ -228,9 +228,10 @@ print_card_key_info (FILE *fp, KBNODE keyblock)
/* Flags = 0x01 hashed 0x02 critical */
/* Flags = 0x01 hashed 0x02 critical. */
static void
status_one_subpacket(sigsubpkttype_t type,size_t len,int flags,const byte *buf)
status_one_subpacket (sigsubpkttype_t type, size_t len, int flags,
const byte * buf)
{
char status[40];
@ -243,12 +244,12 @@ status_one_subpacket(sigsubpkttype_t type,size_t len,int flags,const byte *buf)
write_status_text_and_buffer (STATUS_SIG_SUBPACKET, status, buf, len, 0);
}
/*
mode=0 for stdout.
mode=1 for log_info + status messages
mode=2 for status messages only
*/
/* Print a policy URL. Allowed values for MODE are:
* 0 - print to stdout.
* 1 - use log_info and emit status messages.
* 2 - emit only status messages.
*/
void
show_policy_url (PKT_signature * sig, int indent, int mode)
{
@ -257,7 +258,8 @@ show_policy_url(PKT_signature *sig,int indent,int mode)
int seq = 0, crit;
FILE *fp = mode ? log_get_stream () : stdout;
while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_POLICY,&len,&seq,&crit)))
while ((p =
enum_sig_subpkt (sig->hashed, SIGSUBPKT_POLICY, &len, &seq, &crit)))
{
if (mode != 2)
{
@ -284,6 +286,7 @@ show_policy_url(PKT_signature *sig,int indent,int mode)
}
}
/*
mode=0 for stdout.
mode=1 for log_info + status messages
@ -298,7 +301,9 @@ show_keyserver_url(PKT_signature *sig,int indent,int mode)
int seq = 0, crit;
FILE *fp = mode ? log_get_stream () : stdout;
while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_PREF_KS,&len,&seq,&crit)))
while ((p =
enum_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_KS, &len, &seq,
&crit)))
{
if (mode != 2)
{
@ -321,7 +326,8 @@ show_keyserver_url(PKT_signature *sig,int indent,int mode)
}
if (mode)
status_one_subpacket(SIGSUBPKT_PREF_KS,len,(crit?0x02:0)|0x01,p);
status_one_subpacket (SIGSUBPKT_PREF_KS, len,
(crit ? 0x02 : 0) | 0x01, p);
}
}
@ -330,11 +336,10 @@ show_keyserver_url(PKT_signature *sig,int indent,int mode)
mode=1 for log_info + status messages
mode=2 for status messages only
which bits:
Defined bits in WHICH:
1 == standard notations
2 == user notations
*/
void
show_notation (PKT_signature * sig, int indent, int mode, int which)
{
@ -399,7 +404,8 @@ print_signature_stats(struct sig_stats *s)
if (s->no_key == 1)
tty_printf (_("1 signature not checked due to a missing key\n"));
else if (s->no_key)
tty_printf(_("%d signatures not checked due to missing keys\n"),s->no_key);
tty_printf (_("%d signatures not checked due to missing keys\n"),
s->no_key);
if (s->oth_err == 1)
tty_printf (_("1 signature not checked due to an error\n"));
else if (s->oth_err)
@ -422,16 +428,19 @@ list_all( int secret )
rc = G10ERR_GENERAL;
else
rc = keydb_search_first (hd);
if( rc ) {
if (rc)
{
if (rc != -1)
log_error ("keydb_search_first failed: %s\n", g10_errstr (rc));
goto leave;
}
lastresname = NULL;
do {
do
{
rc = keydb_get_keyblock (hd, &keyblock);
if (rc) {
if (rc)
{
log_error ("keydb_get_keyblock failed: %s\n", g10_errstr (rc));
goto leave;
}
@ -454,7 +463,8 @@ list_all( int secret )
opt.check_sigs ? &stats : NULL);
release_kbnode (keyblock);
keyblock = NULL;
} while (!(rc = keydb_search_next (hd)));
}
while (!(rc = keydb_search_next (hd)));
if (rc && rc != -1)
log_error ("keydb_search_next failed: %s\n", g10_errstr (rc));
@ -489,15 +499,19 @@ list_one( strlist_t names, int secret )
* functions) or to have the search function return indicators for
* found names. Yet another way is to use the keydb search
* facilities directly. */
if( secret ) {
if (secret)
{
rc = get_seckey_bynames (&ctx, NULL, names, &keyblock);
if( rc ) {
if (rc)
{
log_error ("error reading key: %s\n", g10_errstr (rc));
get_seckey_end (ctx);
return;
}
do {
if ((opt.list_options&LIST_SHOW_KEYRING) && !opt.with_colons) {
do
{
if ((opt.list_options & LIST_SHOW_KEYRING) && !opt.with_colons)
{
resname = keydb_get_resource_name (get_ctx_handle (ctx));
printf ("%s: %s\n", keyring_str, resname);
for (i = strlen (resname) + strlen (keyring_str) + 2; i; i--)
@ -506,18 +520,23 @@ list_one( strlist_t names, int secret )
}
list_keyblock (keyblock, 1, opt.fingerprint, NULL);
release_kbnode (keyblock);
} while( !get_seckey_next( ctx, NULL, &keyblock ) );
}
while (!get_seckey_next (ctx, NULL, &keyblock));
get_seckey_end (ctx);
}
else {
else
{
rc = get_pubkey_bynames (&ctx, NULL, names, &keyblock);
if( rc ) {
if (rc)
{
log_error ("error reading key: %s\n", g10_errstr (rc));
get_pubkey_end (ctx);
return;
}
do {
if ((opt.list_options&LIST_SHOW_KEYRING) && !opt.with_colons) {
do
{
if ((opt.list_options & LIST_SHOW_KEYRING) && !opt.with_colons)
{
resname = keydb_get_resource_name (get_ctx_handle (ctx));
printf ("%s: %s\n", keyring_str, resname);
for (i = strlen (resname) + strlen (keyring_str) + 2; i; i--)
@ -527,7 +546,8 @@ list_one( strlist_t names, int secret )
list_keyblock (keyblock, 0, opt.fingerprint,
opt.check_sigs ? &stats : NULL);
release_kbnode (keyblock);
} while( !get_pubkey_next( ctx, NULL, &keyblock ) );
}
while (!get_pubkey_next (ctx, NULL, &keyblock));
get_pubkey_end (ctx);
}
@ -580,7 +600,8 @@ print_key_data( PKT_public_key *pk )
int n = pk ? pubkey_get_npkey (pk->pubkey_algo) : 0;
int i;
for(i=0; i < n; i++ ) {
for (i = 0; i < n; i++)
{
printf ("pkd:%d:%u:", i, mpi_get_nbits (pk->pkey[i]));
mpi_print (stdout, pk->pkey[i], 1);
putchar (':');
@ -620,19 +641,23 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
putchar ('a');
}
if ( keyblock ) { /* figure out the usable capabilities */
if (keyblock)
{ /* figure out the usable capabilities */
KBNODE k;
int enc = 0, sign = 0, cert = 0, auth = 0, disabled = 0;
for (k=keyblock; k; k = k->next ) {
for (k = keyblock; k; k = k->next)
{
if (k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY)
{
pk = k->pkt->pkt.public_key;
if (pk->is_primary)
disabled = pk_is_disabled (pk);
if ( pk->is_valid && !pk->is_revoked && !pk->has_expired ) {
if (pk->is_valid && !pk->is_revoked && !pk->has_expired)
{
if (pk->pubkey_usage & PUBKEY_USAGE_ENC)
enc = 1;
if (pk->pubkey_usage & PUBKEY_USAGE_SIG)
@ -648,10 +673,12 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
}
}
else if (k->pkt->pkttype == PKT_SECRET_KEY
|| k->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|| k->pkt->pkttype == PKT_SECRET_SUBKEY)
{
sk = k->pkt->pkt.secret_key;
if (sk->is_valid && !sk->is_revoked && !sk->has_expired
&& sk->protect.s2k.mode!=1001 ) {
&& sk->protect.s2k.mode != 1001)
{
if (sk->pubkey_usage & PUBKEY_USAGE_ENC)
enc = 1;
if (sk->pubkey_usage & PUBKEY_USAGE_SIG)
@ -682,9 +709,11 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
putchar (':');
}
/* Flags = 0x01 hashed 0x02 critical */
/* FLAGS: 0x01 hashed
0x02 critical */
static void
print_one_subpacket(sigsubpkttype_t type,size_t len,int flags,const byte *buf)
print_one_subpacket (sigsubpkttype_t type, size_t len, int flags,
const byte * buf)
{
size_t i;
@ -728,7 +757,8 @@ print_subpackets_colon(PKT_signature *sig)
}
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)
{
int i;
@ -756,9 +786,10 @@ dump_attribs(const PKT_user_id *uid,PKT_public_key *pk,PKT_secret_key *sk)
sprintf (buf + strlen (buf), " %lu %u %u %u %lu %lu %u",
(ulong) uid->attribs[i].len, uid->attribs[i].type, i + 1,
uid->numattribs,(ulong)uid->created,(ulong)uid->expiredate,
((uid->is_primary?0x01:0)|
(uid->is_revoked?0x02:0)|
uid->numattribs, (ulong) uid->created,
(ulong) uid->expiredate,
((uid->is_primary ? 0x01 : 0) | (uid->
is_revoked ? 0x02 : 0) |
(uid->is_expired ? 0x04 : 0)));
write_status_text (STATUS_ATTRIBUTE, buf);
}
@ -781,7 +812,8 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
/* get the keyid from the keyblock */
node = find_kbnode (keyblock, secret ? PKT_SECRET_KEY : PKT_PUBLIC_KEY);
if( !node ) {
if (!node)
{
log_error ("Oops; key lost!\n");
dump_kbnode (keyblock);
return;
@ -865,8 +897,10 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
if (opt.with_key_data)
print_key_data (pk);
for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
if( node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode ) {
for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
{
if (node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode)
{
PKT_user_id *uid = node->pkt->pkt.user_id;
if (pk && (uid->is_expired || uid->is_revoked)
@ -888,7 +922,9 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
int indent;
validity = uid_trust_string_fixed (pk, uid);
indent=(keystrlen()+9)-atoi(uid_trust_string_fixed(NULL,NULL));
indent =
(keystrlen () + 9) -
atoi (uid_trust_string_fixed (NULL, NULL));
if (indent < 0 || indent > 40)
indent = 0;
@ -967,29 +1003,40 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
}
}
else if (opt.list_sigs
&& node->pkt->pkttype == PKT_SIGNATURE
&& !skip_sigs ) {
&& node->pkt->pkttype == PKT_SIGNATURE && !skip_sigs)
{
PKT_signature *sig = node->pkt->pkt.signature;
int sigrc;
char *sigstr;
if( stats ) {
/*fflush(stdout);*/
if (stats)
{
rc = check_key_signature (keyblock, node, NULL);
switch( gpg_err_code (rc) ) {
case 0: sigrc = '!'; break;
switch (gpg_err_code (rc))
{
case 0:
sigrc = '!';
break;
case GPG_ERR_BAD_SIGNATURE:
stats->inv_sigs++; sigrc = '-'; break;
stats->inv_sigs++;
sigrc = '-';
break;
case GPG_ERR_NO_PUBKEY:
case GPG_ERR_UNUSABLE_PUBKEY: stats->no_key++; continue;
default: stats->oth_err++; sigrc = '%'; break;
case GPG_ERR_UNUSABLE_PUBKEY:
stats->no_key++;
continue;
default:
stats->oth_err++;
sigrc = '%';
break;
}
/* TODO: Make sure a cached sig record here still has
the pk that issued it. See also
keyedit.c:print_and_check_one_sig */
}
else {
else
{
rc = 0;
sigrc = ' ';
}
@ -1003,24 +1050,28 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
sigstr = "sig";
else if (sig->sig_class == 0x1F)
sigstr = "sig";
else {
else
{
printf ("sig "
"[unexpected signature class 0x%02x]\n",sig->sig_class );
"[unexpected signature class 0x%02x]\n",
sig->sig_class);
continue;
}
fputs (sigstr, stdout);
printf ("%c%c %c%c%c%c%c%c %s %s",
sigrc, (sig->sig_class - 0x10 > 0 &&
sig->sig_class-0x10<4)?'0'+sig->sig_class-0x10:' ',
sig->sig_class - 0x10 <
4) ? '0' + sig->sig_class - 0x10 : ' ',
sig->flags.exportable ? ' ' : 'L',
sig->flags.revocable ? ' ' : 'R',
sig->flags.policy_url ? 'P' : ' ',
sig->flags.notation ? 'N' : ' ',
sig->flags.expired ? 'X' : ' ',
(sig->trust_depth>9)?'T':
(sig->trust_depth>0)?'0'+sig->trust_depth:' ',
keystr(sig->keyid),datestr_from_sig(sig));
(sig->trust_depth > 9) ? 'T' : (sig->trust_depth >
0) ? '0' +
sig->trust_depth : ' ', keystr (sig->keyid),
datestr_from_sig (sig));
if (opt.list_options & LIST_SHOW_SIG_EXPIRE)
printf (" %s", expirestr_from_sig (sig));
printf (" ");
@ -1028,7 +1079,8 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
printf ("[%s] ", g10_errstr (rc));
else if (sigrc == '?')
;
else if ( !opt.fast_list_mode ) {
else if (!opt.fast_list_mode)
{
size_t n;
char *p = get_user_id (sig->keyid, &n);
print_utf8_string (stdout, p, n);
@ -1042,8 +1094,12 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
if (sig->flags.notation && (opt.list_options & LIST_SHOW_NOTATIONS))
show_notation (sig, 3, 0,
((opt.list_options&LIST_SHOW_STD_NOTATIONS)?1:0)+
((opt.list_options&LIST_SHOW_USER_NOTATIONS)?2:0));
((opt.
list_options & LIST_SHOW_STD_NOTATIONS) ? 1 : 0)
+
((opt.
list_options & LIST_SHOW_USER_NOTATIONS) ? 2 :
0));
if (sig->flags.pref_ks
&& (opt.list_options & LIST_SHOW_KEYSERVER_URLS))
@ -1110,8 +1166,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
nbits_from_sk (sk),
sk->pubkey_algo,
(ulong) keyid[0], (ulong) keyid[1],
colon_datestr_from_sk( sk ),
colon_strtime (sk->expiredate)
colon_datestr_from_sk (sk), colon_strtime (sk->expiredate)
/* fixme: add LID here */ );
}
else
@ -1139,8 +1194,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
nbits_from_pk (pk),
pk->pubkey_algo,
(ulong) keyid[0], (ulong) keyid[1],
colon_datestr_from_pk( pk ),
colon_strtime (pk->expiredate) );
colon_datestr_from_pk (pk), colon_strtime (pk->expiredate));
if (!opt.fast_list_mode && !opt.no_expensive_trust_checks)
putchar (get_ownertrust_info (pk));
putchar (':');
@ -1250,8 +1304,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
nbits_from_pk (pk2),
pk2->pubkey_algo,
(ulong) keyid2[0], (ulong) keyid2[1],
colon_datestr_from_pk( pk2 ),
colon_strtime (pk2->expiredate)
colon_datestr_from_pk (pk2), colon_strtime (pk2->expiredate)
/* fixme: add LID and ownertrust here */
);
print_capabilities (pk2, NULL, NULL);
@ -1271,8 +1324,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
nbits_from_sk (sk2),
sk2->pubkey_algo,
(ulong) keyid2[0], (ulong) keyid2[1],
colon_datestr_from_sk( sk2 ),
colon_strtime (sk2->expiredate)
colon_datestr_from_sk (sk2), colon_strtime (sk2->expiredate)
/* fixme: add LID */ );
print_capabilities (NULL, sk2, NULL);
putchar (':'); /* End of field 13. */
@ -1329,11 +1381,19 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
NULL, NULL, NULL);
switch (gpg_err_code (rc))
{
case 0: sigrc = '!'; break;
case GPG_ERR_BAD_SIGNATURE: sigrc = '-'; break;
case 0:
sigrc = '!';
break;
case GPG_ERR_BAD_SIGNATURE:
sigrc = '-';
break;
case GPG_ERR_NO_PUBKEY:
case GPG_ERR_UNUSABLE_PUBKEY: sigrc = '?'; break;
default: sigrc = '%'; break;
case GPG_ERR_UNUSABLE_PUBKEY:
sigrc = '?';
break;
default:
sigrc = '%';
break;
}
if (opt.no_sig_cache)
@ -1380,7 +1440,8 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
print_string (stdout, p, n, ':');
xfree (p);
}
printf (":%02x%c:", sig->sig_class,sig->flags.exportable?'x':'l');
printf (":%02x%c:", sig->sig_class,
sig->flags.exportable ? 'x' : 'l');
if (opt.no_sig_cache && opt.check_sigs && fprokay)
{
@ -1412,16 +1473,20 @@ do_reorder_keyblock (KBNODE keyblock,int attr)
KBNODE primary = NULL, primary0 = NULL, primary2 = NULL;
KBNODE last, node;
for (node=keyblock; node; primary0=node, node = node->next) {
for (node = keyblock; node; primary0 = node, node = node->next)
{
if (node->pkt->pkttype == PKT_USER_ID &&
((attr && node->pkt->pkt.user_id->attrib_data) ||
(!attr && !node->pkt->pkt.user_id->attrib_data)) &&
node->pkt->pkt.user_id->is_primary ) {
node->pkt->pkt.user_id->is_primary)
{
primary = primary2 = node;
for (node=node->next; node; primary2=node, node = node->next ) {
for (node = node->next; node; primary2 = node, node = node->next)
{
if (node->pkt->pkttype == PKT_USER_ID
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|| node->pkt->pkttype == PKT_SECRET_SUBKEY)
{
break;
}
}
@ -1429,17 +1494,18 @@ do_reorder_keyblock (KBNODE keyblock,int attr)
}
}
if (!primary)
return; /* no primary key flag found (should not happen) */
return; /* No primary key flag found (should not happen). */
for (last=NULL, node=keyblock; node; last = node, node = node->next) {
for (last = NULL, node = keyblock; node; last = node, node = node->next)
{
if (node->pkt->pkttype == PKT_USER_ID)
break;
}
assert (node);
assert (last); /* the user ID is never the first packet */
assert (primary0); /* ditto (this is the node before primary) */
assert (last); /* The user ID is never the first packet. */
assert (primary0); /* Ditto (this is the node before primary). */
if (node == primary)
return; /* already the first one */
return; /* Already the first one. */
last->next = primary;
primary0->next = primary2->next;
@ -1482,12 +1548,14 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
if (sk)
{
if(sk->main_keyid[0]==sk->keyid[0] && sk->main_keyid[1]==sk->keyid[1])
if (sk->main_keyid[0] == sk->keyid[0]
&& sk->main_keyid[1] == sk->keyid[1])
primary = 1;
}
else
{
if(pk->main_keyid[0]==pk->keyid[0] && pk->main_keyid[1]==pk->keyid[1])
if (pk->main_keyid[0] == pk->keyid[0]
&& pk->main_keyid[1] == pk->keyid[1])
primary = 1;
}
@ -1518,15 +1586,17 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
}
}
if (mode == 1) {
if (mode == 1)
{
fp = log_get_stream ();
if (primary)
text = _("Primary key fingerprint:");
else
text = _(" Subkey fingerprint:");
}
else if (mode == 2) {
fp = NULL; /* use tty */
else if (mode == 2)
{
fp = NULL; /* Use tty. */
if (primary)
/* TRANSLATORS: this should fit into 24 bytes to that the
* fingerprint data is properly aligned with the user ID */
@ -1534,11 +1604,13 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
else
text = _(" Subkey fingerprint:");
}
else if (mode == 3) {
fp = NULL; /* use tty */
else if (mode == 3)
{
fp = NULL; /* Use tty. */
text = _(" Key fingerprint =");
}
else {
else
{
fp = stdout;
text = _(" Key fingerprint =");
}
@ -1548,39 +1620,49 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
else
fingerprint_from_pk (pk, array, &n);
p = array;
if (opt.with_colons && !mode) {
if (opt.with_colons && !mode)
{
fprintf (fp, "fpr:::::::::");
for (i = 0; i < n; i++, p++)
fprintf (fp, "%02X", *p);
putc (':', fp);
}
else {
else
{
if (fp)
fputs (text, fp);
else
tty_printf ("%s", text);
if (n == 20) {
for (i=0; i < n ; i++, i++, p += 2 ) {
if (fp) {
if (n == 20)
{
for (i = 0; i < n; i++, i++, p += 2)
{
if (fp)
{
if (i == 10)
putc (' ', fp);
fprintf (fp, " %02X%02X", *p, p[1]);
}
else {
else
{
if (i == 10)
tty_printf (" ");
tty_printf (" %02X%02X", *p, p[1]);
}
}
}
else {
for (i=0; i < n ; i++, p++ ) {
if (fp) {
else
{
for (i = 0; i < n; i++, p++)
{
if (fp)
{
if (i && !(i % 8))
putc (' ', fp);
fprintf (fp, " %02X", *p);
}
else {
else
{
if (i && !(i % 8))
tty_printf (" ");
tty_printf (" %02X", *p);
@ -1611,7 +1693,8 @@ print_card_serialno (PKT_secret_key *sk)
putchar (' ');
if (sk->protect.ivlen == 16
&& !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6))
{ /* This is an OpenPGP card. Just print the relevant part. */
{
/* This is an OpenPGP card. Just print the relevant part. */
for (i = 8; i < 14; i++)
{
if (i == 10)
@ -1620,7 +1703,8 @@ print_card_serialno (PKT_secret_key *sk)
}
}
else
{ /* Something is wrong: Print all. */
{
/* Something is wrong: Print all. */
for (i = 0; i < sk->protect.ivlen; i++)
printf ("%02X", sk->protect.iv[i]);
}