mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -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:
57
Externals/polarssl/library/xtea.c
vendored
57
Externals/polarssl/library/xtea.c
vendored
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* An 32-bit implementation of the XTEA algorithm
|
||||
*
|
||||
* 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>
|
||||
@ -23,14 +23,29 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#include "polarssl/config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_XTEA_C)
|
||||
|
||||
#include "polarssl/xtea.h"
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_XTEA_ALT)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
@ -54,6 +69,19 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
void xtea_init( xtea_context *ctx )
|
||||
{
|
||||
memset( ctx, 0, sizeof( xtea_context ) );
|
||||
}
|
||||
|
||||
void xtea_free( xtea_context *ctx )
|
||||
{
|
||||
if( ctx == NULL )
|
||||
return;
|
||||
|
||||
polarssl_zeroize( ctx, sizeof( xtea_context ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* XTEA key schedule
|
||||
*/
|
||||
@ -61,7 +89,7 @@ void xtea_setup( xtea_context *ctx, const unsigned char key[16] )
|
||||
{
|
||||
int i;
|
||||
|
||||
memset(ctx, 0, sizeof(xtea_context));
|
||||
memset( ctx, 0, sizeof(xtea_context) );
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
@ -132,7 +160,7 @@ int xtea_crypt_cbc( xtea_context *ctx, int mode, size_t length,
|
||||
memcpy( temp, input, 8 );
|
||||
xtea_crypt_ecb( ctx, mode, input, output );
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
for( i = 0; i < 8; i++ )
|
||||
output[i] = (unsigned char)( output[i] ^ iv[i] );
|
||||
|
||||
memcpy( iv, temp, 8 );
|
||||
@ -213,14 +241,15 @@ static const unsigned char xtea_test_ct[6][8] =
|
||||
*/
|
||||
int xtea_self_test( int verbose )
|
||||
{
|
||||
int i;
|
||||
int i, ret = 0;
|
||||
unsigned char buf[8];
|
||||
xtea_context ctx;
|
||||
|
||||
xtea_init( &ctx );
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
if( verbose != 0 )
|
||||
printf( " XTEA test #%d: ", i + 1 );
|
||||
polarssl_printf( " XTEA test #%d: ", i + 1 );
|
||||
|
||||
memcpy( buf, xtea_test_pt[i], 8 );
|
||||
|
||||
@ -230,21 +259,25 @@ int xtea_self_test( int verbose )
|
||||
if( memcmp( buf, xtea_test_ct[i], 8 ) != 0 )
|
||||
{
|
||||
if( verbose != 0 )
|
||||
printf( "failed\n" );
|
||||
polarssl_printf( "failed\n" );
|
||||
|
||||
return( 1 );
|
||||
ret = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "passed\n" );
|
||||
polarssl_printf( "passed\n" );
|
||||
}
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "\n" );
|
||||
polarssl_printf( "\n" );
|
||||
|
||||
return( 0 );
|
||||
exit:
|
||||
xtea_free( &ctx );
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#endif
|
||||
#endif /* POLARSSL_XTEA_C */
|
||||
|
Reference in New Issue
Block a user