Remove individual mdX_file() and shaX_file()

parent 06d5d613
......@@ -81,9 +81,9 @@ Removals
* Removed mbedtls_ecp_group_read_string(). Only named groups are supported.
* Removed mbedtls_ecp_sub() and mbedtls_ecp_add(), use
mbedtls_ecp_muladd().
* Removed individual mdX_hmac and shaX_hmac functions (use generic
md_hmac functions from md.h)
* Removed mbedtls_timing_msleep(). Use mbedtls_timing_usleep() or a custom
* Removed individual mdX_hmac, shaX_hmac, mdX_file and shaX_file functions
(use generic functions from md.h)
* Removed mbedtls_timing_msleep(). Use mbedtls_net_usleep() or a custom
waiting function.
* Removed the PBKDF2 module (use PKCS5).
* Removed POLARSSL_ERROR_STRERROR_BC (use mbedtls_strerror()).
......
......@@ -65,14 +65,7 @@
* NET 9 0x0042-0x0052 0x0043-0x0043
* ENTROPY 1 0x0058-0x0058
* ASN1 7 0x0060-0x006C
* MD2 1 0x0070-0x0070
* MD4 1 0x0072-0x0072
* MD5 1 0x0074-0x0074
* SHA1 1 0x0076-0x0076
* SHA256 1 0x0078-0x0078
* SHA512 1 0x007A-0x007A
* PBKDF2 1 0x007C-0x007C
* RIPEMD160 1 0x007E-0x007E
* HMAC_DRBG 4 0x0003-0x0009
* CCM 2 0x000D-0x000F
*
......
......@@ -32,8 +32,6 @@
#include <stddef.h>
#define MBEDTLS_ERR_MD2_FILE_IO_ERROR -0x0070 /**< Read/write error in file. */
#if !defined(MBEDTLS_MD2_ALT)
// Regular implementation
//
......@@ -113,16 +111,6 @@ extern "C" {
*/
void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] );
/**
* \brief Output = MD2( file contents )
*
* \param path input file name
* \param output MD2 checksum result
*
* \return 0 if successful, or MBEDTLS_ERR_MD2_FILE_IO_ERROR
*/
int mbedtls_md2_file( const char *path, unsigned char output[16] );
/**
* \brief Checkup routine
*
......
......@@ -33,8 +33,6 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_MD4_FILE_IO_ERROR -0x0072 /**< Read/write error in file. */
#if !defined(MBEDTLS_MD4_ALT)
// Regular implementation
//
......@@ -113,16 +111,6 @@ extern "C" {
*/
void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] );
/**
* \brief Output = MD4( file contents )
*
* \param path input file name
* \param output MD4 checksum result
*
* \return 0 if successful, or MBEDTLS_ERR_MD4_FILE_IO_ERROR
*/
int mbedtls_md4_file( const char *path, unsigned char output[16] );
/**
* \brief Checkup routine
*
......
......@@ -33,8 +33,6 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_MD5_FILE_IO_ERROR -0x0074 /**< Read/write error in file. */
#if !defined(MBEDTLS_MD5_ALT)
// Regular implementation
//
......@@ -116,16 +114,6 @@ extern "C" {
*/
void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] );
/**
* \brief Output = MD5( file contents )
*
* \param path input file name
* \param output MD5 checksum result
*
* \return 0 if successful, or MBEDTLS_ERR_MD5_FILE_IO_ERROR
*/
int mbedtls_md5_file( const char *path, unsigned char output[16] );
/**
* \brief Checkup routine
*
......
......@@ -33,8 +33,6 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR -0x007E /**< Read/write error in file. */
#if !defined(MBEDTLS_RIPEMD160_ALT)
// Regular implementation
//
......@@ -118,18 +116,6 @@ extern "C" {
void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
unsigned char output[20] );
#if defined(MBEDTLS_FS_IO)
/**
* \brief Output = RIPEMD-160( file contents )
*
* \param path input file name
* \param output RIPEMD-160 checksum result
*
* \return 0 if successful, or MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR
*/
int mbedtls_ripemd160_file( const char *path, unsigned char output[20] );
#endif /* MBEDTLS_FS_IO */
/**
* \brief Checkup routine
*
......
......@@ -33,8 +33,6 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_SHA1_FILE_IO_ERROR -0x0076 /**< Read/write error in file. */
#if !defined(MBEDTLS_SHA1_ALT)
// Regular implementation
//
......@@ -116,16 +114,6 @@ extern "C" {
*/
void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );
/**
* \brief Output = SHA-1( file contents )
*
* \param path input file name
* \param output SHA-1 checksum result
*
* \return 0 if successful, or MBEDTLS_ERR_SHA1_FILE_IO_ERROR
*/
int mbedtls_sha1_file( const char *path, unsigned char output[20] );
/**
* \brief Checkup routine
*
......
......@@ -33,8 +33,6 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_SHA256_FILE_IO_ERROR -0x0078 /**< Read/write error in file. */
#if !defined(MBEDTLS_SHA256_ALT)
// Regular implementation
//
......@@ -121,17 +119,6 @@ extern "C" {
void mbedtls_sha256( const unsigned char *input, size_t ilen,
unsigned char output[32], int is224 );
/**
* \brief Output = SHA-256( file contents )
*
* \param path input file name
* \param output SHA-224/256 checksum result
* \param is224 0 = use SHA256, 1 = use SHA224
*
* \return 0 if successful, or MBEDTLS_ERR_SHA256_FILE_IO_ERROR
*/
int mbedtls_sha256_file( const char *path, unsigned char output[32], int is224 );
/**
* \brief Checkup routine
*
......
......@@ -33,8 +33,6 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_SHA512_FILE_IO_ERROR -0x007A /**< Read/write error in file. */
#if !defined(MBEDTLS_SHA512_ALT)
// Regular implementation
//
......@@ -118,17 +116,6 @@ extern "C" {
void mbedtls_sha512( const unsigned char *input, size_t ilen,
unsigned char output[64], int is384 );
/**
* \brief Output = SHA-512( file contents )
*
* \param path input file name
* \param output SHA-384/512 checksum result
* \param is384 0 = use SHA512, 1 = use SHA384
*
* \return 0 if successful, or MBEDTLS_ERR_SHA512_FILE_IO_ERROR
*/
int mbedtls_sha512_file( const char *path, unsigned char output[64], int is384 );
/**
* \brief Checkup routine
*
......
......@@ -101,18 +101,6 @@
#include "mbedtls/md.h"
#endif
#if defined(MBEDTLS_MD2_C)
#include "mbedtls/md2.h"
#endif
#if defined(MBEDTLS_MD4_C)
#include "mbedtls/md4.h"
#endif
#if defined(MBEDTLS_MD5_C)
#include "mbedtls/md5.h"
#endif
#if defined(MBEDTLS_NET_C)
#include "mbedtls/net.h"
#endif
......@@ -141,26 +129,10 @@
#include "mbedtls/pkcs5.h"
#endif
#if defined(MBEDTLS_RIPEMD160_C)
#include "mbedtls/ripemd160.h"
#endif
#if defined(MBEDTLS_RSA_C)
#include "mbedtls/rsa.h"
#endif
#if defined(MBEDTLS_SHA1_C)
#include "mbedtls/sha1.h"
#endif
#if defined(MBEDTLS_SHA256_C)
#include "mbedtls/sha256.h"
#endif
#if defined(MBEDTLS_SHA512_C)
#include "mbedtls/sha512.h"
#endif
#if defined(MBEDTLS_SSL_TLS_C)
#include "mbedtls/ssl.h"
#endif
......@@ -293,7 +265,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
#if defined(MBEDTLS_PK_C)
if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "PK - Memory alloation failed" );
mbedtls_snprintf( buf, buflen, "PK - Memory allocation failed" );
if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) )
mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
if( use_ret == -(MBEDTLS_ERR_PK_BAD_INPUT_DATA) )
......@@ -649,21 +621,6 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" );
#endif /* MBEDTLS_HMAC_DRBG_C */
#if defined(MBEDTLS_MD2_C)
if( use_ret == -(MBEDTLS_ERR_MD2_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "MD2 - Read/write error in file" );
#endif /* MBEDTLS_MD2_C */
#if defined(MBEDTLS_MD4_C)
if( use_ret == -(MBEDTLS_ERR_MD4_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "MD4 - Read/write error in file" );
#endif /* MBEDTLS_MD4_C */
#if defined(MBEDTLS_MD5_C)
if( use_ret == -(MBEDTLS_ERR_MD5_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "MD5 - Read/write error in file" );
#endif /* MBEDTLS_MD5_C */
#if defined(MBEDTLS_NET_C)
if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) )
mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" );
......@@ -699,26 +656,6 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" );
#endif /* MBEDTLS_PADLOCK_C */
#if defined(MBEDTLS_RIPEMD160_C)
if( use_ret == -(MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "RIPEMD160 - Read/write error in file" );
#endif /* MBEDTLS_RIPEMD160_C */
#if defined(MBEDTLS_SHA1_C)
if( use_ret == -(MBEDTLS_ERR_SHA1_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "SHA1 - Read/write error in file" );
#endif /* MBEDTLS_SHA1_C */
#if defined(MBEDTLS_SHA256_C)
if( use_ret == -(MBEDTLS_ERR_SHA256_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "SHA256 - Read/write error in file" );
#endif /* MBEDTLS_SHA256_C */
#if defined(MBEDTLS_SHA512_C)
if( use_ret == -(MBEDTLS_ERR_SHA512_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "SHA512 - Read/write error in file" );
#endif /* MBEDTLS_SHA512_C */
#if defined(MBEDTLS_THREADING_C)
if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) )
mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" );
......
......@@ -38,10 +38,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"
......@@ -213,40 +209,6 @@ void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[
mbedtls_md2_free( &ctx );
}
#if defined(MBEDTLS_FS_IO)
/*
* output = MD2( file contents )
*/
int mbedtls_md2_file( const char *path, unsigned char output[16] )
{
FILE *f;
size_t n;
mbedtls_md2_context ctx;
unsigned char buf[1024];
if( ( f = fopen( path, "rb" ) ) == NULL )
return( MBEDTLS_ERR_MD2_FILE_IO_ERROR );
mbedtls_md2_init( &ctx );
mbedtls_md2_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
mbedtls_md2_update( &ctx, buf, n );
mbedtls_md2_finish( &ctx, output );
mbedtls_md2_free( &ctx );
if( ferror( f ) != 0 )
{
fclose( f );
return( MBEDTLS_ERR_MD2_FILE_IO_ERROR );
}
fclose( f );
return( 0 );
}
#endif /* MBEDTLS_FS_IO */
#if defined(MBEDTLS_SELF_TEST)
/*
......
......@@ -38,10 +38,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"
......@@ -309,40 +305,6 @@ void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[
mbedtls_md4_free( &ctx );
}
#if defined(MBEDTLS_FS_IO)
/*
* output = MD4( file contents )
*/
int mbedtls_md4_file( const char *path, unsigned char output[16] )
{
FILE *f;
size_t n;
mbedtls_md4_context ctx;
unsigned char buf[1024];
if( ( f = fopen( path, "rb" ) ) == NULL )
return( MBEDTLS_ERR_MD4_FILE_IO_ERROR );
mbedtls_md4_init( &ctx );
mbedtls_md4_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
mbedtls_md4_update( &ctx, buf, n );
mbedtls_md4_finish( &ctx, output );
mbedtls_md4_free( &ctx );
if( ferror( f ) != 0 )
{
fclose( f );
return( MBEDTLS_ERR_MD4_FILE_IO_ERROR );
}
fclose( f );
return( 0 );
}
#endif /* MBEDTLS_FS_IO */
#if defined(MBEDTLS_SELF_TEST)
/*
......
......@@ -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"
......@@ -326,40 +322,6 @@ void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[
mbedtls_md5_free( &ctx );
}
#if defined(MBEDTLS_FS_IO)
/*
* output = MD5( file contents )
*/
int mbedtls_md5_file( const char *path, unsigned char output[16] )
{
FILE *f;
size_t n;
mbedtls_md5_context ctx;
unsigned char buf[1024];
if( ( f = fopen( path, "rb" ) ) == NULL )
return( MBEDTLS_ERR_MD5_FILE_IO_ERROR );
mbedtls_md5_init( &ctx );
mbedtls_md5_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
mbedtls_md5_update( &ctx, buf, n );
mbedtls_md5_finish( &ctx, output );
mbedtls_md5_free( &ctx );
if( ferror( f ) != 0 )
{
fclose( f );
return( MBEDTLS_ERR_MD5_FILE_IO_ERROR );
}
fclose( f );
return( 0 );
}
#endif /* MBEDTLS_FS_IO */
#if defined(MBEDTLS_SELF_TEST)
/*
* RFC 1321 test vectors
......
......@@ -38,10 +38,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"
......@@ -384,40 +380,6 @@ void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
mbedtls_ripemd160_free( &ctx );
}
#if defined(MBEDTLS_FS_IO)
/*
* output = RIPEMD-160( file contents )
*/
int mbedtls_ripemd160_file( const char *path, unsigned char output[20] )
{
FILE *f;
size_t n;
mbedtls_ripemd160_context ctx;
unsigned char buf[1024];
if( ( f = fopen( path, "rb" ) ) == NULL )
return( MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR );
mbedtls_ripemd160_init( &ctx );
mbedtls_ripemd160_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
mbedtls_ripemd160_update( &ctx, buf, n );
mbedtls_ripemd160_finish( &ctx, output );
mbedtls_ripemd160_free( &ctx );
if( ferror( f ) != 0 )
{
fclose( f );
return( MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR );
}
fclose( f );
return( 0 );
}
#endif /* MBEDTLS_FS_IO */
#if defined(MBEDTLS_SELF_TEST)
/*
* Test vectors from the RIPEMD-160 paper and
......
......@@ -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
......
......@@ -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
......
......@@ -43,10 +43,6 @@
#include <string.h>