1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

* armor.c (parse_hash_header, armor_filter): Accept the new SHAs in the

armor Hash: header.

* g10.c (print_hex): Print long hash strings a little neater. (print_mds):
Add the new SHAs to the hash list.
This commit is contained in:
David Shaw 2003-02-04 18:59:22 +00:00
parent 39db2a7190
commit 443e083f4a
3 changed files with 50 additions and 18 deletions

View File

@ -1,3 +1,11 @@
2003-02-04 David Shaw <dshaw@jabberwocky.com>
* armor.c (parse_hash_header, armor_filter): Accept the new SHAs
in the armor Hash: header.
* g10.c (print_hex): Print long hash strings a little neater.
(print_mds): Add the new SHAs to the hash list.
2003-02-02 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (menu_revuid): Properly handle a nonselfsigned uid on

View File

@ -252,6 +252,12 @@ parse_hash_header( const char *line )
found |= 8;
else if( !strncmp( s, "TIGER", s2-s ) ) /* used by old versions */
found |= 8;
else if( !strncmp( s, "SHA256", s2-s ) )
found |= 16;
else if( !strncmp( s, "SHA384", s2-s ) )
found |= 32;
else if( !strncmp( s, "SHA512", s2-s ) )
found |= 64;
else
return 0;
for(; *s2 && (*s2==' ' || *s2 == '\t'); s2++ )
@ -869,7 +875,7 @@ armor_filter( void *opaque, int control,
/* the buffer is at least 15+n*15 bytes long, so it
* is easy to construct the packets */
hashes &= 1|2|4|8;
hashes &= 1|2|4|8|16|32|64;
if( !hashes ) {
hashes |= 4; /* default to MD 5 */
/* This is non-ideal since PGP 5-8 have the same
@ -893,6 +899,12 @@ armor_filter( void *opaque, int control,
buf[n++] = DIGEST_ALGO_MD5;
if( hashes & 8 )
buf[n++] = DIGEST_ALGO_TIGER;
if( hashes & 16 )
buf[n++] = DIGEST_ALGO_SHA256;
if( hashes & 32 )
buf[n++] = DIGEST_ALGO_SHA384;
if( hashes & 64 )
buf[n++] = DIGEST_ALGO_SHA512;
buf[1] = n - 2;
/* followed by a plaintext packet */

View File

@ -2576,7 +2576,16 @@ print_hex( byte *p, size_t n )
{
int i;
if( n == 20 ) {
if( n == 16 ) {
for(i=0; i < n ; i++, p++ ) {
if( i )
putchar(' ');
if( i && !(i%8) )
putchar(' ');
printf("%02X", *p );
}
}
else if( n == 20 ) {
for(i=0; i < n ; i++, i++, p += 2 ) {
if( i )
putchar(' ');
@ -2585,24 +2594,15 @@ print_hex( byte *p, size_t n )
printf("%02X%02X", *p, p[1] );
}
}
else if( n == 24 ) {
else {
for(i=0; i < n ; i += 4, p += 4 ) {
if( i )
putchar(' ');
if( i == 12 )
if( i == 12 && n <= 24 )
putchar(' ');
printf("%02X%02X%02X%02X", *p, p[1], p[2], p[3] );
}
}
else {
for(i=0; i < n ; i++, p++ ) {
if( i )
putchar(' ');
if( i && !(i%8) )
putchar(' ');
printf("%02X", *p );
}
}
}
static void
@ -2665,6 +2665,9 @@ print_mds( const char *fname, int algo )
md_enable( md, DIGEST_ALGO_RMD160 );
if( !check_digest_algo(DIGEST_ALGO_TIGER) )
md_enable( md, DIGEST_ALGO_TIGER );
md_enable( md, DIGEST_ALGO_SHA256 );
md_enable( md, DIGEST_ALGO_SHA384 );
md_enable( md, DIGEST_ALGO_SHA512 );
}
while( (n=fread( buf, 1, DIM(buf), fp )) )
@ -2682,6 +2685,9 @@ print_mds( const char *fname, int algo )
print_hashline( md, DIGEST_ALGO_RMD160, fname );
if( !check_digest_algo(DIGEST_ALGO_TIGER) )
print_hashline( md, DIGEST_ALGO_TIGER, fname );
print_hashline( md, DIGEST_ALGO_SHA256, fname );
print_hashline( md, DIGEST_ALGO_SHA384, fname );
print_hashline( md, DIGEST_ALGO_SHA512, fname );
}
}
else {
@ -2701,6 +2707,12 @@ print_mds( const char *fname, int algo )
printf("\n%s TIGER = ", fname?pname:"" );
print_hex(md_read(md, DIGEST_ALGO_TIGER), 24 );
}
printf("\n%sSHA256 = ", fname?pname:"" );
print_hex(md_read(md, DIGEST_ALGO_SHA256), 32 );
printf("\n%sSHA384 = ", fname?pname:"" );
print_hex(md_read(md, DIGEST_ALGO_SHA384), 48 );
printf("\n%sSHA512 = ", fname?pname:"" );
print_hex(md_read(md, DIGEST_ALGO_SHA512), 64 );
}
putchar('\n');
}