RetroArch
Macros | Functions | Variables
xtea.c File Reference
#include "mbedtls/config.h"
#include "mbedtls/xtea.h"
#include <string.h>
#include "mbedtls/platform.h"
#include "arc4_alt.h"
Include dependency graph for xtea.c:

Macros

#define GET_UINT32_BE(n, b, i)
 
#define PUT_UINT32_BE(n, b, i)
 

Functions

void mbedtls_xtea_init (mbedtls_xtea_context *ctx)
 Initialize XTEA context. More...
 
void mbedtls_xtea_free (mbedtls_xtea_context *ctx)
 Clear XTEA context. More...
 
void mbedtls_xtea_setup (mbedtls_xtea_context *ctx, const unsigned char key[16])
 XTEA key schedule. More...
 
int mbedtls_xtea_crypt_ecb (mbedtls_xtea_context *ctx, int mode, const unsigned char input[8], unsigned char output[8])
 XTEA cipher function. More...
 
int mbedtls_xtea_crypt_cbc (mbedtls_xtea_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
 XTEA CBC cipher function. More...
 
int mbedtls_xtea_self_test (int verbose)
 Checkup routine. More...
 

Variables

static const unsigned char xtea_test_key [6][16]
 
static const unsigned char xtea_test_pt [6][8]
 
static const unsigned char xtea_test_ct [6][8]
 

Macro Definition Documentation

◆ GET_UINT32_BE

#define GET_UINT32_BE (   n,
  b,
 
)
Value:
{ \
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
| ( (uint32_t) (b)[(i) + 3] ); \
}
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
GLdouble n
Definition: glext.h:8396
unsigned int uint32_t
Definition: stdint.h:126

◆ PUT_UINT32_BE

#define PUT_UINT32_BE (   n,
  b,
 
)
Value:
{ \
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 3] = (unsigned char) ( (n) ); \
}
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
GLdouble n
Definition: glext.h:8396

Function Documentation

◆ mbedtls_xtea_crypt_cbc()

int mbedtls_xtea_crypt_cbc ( mbedtls_xtea_context ctx,
int  mode,
size_t  length,
unsigned char  iv[8],
const unsigned char *  input,
unsigned char *  output 
)

XTEA CBC cipher function.

Parameters
ctxXTEA context
modeMBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT
lengththe length of input, multiple of 8
ivinitialization vector for CBC mode
inputinput block
outputoutput block
Returns
0 if successful, MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH if the length % 8 != 0
Here is the call graph for this function:

◆ mbedtls_xtea_crypt_ecb()

int mbedtls_xtea_crypt_ecb ( mbedtls_xtea_context ctx,
int  mode,
const unsigned char  input[8],
unsigned char  output[8] 
)

XTEA cipher function.

Parameters
ctxXTEA context
modeMBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT
input8-byte input block
output8-byte output block
Returns
0 if successful
Here is the caller graph for this function:

◆ mbedtls_xtea_free()

void mbedtls_xtea_free ( mbedtls_xtea_context ctx)

Clear XTEA context.

Parameters
ctxXTEA context to be cleared
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_xtea_init()

void mbedtls_xtea_init ( mbedtls_xtea_context ctx)

Initialize XTEA context.

Parameters
ctxXTEA context to be initialized
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_xtea_self_test()

int mbedtls_xtea_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if the test failed
Here is the call graph for this function:

◆ mbedtls_xtea_setup()

void mbedtls_xtea_setup ( mbedtls_xtea_context ctx,
const unsigned char  key[16] 
)

XTEA key schedule.

Parameters
ctxXTEA context to be initialized
keythe secret key
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ xtea_test_ct

const unsigned char xtea_test_ct[6][8]
static
Initial value:
=
{
{ 0x49, 0x7d, 0xf3, 0xd0, 0x72, 0x61, 0x2c, 0xb5 },
{ 0xe7, 0x8f, 0x2d, 0x13, 0x74, 0x43, 0x41, 0xd8 },
{ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 },
{ 0xa0, 0x39, 0x05, 0x89, 0xf8, 0xb8, 0xef, 0xa5 },
{ 0xed, 0x23, 0x37, 0x5a, 0x82, 0x1a, 0x8c, 0x2d },
{ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }
}

◆ xtea_test_key

const unsigned char xtea_test_key[6][16]
static
Initial value:
=
{
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 }
}

◆ xtea_test_pt

const unsigned char xtea_test_pt[6][8]
static
Initial value:
=
{
{ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 },
{ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 },
{ 0x5a, 0x5b, 0x6e, 0x27, 0x89, 0x48, 0xd7, 0x7f },
{ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 },
{ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 },
{ 0x70, 0xe1, 0x22, 0x5d, 0x6e, 0x4e, 0x76, 0x55 }
}