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:
76
Externals/mbedtls/library/camellia.c
vendored
76
Externals/mbedtls/library/camellia.c
vendored
@ -34,6 +34,7 @@
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
|
||||
#include "mbedtls/camellia.h"
|
||||
#include "mbedtls/platform_util.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -48,10 +49,11 @@
|
||||
|
||||
#if !defined(MBEDTLS_CAMELLIA_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 CAMELLIA_VALIDATE_RET( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA )
|
||||
#define CAMELLIA_VALIDATE( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
@ -325,6 +327,7 @@ static void camellia_feistel( const uint32_t x[2], const uint32_t k[2],
|
||||
|
||||
void mbedtls_camellia_init( mbedtls_camellia_context *ctx )
|
||||
{
|
||||
CAMELLIA_VALIDATE( ctx != NULL );
|
||||
memset( ctx, 0, sizeof( mbedtls_camellia_context ) );
|
||||
}
|
||||
|
||||
@ -333,14 +336,15 @@ void mbedtls_camellia_free( mbedtls_camellia_context *ctx )
|
||||
if( ctx == NULL )
|
||||
return;
|
||||
|
||||
mbedtls_zeroize( ctx, sizeof( mbedtls_camellia_context ) );
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_camellia_context ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Camellia key schedule (encryption)
|
||||
*/
|
||||
int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key,
|
||||
unsigned int keybits )
|
||||
int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx,
|
||||
const unsigned char *key,
|
||||
unsigned int keybits )
|
||||
{
|
||||
int idx;
|
||||
size_t i;
|
||||
@ -350,6 +354,9 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned c
|
||||
uint32_t KC[16];
|
||||
uint32_t TK[20];
|
||||
|
||||
CAMELLIA_VALIDATE_RET( ctx != NULL );
|
||||
CAMELLIA_VALIDATE_RET( key != NULL );
|
||||
|
||||
RK = ctx->rk;
|
||||
|
||||
memset( t, 0, 64 );
|
||||
@ -360,7 +367,7 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned c
|
||||
case 128: ctx->nr = 3; idx = 0; break;
|
||||
case 192:
|
||||
case 256: ctx->nr = 4; idx = 1; break;
|
||||
default : return( MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH );
|
||||
default : return( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
for( i = 0; i < keybits / 8; ++i )
|
||||
@ -444,14 +451,17 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned c
|
||||
/*
|
||||
* Camellia key schedule (decryption)
|
||||
*/
|
||||
int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key,
|
||||
unsigned int keybits )
|
||||
int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx,
|
||||
const unsigned char *key,
|
||||
unsigned int keybits )
|
||||
{
|
||||
int idx, ret;
|
||||
size_t i;
|
||||
mbedtls_camellia_context cty;
|
||||
uint32_t *RK;
|
||||
uint32_t *SK;
|
||||
CAMELLIA_VALIDATE_RET( ctx != NULL );
|
||||
CAMELLIA_VALIDATE_RET( key != NULL );
|
||||
|
||||
mbedtls_camellia_init( &cty );
|
||||
|
||||
@ -499,6 +509,11 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
|
||||
{
|
||||
int NR;
|
||||
uint32_t *RK, X[4];
|
||||
CAMELLIA_VALIDATE_RET( ctx != NULL );
|
||||
CAMELLIA_VALIDATE_RET( mode == MBEDTLS_CAMELLIA_ENCRYPT ||
|
||||
mode == MBEDTLS_CAMELLIA_DECRYPT );
|
||||
CAMELLIA_VALIDATE_RET( input != NULL );
|
||||
CAMELLIA_VALIDATE_RET( output != NULL );
|
||||
|
||||
( (void) mode );
|
||||
|
||||
@ -556,14 +571,20 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
|
||||
* Camellia-CBC buffer encryption/decryption
|
||||
*/
|
||||
int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
|
||||
int mode,
|
||||
size_t length,
|
||||
unsigned char iv[16],
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
int mode,
|
||||
size_t length,
|
||||
unsigned char iv[16],
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
int i;
|
||||
unsigned char temp[16];
|
||||
CAMELLIA_VALIDATE_RET( ctx != NULL );
|
||||
CAMELLIA_VALIDATE_RET( mode == MBEDTLS_CAMELLIA_ENCRYPT ||
|
||||
mode == MBEDTLS_CAMELLIA_DECRYPT );
|
||||
CAMELLIA_VALIDATE_RET( iv != NULL );
|
||||
CAMELLIA_VALIDATE_RET( length == 0 || input != NULL );
|
||||
CAMELLIA_VALIDATE_RET( length == 0 || output != NULL );
|
||||
|
||||
if( length % 16 )
|
||||
return( MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH );
|
||||
@ -618,7 +639,18 @@ int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx,
|
||||
unsigned char *output )
|
||||
{
|
||||
int c;
|
||||
size_t n = *iv_off;
|
||||
size_t n;
|
||||
CAMELLIA_VALIDATE_RET( ctx != NULL );
|
||||
CAMELLIA_VALIDATE_RET( mode == MBEDTLS_CAMELLIA_ENCRYPT ||
|
||||
mode == MBEDTLS_CAMELLIA_DECRYPT );
|
||||
CAMELLIA_VALIDATE_RET( iv != NULL );
|
||||
CAMELLIA_VALIDATE_RET( iv_off != NULL );
|
||||
CAMELLIA_VALIDATE_RET( length == 0 || input != NULL );
|
||||
CAMELLIA_VALIDATE_RET( length == 0 || output != NULL );
|
||||
|
||||
n = *iv_off;
|
||||
if( n >= 16 )
|
||||
return( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA );
|
||||
|
||||
if( mode == MBEDTLS_CAMELLIA_DECRYPT )
|
||||
{
|
||||
@ -666,7 +698,17 @@ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
|
||||
unsigned char *output )
|
||||
{
|
||||
int c, i;
|
||||
size_t n = *nc_off;
|
||||
size_t n;
|
||||
CAMELLIA_VALIDATE_RET( ctx != NULL );
|
||||
CAMELLIA_VALIDATE_RET( nonce_counter != NULL );
|
||||
CAMELLIA_VALIDATE_RET( stream_block != NULL );
|
||||
CAMELLIA_VALIDATE_RET( nc_off != NULL );
|
||||
CAMELLIA_VALIDATE_RET( length == 0 || input != NULL );
|
||||
CAMELLIA_VALIDATE_RET( length == 0 || output != NULL );
|
||||
|
||||
n = *nc_off;
|
||||
if( n >= 16 )
|
||||
return( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA );
|
||||
|
||||
while( length-- )
|
||||
{
|
||||
|
Reference in New Issue
Block a user