/home/dko/Projects/mobilec/src/security/xyssl-0.9/library/base64.c File Reference

#include "xyssl/config.h"
#include "xyssl/base64.h"
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Functions

int base64_encode (unsigned char *dst, int *dlen, unsigned char *src, int slen)
 Encode a buffer into base64 format.
int base64_decode (unsigned char *dst, int *dlen, unsigned char *src, int slen)
 Decode a base64-formatted buffer.
int base64_self_test (int verbose)
 Checkup routine.

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 []

Function Documentation

int base64_decode ( unsigned char *  dst,
int dlen,
unsigned char *  src,
int  slen 
)

Decode a base64-formatted buffer.

Parameters:
dst destination buffer
dlen size of the buffer
src source buffer
slen amount of data to be decoded
Returns:
0 if successful, XYSSL_ERR_BASE64_BUFFER_TOO_SMALL, or XYSSL_ERR_BASE64_INVALID_DATA if the input data is not correct. *dlen is always updated to reflect the amount of data that has (or would have) been written.
Note:
Call this function with *dlen = 0 to obtain the required buffer size in *dlen

Definition at line 121 of file base64.c.

References base64_dec_map, XYSSL_ERR_BASE64_BUFFER_TOO_SMALL, and XYSSL_ERR_BASE64_INVALID_CHARACTER.

Referenced by base64_self_test(), x509parse_crt(), and x509parse_key().

int base64_encode ( unsigned char *  dst,
int dlen,
unsigned char *  src,
int  slen 
)

Encode a buffer into base64 format.

Parameters:
dst destination buffer
dlen size of the buffer
src source buffer
slen amount of data to be encoded
Returns:
0 if successful, or XYSSL_ERR_BASE64_BUFFER_TOO_SMALL. *dlen is always updated to reflect the amount of data that has (or would have) been written.
Note:
Call this function with *dlen = 0 to obtain the required buffer size in *dlen

Definition at line 58 of file base64.c.

References base64_enc_map, and XYSSL_ERR_BASE64_BUFFER_TOO_SMALL.

Referenced by base64_self_test().

int base64_self_test ( int  verbose  ) 

Checkup routine.

Returns:
0 if successful, or 1 if the test failed

Definition at line 206 of file base64.c.

References base64_decode(), base64_encode(), base64_test_dec, and base64_test_enc.

Referenced by main().


Variable Documentation

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
}

Definition at line 38 of file base64.c.

Referenced by base64_decode().

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', '+', '/'
}

Definition at line 27 of file base64.c.

Referenced by base64_encode().

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
}

Definition at line 187 of file base64.c.

Referenced by base64_self_test().

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

Definition at line 199 of file base64.c.

Referenced by base64_self_test().

Generated on Tue Dec 28 15:15:29 2010 for Mobile-C by  doxygen 1.6.3