Go to the documentation of this file.
57 #ifndef HEADER_ASN1T_H
58 #define HEADER_ASN1T_H
79 #define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
84 #define ASN1_ITEM_start(itname) \
85 const ASN1_ITEM itname##_it = {
87 #define ASN1_ITEM_end(itname) \
92 #define ASN1_ITEM_TEMPLATE(tname) \
93 static const ASN1_TEMPLATE tname##_item_tt
95 #define ASN1_ITEM_TEMPLATE_END(tname) \
97 ASN1_ITEM_start(tname) \
98 ASN1_ITYPE_PRIMITIVE,\
130 #define ASN1_SEQUENCE(tname) \
131 static const ASN1_TEMPLATE tname##_seq_tt[]
133 #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
135 #define ASN1_SEQUENCE_END_name(stname, tname) \
137 ASN1_ITEM_start(tname) \
138 ASN1_ITYPE_SEQUENCE,\
141 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
147 #define ASN1_SEQUENCE_cb(tname, cb) \
148 static const ASN1_AUX tname##_aux = {NULL, 0, 0, cb, 0}; \
151 #define ASN1_SEQUENCE_ref(tname, cb) \
152 static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), cb, 0}; \
155 #define ASN1_SEQUENCE_enc(tname, enc, cb) \
156 static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, cb, offsetof(tname, enc)}; \
159 #define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
161 #define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
163 #define ASN1_SEQUENCE_END_ref(stname, tname) \
165 ASN1_ITEM_start(tname) \
166 ASN1_ITYPE_SEQUENCE,\
169 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
198 #define ASN1_CHOICE(tname) \
199 static const ASN1_TEMPLATE tname##_ch_tt[]
201 #define ASN1_CHOICE_cb(tname, cb) \
202 static const ASN1_AUX tname##_aux = {NULL, 0, 0, cb, 0}; \
205 #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
207 #define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
209 #define ASN1_CHOICE_END_selector(stname, tname, selname) \
211 ASN1_ITEM_start(tname) \
213 offsetof(stname,selname) ,\
215 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
221 #define ASN1_CHOICE_END_cb(stname, tname, selname) \
223 ASN1_ITEM_start(tname) \
225 offsetof(stname,selname) ,\
227 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
235 #define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
237 #name, ASN1_ITEM_ref(type) }
243 #define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
244 (flags), (tag), offsetof(stname, field),\
245 #field, ASN1_ITEM_ref(type) }
249 #define ASN1_EX_COMBINE(flags, tag, type) { \
250 (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }
254 #define ASN1_IMP_EX(stname, field, type, tag, ex) \
255 ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
257 #define ASN1_EXP_EX(stname, field, type, tag, ex) \
258 ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
262 #define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
263 #define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
265 #define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
268 #define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
271 #define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
274 #define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
278 #define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
279 #define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
282 #define ASN1_SEQUENCE_OF(stname, field, type) \
283 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
286 #define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
287 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
291 #define ASN1_SET_OF(stname, field, type) \
292 ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
294 #define ASN1_SET_OF_OPT(stname, field, type) \
295 ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
299 #define ASN1_IMP_SET_OF(stname, field, type, tag) \
300 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
302 #define ASN1_EXP_SET_OF(stname, field, type, tag) \
303 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
305 #define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
306 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
308 #define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
309 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
311 #define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
312 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
314 #define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
315 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
317 #define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
318 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
320 #define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
321 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
325 #define ASN1_ADB(name) \
326 static const ASN1_ADB_TABLE name##_adbtbl[]
328 #define ASN1_ADB_END(name, flags, field, app_table, def, none) \
330 static const ASN1_ADB name##_adb = {\
332 offsetof(name, field),\
335 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
340 #define ADB_ENTRY(val, template) {val, template}
342 #define ASN1_ADB_TEMPLATE(name) \
343 static const ASN1_TEMPLATE name##_tt
361 #define ASN1_TEMPLATE_item(t) (t->item_ptr)
362 #define ASN1_TEMPLATE_adb(t) (t->item_ptr)
387 #define ASN1_TFLG_OPTIONAL (0x1)
390 #define ASN1_TFLG_SET_OF (0x1 << 1)
393 #define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
396 #define ASN1_TFLG_SK_MASK (0x3 << 1)
404 #define ASN1_TFLG_IMPTAG (0x1 << 3)
408 #define ASN1_TFLG_EXPTAG (0x2 << 3)
410 #define ASN1_TFLG_TAG_MASK (0x3 << 3)
413 #define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT
416 #define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
425 #define ASN1_TFLG_UNIVERSAL (0x0<<6)
427 #define ASN1_TFLG_APPLICATION (0x1<<6)
429 #define ASN1_TFLG_CONTEXT (0x2<<6)
431 #define ASN1_TFLG_PRIVATE (0x3<<6)
433 #define ASN1_TFLG_TAG_CLASS (0x3<<6)
441 #define ASN1_TFLG_ADB_MASK (0x3<<8)
443 #define ASN1_TFLG_ADB_OID (0x1<<8)
445 #define ASN1_TFLG_ADB_INT (0x1<<9)
455 #define ASN1_TFLG_COMBINE (0x1<<10)
505 #define ASN1_ITYPE_PRIMITIVE 0x0
507 #define ASN1_ITYPE_SEQUENCE 0x1
509 #define ASN1_ITYPE_CHOICE 0x2
511 #define ASN1_ITYPE_EXTERN 0x4
513 #define ASN1_ITYPE_MSTRING 0x5
544 int indent,
const char *fname,
589 #define ASN1_AFLG_REFCOUNT 1
591 #define ASN1_AFLG_ENCODING 2
595 #define ASN1_OP_NEW_PRE 0
596 #define ASN1_OP_NEW_POST 1
597 #define ASN1_OP_FREE_PRE 2
598 #define ASN1_OP_FREE_POST 3
599 #define ASN1_OP_D2I_PRE 4
600 #define ASN1_OP_D2I_POST 5
603 #define ASN1_OP_PRINT_PRE 8
604 #define ASN1_OP_PRINT_POST 9
605 #define ASN1_OP_STREAM_PRE 10
606 #define ASN1_OP_STREAM_POST 11
607 #define ASN1_OP_DETACHED_PRE 12
608 #define ASN1_OP_DETACHED_POST 13
611 #define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
612 #define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
613 ASN1_ITEM_start(itname) \
614 ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
615 ASN1_ITEM_end(itname)
618 #define IMPLEMENT_ASN1_MSTRING(itname, mask) \
619 ASN1_ITEM_start(itname) \
620 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
621 ASN1_ITEM_end(itname)
623 #define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
624 ASN1_ITEM_start(sname) \
636 #define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
638 #define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
640 #define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
641 IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
643 #define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
644 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
646 #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
647 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
649 #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
650 pre stname *fname##_new(void) \
652 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
654 pre void fname##_free(stname *a) \
656 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
659 #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
660 stname *fname##_new(void) \
662 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
664 void fname##_free(stname *a) \
666 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
669 #define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
670 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
671 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
673 #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
674 stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
676 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
678 int i2d_##fname(stname *a, unsigned char **out) \
680 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
686 #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
687 stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
689 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
691 int i2d_##fname(const stname *a, unsigned char **out) \
693 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
696 #define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
697 stname * stname##_dup(stname *x) \
699 return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
702 #define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
703 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
705 #define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
706 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
707 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
const ASN1_TEMPLATE * default_tt
ASN1_ex_free_func * asn1_ex_free
struct ASN1_AUX_st ASN1_AUX
ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in, long length)
ASN1_ex_d2i * asn1_ex_d2i
ASN1_ex_new_func * asn1_ex_new
struct asn1_pctx_st ASN1_PCTX
ASN1_ex_i2d * asn1_ex_i2d
static void * tag(intptr_t t)
ASN1_ex_free_func * asn1_ex_clear
int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it)
int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx)
ASN1_ex_print_func * asn1_ex_print
const ASN1_TEMPLATE * null_tt
const ASN1_TEMPLATE * templates
#define ASN1_SEQUENCE(tname)
const typedef ASN1_ITEM ASN1_ITEM_EXP
#define DEFINE_STACK_OF(type)
ASN1_VALUE * ASN1_new_func(void)
void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it)
const ASN1_ADB_TABLE * tbl
int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, void *exarg)
int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass)
ASN1_MUST_BE_NULL * unused
struct ASN1_EXTERN_FUNCS_st ASN1_EXTERN_FUNCS
struct ASN1_VALUE_st ASN1_VALUE
#define DECLARE_ASN1_ITEM(name)
int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, int indent, const char *fname, const ASN1_PCTX *pctx)
void ASN1_free_func(ASN1_VALUE *a)
struct asn1_must_be_null_st ASN1_MUST_BE_NULL
int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:34