[svn] GnuPG - r4117 - trunk/g10
svn author dshaw
cvs at cvs.gnupg.org
Thu Apr 20 04:36:22 CEST 2006
Author: dshaw
Date: 2006-04-20 04:36:05 +0200 (Thu, 20 Apr 2006)
New Revision: 4117
Modified:
trunk/g10/ChangeLog
trunk/g10/armor.c
trunk/g10/encode.c
trunk/g10/gpg.c
trunk/g10/main.h
trunk/g10/options.h
trunk/g10/plaintext.c
trunk/g10/sign.c
Log:
* gpg.c (print_mds), armor.c (armor_filter, parse_hash_header): Add
SHA-224.
* sign.c (write_plaintext_packet), encode.c (encode_simple): Factor
common literal packet setup code from here, to...
* main.h, plaintext.c (setup_plaintext_name): Here. New. Make sure the
literal packet filename field is UTF-8 encoded.
* options.h, gpg.c (main): Make sure --set-filename is UTF-8 encoded
and note when filenames are already UTF-8.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/ChangeLog 2006-04-20 02:36:05 UTC (rev 4117)
@@ -1,3 +1,17 @@
+2006-04-19 David Shaw <dshaw at jabberwocky.com>
+
+ * gpg.c (print_mds), armor.c (armor_filter, parse_hash_header):
+ Add SHA-224.
+
+ * sign.c (write_plaintext_packet), encode.c (encode_simple):
+ Factor common literal packet setup code from here, to...
+
+ * main.h, plaintext.c (setup_plaintext_name): Here. New. Make sure
+ the literal packet filename field is UTF-8 encoded.
+
+ * options.h, gpg.c (main): Make sure --set-filename is UTF-8
+ encoded and note when filenames are already UTF-8.
+
2006-04-18 David Shaw <dshaw at jabberwocky.com>
* keyedit.c (menu_backsign): Give some more verbose errors when we
Modified: trunk/g10/armor.c
===================================================================
--- trunk/g10/armor.c 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/armor.c 2006-04-20 02:36:05 UTC (rev 4117)
@@ -1,6 +1,6 @@
/* armor.c - Armor flter
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -242,12 +242,14 @@
found |= 2;
else if( !strncmp( s, "MD5", s2-s ) )
found |= 4;
+ else if( !strncmp( s, "SHA224", s2-s ) )
+ found |= 8;
else if( !strncmp( s, "SHA256", s2-s ) )
- found |= 8;
+ found |= 16;
else if( !strncmp( s, "SHA384", s2-s ) )
- found |= 16;
+ found |= 32;
else if( !strncmp( s, "SHA512", s2-s ) )
- found |= 32;
+ found |= 64;
else
return 0;
for(; *s2 && (*s2==' ' || *s2 == '\t'); s2++ )
@@ -953,10 +955,12 @@
if( hashes & 4 )
buf[n++] = DIGEST_ALGO_MD5;
if( hashes & 8 )
+ buf[n++] = DIGEST_ALGO_SHA224;
+ if( hashes & 16 )
buf[n++] = DIGEST_ALGO_SHA256;
- if( hashes & 16 )
+ if( hashes & 32 )
buf[n++] = DIGEST_ALGO_SHA384;
- if( hashes & 32 )
+ if( hashes & 64 )
buf[n++] = DIGEST_ALGO_SHA512;
buf[1] = n - 2;
Modified: trunk/g10/encode.c
===================================================================
--- trunk/g10/encode.c 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/encode.c 2006-04-20 02:36:05 UTC (rev 4117)
@@ -1,6 +1,6 @@
/* encode.c - encode data
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -268,22 +268,8 @@
xfree(enc);
}
- if (!opt.no_literal) {
- /* setup the inner packet */
- if( filename || opt.set_filename ) {
- char *s = make_basename( opt.set_filename ? opt.set_filename
- : filename,
- iobuf_get_real_fname( inp ) );
- pt = xmalloc( sizeof *pt + strlen(s) - 1 );
- pt->namelen = strlen(s);
- memcpy(pt->name, s, pt->namelen );
- xfree(s);
- }
- else { /* no filename */
- pt = xmalloc( sizeof *pt - 1 );
- pt->namelen = 0;
- }
- }
+ if (!opt.no_literal)
+ pt=setup_plaintext_name(filename,inp);
/* Note that PGP 5 has problems decrypting symmetrically encrypted
data if the file length is in the inner packet. It works when
Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/gpg.c 2006-04-20 02:36:05 UTC (rev 4117)
@@ -2186,7 +2186,12 @@
riscos_not_implemented("run-as-shm-coprocess");
#endif /* __riscos__ */
break;
- case oSetFilename: opt.set_filename = pargs.r.ret_str; break;
+ case oSetFilename:
+ if(utf8_strings)
+ opt.set_filename = pargs.r.ret_str;
+ else
+ opt.set_filename = native_to_utf8(pargs.r.ret_str);
+ break;
case oForYourEyesOnly: eyes_only = 1; break;
case oNoForYourEyesOnly: eyes_only = 0; break;
case oSetPolicyURL:
@@ -2212,8 +2217,12 @@
opt.verify_options&=~VERIFY_SHOW_POLICY_URLS;
break;
case oSigKeyserverURL: add_keyserver_url(pargs.r.ret_str,0); break;
- case oUseEmbeddedFilename: opt.use_embedded_filename = 1; break;
- case oNoUseEmbeddedFilename: opt.use_embedded_filename = 0; break;
+ case oUseEmbeddedFilename:
+ opt.flags.use_embedded_filename=1;
+ break;
+ case oNoUseEmbeddedFilename:
+ opt.flags.use_embedded_filename=0;
+ break;
case oComment:
if(pargs.r.ret_str[0])
append_to_strlist(&opt.comments,pargs.r.ret_str);
@@ -3095,6 +3104,9 @@
fname = argc? *argv : NULL;
+ if(fname && utf8_strings)
+ opt.flags.utf8_filename=1;
+
switch( cmd ) {
case aPrimegen:
case aPrintMD:
@@ -3919,6 +3931,7 @@
md_enable( md, DIGEST_ALGO_SHA1 );
md_enable( md, DIGEST_ALGO_RMD160 );
#ifdef USE_SHA256
+ md_enable( md, DIGEST_ALGO_SHA224 );
md_enable( md, DIGEST_ALGO_SHA256 );
#endif
#ifdef USE_SHA512
@@ -3941,6 +3954,7 @@
print_hashline( md, DIGEST_ALGO_SHA1, fname );
print_hashline( md, DIGEST_ALGO_RMD160, fname );
#ifdef USE_SHA256
+ print_hashline( md, DIGEST_ALGO_SHA224, fname );
print_hashline( md, DIGEST_ALGO_SHA256, fname );
#endif
#ifdef USE_SHA512
@@ -3957,6 +3971,7 @@
print_hex( md, DIGEST_ALGO_SHA1, fname );
print_hex( md, DIGEST_ALGO_RMD160, fname );
#ifdef USE_SHA256
+ print_hex( md, DIGEST_ALGO_SHA224, fname );
print_hex( md, DIGEST_ALGO_SHA256, fname );
#endif
#ifdef USE_SHA512
Modified: trunk/g10/main.h
===================================================================
--- trunk/g10/main.h 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/main.h 2006-04-20 02:36:05 UTC (rev 4117)
@@ -274,6 +274,7 @@
/*-- plaintext.c --*/
int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
STRLIST files, const char *sigfilename, int textmode );
+PKT_plaintext *setup_plaintext_name(const char *filename,IOBUF iobuf);
/*-- pipemode.c --*/
void run_in_pipemode (void);
Modified: trunk/g10/options.h
===================================================================
--- trunk/g10/options.h 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/options.h 2006-04-20 02:36:05 UTC (rev 4117)
@@ -170,7 +170,6 @@
STRLIST sig_keyserver_url;
STRLIST cert_subpackets;
STRLIST sig_subpackets;
- int use_embedded_filename;
int allow_non_selfsigned_uid;
int allow_freeform_uid;
int no_literal;
@@ -221,6 +220,8 @@
made by signing subkeys. If not set, a missing backsig is not
an error (but an invalid backsig still is). */
unsigned int require_cross_cert:1;
+ unsigned int use_embedded_filename:1;
+ unsigned int utf8_filename:1;
} flags;
/* Linked list of ways to find a key if the key isn't on the local
Modified: trunk/g10/plaintext.c
===================================================================
--- trunk/g10/plaintext.c 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/plaintext.c 2006-04-20 02:36:05 UTC (rev 4117)
@@ -1,6 +1,6 @@
/* plaintext.c - process plaintext packets
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -91,7 +91,7 @@
log_info(_("data not saved; use option \"--output\" to save it\n"));
nooutput = 1;
}
- else if( !opt.use_embedded_filename ) {
+ else if( !opt.flags.use_embedded_filename ) {
fname = make_outfile_name( iobuf_get_real_fname(pt->buf) );
if( !fname )
fname = ask_outfile_name( pt->name, pt->namelen );
@@ -100,9 +100,8 @@
goto leave;
}
}
- else {
- fname = make_printable_string( pt->name, pt->namelen, 0 );
- }
+ else
+ fname=utf8_to_native(pt->name,pt->namelen,0);
if( nooutput )
;
@@ -547,3 +546,44 @@
return 0;
}
+
+
+/* Set up a plaintext packet with the appropriate filename. If there
+ is a --set-filename, use it (it's already UTF8). If there is a
+ regular filename, UTF8-ize it if necessary. If there is no
+ filenames at all, set the field empty. */
+
+PKT_plaintext *
+setup_plaintext_name(const char *filename,IOBUF iobuf)
+{
+ PKT_plaintext *pt;
+
+ if(filename || opt.set_filename)
+ {
+ char *s;
+
+ if(opt.set_filename)
+ s=make_basename(opt.set_filename,iobuf_get_real_fname(iobuf));
+ else if(filename && !opt.flags.utf8_filename)
+ {
+ char *tmp=native_to_utf8(filename);
+ s=make_basename(tmp,iobuf_get_real_fname(iobuf));
+ xfree(tmp);
+ }
+ else
+ s=make_basename(filename,iobuf_get_real_fname(iobuf));
+
+ pt = xmalloc (sizeof *pt + strlen(s) - 1);
+ pt->namelen = strlen (s);
+ memcpy (pt->name, s, pt->namelen);
+ xfree (s);
+ }
+ else
+ {
+ /* no filename */
+ pt = xmalloc (sizeof *pt - 1);
+ pt->namelen = 0;
+ }
+
+ return pt;
+}
Modified: trunk/g10/sign.c
===================================================================
--- trunk/g10/sign.c 2006-04-20 02:12:34 UTC (rev 4116)
+++ trunk/g10/sign.c 2006-04-20 02:36:05 UTC (rev 4117)
@@ -537,21 +537,8 @@
u32 filesize;
int rc = 0;
- if (!opt.no_literal) {
- if (fname || opt.set_filename) {
- char *s = make_basename (opt.set_filename? opt.set_filename
- : fname,
- iobuf_get_real_fname(inp));
- pt = xmalloc (sizeof *pt + strlen(s) - 1);
- pt->namelen = strlen (s);
- memcpy (pt->name, s, pt->namelen);
- xfree (s);
- }
- else { /* no filename */
- pt = xmalloc (sizeof *pt - 1);
- pt->namelen = 0;
- }
- }
+ if (!opt.no_literal)
+ pt=setup_plaintext_name(fname,inp);
/* try to calculate the length of the data */
if ( !iobuf_is_pipe_filename (fname) && *fname )
More information about the Gnupg-commits
mailing list