diff --git a/g10/ChangeLog b/g10/ChangeLog index be759ba91..fb49adea7 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,15 @@ +2004-12-09 David Shaw + + * options.h, g10.c (main), textfilter.c (len_without_trailing_ws): + Removed (not used). + (standard): 2440 says that textmode hashes should canonicalize + line endings to CRLF and remove spaces and tabs. 2440bis-12 says + to just canonicalize to CRLF. So, we default to the 2440bis-12 + behavior, but revert to the strict 2440 behavior if the user + specifies --rfc2440. In practical terms this makes no difference + to any signatures in the real world except for a textmode detached + signature. + 2004-12-09 Werner Koch * passphrase.c (agent_get_passphrase): New args CUSTOM_PROMPT and diff --git a/g10/g10.c b/g10/g10.c index 2a17214d9..a01df371c 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -2092,6 +2092,8 @@ main( int argc, char **argv ) opt.escape_from = 1; break; case oRFC2440: + opt.strict_2440_line_endings=1; + /* fall through */ case oOpenPGP: /* TODO: When 2440bis becomes a RFC, these may need changing. */ diff --git a/g10/options.h b/g10/options.h index e8463f0e8..340056c6f 100644 --- a/g10/options.h +++ b/g10/options.h @@ -192,6 +192,7 @@ struct unsigned int screen_columns; unsigned int screen_lines; byte *show_subpackets; + int strict_2440_line_endings; #ifdef ENABLE_CARD_SUPPORT const char *ctapi_driver; /* Library to access the ctAPI. */ diff --git a/g10/textfilter.c b/g10/textfilter.c index 6f3fe1bbf..16f0d9faa 100644 --- a/g10/textfilter.c +++ b/g10/textfilter.c @@ -1,5 +1,5 @@ /* textfilter.c - * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -61,15 +61,6 @@ len_without_trailing_chars( byte *line, unsigned len, const char *trimchars ) return mark? (mark - line) : len; } -unsigned -len_without_trailing_ws( byte *line, unsigned len ) -{ - return len_without_trailing_chars( line, len, " \t\r\n" ); -} - - - - static int standard( text_filter_context_t *tfx, IOBUF a, byte *buf, size_t size, size_t *ret_len) @@ -101,7 +92,25 @@ standard( text_filter_context_t *tfx, IOBUF a, break; } lf_seen = tfx->buffer[tfx->buffer_len-1] == '\n'; - tfx->buffer_len = trim_trailing_ws( tfx->buffer, tfx->buffer_len ); + + /* The story behind this is that 2440 says that textmode + hashes should canonicalize line endings to CRLF and remove + spaces and tabs. 2440bis-12 says to just canonicalize to + CRLF. So, we default to the 2440bis-12 behavior, but + revert to the strict 2440 behavior if the user specifies + --rfc2440. In practical terms this makes no difference to + any signatures in the real world except for a textmode + detached signature. PGP always used the 2440bis-12 (1991) + behavior (ignoring 2440 itself), so this actually makes us + compatible with PGP textmode detached signatures for the + first time. */ + if(opt.strict_2440_line_endings) + tfx->buffer_len=trim_trailing_chars(tfx->buffer,tfx->buffer_len, + " \t\r\n"); + else + tfx->buffer_len=trim_trailing_chars(tfx->buffer,tfx->buffer_len, + "\r\n"); + if( lf_seen ) { tfx->buffer[tfx->buffer_len++] = '\r'; tfx->buffer[tfx->buffer_len++] = '\n';