SHA2 renamed to SHA256, SHA4 renamed to SHA512 and functions accordingly

The SHA4 name was not clear with regards to the new SHA-3 standard. So
SHA2 and SHA4 have been renamed to better represent what they are:
SHA256 and SHA512 modules.
This commit is contained in:
Paul Bakker 2013-06-30 14:34:05 +02:00
parent 3866b9f4b5
commit 9e36f0475f
32 changed files with 700 additions and 697 deletions

View file

@ -1,5 +1,5 @@
/*
* sha2sum demonstration program
* sha256sum demonstration program
*
* Copyright (C) 2006-2011, Brainspark B.V.
*
@ -34,19 +34,19 @@
#include "polarssl/sha2.h"
#if !defined(POLARSSL_SHA2_C) || !defined(POLARSSL_FS_IO)
#if !defined(POLARSSL_SHA256_C) || !defined(POLARSSL_FS_IO)
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_SHA2_C and/or POLARSSL_FS_IO not defined.\n");
printf("POLARSSL_SHA256_C and/or POLARSSL_FS_IO not defined.\n");
return( 0 );
}
#else
static int sha2_wrapper( char *filename, unsigned char *sum )
static int sha256_wrapper( char *filename, unsigned char *sum )
{
int ret = sha2_file( filename, sum, 0 );
int ret = sha256_file( filename, sum, 0 );
if( ret == 1 )
fprintf( stderr, "failed to open: %s\n", filename );
@ -57,12 +57,12 @@ static int sha2_wrapper( char *filename, unsigned char *sum )
return( ret );
}
static int sha2_print( char *filename )
static int sha256_print( char *filename )
{
int i;
unsigned char sum[32];
if( sha2_wrapper( filename, sum ) != 0 )
if( sha256_wrapper( filename, sum ) != 0 )
return( 1 );
for( i = 0; i < 32; i++ )
@ -72,7 +72,7 @@ static int sha2_print( char *filename )
return( 0 );
}
static int sha2_check( char *filename )
static int sha256_check( char *filename )
{
int i;
size_t n;
@ -110,7 +110,7 @@ static int sha2_check( char *filename )
nb_tot1++;
if( sha2_wrapper( line + 66, sum ) != 0 )
if( sha256_wrapper( line + 66, sum ) != 0 )
{
nb_err1++;
continue;
@ -151,8 +151,8 @@ int main( int argc, char *argv[] )
if( argc == 1 )
{
printf( "print mode: sha2sum <file> <file> ...\n" );
printf( "check mode: sha2sum -c <checksum file>\n" );
printf( "print mode: sha256sum <file> <file> ...\n" );
printf( "check mode: sha256sum -c <checksum file>\n" );
#if defined(_WIN32)
printf( "\n Press Enter to exit this program.\n" );
@ -163,12 +163,12 @@ int main( int argc, char *argv[] )
}
if( argc == 3 && strcmp( "-c", argv[1] ) == 0 )
return( sha2_check( argv[2] ) );
return( sha256_check( argv[2] ) );
ret = 0;
for( i = 1; i < argc; i++ )
ret |= sha2_print( argv[i] );
ret |= sha256_print( argv[i] );
return( ret );
}
#endif /* POLARSSL_SHA2_C && POLARSSL_FS_IO */
#endif /* POLARSSL_SHA256_C && POLARSSL_FS_IO */