1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Remove individual mdX_file() and shaX_file()

This commit is contained in:
Manuel Pégourié-Gonnard
2015-05-28 14:56:20 +02:00
parent 06d5d61302
commit 41b9c2b418
21 changed files with 4 additions and 703 deletions

View File

@ -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"
@ -359,40 +355,6 @@ void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output
mbedtls_sha1_free( &ctx );
}
#if defined(MBEDTLS_FS_IO)
/*
* output = SHA-1( file contents )
*/
int mbedtls_sha1_file( const char *path, unsigned char output[20] )
{
FILE *f;
size_t n;
mbedtls_sha1_context ctx;
unsigned char buf[1024];
if( ( f = fopen( path, "rb" ) ) == NULL )
return( MBEDTLS_ERR_SHA1_FILE_IO_ERROR );
mbedtls_sha1_init( &ctx );
mbedtls_sha1_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
mbedtls_sha1_update( &ctx, buf, n );
mbedtls_sha1_finish( &ctx, output );
mbedtls_sha1_free( &ctx );
if( ferror( f ) != 0 )
{
fclose( f );
return( MBEDTLS_ERR_SHA1_FILE_IO_ERROR );
}
fclose( f );
return( 0 );
}
#endif /* MBEDTLS_FS_IO */
#if defined(MBEDTLS_SELF_TEST)
/*
* FIPS-180-1 test vectors