Remove individual mdX_file() and shaX_file()
This commit is contained in:
parent
06d5d61302
commit
41b9c2b418
21 changed files with 4 additions and 703 deletions
|
@ -37,10 +37,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
|
@ -331,40 +327,6 @@ void mbedtls_sha256( const unsigned char *input, size_t ilen,
|
|||
mbedtls_sha256_free( &ctx );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
/*
|
||||
* output = SHA-256( file contents )
|
||||
*/
|
||||
int mbedtls_sha256_file( const char *path, unsigned char output[32], int is224 )
|
||||
{
|
||||
FILE *f;
|
||||
size_t n;
|
||||
mbedtls_sha256_context ctx;
|
||||
unsigned char buf[1024];
|
||||
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_SHA256_FILE_IO_ERROR );
|
||||
|
||||
mbedtls_sha256_init( &ctx );
|
||||
mbedtls_sha256_starts( &ctx, is224 );
|
||||
|
||||
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
|
||||
mbedtls_sha256_update( &ctx, buf, n );
|
||||
|
||||
mbedtls_sha256_finish( &ctx, output );
|
||||
mbedtls_sha256_free( &ctx );
|
||||
|
||||
if( ferror( f ) != 0 )
|
||||
{
|
||||
fclose( f );
|
||||
return( MBEDTLS_ERR_SHA256_FILE_IO_ERROR );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
/*
|
||||
* FIPS-180-2 test vectors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue