Orcania
Potluck with different functions for different purposes that can be shared among C programs
Functions
Base64 encode and decode functions

Functions

int o_base64_encode (const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
 
int o_base64_decode (const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
 
int o_base64url_encode (const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
 
int o_base64url_decode (const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
 
int o_base64url_2_base64 (const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
 
int o_base64_2_base64url (const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
 
int o_base64_encode_alloc (const unsigned char *src, size_t len, struct _o_datum *dat)
 
int o_base64_decode_alloc (const unsigned char *src, size_t len, struct _o_datum *dat)
 
int o_base64url_encode_alloc (const unsigned char *src, size_t len, struct _o_datum *dat)
 
int o_base64url_decode_alloc (const unsigned char *src, size_t len, struct _o_datum *dat)
 
int o_base64url_2_base64_alloc (const unsigned char *src, size_t len, struct _o_datum *dat)
 
int o_base64_2_base64url_alloc (const unsigned char *src, size_t len, struct _o_datum *dat)
 

Detailed Description

Function Documentation

◆ o_base64_2_base64url()

int o_base64_2_base64url ( const unsigned char *  src,
size_t  len,
unsigned char *  out,
size_t *  out_len 
)

o_base64_2_base64url - Convert a base64 url format to base64 format - Does not check if src is a valid base64url

Parameters
srcData to be decoded
lenLength of the data to be decoded
outPointer to output variable
out_lenPointer to output length variable
Returns
1 on success, 0 on failure

The nul terminator is not included in out_len. out must be at least len+2

◆ o_base64_2_base64url_alloc()

int o_base64_2_base64url_alloc ( const unsigned char *  src,
size_t  len,
struct _o_datum dat 
)

o_base64_2_base64url_alloc - Convert a base64 format to base64 url format - allocate data result in a struct _o_datum *

Parameters
srcData to be decoded
lenLength of the data to be decoded
datPointer to a struct _o_datum * to store result
Returns
1 on success, 0 on failure

dat->data must be o_free'd after use The nul terminator is not included in dat->data.

◆ o_base64_decode()

int o_base64_decode ( const unsigned char *  src,
size_t  len,
unsigned char *  out,
size_t *  out_len 
)

o_base64_decode - Base64 decode

Parameters
srcData to be decoded
lenLength of the data to be decoded
outPointer to output variable, you might add up to 2 bytes to out length than expected for safety
out_lenPointer to output length variable
Returns
1 on success, 0 on failure

The nul terminator is not included in out_len.

◆ o_base64_decode_alloc()

int o_base64_decode_alloc ( const unsigned char *  src,
size_t  len,
struct _o_datum dat 
)

o_base64_decode_alloc - Base64 decode - allocate data result in a struct _o_datum *

Parameters
srcData to be decoded
lenLength of the data to be decoded
datPointer to a struct _o_datum * to store result
Returns
1 on success, 0 on failure

dat->data must be o_free'd after use The nul terminator is not included in dat->data.

◆ o_base64_encode()

int o_base64_encode ( const unsigned char *  src,
size_t  len,
unsigned char *  out,
size_t *  out_len 
)

o_base64_encode - Base64 encode

Parameters
srcData to be encoded
lenLength of the data to be encoded
outPointer to output variable, you might add up to 2 bytes to out length than expected for safety
out_lenPointer to output length variable
Returns
1 on success, 0 on failure

The nul terminator is not included in out_len.

◆ o_base64_encode_alloc()

int o_base64_encode_alloc ( const unsigned char *  src,
size_t  len,
struct _o_datum dat 
)

o_base64_encode_alloc - Base64 encode - allocate data result in a struct _o_datum *

Parameters
srcData to be encoded
lenLength of the data to be encoded
datPointer to a struct _o_datum * to store result
Returns
1 on success, 0 on failure

dat->data must be o_free'd after use The nul terminator is not included in dat->data.

◆ o_base64url_2_base64()

int o_base64url_2_base64 ( const unsigned char *  src,
size_t  len,
unsigned char *  out,
size_t *  out_len 
)

o_base64url_2_base64 - Convert a base64 url format to base64 format - Does not check if src is a valid base64

Parameters
srcData to be decoded
lenLength of the data to be decoded
outPointer to output variable
out_lenPointer to output length variable
Returns
1 on success, 0 on failure

The nul terminator is not included in out_len. out must be at least len+2

◆ o_base64url_2_base64_alloc()

int o_base64url_2_base64_alloc ( const unsigned char *  src,
size_t  len,
struct _o_datum dat 
)

o_base64url_2_base64_alloc - Convert a base64 url format to base64 format - allocate data result in a struct _o_datum *

Parameters
srcData to be decoded
lenLength of the data to be decoded
datPointer to a struct _o_datum * to store result
Returns
1 on success, 0 on failure

dat->data must be o_free'd after use The nul terminator is not included in dat->data.

◆ o_base64url_decode()

int o_base64url_decode ( const unsigned char *  src,
size_t  len,
unsigned char *  out,
size_t *  out_len 
)

o_base64url_decode - Base64 decode (url format)

Parameters
srcData to be decoded
lenLength of the data to be decoded
outPointer to output variable, you might add up to 2 bytes to out length than expected for safety
out_lenPointer to output length variable
Returns
1 on success, 0 on failure

The nul terminator is not included in out_len.

◆ o_base64url_decode_alloc()

int o_base64url_decode_alloc ( const unsigned char *  src,
size_t  len,
struct _o_datum dat 
)

o_base64url_decode_alloc - Base64 decode (url format) - allocate data result in a struct _o_datum *

Parameters
srcData to be decoded
lenLength of the data to be decoded
datPointer to a struct _o_datum * to store result
Returns
1 on success, 0 on failure

dat->data must be o_free'd after use The nul terminator is not included in dat->data.

◆ o_base64url_encode()

int o_base64url_encode ( const unsigned char *  src,
size_t  len,
unsigned char *  out,
size_t *  out_len 
)

o_base64url_encode - Base64url encode (url format)

Parameters
srcData to be encoded
lenLength of the data to be encoded
outPointer to output variable, you might add up to 2 bytes to out length than expected for safety
out_lenPointer to output length variable
Returns
1 on success, 0 on failure

The nul terminator is not included in out_len.

◆ o_base64url_encode_alloc()

int o_base64url_encode_alloc ( const unsigned char *  src,
size_t  len,
struct _o_datum dat 
)

o_base64url_encode_alloc - Base64url encode (url format) - allocate data result in a struct _o_datum *

Parameters
srcData to be encoded
lenLength of the data to be encoded
datPointer to a struct _o_datum * to store result
Returns
1 on success, 0 on failure

dat->data must be o_free'd after use The nul terminator is not included in dat->data.