mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Update external polarssl to 1.3.8
There were some fixes back on March 13th, 2014 for fixing compiling on MIPS64. Also some fixes on June 25th, 2014 for SPARC64 fixes. Probably more things, but those are what I care about.
This commit is contained in:
68
Externals/polarssl/library/md4.c
vendored
68
Externals/polarssl/library/md4.c
vendored
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RFC 1186/1320 compliant MD4 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
* Copyright (C) 2006-2014, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
@ -29,7 +29,11 @@
|
||||
* http://www.ietf.org/rfc/rfc1320.txt
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#include "polarssl/config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_MD4_C)
|
||||
|
||||
@ -39,6 +43,17 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
}
|
||||
|
||||
#if !defined(POLARSSL_MD4_ALT)
|
||||
|
||||
/*
|
||||
@ -64,6 +79,19 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
void md4_init( md4_context *ctx )
|
||||
{
|
||||
memset( ctx, 0, sizeof( md4_context ) );
|
||||
}
|
||||
|
||||
void md4_free( md4_context *ctx )
|
||||
{
|
||||
if( ctx == NULL )
|
||||
return;
|
||||
|
||||
polarssl_zeroize( ctx, sizeof( md4_context ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* MD4 context setup
|
||||
*/
|
||||
@ -189,7 +217,7 @@ void md4_update( md4_context *ctx, const unsigned char *input, size_t ilen )
|
||||
size_t fill;
|
||||
uint32_t left;
|
||||
|
||||
if( ilen <= 0 )
|
||||
if( ilen == 0 )
|
||||
return;
|
||||
|
||||
left = ctx->total[0] & 0x3F;
|
||||
@ -270,11 +298,11 @@ void md4( const unsigned char *input, size_t ilen, unsigned char output[16] )
|
||||
{
|
||||
md4_context ctx;
|
||||
|
||||
md4_init( &ctx );
|
||||
md4_starts( &ctx );
|
||||
md4_update( &ctx, input, ilen );
|
||||
md4_finish( &ctx, output );
|
||||
|
||||
memset( &ctx, 0, sizeof( md4_context ) );
|
||||
md4_free( &ctx );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
@ -291,14 +319,14 @@ int md4_file( const char *path, unsigned char output[16] )
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( POLARSSL_ERR_MD4_FILE_IO_ERROR );
|
||||
|
||||
md4_init( &ctx );
|
||||
md4_starts( &ctx );
|
||||
|
||||
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
|
||||
md4_update( &ctx, buf, n );
|
||||
|
||||
md4_finish( &ctx, output );
|
||||
|
||||
memset( &ctx, 0, sizeof( md4_context ) );
|
||||
md4_free( &ctx );
|
||||
|
||||
if( ferror( f ) != 0 )
|
||||
{
|
||||
@ -314,7 +342,8 @@ int md4_file( const char *path, unsigned char output[16] )
|
||||
/*
|
||||
* MD4 HMAC context setup
|
||||
*/
|
||||
void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen )
|
||||
void md4_hmac_starts( md4_context *ctx, const unsigned char *key,
|
||||
size_t keylen )
|
||||
{
|
||||
size_t i;
|
||||
unsigned char sum[16];
|
||||
@ -338,13 +367,14 @@ void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen
|
||||
md4_starts( ctx );
|
||||
md4_update( ctx, ctx->ipad, 64 );
|
||||
|
||||
memset( sum, 0, sizeof( sum ) );
|
||||
polarssl_zeroize( sum, sizeof( sum ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* MD4 HMAC process buffer
|
||||
*/
|
||||
void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen )
|
||||
void md4_hmac_update( md4_context *ctx, const unsigned char *input,
|
||||
size_t ilen )
|
||||
{
|
||||
md4_update( ctx, input, ilen );
|
||||
}
|
||||
@ -362,7 +392,7 @@ void md4_hmac_finish( md4_context *ctx, unsigned char output[16] )
|
||||
md4_update( ctx, tmpbuf, 16 );
|
||||
md4_finish( ctx, output );
|
||||
|
||||
memset( tmpbuf, 0, sizeof( tmpbuf ) );
|
||||
polarssl_zeroize( tmpbuf, sizeof( tmpbuf ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -383,11 +413,11 @@ void md4_hmac( const unsigned char *key, size_t keylen,
|
||||
{
|
||||
md4_context ctx;
|
||||
|
||||
md4_init( &ctx );
|
||||
md4_hmac_starts( &ctx, key, keylen );
|
||||
md4_hmac_update( &ctx, input, ilen );
|
||||
md4_hmac_finish( &ctx, output );
|
||||
|
||||
memset( &ctx, 0, sizeof( md4_context ) );
|
||||
md4_free( &ctx );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
@ -397,7 +427,7 @@ void md4_hmac( const unsigned char *key, size_t keylen,
|
||||
*/
|
||||
static const char md4_test_str[7][81] =
|
||||
{
|
||||
{ "" },
|
||||
{ "" },
|
||||
{ "a" },
|
||||
{ "abc" },
|
||||
{ "message digest" },
|
||||
@ -436,7 +466,7 @@ int md4_self_test( int verbose )
|
||||
for( i = 0; i < 7; i++ )
|
||||
{
|
||||
if( verbose != 0 )
|
||||
printf( " MD4 test #%d: ", i + 1 );
|
||||
polarssl_printf( " MD4 test #%d: ", i + 1 );
|
||||
|
||||
md4( (unsigned char *) md4_test_str[i],
|
||||
strlen( md4_test_str[i] ), md4sum );
|
||||
@ -444,21 +474,21 @@ int md4_self_test( int verbose )
|
||||
if( memcmp( md4sum, md4_test_sum[i], 16 ) != 0 )
|
||||
{
|
||||
if( verbose != 0 )
|
||||
printf( "failed\n" );
|
||||
polarssl_printf( "failed\n" );
|
||||
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "passed\n" );
|
||||
polarssl_printf( "passed\n" );
|
||||
}
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "\n" );
|
||||
polarssl_printf( "\n" );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#endif
|
||||
#endif /* POLARSSL_MD4_C */
|
||||
|
Reference in New Issue
Block a user