mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Externals: Update mbedtls to 2.16.1
On a few of our buildbot instances, we get warnings about the usage of deprecated functions. We should correct these, especially if we're delegating to system versions of the libraries if they're available. However, in order to do that, we need to update our library variant from 2.1.1 so that the non-deprecated alternatives are actually available.
This commit is contained in:
64
Externals/mbedtls/library/blowfish.c
vendored
64
Externals/mbedtls/library/blowfish.c
vendored
@ -34,15 +34,17 @@
|
||||
#if defined(MBEDTLS_BLOWFISH_C)
|
||||
|
||||
#include "mbedtls/blowfish.h"
|
||||
#include "mbedtls/platform_util.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(MBEDTLS_BLOWFISH_ALT)
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void mbedtls_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
|
||||
}
|
||||
/* Parameter validation macros */
|
||||
#define BLOWFISH_VALIDATE_RET( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA )
|
||||
#define BLOWFISH_VALIDATE( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
@ -157,6 +159,7 @@ static void blowfish_dec( mbedtls_blowfish_context *ctx, uint32_t *xl, uint32_t
|
||||
|
||||
void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx )
|
||||
{
|
||||
BLOWFISH_VALIDATE( ctx != NULL );
|
||||
memset( ctx, 0, sizeof( mbedtls_blowfish_context ) );
|
||||
}
|
||||
|
||||
@ -165,22 +168,26 @@ void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx )
|
||||
if( ctx == NULL )
|
||||
return;
|
||||
|
||||
mbedtls_zeroize( ctx, sizeof( mbedtls_blowfish_context ) );
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_blowfish_context ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Blowfish key schedule
|
||||
*/
|
||||
int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key,
|
||||
unsigned int keybits )
|
||||
int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx,
|
||||
const unsigned char *key,
|
||||
unsigned int keybits )
|
||||
{
|
||||
unsigned int i, j, k;
|
||||
uint32_t data, datal, datar;
|
||||
BLOWFISH_VALIDATE_RET( ctx != NULL );
|
||||
BLOWFISH_VALIDATE_RET( key != NULL );
|
||||
|
||||
if( keybits < MBEDTLS_BLOWFISH_MIN_KEY_BITS || keybits > MBEDTLS_BLOWFISH_MAX_KEY_BITS ||
|
||||
( keybits % 8 ) )
|
||||
if( keybits < MBEDTLS_BLOWFISH_MIN_KEY_BITS ||
|
||||
keybits > MBEDTLS_BLOWFISH_MAX_KEY_BITS ||
|
||||
keybits % 8 != 0 )
|
||||
{
|
||||
return( MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH );
|
||||
return( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
keybits >>= 3;
|
||||
@ -235,6 +242,11 @@ int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx,
|
||||
unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] )
|
||||
{
|
||||
uint32_t X0, X1;
|
||||
BLOWFISH_VALIDATE_RET( ctx != NULL );
|
||||
BLOWFISH_VALIDATE_RET( mode == MBEDTLS_BLOWFISH_ENCRYPT ||
|
||||
mode == MBEDTLS_BLOWFISH_DECRYPT );
|
||||
BLOWFISH_VALIDATE_RET( input != NULL );
|
||||
BLOWFISH_VALIDATE_RET( output != NULL );
|
||||
|
||||
GET_UINT32_BE( X0, input, 0 );
|
||||
GET_UINT32_BE( X1, input, 4 );
|
||||
@ -267,6 +279,12 @@ int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx,
|
||||
{
|
||||
int i;
|
||||
unsigned char temp[MBEDTLS_BLOWFISH_BLOCKSIZE];
|
||||
BLOWFISH_VALIDATE_RET( ctx != NULL );
|
||||
BLOWFISH_VALIDATE_RET( mode == MBEDTLS_BLOWFISH_ENCRYPT ||
|
||||
mode == MBEDTLS_BLOWFISH_DECRYPT );
|
||||
BLOWFISH_VALIDATE_RET( iv != NULL );
|
||||
BLOWFISH_VALIDATE_RET( length == 0 || input != NULL );
|
||||
BLOWFISH_VALIDATE_RET( length == 0 || output != NULL );
|
||||
|
||||
if( length % MBEDTLS_BLOWFISH_BLOCKSIZE )
|
||||
return( MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH );
|
||||
@ -321,7 +339,19 @@ int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx,
|
||||
unsigned char *output )
|
||||
{
|
||||
int c;
|
||||
size_t n = *iv_off;
|
||||
size_t n;
|
||||
|
||||
BLOWFISH_VALIDATE_RET( ctx != NULL );
|
||||
BLOWFISH_VALIDATE_RET( mode == MBEDTLS_BLOWFISH_ENCRYPT ||
|
||||
mode == MBEDTLS_BLOWFISH_DECRYPT );
|
||||
BLOWFISH_VALIDATE_RET( iv != NULL );
|
||||
BLOWFISH_VALIDATE_RET( iv_off != NULL );
|
||||
BLOWFISH_VALIDATE_RET( length == 0 || input != NULL );
|
||||
BLOWFISH_VALIDATE_RET( length == 0 || output != NULL );
|
||||
|
||||
n = *iv_off;
|
||||
if( n >= 8 )
|
||||
return( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA );
|
||||
|
||||
if( mode == MBEDTLS_BLOWFISH_DECRYPT )
|
||||
{
|
||||
@ -369,7 +399,17 @@ int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx,
|
||||
unsigned char *output )
|
||||
{
|
||||
int c, i;
|
||||
size_t n = *nc_off;
|
||||
size_t n;
|
||||
BLOWFISH_VALIDATE_RET( ctx != NULL );
|
||||
BLOWFISH_VALIDATE_RET( nonce_counter != NULL );
|
||||
BLOWFISH_VALIDATE_RET( stream_block != NULL );
|
||||
BLOWFISH_VALIDATE_RET( nc_off != NULL );
|
||||
BLOWFISH_VALIDATE_RET( length == 0 || input != NULL );
|
||||
BLOWFISH_VALIDATE_RET( length == 0 || output != NULL );
|
||||
|
||||
n = *nc_off;
|
||||
if( n >= 8 )
|
||||
return( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA );
|
||||
|
||||
while( length-- )
|
||||
{
|
||||
|
Reference in New Issue
Block a user