The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
base16.c File Reference
#include <freeradius-devel/util/base16.h>
+ Include dependency graph for base16.c:

Go to the source code of this file.

Macros

#define us(x)   (uint8_t) x
 Encode/decode binary data using printable characters (base16 format - hex) More...
 

Functions

fr_slen_t fr_base16_decode_nstd (fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr_sbuff_t *in, bool no_trailing, uint8_t const alphabet[static UINT8_MAX+1])
 Decode base16 encoded input. More...
 
fr_slen_t fr_base16_encode_nstd (fr_sbuff_t *out, fr_dbuff_t *in, char const alphabet[static UINT8_MAX+1])
 Convert binary data to a hex string. More...
 

Variables

uint8_t const fr_base16_alphabet_decode_mc [UINT8_MAX+1]
 Mixed case decode alphabet for base16. More...
 
char const fr_base16_alphabet_encode_lc [UINT8_MAX+1]
 lower case encode alphabet for base16 More...
 
char const fr_base16_alphabet_encode_uc [UINT8_MAX+1]
 lower case encode alphabet for base16 More...
 

Macro Definition Documentation

◆ us

#define us (   x)    (uint8_t) x

Encode/decode binary data using printable characters (base16 format - hex)

See also
RFC 4648 http://www.ietf.org/rfc/rfc4648.txt.

Definition at line 26 of file base16.c.

Function Documentation

◆ fr_base16_decode_nstd()

fr_slen_t fr_base16_decode_nstd ( fr_sbuff_parse_error_t err,
fr_dbuff_t out,
fr_sbuff_t in,
bool  no_trailing,
uint8_t const  alphabet[static UINT8_MAX+1] 
)

Decode base16 encoded input.

Parameters
[out]errIf non-null contains any parse errors.
[out]outWhere to write the decoded binary data.
[in]inString to decode.
[in]no_trailingError out if we find non-base16 characters at the end of the string.
[in]alphabetto use for decoding.
Returns
  • < 0 on failure. The offset where the decoding error occurred as a negative integer.
  • Length of decoded data.

Definition at line 144 of file base16.c.

+ Here is the call graph for this function:

◆ fr_base16_encode_nstd()

fr_slen_t fr_base16_encode_nstd ( fr_sbuff_t out,
fr_dbuff_t in,
char const  alphabet[static UINT8_MAX+1] 
)

Convert binary data to a hex string.

Ascii encoded hex string will not be prefixed with '0x'

Parameters
[out]outOutput buffer to write to.
[in]ininput.
[in]alphabetto use for encode.
Returns
  • >=0 the number of bytes written to out.
  • <0 number of bytes we would have needed to print the next hexit.

Definition at line 115 of file base16.c.

+ Here is the call graph for this function:

Variable Documentation

◆ fr_base16_alphabet_decode_mc

uint8_t const fr_base16_alphabet_decode_mc[UINT8_MAX+1]
Initial value:
= {
['0'] = 0,
['1'] = 1,
['2'] = 2,
['3'] = 3,
['4'] = 4,
['5'] = 5,
['6'] = 6,
['7'] = 7,
['8'] = 8,
['9'] = 9,
F4(58, UINT8_MAX), F2(62, UINT8_MAX), F1(64, UINT8_MAX),
['A'] = 10,
['B'] = 11,
['C'] = 12,
['D'] = 13,
['E'] = 14,
['F'] = 15,
F16(71, UINT8_MAX), F8(87, UINT8_MAX), F2(95, UINT8_MAX),
['a'] = 10,
['b'] = 11,
['c'] = 12,
['d'] = 13,
['e'] = 14,
['f'] = 15,
F128(103, UINT8_MAX), F16(231, UINT8_MAX), F8(247, UINT8_MAX), F1(255, UINT8_MAX)
}
#define F4(_idx, _val)
Definition: build.h:213
#define F128(_idx, _val)
Definition: build.h:218
#define F8(_idx, _val)
Definition: build.h:214
#define F2(_idx, _val)
Definition: build.h:212
#define F32(_idx, _val)
Definition: build.h:216
#define F16(_idx, _val)
Definition: build.h:215
#define F1(_idx, _val)
Fill macros for array initialisation.
Definition: build.h:211
#define UINT8_MAX
Definition: merged_model.c:32

Mixed case decode alphabet for base16.

Definition at line 75 of file base16.c.

◆ fr_base16_alphabet_encode_lc

char const fr_base16_alphabet_encode_lc[UINT8_MAX+1]
Initial value:
= {
[0] = '0',
[1] = '1',
[2] = '2',
[3] = '3',
[4] = '4',
[5] = '5',
[6] = '6',
[7] = '7',
[8] = '8',
[9] = '9',
[10] = 'a',
[11] = 'b',
[12] = 'c',
[13] = 'd',
[14] = 'e',
[15] = 'f'
}

lower case encode alphabet for base16

Encode/decode binary data using printable characters (base16 format - hex)

Definition at line 31 of file base16.c.

◆ fr_base16_alphabet_encode_uc

char const fr_base16_alphabet_encode_uc[UINT8_MAX+1]
Initial value:
= {
[0] = '0',
[1] = '1',
[2] = '2',
[3] = '3',
[4] = '4',
[5] = '5',
[6] = '6',
[7] = '7',
[8] = '8',
[9] = '9',
[10] = 'A',
[11] = 'B',
[12] = 'C',
[13] = 'D',
[14] = 'E',
[15] = 'F'
}

lower case encode alphabet for base16

Definition at line 53 of file base16.c.