mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-14 08:13:25 +02:00
* 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.
This commit is contained in:
parent
ebdd458f82
commit
99b1f3e1da
@ -1,3 +1,17 @@
|
|||||||
|
2006-04-19 David Shaw <dshaw@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@jabberwocky.com>
|
2006-04-18 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* keyedit.c (menu_backsign): Give some more verbose errors when we
|
* keyedit.c (menu_backsign): Give some more verbose errors when we
|
||||||
|
18
g10/armor.c
18
g10/armor.c
@ -1,6 +1,6 @@
|
|||||||
/* armor.c - Armor flter
|
/* armor.c - Armor flter
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
* 2005 Free Software Foundation, Inc.
|
* 2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -242,12 +242,14 @@ parse_hash_header( const char *line )
|
|||||||
found |= 2;
|
found |= 2;
|
||||||
else if( !strncmp( s, "MD5", s2-s ) )
|
else if( !strncmp( s, "MD5", s2-s ) )
|
||||||
found |= 4;
|
found |= 4;
|
||||||
else if( !strncmp( s, "SHA256", s2-s ) )
|
else if( !strncmp( s, "SHA224", s2-s ) )
|
||||||
found |= 8;
|
found |= 8;
|
||||||
else if( !strncmp( s, "SHA384", s2-s ) )
|
else if( !strncmp( s, "SHA256", s2-s ) )
|
||||||
found |= 16;
|
found |= 16;
|
||||||
else if( !strncmp( s, "SHA512", s2-s ) )
|
else if( !strncmp( s, "SHA384", s2-s ) )
|
||||||
found |= 32;
|
found |= 32;
|
||||||
|
else if( !strncmp( s, "SHA512", s2-s ) )
|
||||||
|
found |= 64;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
for(; *s2 && (*s2==' ' || *s2 == '\t'); s2++ )
|
for(; *s2 && (*s2==' ' || *s2 == '\t'); s2++ )
|
||||||
@ -953,10 +955,12 @@ armor_filter( void *opaque, int control,
|
|||||||
if( hashes & 4 )
|
if( hashes & 4 )
|
||||||
buf[n++] = DIGEST_ALGO_MD5;
|
buf[n++] = DIGEST_ALGO_MD5;
|
||||||
if( hashes & 8 )
|
if( hashes & 8 )
|
||||||
buf[n++] = DIGEST_ALGO_SHA256;
|
buf[n++] = DIGEST_ALGO_SHA224;
|
||||||
if( hashes & 16 )
|
if( hashes & 16 )
|
||||||
buf[n++] = DIGEST_ALGO_SHA384;
|
buf[n++] = DIGEST_ALGO_SHA256;
|
||||||
if( hashes & 32 )
|
if( hashes & 32 )
|
||||||
|
buf[n++] = DIGEST_ALGO_SHA384;
|
||||||
|
if( hashes & 64 )
|
||||||
buf[n++] = DIGEST_ALGO_SHA512;
|
buf[n++] = DIGEST_ALGO_SHA512;
|
||||||
buf[1] = n - 2;
|
buf[1] = n - 2;
|
||||||
|
|
||||||
|
22
g10/encode.c
22
g10/encode.c
@ -1,6 +1,6 @@
|
|||||||
/* encode.c - encode data
|
/* encode.c - encode data
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
* 2005 Free Software Foundation, Inc.
|
* 2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -268,22 +268,8 @@ encode_simple( const char *filename, int mode, int use_seskey )
|
|||||||
xfree(enc);
|
xfree(enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opt.no_literal) {
|
if (!opt.no_literal)
|
||||||
/* setup the inner packet */
|
pt=setup_plaintext_name(filename,inp);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note that PGP 5 has problems decrypting symmetrically encrypted
|
/* Note that PGP 5 has problems decrypting symmetrically encrypted
|
||||||
data if the file length is in the inner packet. It works when
|
data if the file length is in the inner packet. It works when
|
||||||
|
21
g10/gpg.c
21
g10/gpg.c
@ -2186,7 +2186,12 @@ main (int argc, char **argv )
|
|||||||
riscos_not_implemented("run-as-shm-coprocess");
|
riscos_not_implemented("run-as-shm-coprocess");
|
||||||
#endif /* __riscos__ */
|
#endif /* __riscos__ */
|
||||||
break;
|
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 oForYourEyesOnly: eyes_only = 1; break;
|
||||||
case oNoForYourEyesOnly: eyes_only = 0; break;
|
case oNoForYourEyesOnly: eyes_only = 0; break;
|
||||||
case oSetPolicyURL:
|
case oSetPolicyURL:
|
||||||
@ -2212,8 +2217,12 @@ main (int argc, char **argv )
|
|||||||
opt.verify_options&=~VERIFY_SHOW_POLICY_URLS;
|
opt.verify_options&=~VERIFY_SHOW_POLICY_URLS;
|
||||||
break;
|
break;
|
||||||
case oSigKeyserverURL: add_keyserver_url(pargs.r.ret_str,0); break;
|
case oSigKeyserverURL: add_keyserver_url(pargs.r.ret_str,0); break;
|
||||||
case oUseEmbeddedFilename: opt.use_embedded_filename = 1; break;
|
case oUseEmbeddedFilename:
|
||||||
case oNoUseEmbeddedFilename: opt.use_embedded_filename = 0; break;
|
opt.flags.use_embedded_filename=1;
|
||||||
|
break;
|
||||||
|
case oNoUseEmbeddedFilename:
|
||||||
|
opt.flags.use_embedded_filename=0;
|
||||||
|
break;
|
||||||
case oComment:
|
case oComment:
|
||||||
if(pargs.r.ret_str[0])
|
if(pargs.r.ret_str[0])
|
||||||
append_to_strlist(&opt.comments,pargs.r.ret_str);
|
append_to_strlist(&opt.comments,pargs.r.ret_str);
|
||||||
@ -3095,6 +3104,9 @@ main (int argc, char **argv )
|
|||||||
|
|
||||||
fname = argc? *argv : NULL;
|
fname = argc? *argv : NULL;
|
||||||
|
|
||||||
|
if(fname && utf8_strings)
|
||||||
|
opt.flags.utf8_filename=1;
|
||||||
|
|
||||||
switch( cmd ) {
|
switch( cmd ) {
|
||||||
case aPrimegen:
|
case aPrimegen:
|
||||||
case aPrintMD:
|
case aPrintMD:
|
||||||
@ -3919,6 +3931,7 @@ print_mds( const char *fname, int algo )
|
|||||||
md_enable( md, DIGEST_ALGO_SHA1 );
|
md_enable( md, DIGEST_ALGO_SHA1 );
|
||||||
md_enable( md, DIGEST_ALGO_RMD160 );
|
md_enable( md, DIGEST_ALGO_RMD160 );
|
||||||
#ifdef USE_SHA256
|
#ifdef USE_SHA256
|
||||||
|
md_enable( md, DIGEST_ALGO_SHA224 );
|
||||||
md_enable( md, DIGEST_ALGO_SHA256 );
|
md_enable( md, DIGEST_ALGO_SHA256 );
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SHA512
|
#ifdef USE_SHA512
|
||||||
@ -3941,6 +3954,7 @@ print_mds( const char *fname, int algo )
|
|||||||
print_hashline( md, DIGEST_ALGO_SHA1, fname );
|
print_hashline( md, DIGEST_ALGO_SHA1, fname );
|
||||||
print_hashline( md, DIGEST_ALGO_RMD160, fname );
|
print_hashline( md, DIGEST_ALGO_RMD160, fname );
|
||||||
#ifdef USE_SHA256
|
#ifdef USE_SHA256
|
||||||
|
print_hashline( md, DIGEST_ALGO_SHA224, fname );
|
||||||
print_hashline( md, DIGEST_ALGO_SHA256, fname );
|
print_hashline( md, DIGEST_ALGO_SHA256, fname );
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SHA512
|
#ifdef USE_SHA512
|
||||||
@ -3957,6 +3971,7 @@ print_mds( const char *fname, int algo )
|
|||||||
print_hex( md, DIGEST_ALGO_SHA1, fname );
|
print_hex( md, DIGEST_ALGO_SHA1, fname );
|
||||||
print_hex( md, DIGEST_ALGO_RMD160, fname );
|
print_hex( md, DIGEST_ALGO_RMD160, fname );
|
||||||
#ifdef USE_SHA256
|
#ifdef USE_SHA256
|
||||||
|
print_hex( md, DIGEST_ALGO_SHA224, fname );
|
||||||
print_hex( md, DIGEST_ALGO_SHA256, fname );
|
print_hex( md, DIGEST_ALGO_SHA256, fname );
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SHA512
|
#ifdef USE_SHA512
|
||||||
|
@ -274,6 +274,7 @@ void decrypt_messages(int nfiles, char *files[]);
|
|||||||
/*-- plaintext.c --*/
|
/*-- plaintext.c --*/
|
||||||
int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
|
int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
|
||||||
STRLIST files, const char *sigfilename, int textmode );
|
STRLIST files, const char *sigfilename, int textmode );
|
||||||
|
PKT_plaintext *setup_plaintext_name(const char *filename,IOBUF iobuf);
|
||||||
|
|
||||||
/*-- pipemode.c --*/
|
/*-- pipemode.c --*/
|
||||||
void run_in_pipemode (void);
|
void run_in_pipemode (void);
|
||||||
|
@ -170,7 +170,6 @@ struct
|
|||||||
STRLIST sig_keyserver_url;
|
STRLIST sig_keyserver_url;
|
||||||
STRLIST cert_subpackets;
|
STRLIST cert_subpackets;
|
||||||
STRLIST sig_subpackets;
|
STRLIST sig_subpackets;
|
||||||
int use_embedded_filename;
|
|
||||||
int allow_non_selfsigned_uid;
|
int allow_non_selfsigned_uid;
|
||||||
int allow_freeform_uid;
|
int allow_freeform_uid;
|
||||||
int no_literal;
|
int no_literal;
|
||||||
@ -221,6 +220,8 @@ struct
|
|||||||
made by signing subkeys. If not set, a missing backsig is not
|
made by signing subkeys. If not set, a missing backsig is not
|
||||||
an error (but an invalid backsig still is). */
|
an error (but an invalid backsig still is). */
|
||||||
unsigned int require_cross_cert:1;
|
unsigned int require_cross_cert:1;
|
||||||
|
unsigned int use_embedded_filename:1;
|
||||||
|
unsigned int utf8_filename:1;
|
||||||
} flags;
|
} flags;
|
||||||
|
|
||||||
/* Linked list of ways to find a key if the key isn't on the local
|
/* Linked list of ways to find a key if the key isn't on the local
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* plaintext.c - process plaintext packets
|
/* plaintext.c - process plaintext packets
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
* 2005, 2006 Free Software Foundation, Inc.
|
* 2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -91,7 +91,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||||||
log_info(_("data not saved; use option \"--output\" to save it\n"));
|
log_info(_("data not saved; use option \"--output\" to save it\n"));
|
||||||
nooutput = 1;
|
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) );
|
fname = make_outfile_name( iobuf_get_real_fname(pt->buf) );
|
||||||
if( !fname )
|
if( !fname )
|
||||||
fname = ask_outfile_name( pt->name, pt->namelen );
|
fname = ask_outfile_name( pt->name, pt->namelen );
|
||||||
@ -100,9 +100,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
fname = make_printable_string( pt->name, pt->namelen, 0 );
|
fname=utf8_to_native(pt->name,pt->namelen,0);
|
||||||
}
|
|
||||||
|
|
||||||
if( nooutput )
|
if( nooutput )
|
||||||
;
|
;
|
||||||
@ -547,3 +546,44 @@ hash_datafiles( MD_HANDLE md, MD_HANDLE md2, STRLIST files,
|
|||||||
|
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
17
g10/sign.c
17
g10/sign.c
@ -537,21 +537,8 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode)
|
|||||||
u32 filesize;
|
u32 filesize;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (!opt.no_literal) {
|
if (!opt.no_literal)
|
||||||
if (fname || opt.set_filename) {
|
pt=setup_plaintext_name(fname,inp);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* try to calculate the length of the data */
|
/* try to calculate the length of the data */
|
||||||
if ( !iobuf_is_pipe_filename (fname) && *fname )
|
if ( !iobuf_is_pipe_filename (fname) && *fname )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user