Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/crypto/base64.cc File Reference

#include "base64.h"

Include dependency graph for base64.cc:

Include dependency graph

Go to the source code of this file.

Functions

ssize_t Base64Encode (const char *_in, size_t inlen, char *_out, size_t outlen, uint32 *state, int lwidth)
ssize_t Base64Decode (const char *_in, size_t inlen, char *_out, size_t outlen, uint32 *state)

Variables

const unsigned char * _base64_encode
const unsigned char * _base64_decode


Function Documentation

ssize_t Base64Decode const char *  _in,
size_t  inlen,
char *  _out,
size_t  outlen,
uint32 state
[static]
 

For internal use only.

Reads in the base64 encoded string passed in _in of size inlen and stores the decoded result in buffer _out of size outlen. If state is non-NULL state info is updated. State info (carry) is needed only if you have a large amount of base64 data which cannot be decoded in one single call. To do this, set up the uint32 state value to zero and pass a pointer to it whenever calling Base64Decode(). The function will store non-decoded chars (max. 18 bits + 2 bit counter) in state to be able to process them the next time unless

  • the base64 termination char (`=') is encountered or
  • you call Base64Decode() with inlen=0 which does just the same as if you merely pass "=" as input. (state will be 0 after reading `=' / when passig inlen=0 but better relay on the return values for error diagnosis.)
Returns:
>=0 -> number of bytes in output -2 -> illegal char in input -3 -> premature end (only if state is NULL or base64 termination char `=' is encountered too early) -4 -> output buffer too small

Definition at line 178 of file base64.cc.

References _base64_decode, ssize_t, and uint32.

ssize_t Base64Encode const char *  _in,
size_t  inlen,
char *  _out,
size_t  outlen,
uint32 state,
int  lwidth
[static]
 

For internal use only.

Reads in binary (8 bit) input data in _in of size inlen and encodes it as base64 storing the result in _out of size outlen. You may set lwidth to something non-zero to make Base64Encode() insert newlines every lwidth*4 chars. (lwidth=1 -> every 4 chars; lwidth=0 -> disable this feature) If state is non-NULL state info is updated. State info (carry) is needed only if you have a large amount of 8bit data which cannot be encoded in one single call. To do this, set up the uint32 state value to zero and pass a pointer to it whenever calling Base64Encode(). The function will store non-encoded bytes (max. 2 bytes + 2 bit counter) in state to be able to process them the next time unless you call Base64Encode() with inlen=0 to tell it that this is the end of the input data. (state will be 0 after that but better relay on the return values for error diagnosis.) When reaching input data end (either state!=NULL and inlen=0 or state=NULL), the base64 termination char `=' is appended to the output.

Note:
the current byte quartett count is also stored in state as 14 bit value so that the base64 text stays formatted even if you have to call Base64Encode() repeatedly. So, you don't try to set lwidth to values >2^14 (that is 2^14*4=65536 chars per line).
Returns:
>=0 -> number of bytes in output -4 -> output buffer too small

Definition at line 71 of file base64.cc.

References _base64_encode, ssize_t, and uint32.


Variable Documentation

const unsigned char* _base64_decode [static]
 

Initial value:

(const unsigned char *)
    "\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xfe\xfe\xfe\xfe\xfe\xff\xff"
    "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
    "\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3e\xff\xff\xff\x3f"
    "\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\xff\xff\xff\xfd\xff\xff"
    "\xff\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e"
    "\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\xff\xfe\xff\xff\xff"
    "\xff\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28"
    "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\xff\xff\xff\xff\xfe"

Definition at line 31 of file base64.cc.

Referenced by Base64Decode().

const unsigned char* _base64_encode [static]
 

Initial value:

(unsigned char *)
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "abcdefghijklmnopqrstuvwxyz"
    "0123456789+/"

Definition at line 21 of file base64.cc.

Referenced by Base64Encode().


Generated on Sat Feb 19 22:33:49 2005 for Ray by doxygen 1.3.5