aboutsummaryrefslogtreecommitdiffstats
path: root/g10/g10.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2003-02-04 19:33:09 +0000
committerDavid Shaw <[email protected]>2003-02-04 19:33:09 +0000
commitf523e53d4e7a59feabf3873f39291061aff9e8d5 (patch)
tree0ac23fb15a502fcdef33131da70908df8dd34a70 /g10/g10.c
parent* sha256.c, sha512.c: New. (diff)
downloadgnupg-f523e53d4e7a59feabf3873f39291061aff9e8d5.tar.gz
gnupg-f523e53d4e7a59feabf3873f39291061aff9e8d5.zip
* 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.
Diffstat (limited to 'g10/g10.c')
-rw-r--r--g10/g10.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/g10/g10.c b/g10/g10.c
index dd0c2b7af..19e669b47 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -2694,31 +2694,31 @@ print_hex( byte *p, size_t n )
{
int i;
- if( n == 20 ) {
- for(i=0; i < n ; i++, i++, p += 2 ) {
- if( i )
+ if( n == 16 ) {
+ for(i=0; i < n ; i++, p++ ) {
+ if( i )
putchar(' ');
- if( i == 10 )
+ if( i && !(i%8) )
putchar(' ');
- printf("%02X%02X", *p, p[1] );
+ printf("%02X", *p );
}
}
- else if( n == 24 ) {
- for(i=0; i < n ; i += 4, p += 4 ) {
+ else if( n == 20 ) {
+ for(i=0; i < n ; i++, i++, p += 2 ) {
if( i )
putchar(' ');
- if( i == 12 )
+ if( i == 10 )
putchar(' ');
- printf("%02X%02X%02X%02X", *p, p[1], p[2], p[3] );
+ printf("%02X%02X", *p, p[1] );
}
}
else {
- for(i=0; i < n ; i++, p++ ) {
+ for(i=0; i < n ; i += 4, p += 4 ) {
if( i )
putchar(' ');
- if( i && !(i%8) )
+ if( i == 12 && n <= 24 )
putchar(' ');
- printf("%02X", *p );
+ printf("%02X%02X%02X%02X", *p, p[1], p[2], p[3] );
}
}
}
@@ -2783,6 +2783,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 )) )
@@ -2800,6 +2803,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 {
@@ -2818,7 +2824,13 @@ print_mds( const char *fname, int algo )
if( !check_digest_algo(DIGEST_ALGO_TIGER) ) {
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');
}