aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g10/ChangeLog12
-rw-r--r--g10/armor.c95
-rw-r--r--g10/keyedit.c46
-rw-r--r--g10/keylist.c53
4 files changed, 104 insertions, 102 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index bbae614c6..b583caf78 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,15 @@
+2004-10-14 David Shaw <[email protected]>
+
+ * keylist.c (list_keyblock_print): Show the fingerprint after the
+ key, not after the first user ID.
+
+ * keyedit.c (show_key_with_all_names): Don't show validity if
+ we're just printing user IDs for signing.
+
+ * armor.c (fake_packet): Properly handle the case where the line
+ is dash-space (i.e. a blank line that was quoted). Give a warning
+ for bad dash escaping.
+
2004-10-14 Werner Koch <[email protected]>
* export.c (do_export_stream) [ENABLE_SELINUX_HACKS]: Don't allow
diff --git a/g10/armor.c b/g10/armor.c
index 489f73dcc..1fe73f2ed 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -518,15 +518,64 @@ fake_packet( armor_filter_context_t *afx, IOBUF a,
}
if( !maxlen )
afx->truncated++;
- if( !afx->not_dash_escaped ) {
- int crlf;
- p = afx->buffer;
- n = afx->buffer_len;
- crlf = n > 1 && p[n-2] == '\r' && p[n-1]=='\n';
+
+ p = afx->buffer;
+ n = afx->buffer_len;
+
+ /* Armor header or dash-escaped line? */
+ if(p[0]=='-')
+ {
+ /* 2440bis-10: When reversing dash-escaping, an
+ implementation MUST strip the string "- " if it occurs
+ at the beginning of a line, and SHOULD warn on "-" and
+ any character other than a space at the beginning of a
+ line. */
+
+ if(p[1]==' ' && !afx->not_dash_escaped)
+ {
+ /* It's a dash-escaped line, so skip over the
+ escape. */
+ afx->buffer_pos = 2;
+ }
+ else if(p[1]=='-' && p[2]=='-' && p[3]=='-' && p[4]=='-')
+ {
+ /* Five dashes in a row mean it's probably armor
+ header. */
+ int type = is_armor_header( p, n );
+ if( afx->not_dash_escaped && type != BEGIN_SIGNATURE )
+ ; /* this is okay */
+ else
+ {
+ if( type != BEGIN_SIGNATURE )
+ {
+ log_info(_("unexpected armor: "));
+ print_string( stderr, p, n, 0 );
+ putc('\n', stderr);
+ }
+
+ lastline = 1;
+ rc = -1;
+ }
+ }
+ else if(!afx->not_dash_escaped)
+ {
+ /* Bad dash-escaping. */
+ log_info(_("invalid dash escaped line: "));
+ print_string( stderr, p, n, 0 );
+ putc('\n', stderr);
+ }
+ }
+
+ /* Now handle the end-of-line canonicalization */
+ if( !afx->not_dash_escaped )
+ {
+ int crlf = n > 1 && p[n-2] == '\r' && p[n-1]=='\n';
/* PGP2 does not treat a tab as white space character */
- afx->buffer_len = trim_trailing_chars( p, n,
- afx->pgp2mode ? " \r\n" : " \t\r\n");
+ afx->buffer_len=
+ trim_trailing_chars( &p[afx->buffer_pos], n-afx->buffer_pos,
+ afx->pgp2mode ? " \r\n" : " \t\r\n");
+ afx->buffer_len+=afx->buffer_pos;
/* the buffer is always allocated with enough space to append
* the removed [CR], LF and a Nul
* The reason for this complicated procedure is to keep at least
@@ -538,37 +587,9 @@ fake_packet( armor_filter_context_t *afx, IOBUF a,
* faked packet could do the job).
*/
if( crlf )
- afx->buffer[afx->buffer_len++] = '\r';
+ afx->buffer[afx->buffer_len++] = '\r';
afx->buffer[afx->buffer_len++] = '\n';
- afx->buffer[afx->buffer_len] = 0;
- }
- p = afx->buffer;
- n = afx->buffer_len;
-
- if( n > 2 && *p == '-' )
- {
- /* check for dash escaped or armor header */
- if( p[1] == ' ' && !afx->not_dash_escaped )
- {
- /* It's a dash-escaped line */
- afx->buffer_pos = 2; /* skip */
- }
- else if( n >= 15 && p[1] == '-' && p[2] == '-' && p[3] == '-' )
- {
- /* It's armor header */
- int type = is_armor_header( p, n );
- if( afx->not_dash_escaped && type != BEGIN_SIGNATURE )
- ; /* this is okay */
- else {
- if( type != BEGIN_SIGNATURE ) {
- log_info(_("unexpected armor: "));
- print_string( stderr, p, n, 0 );
- putc('\n', stderr);
- }
- lastline = 1;
- rc = -1;
- }
- }
+ afx->buffer[afx->buffer_len] = '\0';
}
}
diff --git a/g10/keyedit.c b/g10/keyedit.c
index a40ae1852..53fbf5964 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -915,8 +915,8 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
}
p=get_user_id_native(sk_keyid);
- tty_printf(_("Are you really sure that you want to sign this key\n"
- "with your key \"%s\" (%s)\n"),p,keystr_from_sk(sk));
+ tty_printf(_("Are you sure that you want to sign this key with your\n"
+ "key \"%s\" (%s)\n"),p,keystr_from_sk(sk));
m_free(p);
if(selfsig)
@@ -2325,26 +2325,34 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
/* the user ids */
i = 0;
- for( node = keyblock; node; node = node->next ) {
- if( node->pkt->pkttype == PKT_USER_ID ) {
+ for( node = keyblock; node; node = node->next )
+ {
+ if( node->pkt->pkttype == PKT_USER_ID )
+ {
PKT_user_id *uid = node->pkt->pkt.user_id;
++i;
- if( !only_marked || (only_marked && (node->flag & NODFLG_MARK_A))){
- if(uid->is_revoked)
- tty_printf(_("[%8.8s] "),_("revoked"));
- else if(uid->is_expired)
- tty_printf(_("[%8.8s] "),_("expired"));
- else if(primary)
- tty_printf(_("[%8.8s] "),
- trust_value_to_string(get_validity(primary,uid)));
+ if( !only_marked || (only_marked && (node->flag & NODFLG_MARK_A)))
+ {
+ if(!only_marked)
+ {
+ if(uid->is_revoked)
+ tty_printf(_("[%8.8s] "),_("revoked"));
+ else if(uid->is_expired)
+ tty_printf(_("[%8.8s] "),_("expired"));
+ else if(primary)
+ tty_printf(_("[%8.8s] "),
+ trust_value_to_string(get_validity(primary,
+ uid)));
+ }
+
if( only_marked )
- tty_printf(" ");
+ tty_printf(" ");
else if( node->flag & NODFLG_SELUID )
- tty_printf("(%d)* ", i);
+ tty_printf("(%d)* ", i);
else if( uid->is_primary )
- tty_printf("(%d). ", i);
+ tty_printf("(%d). ", i);
else
- tty_printf("(%d) ", i);
+ tty_printf("(%d) ", i);
tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
if( with_prefs )
@@ -2372,9 +2380,9 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
tty_printf(_("There are no preferences on a "
"PGP 2.x-style user ID.\n"));
}
- }
- }
- }
+ }
+ }
+ }
if (do_warn)
tty_printf (_("Please note that the shown key validity "
diff --git a/g10/keylist.c b/g10/keylist.c
index f5578c28e..39ccb556d 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -651,7 +651,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
KBNODE node;
PKT_public_key *pk;
PKT_secret_key *sk;
- int any=0;
struct sig_stats *stats=opaque;
int skip_sigs=0;
@@ -735,6 +734,12 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
printf("\n");
}
+ if( fpr )
+ print_fingerprint( pk, sk, 0 );
+ print_card_serialno (sk);
+ 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 ) {
PKT_user_id *uid=node->pkt->pkt.user_id;
@@ -776,14 +781,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
print_utf8_string( stdout, uid->name, uid->len );
putchar('\n');
- if( !any ) {
- if( fpr )
- print_fingerprint( pk, sk, 0 );
- print_card_serialno (sk);
- if( opt.with_key_data )
- print_key_data( pk );
- any = 1;
- }
if((opt.list_options&LIST_SHOW_PHOTOS) && uid->attribs!=NULL)
show_photos(uid->attribs,uid->numattribs,pk,sk);
@@ -801,14 +798,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
else
skip_sigs=0;
- if( !any )
- {
- putchar('\n');
- if( fpr )
- print_fingerprint( pk, sk, 0 ); /* of the main key */
- any = 1;
- }
-
printf("sub %4u%c/%s %s",
nbits_from_pk( pk2 ),pubkey_letter( pk2->pubkey_algo ),
keystr_from_pk(pk2),datestr_from_pk(pk2));
@@ -840,15 +829,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
{
PKT_secret_key *sk2 = node->pkt->pkt.secret_key;
- if( !any )
- {
- putchar('\n');
- if( fpr )
- print_fingerprint( pk, sk, 0 ); /* of the main key */
- print_card_serialno (sk);
- any = 1;
- }
-
printf("ssb%c %4u%c/%s %s",
(sk2->protect.s2k.mode==1001)?'#':
(sk2->protect.s2k.mode==1002)?'>':' ',
@@ -894,25 +874,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
sigrc = ' ';
}
- if( !any ) { /* no user id, (maybe a revocation follows)*/
- /* Check if the pk is really revoked - there could be a
- 0x20 sig packet there even if we are not revoked
- (say, if a revocation key issued the packet, but the
- revocation key isn't present to verify it.) */
- if( sig->sig_class == 0x20 && pk->is_revoked )
- puts("[revoked]");
- else if( sig->sig_class == 0x18 )
- puts("[key binding]");
- else if( sig->sig_class == 0x28 )
- puts("[subkey revoked]");
- else
- putchar('\n');
- if( fpr )
- print_fingerprint( pk, sk, 0 );
- print_card_serialno (sk);
- any=1;
- }
-
if( sig->sig_class == 0x20 || sig->sig_class == 0x28
|| sig->sig_class == 0x30 )
sigstr = "rev";
@@ -1535,7 +1496,7 @@ print_card_serialno (PKT_secret_key *sk)
if (!sk->is_protected || sk->protect.s2k.mode != 1002)
return; /* Not a card. */
if (opt.with_colons)
- return; /* Handled elesewhere. */
+ return; /* Handled elsewhere. */
fputs (_(" Card serial no. ="), stdout);
putchar (' ');