The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
base16.h File Reference
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/dbuff.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
+ Include dependency graph for base16.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define fr_base16_decode(_err, _out, _in, _no_trailing)    fr_base16_decode_nstd(_err, _out, _in, _no_trailing, fr_base16_alphabet_decode_mc)
 
#define fr_base16_encode(_out, _in)    fr_base16_encode_nstd(_out, _in, fr_base16_alphabet_encode_lc)
 

Functions

static fr_slen_t fr_base16_aencode (TALLOC_CTX *ctx, char **out, fr_dbuff_t *in)
 Convert binary data to a hex string, allocating the output buffer. More...
 
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...
 
static bool fr_is_base16_nstd (char c, uint8_t const alphabet[static UINT8_MAX+1])
 Check if char is in base16 alphabet. 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]
 Encode/decode binary data using printable characters (base16 format - hex) More...
 
char const fr_base16_alphabet_encode_uc [UINT8_MAX+1]
 lower case encode alphabet for base16 More...
 

Macro Definition Documentation

◆ fr_base16_decode

#define fr_base16_decode (   _err,
  _out,
  _in,
  _no_trailing 
)     fr_base16_decode_nstd(_err, _out, _in, _no_trailing, fr_base16_alphabet_decode_mc)

Definition at line 95 of file base16.h.

◆ fr_base16_encode

#define fr_base16_encode (   _out,
  _in 
)     fr_base16_encode_nstd(_out, _in, fr_base16_alphabet_encode_lc)

Definition at line 57 of file base16.h.

Function Documentation

◆ fr_base16_aencode()

static fr_slen_t fr_base16_aencode ( TALLOC_CTX *  ctx,
char **  out,
fr_dbuff_t in 
)
inlinestatic

Convert binary data to a hex string, allocating the output buffer.

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

Parameters
[in]ctxto allocate the buffer in.
[out]outwhere to write the new buffer.
[in]ininput.
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 71 of file base16.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 65 of file merged_model.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 56 of file merged_model.c.

+ Here is the call graph for this function:

◆ fr_is_base16_nstd()

static bool fr_is_base16_nstd ( char  c,
uint8_t const  alphabet[static UINT8_MAX+1] 
)
inlinestatic

Check if char is in base16 alphabet.

Parameters
[in]cchar to check.
[in]alphabetto use.
Returns
  • true if c is a character from the base32 alphabet.
  • false if character is not in the base32 alphabet.

Definition at line 51 of file base16.h.

+ Here is the caller graph for this function:

Variable Documentation

◆ fr_base16_alphabet_decode_mc

uint8_t const fr_base16_alphabet_decode_mc[UINT8_MAX+1]
extern

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]
extern

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

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

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]
extern

lower case encode alphabet for base16

Definition at line 53 of file base16.c.