The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
decode.c File Reference

Functions to decode DER encoded data. More...

#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/decode.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/struct.h>
#include "attrs.h"
#include "der.h"
+ Include dependency graph for decode.c:

Go to the source code of this file.

Data Structures

struct  fr_der_decode_oid_to_da_ctx_t
 
struct  fr_der_decode_oid_to_stack_ctx_t
 
struct  fr_der_tag_decode_t
 

Macros

#define fr_der_decode_enumerated   fr_der_decode_integer
 
#define IS_DER_LEN_MULTI_BYTE(_len)   (((_len) & DER_LEN_MULTI_BYTE) == DER_LEN_MULTI_BYTE)
 
#define IS_DER_TAG_CONSTRUCTED(_tag)   (((_tag) & 0x20) == 0x20)
 
#define IS_DER_TAG_CONTINUATION(_tag)   (((_tag) & DER_TAG_CONTINUATION) == DER_TAG_CONTINUATION)
 

Typedefs

typedef ssize_t(* fr_der_decode_oid_t) (uint64_t subidentifier, void *uctx, bool is_last)
 
typedef ssize_t(* fr_der_decode_t) (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 

Functions

static ssize_t decode_pair (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
 Decode a DER structure using the specific dictionary.
 
static int decode_test_ctx (void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict, fr_dict_attr_t const *root_da)
 
static ssize_t fr_der_decode_bitstring (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_boolean (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_choice (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 Decode a CHOICE type This is where the actual decoding of the CHOICE type happens.
 
static ssize_t fr_der_decode_combo_ip_addr (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static int fr_der_decode_default (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_der_attr_flags_t const *flags)
 Create a default value.
 
static ssize_t fr_der_decode_general_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_generalized_time (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_hdr (fr_dict_attr_t const *parent, fr_dbuff_t *in, uint8_t *tag, size_t *len, fr_der_tag_t expected)
 Decode the tag and length fields of a DER encoded structure.
 
static ssize_t fr_der_decode_ia5_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_integer (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_ipv4_addr (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_ipv4_prefix (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_ipv6_addr (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_ipv6_prefix (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_null (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_octetstring (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_oid (fr_dbuff_t *in, fr_der_decode_oid_t func, void *uctx)
 Decode an OID from a DER encoded buffer using a callback.
 
static ssize_t fr_der_decode_oid_and_value (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 Decode an OID value pair.
 
static ssize_t fr_der_decode_oid_to_da (uint64_t subidentifier, void *uctx, bool is_last)
 Decode an OID to a dictionary attribute.
 
static ssize_t fr_der_decode_oid_to_stack (uint64_t subidentifier, void *uctx, UNUSED bool is_last)
 Decode an OID to an exploded list.
 
static ssize_t fr_der_decode_oid_wrapper (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
ssize_t fr_der_decode_pair_dbuff (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_printable_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_proto (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx)
 
static ssize_t fr_der_decode_sequence (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_set (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, bool const allowed_chars[], fr_der_decode_ctx_t *decode_ctx))
 Function signature for DER decode functions.
 
static ssize_t fr_der_decode_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, bool const allowed_chars[], UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_t61_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_universal_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_unknown (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t tag_byte, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 Decode an unknown attribute.
 
static ssize_t fr_der_decode_utc_time (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_utf8_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_visible_string (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
 
static ssize_t fr_der_decode_x509_extensions (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dbuff_t *in, fr_dict_attr_t const *parent, fr_der_decode_ctx_t *decode_ctx)
 Decode an X509 Extentions Field.
 
static fr_dict_attr_t * fr_der_unknown_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, fr_type_t type, unsigned int attr, uint8_t tag_byte, bool raw)
 Create an unknown DER attribute.
 

Variables

fr_test_point_pair_decode_t der_tp_decode_pair
 
fr_test_point_proto_decode_t der_tp_decode_proto
 
static const fr_der_tag_decode_t oid_and_value_func
 
static bool const sbuff_char_class_num [SBUFF_CHAR_CLASS]
 
static const fr_der_tag_decode_t tag_funcs [FR_DER_TAG_VALUE_MAX]
 
static const fr_der_tag_decode_t type_funcs [FR_TYPE_MAX]
 

Detailed Description

Functions to decode DER encoded data.

Id
c46b454be2467beb6ce49f88e494817b7166bd25
Author
Ethan Thompson (ethan.nosp@m..tho.nosp@m.mpson.nosp@m.@ink.nosp@m.bridg.nosp@m.e.io)
Id
44657d8c1dc1db8cbbbcb6c677ff95dd376048fc
Author
Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
Ethan Thompson (ethan.nosp@m..tho.nosp@m.mpson.nosp@m.@ink.nosp@m.bridg.nosp@m.e.io)

Definition in file decode.c.


Data Structure Documentation

◆ fr_der_decode_oid_to_da_ctx_t

struct fr_der_decode_oid_to_da_ctx_t

Definition at line 557 of file decode.c.

+ Collaboration diagram for fr_der_decode_oid_to_da_ctx_t:
Data Fields
TALLOC_CTX * ctx Allocation context.
fr_dict_attr_t const * parent_da Parent dictionary attribute.
fr_pair_list_t * parent_list Parent pair list.

◆ fr_der_decode_oid_to_stack_ctx_t

struct fr_der_decode_oid_to_stack_ctx_t

Definition at line 465 of file decode.c.

Data Fields
int depth
unsigned int oid[FR_DICT_MAX_TLV_STACK]

◆ fr_der_tag_decode_t

struct fr_der_tag_decode_t

Definition at line 54 of file decode.c.

+ Collaboration diagram for fr_der_tag_decode_t:
Data Fields
fr_der_tag_constructed_t constructed
fr_der_decode_t decode

Macro Definition Documentation

◆ fr_der_decode_enumerated

#define fr_der_decode_enumerated   fr_der_decode_integer

Definition at line 1513 of file decode.c.

◆ IS_DER_LEN_MULTI_BYTE

#define IS_DER_LEN_MULTI_BYTE (   _len)    (((_len) & DER_LEN_MULTI_BYTE) == DER_LEN_MULTI_BYTE)

Definition at line 42 of file decode.c.

◆ IS_DER_TAG_CONSTRUCTED

#define IS_DER_TAG_CONSTRUCTED (   _tag)    (((_tag) & 0x20) == 0x20)

Definition at line 41 of file decode.c.

◆ IS_DER_TAG_CONTINUATION

#define IS_DER_TAG_CONTINUATION (   _tag)    (((_tag) & DER_TAG_CONTINUATION) == DER_TAG_CONTINUATION)

Definition at line 40 of file decode.c.

Typedef Documentation

◆ fr_der_decode_oid_t

typedef ssize_t(* fr_der_decode_oid_t) (uint64_t subidentifier, void *uctx, bool is_last)

Definition at line 44 of file decode.c.

◆ fr_der_decode_t

typedef ssize_t(* fr_der_decode_t) (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)

Definition at line 51 of file decode.c.

Function Documentation

◆ decode_pair()

static ssize_t decode_pair ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
uint8_t const *  data,
size_t  data_len,
void *  decode_ctx 
)
static

Decode a DER structure using the specific dictionary.

Parameters
[in]ctxto allocate new pairs in.
[in]outwhere new VPs will be added
[in]parentParent attribute. This should be the root of the dictionary we're using to decode DER data. This only specifies structures like SEQUENCES. OID based pairs are resolved using the global dictionary tree.
[in]datato decode.
[in]data_lenLength of data.
[in]decode_ctxto pass to decode function.

Definition at line 2958 of file decode.c.

+ Here is the call graph for this function:

◆ decode_test_ctx()

static int decode_test_ctx ( void **  out,
TALLOC_CTX *  ctx,
UNUSED fr_dict_t const *  dict,
fr_dict_attr_t const *  root_da 
)
static

Definition at line 2972 of file decode.c.

◆ fr_der_decode_bitstring()

static ssize_t fr_der_decode_bitstring ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 216 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_boolean()

static ssize_t fr_der_decode_boolean ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 76 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_choice()

static ssize_t fr_der_decode_choice ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Decode a CHOICE type This is where the actual decoding of the CHOICE type happens.

The CHOICE type is a type that can have multiple types, but only one of them can be present at a time. The type that is present is determined by the tag of the data

Parameters
[in]ctxTalloc context
[in]outOutput list
[in]parentParent attribute
[in]inInput buffer
[in]decode_ctxDecode context

Definition at line 2170 of file decode.c.

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

◆ fr_der_decode_combo_ip_addr()

static ssize_t fr_der_decode_combo_ip_addr ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1725 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_default()

static int fr_der_decode_default ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_der_attr_flags_t const *  flags 
)
static

Create a default value.

Some sequences are encoded with no data, and that can mean "use a default value". We create that default value here.

Parameters
[in]ctxto allocate the pair in.
[out]outlist to append the pair to.
[in]parentattribute to take the default value from.
[in]flagsDER flags of parent.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2612 of file decode.c.

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

◆ fr_der_decode_general_string()

static ssize_t fr_der_decode_general_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1515 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_generalized_time()

static ssize_t fr_der_decode_generalized_time ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1302 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_hdr()

static ssize_t fr_der_decode_hdr ( fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
uint8_t *  tag,
size_t *  len,
fr_der_tag_t  expected 
)
static

Decode the tag and length fields of a DER encoded structure.

Parameters
[in]parentParent attribute
[in]inInput buffer
[out]tagTag value
[out]lenLength of the value field
[in]expectedthe expected / required tag
Returns
0 on success, -1 on failure

Definition at line 1968 of file decode.c.

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

◆ fr_der_decode_ia5_string()

static ssize_t fr_der_decode_ia5_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1210 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_integer()

static ssize_t fr_der_decode_integer ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 126 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_ipv4_addr()

static ssize_t fr_der_decode_ipv4_addr ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1527 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_ipv4_prefix()

static ssize_t fr_der_decode_ipv4_prefix ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1575 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_ipv6_addr()

static ssize_t fr_der_decode_ipv6_addr ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1626 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_ipv6_prefix()

static ssize_t fr_der_decode_ipv6_prefix ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1674 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_null()

static ssize_t fr_der_decode_null ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 415 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_octetstring()

static ssize_t fr_der_decode_octetstring ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 360 of file decode.c.

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

◆ fr_der_decode_oid()

static ssize_t fr_der_decode_oid ( fr_dbuff_t *  in,
fr_der_decode_oid_t  func,
void *  uctx 
)
static

Decode an OID from a DER encoded buffer using a callback.

Parameters
[in]inThe DER encoded data.
[in]funcThe callback function to call for each subidentifier.
[in]uctxUser context for the callback function.
Returns
  • 0 on success
  • < 0 on error

Definition at line 648 of file decode.c.

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

◆ fr_der_decode_oid_and_value()

static ssize_t fr_der_decode_oid_and_value ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Decode an OID value pair.

Parameters
[in]ctxTalloc context
[out]outOutput list
[in]parentParent attribute
[in]inInput buffer
[in]decode_ctxDecode context
Returns
0 on success, -1 on failure

Definition at line 1839 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_oid_to_da()

static ssize_t fr_der_decode_oid_to_da ( uint64_t  subidentifier,
void *  uctx,
bool  is_last 
)
static

Decode an OID to a dictionary attribute.

Parameters
[in]subidentifierThe subidentifier to decode
[in]uctxUser context
[in]is_lastIs this the last subidentifier in the OID
Returns
  • 1 on success
  • < 0 on error

Definition at line 572 of file decode.c.

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

◆ fr_der_decode_oid_to_stack()

static ssize_t fr_der_decode_oid_to_stack ( uint64_t  subidentifier,
void *  uctx,
UNUSED bool  is_last 
)
static

Decode an OID to an exploded list.

Parameters
[in]subidentifierThe subidentifier to decode
[in]uctxUser context
[in]is_lastIs this the last subidentifier in the OID
Returns
  • 1 on success
  • < 0 on error

Definition at line 479 of file decode.c.

+ Here is the caller graph for this function:

◆ fr_der_decode_oid_wrapper()

static ssize_t fr_der_decode_oid_wrapper ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1771 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_pair_dbuff()

ssize_t fr_der_decode_pair_dbuff ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)

Definition at line 2640 of file decode.c.

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

◆ fr_der_decode_printable_string()

static ssize_t fr_der_decode_printable_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1155 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_proto()

static ssize_t fr_der_decode_proto ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
uint8_t const *  data,
size_t  data_len,
void *  proto_ctx 
)
static

Definition at line 2930 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_sequence()

static ssize_t fr_der_decode_sequence ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 805 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_set()

static ssize_t fr_der_decode_set ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 964 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_string() [1/2]

static ssize_t fr_der_decode_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
bool const  allowed_chars[],
fr_der_decode_ctx_t *  decode_ctx 
)
static

Function signature for DER decode functions.

Parameters
[in]ctxAllocation context
[in]outWhere to store the decoded pairs.
[in]parentParent attribute. This should be the root of the dictionary we're using to decode DER data initially, and then nested children.
[in]inThe DER encoded data.
[in]allowed_charsOptional array indicating which ASCII characters are allowed.
[in]decode_ctxAny decode specific data.
Returns
  • > 0 on success. How many bytes were decoded.
  • 0 no bytes decoded.
  • < 0 on error. May be the offset (as a negative value) where the error occurred.
+ Here is the caller graph for this function:

◆ fr_der_decode_string() [2/2]

static ssize_t fr_der_decode_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
bool const  allowed_chars[],
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 2500 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_t61_string()

static ssize_t fr_der_decode_t61_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1169 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_universal_string()

static ssize_t fr_der_decode_universal_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1521 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_unknown()

static ssize_t fr_der_decode_unknown ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
uint8_t  tag_byte,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Decode an unknown attribute.

We don't know how to decode unknown attributes. Instead, save the header information in da->flags, and then decode the value as octets.

Parameters
[in]ctxTalloc context
[out]outOutput list
[in]parentUnknown attribute. Its DER flags are updated from the tag byte.
[in]tag_byteFirst byte of the header which the value was decoded from.
[in]inInput buffer, which starts at the value.
[in]decode_ctxDecode context
Returns
  • the number of bytes decoded on success.
  • < 0 on error.

Definition at line 2574 of file decode.c.

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

◆ fr_der_decode_utc_time()

static ssize_t fr_der_decode_utc_time ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1222 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_utf8_string()

static ssize_t fr_der_decode_utf8_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 795 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_visible_string()

static ssize_t fr_der_decode_visible_string ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dict_attr_t const *  parent,
fr_dbuff_t *  in,
UNUSED fr_der_decode_ctx_t *  decode_ctx 
)
static

Definition at line 1489 of file decode.c.

+ Here is the call graph for this function:

◆ fr_der_decode_x509_extensions()

static ssize_t fr_der_decode_x509_extensions ( TALLOC_CTX *  ctx,
fr_pair_list_t *  out,
fr_dbuff_t *  in,
fr_dict_attr_t const *  parent,
fr_der_decode_ctx_t *  decode_ctx 
)
static

Decode an X509 Extentions Field.

Parameters
[in]ctxTalloc context
[in]outOutput list
[in]inInput buffer
[in]parentParent attribute
[in]decode_ctxDecode context
Returns
0 on success, -1 on failure

Definition at line 2228 of file decode.c.

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

◆ fr_der_unknown_afrom_num()

static fr_dict_attr_t * fr_der_unknown_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
fr_type_t  type,
unsigned int  attr,
uint8_t  tag_byte,
bool  raw 
)
static

Create an unknown DER attribute.

The decoder needs do a number of DER-specific things for unknown / raw attributes.

  • grouped attributes with refs are dereferenced, so that the unknown one is created with the correct parent
  • the der type / tag need to be associated with the new da, so that it can be encoded correctly.
  • we also need to remember the option numver and class, so they can be encoded, too.
Parameters
[in]ctxallocation context. For FR_TYPE_ATTR should be the parent fr_pair_t
[in]parentParent da. If it has a ref, the ref is resolved.
[in]typeof the unknown attribute.
[in]attrnumber of the unknown attribute: an OID component, or a DER tag / option.
[in]tag_bytethe DER header byte the attribute was created from, or 0 when it was created from an OID component.
[in]rawshould we create a "raw" da versus an "unknown" one.
Returns
  • the unknown attribute on success.
  • NULL on failure.

Definition at line 514 of file decode.c.

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

Variable Documentation

◆ der_tp_decode_pair

fr_test_point_pair_decode_t der_tp_decode_pair
Initial value:
= {
.test_ctx = decode_test_ctx,
.func = decode_pair,
}
static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict, UNUSED fr_dict_attr_t const *root_da)
Definition decode.c:102
static ssize_t decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
Definition decode.c:562

Definition at line 2989 of file decode.c.

◆ der_tp_decode_proto

fr_test_point_proto_decode_t der_tp_decode_proto
Initial value:
= {
.test_ctx = decode_test_ctx,
}
static ssize_t fr_der_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx)
Definition decode.c:2930

Definition at line 2995 of file decode.c.

◆ oid_and_value_func

const fr_der_tag_decode_t oid_and_value_func
static
Initial value:
= {
}
@ FR_DER_TAG_PRIMITIVE
This is a leaf value, it contains no children.
Definition der.h:64
static ssize_t fr_der_decode_oid_and_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
Decode an OID value pair.
Definition decode.c:1839

Definition at line 1954 of file decode.c.

◆ sbuff_char_class_num

bool const sbuff_char_class_num[SBUFF_CHAR_CLASS]
static
Initial value:
= {
}
#define SBUFF_CHAR_CLASS_NUM

Definition at line 1298 of file decode.c.

◆ tag_funcs

const fr_der_tag_decode_t tag_funcs[FR_DER_TAG_VALUE_MAX]
static
Initial value:
= {
[FR_DER_TAG_NULL] = { .constructed = FR_DER_TAG_PRIMITIVE, .decode = fr_der_decode_null },
[FR_DER_TAG_SET] = { .constructed = FR_DER_TAG_CONSTRUCTED, .decode = fr_der_decode_set },
}
@ FR_DER_TAG_IA5_STRING
String of IA5 (7bit) chars.
Definition der.h:48
@ FR_DER_TAG_SEQUENCE
A sequence of DER encoded data (a structure).
Definition der.h:44
@ FR_DER_TAG_SET
A set of DER encoded data (a structure).
Definition der.h:45
@ FR_DER_TAG_INTEGER
Arbitrary width signed integer.
Definition der.h:37
@ FR_DER_TAG_BOOLEAN
Boolean true/false.
Definition der.h:36
@ FR_DER_TAG_UTF8_STRING
String of UTF8 chars.
Definition der.h:43
@ FR_DER_TAG_UTC_TIME
A time in UTC "YYMMDDhhmmssZ" format.
Definition der.h:49
@ FR_DER_TAG_GENERALIZED_TIME
A time in "YYYYMMDDHHMMSS[.fff]Z" format.
Definition der.h:50
@ FR_DER_TAG_NULL
An empty value.
Definition der.h:40
@ FR_DER_TAG_OCTETSTRING
String of octets (length field specifies bytes).
Definition der.h:39
@ FR_DER_TAG_VISIBLE_STRING
String of visible chars.
Definition der.h:51
@ FR_DER_TAG_BITSTRING
String of bits (length field specifies bits).
Definition der.h:38
@ FR_DER_TAG_T61_STRING
String of T61 (8bit) chars.
Definition der.h:47
@ FR_DER_TAG_ENUMERATED
An enumerated value.
Definition der.h:42
@ FR_DER_TAG_UNIVERSAL_STRING
String of universal chars.
Definition der.h:53
@ FR_DER_TAG_PRINTABLE_STRING
String of printable chars.
Definition der.h:46
@ FR_DER_TAG_GENERAL_STRING
String of general chars.
Definition der.h:52
@ FR_DER_TAG_OID
Reference to an OID based attribute.
Definition der.h:41
@ FR_DER_TAG_CONSTRUCTED
This is a sequence or set, it contains children.
Definition der.h:65
static ssize_t fr_der_decode_visible_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1489
static ssize_t fr_der_decode_generalized_time(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1302
static ssize_t fr_der_decode_oid_wrapper(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1771
static ssize_t fr_der_decode_t61_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1169
static ssize_t fr_der_decode_universal_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1521
static ssize_t fr_der_decode_general_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1515
static ssize_t fr_der_decode_integer(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:126
static ssize_t fr_der_decode_bitstring(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:216
static ssize_t fr_der_decode_octetstring(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:360
static ssize_t fr_der_decode_ia5_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1210
static ssize_t fr_der_decode_null(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:415
#define fr_der_decode_enumerated
Definition decode.c:1513
static ssize_t fr_der_decode_utf8_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:795
static ssize_t fr_der_decode_printable_string(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1155
static ssize_t fr_der_decode_utc_time(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1222
static ssize_t fr_der_decode_set(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:964
static ssize_t fr_der_decode_boolean(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:76
static ssize_t fr_der_decode_sequence(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:805

Definition at line 1921 of file decode.c.

◆ type_funcs

const fr_der_tag_decode_t type_funcs[FR_TYPE_MAX]
static
Initial value:
= {
}
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
static ssize_t fr_der_decode_ipv4_addr(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1527
static ssize_t fr_der_decode_ipv6_addr(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1626
static ssize_t fr_der_decode_ipv4_prefix(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1575
static ssize_t fr_der_decode_ipv6_prefix(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1674
static ssize_t fr_der_decode_combo_ip_addr(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *in, UNUSED fr_der_decode_ctx_t *decode_ctx)
Definition decode.c:1725

Definition at line 1945 of file decode.c.