25 RCSID(
"$Id: b40713d51eb16ce6fb5c2eb3f08c9e69e708f623 $")
29 #include <freeradius-devel/util/value.h>
30 #define us(x) (uint8_t) x
327 bool add_padding,
char const alphabet[
static UINT8_MAX])
346 alphabet[(a >> 2) & 0x3f],
347 alphabet[((a << 4) | (b >> 4)) & 0x3f],
348 alphabet[((b << 2) | (c >> 6)) & 0x3f],
357 alphabet[(a >> 2) & 0x3f],
358 alphabet[((a << 4) | (b >> 4)) & 0x3f],
359 alphabet[(b << 2) & 0x3f]);
367 alphabet[(a >> 2) & 0x3f],
368 alphabet[(a << 4) & 0x3f]);
381 fr_sbuff_terminate(&our_out);
402 bool expect_padding,
bool no_trailing,
uint8_t const alphabet[
static UINT8_MAX])
421 ((alphabet[
us(p[0])] << 2) | (alphabet[
us(p[1])] >> 4)),
422 ((alphabet[
us(p[1])] << 4) & 0xf0) | (alphabet[
us(p[2])] >> 2),
423 ((alphabet[
us(p[2])] << 6) & 0xc0) | alphabet[
us(p[3])]) != 3) {
436 fr_sbuff_marker(&m_final, &our_in);
455 (alphabet[
us(p[0])] << 2) | (alphabet[
us(p[1])] >> 4)) != 1)
goto oob;
465 ((alphabet[
us(p[0])] << 2) | (alphabet[
us(p[1])] >> 4)),
466 ((alphabet[
us(p[1])] << 4) & 0xf0) | (alphabet[
us(p[2])] >> 2)) != 2)
goto oob;
480 if (expect_padding) {
482 for (i = 0; i < pad; i++) {
485 "Expected %u padding char(s)", pad);
char const fr_base64_alphabet_encode[UINT8_MAX]
uint8_t const fr_base64_alphabet_decode[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.
fr_slen_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])
uint8_t const fr_base64_url_alphabet_decode[UINT8_MAX]
char const fr_base64_url_alphabet_encode[UINT8_MAX]
static bool fr_is_base64_nstd(char c, uint8_t const alphabet[static UINT8_MAX])
Check if char is in Base64 alphabet.
#define F1(_idx, _val)
Fill macros for array initialisation.
#define fr_dbuff_advance(_dbuff_or_marker, _len)
Advance 'current' position in dbuff or marker by _len bytes.
#define fr_dbuff_used(_dbuff_or_marker)
Return the number of bytes remaining between the start of the dbuff or marker and the current positio...
#define fr_dbuff_current(_dbuff_or_marker)
Return the 'current' position of a dbuff or marker.
#define fr_dbuff_extend_lowat(_status, _dbuff_or_marker, _lowat)
Extend if we're below _lowat.
#define fr_dbuff_in_bytes(_dbuff_or_marker,...)
Copy a byte sequence into a dbuff or marker.
#define FR_DBUFF(_dbuff_or_marker)
Create a new dbuff pointing to the same underlying buffer.
@ FR_SBUFF_PARSE_ERROR_FORMAT
Format of data was invalid.
@ FR_SBUFF_PARSE_ERROR_OUT_OF_SPACE
No space available in output buffer.
@ FR_SBUFF_PARSE_ERROR_TRAILING
Trailing characters found.
bool fr_sbuff_next_if_char(fr_sbuff_t *sbuff, char c)
Return true if the current char matches, and if it does, advance.
#define FR_SBUFF_IN_CHAR_RETURN(_sbuff,...)
#define fr_sbuff_set(_dst, _src)
#define fr_sbuff_current(_sbuff_or_marker)
#define fr_sbuff_char(_sbuff_or_marker, _eob)
#define FR_SBUFF_IN_STRCPY_LITERAL_RETURN(_sbuff, _str)
#define fr_sbuff_extend(_sbuff_or_marker)
#define FR_SBUFF_ERROR_RETURN(_sbuff_or_marker)
#define FR_SBUFF(_sbuff_or_marker)
#define fr_sbuff_advance(_sbuff_or_marker, _len)
#define fr_sbuff_behind(_sbuff_or_marker)
#define fr_sbuff_extend_lowat(_status, _sbuff_or_marker, _lowat)
void fr_strerror_clear(void)
Clears all pending messages from the talloc pools.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
return fr_dbuff_set(dbuff, &our_dbuff)
FR_SBUFF_SET_RETURN(sbuff, &our_sbuff)
static size_t char ** out