CJOSE  0.6.0
Functions
base64.h File Reference

Functions for encoding to and decoding from base64 and base64url. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "cjose/error.h"

Go to the source code of this file.

Functions

bool cjose_base64_encode (const uint8_t *input, const size_t inlen, char **output, size_t *outlen, cjose_err *err)
 
bool cjose_base64url_encode (const uint8_t *input, const size_t inlen, char **output, size_t *outlen, cjose_err *err)
 
bool cjose_base64_decode (const char *input, const size_t inlen, uint8_t **output, size_t *outlen, cjose_err *err)
 
bool cjose_base64url_decode (const char *input, const size_t inlen, uint8_t **output, size_t *outlen, cjose_err *err)
 

Detailed Description

Functions for encoding to and decoding from base64 and base64url.

NOTE: When successful, the output of each function MUST be released by calling free(), even if the output is of 0 length.

Function Documentation

◆ cjose_base64_decode()

bool cjose_base64_decode ( const char *  input,
const size_t  inlen,
uint8_t **  output,
size_t *  outlen,
cjose_err err 
)

Decodes the given string from Base64.

NOTE: output is NOT NULL-terminated.

Parameters
inputThe text string to decode.
inlenThe length of input.
outputThe decoded octet string.
outlenThe length of output.
err[out] An optional error object which can be used to get additional information in the event of an error.

◆ cjose_base64_encode()

bool cjose_base64_encode ( const uint8_t *  input,
const size_t  inlen,
char **  output,
size_t *  outlen,
cjose_err err 
)

Encodes the given octet string to Base64.

Parameters
inputThe octet string to encode.
inlenThe length of input.
outputThe encoded text string.
outlenThe length of output (not including the terminating NULL).
err[out] An optional error object which can be used to get additional information in the event of an error.

◆ cjose_base64url_decode()

bool cjose_base64url_decode ( const char *  input,
const size_t  inlen,
uint8_t **  output,
size_t *  outlen,
cjose_err err 
)

Decodes the given string from URL-Safe Base64.

NOTE: output is NOT NULL-terminated.

Parameters
inputThe text string to decode.
inlenThe length of input.
outputThe decoded octet string.
outlenThe length of output.
err[out] An optional error object which can be used to get additional information in the event of an error.

◆ cjose_base64url_encode()

bool cjose_base64url_encode ( const uint8_t *  input,
const size_t  inlen,
char **  output,
size_t *  outlen,
cjose_err err 
)

Encodes the given octet string to URL-safe Base64.

Parameters
inputThe octet string to encode.
inlenThe length of input.
outputThe encoded output string.
outlenThe length of output (not including the terminating NULL).
err[out] An optional error object which can be used to get additional information in the event of an error.