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

Macros

#define BASE64_SIZE_T_MAX   ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
 

Functions

int mbedtls_base64_encode (unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen)
 Encode a buffer into base64 format. More...
 
int mbedtls_base64_decode (unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen)
 Decode a base64-formatted buffer. More...
 
int mbedtls_base64_self_test (int verbose)
 Checkup routine. More...
 

Variables

static const unsigned char base64_enc_map [64]
 
static const unsigned char base64_dec_map [128]
 
static const unsigned char base64_test_dec [64]
 
static const unsigned char base64_test_enc []
 

Macro Definition Documentation

◆ BASE64_SIZE_T_MAX

#define BASE64_SIZE_T_MAX   ( (size_t) -1 ) /* SIZE_T_MAX is not standard */

Function Documentation

◆ mbedtls_base64_decode()

int mbedtls_base64_decode ( unsigned char *  dst,
size_t  dlen,
size_t *  olen,
const unsigned char *  src,
size_t  slen 
)

Decode a base64-formatted buffer.

Parameters
dstdestination buffer (can be NULL for checking size)
dlensize of the destination buffer
olennumber of bytes written
srcsource buffer
slenamount of data to be decoded
Returns
0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is not correct. *olen is always updated to reflect the amount of data that has (or would have) been written.
Note
Call this function with *dst = NULL or dlen = 0 to obtain the required buffer size in *olen
Here is the caller graph for this function:

◆ mbedtls_base64_encode()

int mbedtls_base64_encode ( unsigned char *  dst,
size_t  dlen,
size_t *  olen,
const unsigned char *  src,
size_t  slen 
)

Encode a buffer into base64 format.

Parameters
dstdestination buffer
dlensize of the destination buffer
olennumber of bytes written
srcsource buffer
slenamount of data to be encoded
Returns
0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL. *olen is always updated to reflect the amount of data that has (or would have) been written. If that length cannot be represented, then no data is written to the buffer and *olen is set to the maximum length representable as a size_t.
Note
Call this function with dlen = 0 to obtain the required buffer size in *olen
Here is the caller graph for this function:

◆ mbedtls_base64_self_test()

int mbedtls_base64_self_test ( int  verbose)

Checkup routine.

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

Variable Documentation

◆ base64_dec_map

const unsigned char base64_dec_map[128]
static
Initial value:
=
{
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 62, 127, 127, 127, 63, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 127, 127,
127, 64, 127, 127, 127, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 127, 127, 127, 127, 127, 127, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 127, 127, 127, 127, 127
}

◆ base64_enc_map

const unsigned char base64_enc_map[64]
static
Initial value:
=
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '+', '/'
}

◆ base64_test_dec

const unsigned char base64_test_dec[64]
static
Initial value:
=
{
0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01,
0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09,
0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13,
0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31,
0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38,
0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B,
0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97
}

◆ base64_test_enc

const unsigned char base64_test_enc[]
static
Initial value:
=
"JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK"
"swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw=="