aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog12
-rw-r--r--g10/helptext.c6
-rw-r--r--g10/keyedit.c20
-rw-r--r--g10/keylist.c16
-rw-r--r--g10/mainproc.c27
-rw-r--r--g10/packet.h3
-rw-r--r--g10/plaintext.c47
7 files changed, 83 insertions, 48 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 329b3a7b1..dec722de9 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,15 @@
+Tue Aug 31 17:20:44 CEST 1999 Werner Koch <[email protected]>
+
+
+ * plaintext.c (do_hash): Hash CR,LF for a single CR.
+ (ask_for_detached_datafile): Changed arguments to be closer to
+ those of hash_datafiles and cleanup the code a bit.
+ * mainproc.c (proc_tree): Workaround for pgp5 textmode detached
+ signatures. Changed behavior of asking for data file to be the same
+ as with provided data files.
+
+ * keylist.c (list_keyblock): Use UTF8 print functions.
+
Mon Aug 30 20:38:33 CEST 1999 Werner Koch <[email protected]>
diff --git a/g10/helptext.c b/g10/helptext.c
index d34a3a9ac..e6957da3b 100644
--- a/g10/helptext.c
+++ b/g10/helptext.c
@@ -103,7 +103,7 @@ static struct helptexts { const char *key; const char *help; } helptexts[] = {
{ "keygen.valid", N_(
- "Enter the required value as shown in the pronpt.\n"
+ "Enter the required value as shown in the prompt.\n"
"It is possible to enter a ISO date (YYYY-MM-DD) but you won't\n"
"get a good error response - instead the system tries to interpret\n"
"the given value as an interval."
@@ -176,8 +176,8 @@ static struct helptexts { const char *key; const char *help; } helptexts[] = {
{ "keyedit.delsig.valid", N_(
"This is a valid signature on the key; you normally don't want\n"
- "to delete this signature may be important to establish a trust\n"
- "connection to the key or another key certified by this key."
+ "to delete this signature because it may be important to establish a\n"
+ "trust connection to the key or another key certified by this key."
)},
{ "keyedit.delsig.unknown", N_(
"This signature can't be checked because you don't have the\n"
diff --git a/g10/keyedit.c b/g10/keyedit.c
index db5c0050f..d54e90d6c 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -157,7 +157,7 @@ print_and_check_one_sig( KBNODE keyblock, KBNODE node,
else {
size_t n;
char *p = get_user_id( sig->keyid, &n );
- tty_print_string( p, n > 40? 40 : n );
+ tty_print_utf8_string( p, n > 40? 40 : n );
m_free(p);
}
tty_printf("\n");
@@ -192,7 +192,7 @@ check_all_keysigs( KBNODE keyblock, int only_selected )
selected = (node->flag & NODFLG_SELUID);
if( selected ) {
tty_printf("uid ");
- tty_print_string( uid->name, uid->len );
+ tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
if( anyuid && !has_selfsig )
mis_selfsig++;
@@ -330,7 +330,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified, int local )
"Are you really sure that you want to sign this key\n"
"with your key: \""));
p = get_user_id( sk_keyid, &n );
- tty_print_string( p, n );
+ tty_print_utf8_string( p, n );
m_free(p); p = NULL;
tty_printf("\"\n\n");
@@ -1112,7 +1112,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked,
tty_printf("(%d)* ", i);
else
tty_printf("(%d) ", i);
- tty_print_string( uid->name, uid->len );
+ tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
if( with_prefs )
show_prefs( keyblock, uid );
@@ -1138,7 +1138,7 @@ show_key_and_fingerprint( KBNODE keyblock )
}
else if( node->pkt->pkttype == PKT_USER_ID ) {
PKT_user_id *uid = node->pkt->pkt.user_id;
- tty_print_string( uid->name, uid->len );
+ tty_print_utf8_string( uid->name, uid->len );
break;
}
}
@@ -1322,7 +1322,7 @@ menu_delsig( KBNODE pub_keyblock )
int okay, valid, selfsig, inv_sig, no_key, other_err;
tty_printf("uid ");
- tty_print_string( uid->name, uid->len );
+ tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
okay = inv_sig = no_key = other_err = 0;
@@ -1708,8 +1708,8 @@ ask_revoke_sig( KBNODE keyblock, KBNODE node )
}
tty_printf(_("user ID: \""));
- tty_print_string( unode->pkt->pkt.user_id->name,
- unode->pkt->pkt.user_id->len );
+ tty_print_utf8_string( unode->pkt->pkt.user_id->name,
+ unode->pkt->pkt.user_id->len );
tty_printf(_("\"\nsigned with your key %08lX at %s\n"),
sig->keyid[1], datestr_from_sig(sig) );
@@ -1744,7 +1744,7 @@ menu_revsig( KBNODE keyblock )
PKT_user_id *uid = node->pkt->pkt.user_id;
/* Hmmm: Should we show only UIDs with a signature? */
tty_printf(" ");
- tty_print_string( uid->name, uid->len );
+ tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
}
else if( node->pkt->pkttype == PKT_SIGNATURE
@@ -1781,7 +1781,7 @@ menu_revsig( KBNODE keyblock )
if( node->pkt->pkttype == PKT_USER_ID ) {
PKT_user_id *uid = node->pkt->pkt.user_id;
tty_printf(" ");
- tty_print_string( uid->name, uid->len );
+ tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
}
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
diff --git a/g10/keylist.c b/g10/keylist.c
index 02a265394..91a13afaf 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -255,10 +255,15 @@ list_keyblock( KBNODE keyblock, int secret )
else
printf("uid%*s", 28, "");
}
- print_string( stdout, node->pkt->pkt.user_id->name,
- node->pkt->pkt.user_id->len, opt.with_colons );
- if( opt.with_colons )
+ if( opt.with_colons ) {
+ print_string( stdout, node->pkt->pkt.user_id->name,
+ node->pkt->pkt.user_id->len, ':' );
putchar(':');
+ }
+ else
+ print_utf8_string( stdout, node->pkt->pkt.user_id->name,
+ node->pkt->pkt.user_id->len );
+
putchar('\n');
if( !any ) {
if( opt.fingerprint )
@@ -402,7 +407,10 @@ list_keyblock( KBNODE keyblock, int secret )
else {
size_t n;
char *p = get_user_id( sig->keyid, &n );
- print_string( stdout, p, n, opt.with_colons );
+ if( opt.with_colons )
+ print_string( stdout, p, n, ':' );
+ else
+ print_utf8_string( stdout, p, n );
m_free(p);
}
if( opt.with_colons )
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 99713f9a4..033157269 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -1158,8 +1158,8 @@ proc_tree( CTX c, KBNODE node )
c->signed_data, c->sigfilename,
n1? (n1->pkt->pkt.onepass_sig->sig_class == 0x01):0 );
else
- rc = ask_for_detached_datafile( &c->mfx,
- iobuf_get_fname(c->iobuf));
+ rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2,
+ iobuf_get_fname(c->iobuf), 0 );
if( rc ) {
log_error("can't hash datafile: %s\n", g10_errstr(rc));
return;
@@ -1173,6 +1173,7 @@ proc_tree( CTX c, KBNODE node )
PKT_signature *sig = node->pkt->pkt.signature;
if( !c->have_data ) {
+ /* detached signature */
free_md_filter_context( &c->mfx );
c->mfx.md = md_open(sig->digest_algo, 0);
if( sig->digest_algo == DIGEST_ALGO_MD5
@@ -1180,15 +1181,16 @@ proc_tree( CTX c, KBNODE node )
/* enable a workaround for a pgp2 bug */
c->mfx.md2 = md_open( DIGEST_ALGO_MD5, 0 );
}
- #if 0
- #warning md_start_debug enabled
- md_start_debug( c->mfx.md, "det1" );
- if( c->mfx.md2 )
- md_start_debug( c->mfx.md2, "det2" );
- #endif
+ else if( sig->digest_algo == DIGEST_ALGO_SHA1
+ && sig->pubkey_algo == PUBKEY_ALGO_DSA
+ && sig->sig_class == 0x01 ) {
+ /* enable the workaround also for pgp5 when the detached
+ * signature has been created in textmode */
+ c->mfx.md2 = md_open( sig->digest_algo, 0 );
+ }
/* Here we have another hack to work around a pgp 2 bug
* It works by not using the textmode for detached signatures;
- * this will let the first signazure check (on md) fail
+ * this will let the first signature check (on md) fail
* but the second one (on md2) which adds an extra CR should
* then produce the "correct" hash. This is very, very ugly
* hack but it may help in some cases (and break others)
@@ -1196,10 +1198,11 @@ proc_tree( CTX c, KBNODE node )
if( c->sigs_only )
rc = hash_datafiles( c->mfx.md, c->mfx.md2,
c->signed_data, c->sigfilename,
- c->mfx.md2? 0 :(sig->sig_class == 0x01) );
+ c->mfx.md2? 0 :(sig->sig_class == 0x01) );
else
- rc = ask_for_detached_datafile( &c->mfx,
- iobuf_get_fname(c->iobuf));
+ rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2,
+ iobuf_get_fname(c->iobuf),
+ c->mfx.md2? 0 :(sig->sig_class == 0x01) );
if( rc ) {
log_error("can't hash datafile: %s\n", g10_errstr(rc));
return;
diff --git a/g10/packet.h b/g10/packet.h
index 91253ebe2..50ea65b3f 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -334,7 +334,8 @@ int encrypt_data( PKT_encrypted *ed, DEK *dek );
/*-- plaintext.c --*/
int handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
int nooutput, int clearsig );
-int ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname );
+int ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2,
+ const char *inname, int textmode );
/*-- comment.c --*/
int write_comment( IOBUF out, const char *s );
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 878bdc46b..7411a4b16 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -249,7 +249,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
* INFILE is the name of the input file.
*/
int
-ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname )
+ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2,
+ const char *inname, int textmode )
{
char *answer = NULL;
IOBUF fp;
@@ -285,18 +286,12 @@ ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname )
if( !fp ) {
if( opt.verbose )
log_info(_("reading stdin ...\n"));
- while( (c = getchar()) != EOF ) {
- if( mfx->md )
- md_putc(mfx->md, c );
- }
- }
- else {
- while( (c = iobuf_get(fp)) != -1 ) {
- if( mfx->md )
- md_putc(mfx->md, c );
- }
- iobuf_close(fp);
+ fp = iobuf_open( NULL );
+ assert(fp);
}
+ do_hash( md, md2, fp, textmode );
+ iobuf_close(fp);
+
leave:
m_free(answer);
@@ -315,16 +310,32 @@ do_hash( MD_HANDLE md, MD_HANDLE md2, IOBUF fp, int textmode )
iobuf_push_filter( fp, text_filter, &tfx );
}
if( md2 ) { /* work around a strange behaviour in pgp2 */
+ /* It seems that at least PGP5 converts a single CR to a CR,LF too */
+ int lc = -1;
while( (c = iobuf_get(fp)) != -1 ) {
- if( c == '\n' )
- md_putc(md2, '\r' );
- md_putc(md, c );
- md_putc(md2, c );
+ if( c == '\n' && lc == '\r' )
+ md_putc(md2, c);
+ else if( c == '\n' ) {
+ md_putc(md2, '\r');
+ md_putc(md2, c);
+ }
+ else if( c != '\n' && lc == '\r' ) {
+ md_putc(md2, '\n');
+ md_putc(md2, c);
+ }
+ else
+ md_putc(md2, c);
+
+ if( md )
+ md_putc(md, c );
+ lc = c;
}
}
else {
- while( (c = iobuf_get(fp)) != -1 )
- md_putc(md, c );
+ while( (c = iobuf_get(fp)) != -1 ) {
+ if( md )
+ md_putc(md, c );
+ }
}
}