29#include <freeradius-devel/build.h>
30#include <freeradius-devel/util/value.h>
61#define FR_DER_TAG_VALUE_MAX (0x1f)
76#define DER_MAX_STR 16384
78#define DER_UTC_TIME_LEN 13
79#define DER_GENERALIZED_TIME_LEN_MIN 15
80#define DER_GENERALIZED_TIME_PRECISION_MAX 9
82#define DER_TAG_CLASS_MASK 0xc0
83#define DER_TAG_CONSTRUCTED_MASK 0x20
84#define DER_TAG_NUM_MASK 0x1f
86#define DER_TAG_CONTINUATION 0x1f
88#define DER_LEN_MULTI_BYTE 0x80
90#define DER_BOOLEAN_FALSE 0x00
91#define DER_BOOLEAN_TRUE 0xff
115 char const *shortname;
136#define fr_der_flag_has_none(_flags) ((_flags)->flag_type == FR_DER_ATTR_FLAG_NONE)
137#define fr_der_flag_has_sequence_of(_flags) ((_flags)->flag_type == FR_DER_ATTR_FLAG_SEQUENCE_OF)
138#define fr_der_flag_has_set_of(_flags) ((_flags)->flag_type == FR_DER_ATTR_FLAG_SETOF)
139#define fr_der_flag_has_value(_flags) ((_flags)->flag_type == FR_DER_ATTR_FLAG_DEFAULT_VALUE)
140#define fr_der_flag_has_shortname(_flags) ((_flags)->flag_type == FR_DER_ATTR_FLAG_SHORTNAME)
163 "%s is not a DER attribute, it is from the \"%s\" dictionary",
167 if (!
fr_cond_assert_msg(flags,
"%s is not a DER attribute, it has no protocol extension",
168 da->name))
return &no_flags;
198 "%s is not a 'sequence_of=...' attribute, so the union does not hold 'sequence_of'",
201 return flags->sequence_of;
214 "%s is not a 'set_of=...' attribute, so the union does not hold 'set_of'",
217 return flags->set_of;
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
#define fr_cond_assert_msg(_x, _fmt,...)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
static fr_der_tag_t fr_der_attr_sequence_of(fr_dict_attr_t const *da)
fr_der_tag_t
Enumeration describing the data types in a DER encoded structure.
@ FR_DER_TAG_IA5_STRING
String of IA5 (7bit) chars.
@ FR_DER_TAG_SEQUENCE
A sequence of DER encoded data (a structure).
@ FR_DER_TAG_SET
A set of DER encoded data (a structure).
@ FR_DER_TAG_BMP_STRING
String of BMP chars.
@ FR_DER_TAG_INTEGER
Arbitrary width signed integer.
@ FR_DER_TAG_BOOLEAN
Boolean true/false.
@ FR_DER_TAG_CHOICE
A choice of types. Techically not a DER tag, but used to represent a choice.
@ FR_DER_TAG_UTF8_STRING
String of UTF8 chars.
@ FR_DER_TAG_UTC_TIME
A time in UTC "YYMMDDhhmmssZ" format.
@ FR_DER_TAG_GENERALIZED_TIME
A time in "YYYYMMDDHHMMSS[.fff]Z" format.
@ FR_DER_TAG_INVALID
Invalid tag.
@ FR_DER_TAG_NULL
An empty value.
@ FR_DER_TAG_OCTETSTRING
String of octets (length field specifies bytes).
@ FR_DER_TAG_VISIBLE_STRING
String of visible chars.
@ FR_DER_TAG_BITSTRING
String of bits (length field specifies bits).
@ FR_DER_TAG_T61_STRING
String of T61 (8bit) chars.
@ FR_DER_TAG_ENUMERATED
An enumerated value.
@ FR_DER_TAG_UNIVERSAL_STRING
String of universal chars.
@ FR_DER_TAG_PRINTABLE_STRING
String of printable chars.
@ FR_DER_TAG_GENERAL_STRING
String of general chars.
@ FR_DER_TAG_OID
Reference to an OID based attribute.
bool fr_der_tags_compatible(fr_der_tag_t tag1, fr_der_tag_t tag2)
static bool fr_der_attr_is_sequence_of(fr_dict_attr_t const *da)
fr_der_attr_flag_type_t
Which member of the fr_der_attr_flags_t union is in use.
@ FR_DER_ATTR_FLAG_NONE
no member is in use
@ FR_DER_ATTR_FLAG_SHORTNAME
has a short name
@ FR_DER_ATTR_FLAG_SEQUENCE_OF
sequence_of has been defined
@ FR_DER_ATTR_FLAG_SETOF
set_of has been defined
@ FR_DER_ATTR_FLAG_DEFAULT_VALUE
a default value exists
void fr_der_global_free(void)
static fr_der_tag_class_t fr_der_attr_class(fr_dict_attr_t const *da)
static fr_der_tag_t fr_der_attr_der_type(fr_dict_attr_t const *da)
fr_der_tag_t der_type
the DER type, which is different from the FreeRADIUS type
static bool fr_der_attr_is_set_of(fr_dict_attr_t const *da)
static bool fr_der_attr_has_default_value(fr_dict_attr_t const *da)
TALLOC_CTX * tmp_ctx
ctx under which temporary data will be allocated
unsigned int optional
optional, we MUST already have set 'option'
static fr_der_tag_t fr_der_attr_set_of(fr_dict_attr_t const *da)
int fr_der_global_init(void)
uint32_t restrictions
for choice of options and tags - no dups allowed
fr_dict_attr_t const * root
where to start decoding from
fr_dict_protocol_t libfreeradius_der_dict_protocol
bool fr_type_to_der_tag_valid(fr_type_t type, fr_der_tag_t tag)
static bool fr_der_attr_is_oid_and_value(fr_dict_attr_t const *da)
#define fr_der_flag_has_value(_flags)
fr_der_attr_flag_type_t flag_type
which member of the union is in use
fr_der_tag_t fr_type_to_der_tag_default(fr_type_t type)
char const * fr_der_tag_to_str(fr_der_tag_t tag)
unsigned int leaf
encode this OID along with its value
static bool fr_der_attr_optional(fr_dict_attr_t const *da)
#define fr_der_flag_has_set_of(_flags)
static uint64_t fr_der_attr_max(fr_dict_attr_t const *da)
char const * fr_der_dict_attr_to_shortname(fr_dict_attr_t const *da)
unsigned int is_constructed
for raw attributes, the data said that the value was constructed
@ FR_DER_TAG_CONSTRUCTED
This is a sequence or set, it contains children.
@ FR_DER_TAG_PRIMITIVE
This is a leaf value, it contains no children.
unsigned int is_choice
DER name "choice".
unsigned int is_oid_and_value
is OID+value
#define fr_der_flag_has_sequence_of(_flags)
unsigned int is_extensions
a list of X.509 extensions
static bool fr_der_attr_leaf(fr_dict_attr_t const *da)
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 bool fr_der_attr_is_choice(fr_dict_attr_t const *da)
static fr_der_attr_flags_t const * fr_der_attr_flags(fr_dict_attr_t const *da)
Return DER-specific flags for a given attribute.
unsigned int is_option
has an option defined
uint8_t option
an "attribute number" encoded in the tag field.
static bool fr_der_attr_is_extensions(fr_dict_attr_t const *da)
fr_der_tag_class_t class
tag Class
static uint8_t fr_der_attr_option(fr_dict_attr_t const *da)
uint64_t max
maximum count of items in a sequence, set, or string.
@ FR_DER_CLASS_APPLICATION
fr_dict_protocol_t const * fr_dict_protocol(fr_dict_t const *dict)
Return the protocol descriptor for the dictionary.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
@ FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC
Protocol specific extensions.
Protocol-specific callbacks in libfreeradius-PROTOCOL.
static void * fr_dict_attr_ext(fr_dict_attr_t const *da, fr_dict_attr_ext_t ext)
fr_aka_sim_id_type_t type
static fr_sbuff_err_t char size_t fr_sbuff_t * in
static fr_sbuff_err_t char ** out