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

Macros

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

Functions

static uint32_t F (mbedtls_blowfish_context *ctx, uint32_t x)
 
static void blowfish_enc (mbedtls_blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
 
static void blowfish_dec (mbedtls_blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
 
void mbedtls_blowfish_init (mbedtls_blowfish_context *ctx)
 Initialize Blowfish context. More...
 
void mbedtls_blowfish_free (mbedtls_blowfish_context *ctx)
 Clear Blowfish context. More...
 
int mbedtls_blowfish_setkey (mbedtls_blowfish_context *ctx, const unsigned char *key, unsigned int keybits)
 Blowfish key schedule. More...
 
int mbedtls_blowfish_crypt_ecb (mbedtls_blowfish_context *ctx, int mode, const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE])
 Blowfish-ECB block encryption/decryption. More...
 
int mbedtls_blowfish_crypt_cbc (mbedtls_blowfish_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
 Blowfish-CBC buffer encryption/decryption Length should be a multiple of the block size (8 bytes) More...
 
int mbedtls_blowfish_crypt_cfb64 (mbedtls_blowfish_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
 Blowfish CFB buffer encryption/decryption. More...
 
int mbedtls_blowfish_crypt_ctr (mbedtls_blowfish_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
 Blowfish-CTR buffer encryption/decryption. More...
 

Variables

static const uint32_t P [MBEDTLS_BLOWFISH_ROUNDS+2]
 
static const uint32_t S [4][256]
 

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

◆ blowfish_dec()

static void blowfish_dec ( mbedtls_blowfish_context ctx,
uint32_t xl,
uint32_t xr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ blowfish_enc()

static void blowfish_enc ( mbedtls_blowfish_context ctx,
uint32_t xl,
uint32_t xr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ F()

static uint32_t F ( mbedtls_blowfish_context ctx,
uint32_t  x 
)
static
Here is the caller graph for this function:

◆ mbedtls_blowfish_crypt_cbc()

int mbedtls_blowfish_crypt_cbc ( mbedtls_blowfish_context ctx,
int  mode,
size_t  length,
unsigned char  iv[MBEDTLS_BLOWFISH_BLOCKSIZE],
const unsigned char *  input,
unsigned char *  output 
)

Blowfish-CBC buffer encryption/decryption Length should be a multiple of the block size (8 bytes)

Note
Upon exit, the content of the IV is updated so that you can call the function same function again on the following block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If on the other hand you need to retain the contents of the IV, you should either save it manually or use the cipher module instead.
Parameters
ctxBlowfish context
modeMBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT
lengthlength of the input data
ivinitialization vector (updated after use)
inputbuffer holding the input data
outputbuffer holding the output data
Returns
0 if successful, or MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_blowfish_crypt_cfb64()

int mbedtls_blowfish_crypt_cfb64 ( mbedtls_blowfish_context ctx,
int  mode,
size_t  length,
size_t *  iv_off,
unsigned char  iv[MBEDTLS_BLOWFISH_BLOCKSIZE],
const unsigned char *  input,
unsigned char *  output 
)

Blowfish CFB buffer encryption/decryption.

Note
Upon exit, the content of the IV is updated so that you can call the function same function again on the following block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If on the other hand you need to retain the contents of the IV, you should either save it manually or use the cipher module instead.
Parameters
ctxBlowfish context
modeMBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT
lengthlength of the input data
iv_offoffset in IV (updated after use)
ivinitialization vector (updated after use)
inputbuffer holding the input data
outputbuffer holding the output data
Returns
0 if successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_blowfish_crypt_ctr()

int mbedtls_blowfish_crypt_ctr ( mbedtls_blowfish_context ctx,
size_t  length,
size_t *  nc_off,
unsigned char  nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE],
unsigned char  stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE],
const unsigned char *  input,
unsigned char *  output 
)

Blowfish-CTR buffer encryption/decryption.

Warning: You have to keep the maximum use of your counter in mind!

Parameters
ctxBlowfish context
lengthThe length of the data
nc_offThe offset in the current stream_block (for resuming within current cipher stream). The offset pointer to should be 0 at the start of a stream.
nonce_counterThe 64-bit nonce and counter.
stream_blockThe saved stream-block for resuming. Is overwritten by the function.
inputThe input data stream
outputThe output data stream
Returns
0 if successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_blowfish_crypt_ecb()

int mbedtls_blowfish_crypt_ecb ( mbedtls_blowfish_context ctx,
int  mode,
const unsigned char  input[MBEDTLS_BLOWFISH_BLOCKSIZE],
unsigned char  output[MBEDTLS_BLOWFISH_BLOCKSIZE] 
)

Blowfish-ECB block encryption/decryption.

Parameters
ctxBlowfish context
modeMBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT
input8-byte input block
output8-byte output block
Returns
0 if successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_blowfish_free()

void mbedtls_blowfish_free ( mbedtls_blowfish_context ctx)

Clear Blowfish context.

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

◆ mbedtls_blowfish_init()

void mbedtls_blowfish_init ( mbedtls_blowfish_context ctx)

Initialize Blowfish context.

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

◆ mbedtls_blowfish_setkey()

int mbedtls_blowfish_setkey ( mbedtls_blowfish_context ctx,
const unsigned char *  key,
unsigned int  keybits 
)

Blowfish key schedule.

Parameters
ctxBlowfish context to be initialized
keyencryption key
keybitsmust be between 32 and 448 bits
Returns
0 if successful, or MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ P

Initial value:
= {
0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L,
0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L,
0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL,
0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L,
0x9216D5D9L, 0x8979FB1BL
}
Ιστορικό Εικόνα Πληροφορίες Όλοι Οι Χρήστες Χειρίζονται Το Μενού Αριστερό Αναλογικό Αριστερό Αναλογικό Αριστερό Αναλογικό Y Αριστερό Αναλογικό Δεξί Αναλογικό X Δεξί Αναλογικό Δεξί Αναλογικό Y Δεξί Αναλογικό Σκανδάλη Όπλου Όπλο Aux A Όπλο Aux C Όπλο Select Όπλο D pad Κάτω Όπλο D pad Δεξιά Νεκρή Ζώνη Αναλογικού Σύνδεση Όλων Λήξη Χρόνου Σύνδεσης Hide Unbound Core Input Descriptors Κατάλογος Συσκευών Κατάλογος Ποντικιού Duty Cycle Keyboard Gamepad Mapping Enable Κουμπί D pad κάτω Κουμπί Κουμπί L(πίσω)" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT

◆ S

const uint32_t S[4][256]
static