From 77d6309e2189254cf7a45884fb7ef6a415761988 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 20 May 1999 12:11:41 +0000 Subject: [PATCH] See ChangeLog: Thu May 20 14:04:08 CEST 1999 Werner Koch --- NEWS | 4 ++-- doc/DETAILS | 2 +- doc/FAQ | 15 +++++++++------ g10/ChangeLog | 13 +++++++++++++ g10/armor.c | 12 ++++++++---- g10/filter.h | 3 ++- g10/misc.c | 5 ++++- g10/sig-check.c | 2 +- g10/sign.c | 2 +- g10/textfilter.c | 18 +++++++++++++----- include/util.h | 1 + util/ChangeLog | 6 ++++++ util/memory.c | 4 ++-- util/strgutil.c | 16 +++++++++++----- 14 files changed, 74 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index aadd1b17f..6be1ae0ba 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ - * New option --interactive to prompt before overwriting files. + * New option --interactive to prompt before creating files. - * Add a work around for a bug in pgp 2 which led to bad signatures + * Add some work arounds for a bugs in pgp 2 which led to bad signatures when used with canoncial texts in some cases. diff --git a/doc/DETAILS b/doc/DETAILS index a681c2f89..a8acfe6ce 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -64,7 +64,7 @@ more arguments in future versions. status lines ere emitted for a good signature. SIG_ID - This is emitted only for signatures which + This is emitted only for signatures of class 0 or 1 which have been verified okay. The string is a signature id and may be used in applications to detect replay attacks of signed messages. Note that only DLP algorithms give diff --git a/doc/FAQ b/doc/FAQ index b008f2ce7..e22533e55 100644 --- a/doc/FAQ +++ b/doc/FAQ @@ -21,7 +21,7 @@ public key, and he would only be able to decrypt it by having the secret key and putting in the password to use his secret key. - GNUPG is also useful for signing things. Things that are encrypted with + GnuPG is also useful for signing things. Things that are encrypted with the secret key can be decrypted with the public key. To sign something, a hash is taken of the data, and then the hash is in some form encoded with the secret key. If someone has your public key, they can verify that it @@ -71,7 +71,7 @@ readable, just add the '-a' option. But the preferred method is to use a MIME aware mail reader (Mutt, Pine and many more). - There is a small security glitch in the OpenPGP (and therefor GNUPG) system; + There is a small security glitch in the OpenPGP (and therefore GnuPG) system; to avoid this you should always sign and encrypt a message instead of only encrypting it. @@ -85,13 +85,13 @@ "gpg --fingerprint --fingerprint ". Q: Why are some signatures with an ELG-E key valid? - A: These are ElGamal Key generated by GNUPG in v3 (rfc1991) + A: These are ElGamal Key generated by GnuPG in v3 (rfc1991) packets. The OpenPGP draft later changed the algorithm identifier for ElGamal keys which are usable for signatures - and encryption from 16 to 20. GNUPG now uses 20 when it + and encryption from 16 to 20. GnuPG now uses 20 when it generates new ElGamal keys but still accept 16 (which is according to OpenPGP "encryption only") if this key is in - a v3 packet. GNUPG is the only program which had used + a v3 packet. GnuPG is the only program which had used these v3 ElGamal keys - so this assumption is quite safe. Q: Why is PGP 5.x not able to encrypt messages with some keys? @@ -120,11 +120,14 @@ Q: How can I encrypt a message so that pgp 2.x is able to decrypt it? A: You can't do that because pgp 2.x normally uses IDEA which is not - supported by GNUPG because it is patented, but if you have a modified + supported by GnuPG because it is patented, but if you have a modified version of PGP you can try this: gpg --rfc1991 --cipher-algo 3des ... + Please don't pipe the data to encrypt to gpg but give it as a filename; + other wise, pgp 2 will not be able to handle it. + Q: How can I conventional encrypt a message, so that PGP can decrypt it? A: You can't do this for PGP 2. For PGP 5 you should use this: diff --git a/g10/ChangeLog b/g10/ChangeLog index 4b8d98942..7cebaabd2 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,16 @@ +Thu May 20 14:04:08 CEST 1999 Werner Koch + + * misc.c (pull_in_libs): do the volatile only for gcc + + * sig-check (signature_check): Emit SIG_iD only for classes 0 and 1. + + * armor.c (armor_filter): Add detection of PGP2 created clearsigs. + (fake_packet): A tab is not a WS for pgp2 - handle this. + * textfilter.c (len_without_trailing_chars): New. + (copy_clearsig_text): Add pgp2mode arg. + * sign.c (clearsign_file): pass old_style to the above fnc. + + Wed May 19 16:04:30 CEST 1999 Werner Koch * g10.c: New option --interactive. diff --git a/g10/armor.c b/g10/armor.c index c49dc5cad..38c48fbbe 100644 --- a/g10/armor.c +++ b/g10/armor.c @@ -425,9 +425,8 @@ check_input( armor_filter_context_t *afx, IOBUF a ) if( rc ) invalid_armor(); - else if( afx->in_cleartext ) { + else if( afx->in_cleartext ) afx->faked = 1; - } else { afx->inp_checked = 1; afx->crc = CRCINIT; @@ -480,7 +479,10 @@ fake_packet( armor_filter_context_t *afx, IOBUF a, if( !maxlen ) afx->truncated++; if( !afx->not_dash_escaped ) { - afx->buffer_len = trim_trailing_ws( afx->buffer, afx->buffer_len ); + /* PGP2 does not treat a tab as white space character */ + afx->buffer_len = + trim_trailing_chars( afx->buffer, afx->buffer_len, + afx->pgp2mode ? " \r\n" : " \t\r\n"); /* the buffer is always allocated with enough space to append * a CR, LF, Nul */ afx->buffer[afx->buffer_len++] = '\r'; @@ -809,8 +811,10 @@ armor_filter( void *opaque, int control, * is easy to construct the packets */ hashes &= 1|2|4|8; - if( !hashes ) + if( !hashes ) { hashes |= 4; /* default to MD 5 */ + afx->pgp2mode = 1; + } n=0; do { /* first some onepass signature packets */ diff --git a/g10/filter.h b/g10/filter.h index 30a59d199..86a8e45b8 100644 --- a/g10/filter.h +++ b/g10/filter.h @@ -44,6 +44,7 @@ typedef struct { int faked; /* we are faking a literal data packet */ int truncated; /* number of truncated lines */ int qp_detected; + int pgp2mode; byte *buffer; /* malloced buffer */ unsigned buffer_size; /* and size of this buffer */ @@ -119,7 +120,7 @@ int cipher_filter( void *opaque, int control, int text_filter( void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len); int copy_clearsig_text( IOBUF out, IOBUF inp, MD_HANDLE md, - int escape_dash, int escape_from ); + int escape_dash, int escape_from, int pgp2mode ); diff --git a/g10/misc.c b/g10/misc.c index 47420638d..07d166940 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -41,7 +41,10 @@ const char *g10m_revision_string(int); const char *g10c_revision_string(int); const char *g10u_revision_string(int); -volatile void +#ifdef __GNUC__ +volatile +#endif + void pull_in_libs(void) { g10m_revision_string(0); diff --git a/g10/sig-check.c b/g10/sig-check.c index 068035cf4..b8d2f7f21 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -64,7 +64,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest ) free_public_key( pk ); - if( !rc && is_status_enabled() ) { + if( !rc && sig->sig_class < 2 && is_status_enabled() ) { /* This signature id works best with DLP algorithms because * they use a random parameter for every signature. Instead of * this sig-id we could have also used the hash of the document diff --git a/g10/sign.c b/g10/sign.c index afc1dafc1..a74ee867e 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -548,7 +548,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile ) } /*md_start_debug( textmd, "sign" );*/ copy_clearsig_text( out, inp, textmd, - !opt.not_dash_escaped, opt.escape_from ); + !opt.not_dash_escaped, opt.escape_from, old_style ); /* fixme: check for read errors */ /* now write the armor */ diff --git a/g10/textfilter.c b/g10/textfilter.c index 5896c3f32..3125925b6 100644 --- a/g10/textfilter.c +++ b/g10/textfilter.c @@ -37,14 +37,14 @@ /* to make sure that a warning is displayed while */ /* creating a message */ -unsigned -len_without_trailing_ws( byte *line, unsigned len ) +static unsigned +len_without_trailing_chars( byte *line, unsigned len, const char *trimchars ) { byte *p, *mark; unsigned n; for(mark=NULL, p=line, n=0; n < len; n++, p++ ) { - if( strchr(" \t\r\n", *p ) ) { + if( strchr( trimchars, *p ) ) { if( !mark ) mark = p; } @@ -55,6 +55,12 @@ len_without_trailing_ws( byte *line, unsigned len ) return mark? (mark - line) : len; } +unsigned +len_without_trailing_ws( byte *line, unsigned len ) +{ + return len_without_trailing_chars( line, len, " \t\r\n" ); +} + @@ -136,7 +142,7 @@ text_filter( void *opaque, int control, */ int copy_clearsig_text( IOBUF out, IOBUF inp, MD_HANDLE md, - int escape_dash, int escape_from ) + int escape_dash, int escape_from, int pgp2mode ) { unsigned maxlen; byte *buffer = NULL; /* malloced buffer */ @@ -163,7 +169,9 @@ copy_clearsig_text( IOBUF out, IOBUF inp, MD_HANDLE md, md_putc( md, '\r' ); md_putc( md, '\n' ); } - md_write( md, buffer, len_without_trailing_ws( buffer, n ) ); + md_write( md, buffer, + len_without_trailing_chars( buffer, n, + pgp2mode? " \r\n":" \t\r\n")); } else md_write( md, buffer, n ); diff --git a/include/util.h b/include/util.h index 36ce319c3..8dcf6d1f6 100644 --- a/include/util.h +++ b/include/util.h @@ -163,6 +163,7 @@ STRLIST strlist_last( STRLIST node ); const char *memistr( const char *buf, size_t buflen, const char *sub ); char *mem2str( char *, const void *, size_t); char *trim_spaces( char *string ); +unsigned trim_trailing_chars( byte *line, unsigned len, const char *trimchars); unsigned trim_trailing_ws( byte *line, unsigned len ); int string_count_chr( const char *string, int c ); int set_native_charset( const char *newset ); diff --git a/util/ChangeLog b/util/ChangeLog index 1905d19c9..417c7b402 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,9 @@ +Thu May 20 14:04:08 CEST 1999 Werner Koch + + * memory.c (membug): Nanu, there was a const instead of a static. + + * strgutil.c (trim_trailing_chars): New. + Mon May 17 21:54:43 CEST 1999 Werner Koch * logger.c (g10_log_hexdump): Made 2nd arg a const. diff --git a/util/memory.c b/util/memory.c index 4370c72ec..ebf8f8893 100644 --- a/util/memory.c +++ b/util/memory.c @@ -48,7 +48,7 @@ #define EXTRA_ALIGN 0 #endif -const void membug( const char *fmt, ... ); +static void membug( const char *fmt, ... ); #ifdef M_DEBUG #ifndef M_GUARD @@ -320,7 +320,7 @@ check_allmem( const char *info ) #endif /* M_DEBUG */ -const void +static void membug( const char *fmt, ... ) { va_list arg_ptr ; diff --git a/util/strgutil.c b/util/strgutil.c index 5cef77bf6..ab0d2234a 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -213,17 +213,14 @@ trim_spaces( char *str ) -/**************** - * remove trailing white spaces and return the length of the buffer - */ unsigned -trim_trailing_ws( byte *line, unsigned len ) +trim_trailing_chars( byte *line, unsigned len, const char *trimchars ) { byte *p, *mark; unsigned n; for(mark=NULL, p=line, n=0; n < len; n++, p++ ) { - if( strchr(" \t\r\n", *p ) ) { + if( strchr(trimchars, *p ) ) { if( !mark ) mark = p; } @@ -238,6 +235,15 @@ trim_trailing_ws( byte *line, unsigned len ) return len; } +/**************** + * remove trailing white spaces and return the length of the buffer + */ +unsigned +trim_trailing_ws( byte *line, unsigned len ) +{ + return trim_trailing_chars( line, len, " \t\r\n" ); +} + int