24 RCSIDH(base64_h,
"$Id: def04ff57e9d08301f81e62822a4c41689fa909a $")
30 #include <freeradius-devel/missing.h>
31 #include <freeradius-devel/util/sbuff.h>
32 #include <freeradius-devel/util/dbuff.h>
37 #include <sys/types.h>
43 #define FR_BASE64_ENC_LENGTH(_inlen) ((((_inlen) + 2) / 3) * 4)
44 #define FR_BASE64_DEC_LENGTH(_inlen) ((3 * ((_inlen) / 4)) + 2)
63 return alphabet[(
uint8_t)c] < 64;
67 #define fr_is_base64(_c) fr_is_base64_nstd(_c, fr_base64_alphabet_decode)
71 bool add_padding,
char const alphabet[
static UINT8_MAX])
74 #define fr_base64_encode(_out, _in, _add_padding) \
75 fr_base64_encode_nstd(_out, _in, _add_padding, fr_base64_alphabet_encode)
78 bool expect_padding,
bool no_trailing,
uint8_t const alphabet[
static UINT8_MAX])
81 #define fr_base64_decode(_out, _in, _expect_padding, _no_trailing) \
82 fr_base64_decode_nstd(NULL, _out, _in, _expect_padding, _no_trailing, fr_base64_alphabet_decode)
char const fr_base64_alphabet_encode[UINT8_MAX]
uint8_t const fr_base64_alphabet_decode[UINT8_MAX]
ssize_t fr_base64_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr_sbuff_t *in, bool expect_padding, bool no_trailing, uint8_t const alphabet[static UINT8_MAX]))
ssize_t fr_base64_encode_nstd(fr_sbuff_t *out, fr_dbuff_t *in, bool add_padding, char const alphabet[static UINT8_MAX])
Base 64 encode binary data.
#define fr_base64_encode(_out, _in, _add_padding)
static bool fr_is_base64_nstd(char c, uint8_t const alphabet[static UINT8_MAX])
Check if char is in Base64 alphabet.
uint8_t const fr_base64_url_alphabet_decode[UINT8_MAX]
char const fr_base64_url_alphabet_encode[UINT8_MAX]
static size_t char fr_sbuff_t size_t inlen
static size_t char ** out