1 #ifndef	ASN1_PARSER_EXPR2UCLASS_H
2 #define	ASN1_PARSER_EXPR2UCLASS_H
3 
4 #ifndef	__GNUC__
5 #define	__attribute__(x)	/* unused */
6 #endif
7 
8 static int expr_type2uclass_value[ASN_EXPR_TYPE_MAX]
9 		__attribute__ ((unused)) = {
10 	[ ASN_BASIC_BOOLEAN ]		= 1,
11 	[ ASN_BASIC_INTEGER ]		= 2,
12 	[ ASN_BASIC_BIT_STRING ]	= 3,
13 	[ ASN_BASIC_OCTET_STRING ]	= 4,
14 	[ ASN_BASIC_NULL ]		= 5,
15 	[ ASN_BASIC_OBJECT_IDENTIFIER ]	= 6,
16 	[ ASN_STRING_ObjectDescriptor ]	= 7,
17 	[ ASN_BASIC_EXTERNAL ]		= 8,
18 	[ ASN_BASIC_REAL ]		= 9,
19 	[ ASN_BASIC_ENUMERATED ]	= 10,
20 	[ ASN_BASIC_EMBEDDED_PDV ]	= 11,
21 	[ ASN_STRING_UTF8String ]	= 12,
22 	[ ASN_BASIC_RELATIVE_OID ]	= 13,
23 	[ ASN_CONSTR_SEQUENCE ]		= 16,
24 	[ ASN_CONSTR_SEQUENCE_OF ]	= 16,
25 	[ ASN_CONSTR_SET ]		= 17,
26 	[ ASN_CONSTR_SET_OF ]		= 17,
27 	[ ASN_STRING_NumericString ]	= 18,
28 	[ ASN_STRING_PrintableString ]	= 19,
29 	[ ASN_STRING_TeletexString ]	= 20,
30 	[ ASN_STRING_T61String ]	= 20,
31 	[ ASN_STRING_VideotexString ]	= 21,
32 	[ ASN_STRING_IA5String ]	= 22,
33 	[ ASN_BASIC_UTCTime ]		= 23,
34 	[ ASN_BASIC_GeneralizedTime ]	= 24,
35 	[ ASN_STRING_GraphicString ]	= 25,
36 	[ ASN_STRING_VisibleString ]	= 26,
37 	[ ASN_STRING_ISO646String ]	= 26,
38 	[ ASN_STRING_GeneralString ]	= 27,
39 	[ ASN_STRING_UniversalString ]	= 28,
40 	[ ASN_BASIC_CHARACTER_STRING ]	= 29,
41 	[ ASN_STRING_BMPString ]	= 30,
42 };
43 
44 static enum asn1p_expr_type expr_utag2type[32] __attribute__ ((unused)) = {
45 	[ 0 ]	= 0,			/* If zero length, end-of-content */
46 	[ 1 ]	= ASN_BASIC_BOOLEAN,
47 	[ 2 ]	= ASN_BASIC_INTEGER,
48 	[ 3 ]	= ASN_BASIC_BIT_STRING,
49 	[ 4 ]	= ASN_BASIC_OCTET_STRING,
50 	[ 5 ]	= ASN_BASIC_NULL,
51 	[ 6 ]	= ASN_BASIC_OBJECT_IDENTIFIER,
52 	[ 7 ]	= ASN_STRING_ObjectDescriptor,
53 	[ 8 ]	= ASN_BASIC_EXTERNAL,
54 	[ 9 ]	= ASN_BASIC_REAL,
55 	[ 10 ]	= ASN_BASIC_ENUMERATED,
56 	[ 11 ]	= ASN_BASIC_EMBEDDED_PDV,
57 	[ 12 ]	= ASN_STRING_UTF8String,
58 	[ 13 ]	= ASN_BASIC_RELATIVE_OID,
59 	[ 14 ]	= 0,
60 	[ 15 ]	= 0,
61 	[ 16 ]	= ASN_CONSTR_SEQUENCE,		/* Or SEQUENCE OF */
62 	[ 17 ]	= ASN_CONSTR_SET,		/* Or SET OF */
63 	[ 18 ]	= ASN_STRING_NumericString,	/* " "|"0".."9" */
64 	[ 19 ]	= ASN_STRING_PrintableString,
65 	[ 20 ]	= ASN_STRING_TeletexString,
66 	[ 21 ]	= ASN_STRING_VideotexString,
67 	[ 22 ]	= ASN_STRING_IA5String,
68 	[ 23 ]	= ASN_BASIC_UTCTime,
69 	[ 24 ]	= ASN_BASIC_GeneralizedTime,
70 	[ 25 ]	= ASN_STRING_GraphicString,
71 	[ 26 ]	= ASN_STRING_VisibleString,
72 	[ 27 ]	= ASN_STRING_GeneralString,
73 	[ 28 ]	= ASN_STRING_UniversalString,	/* 32-bit UCS-4 */
74 	[ 29 ]	= ASN_BASIC_CHARACTER_STRING,
75 	[ 30 ]	= ASN_STRING_BMPString,		/* 16-bit UCS-2 */
76 };
77 
78 /*
79  * Convert the [UNIVERSAL value] into the internal type or a string.
80  */
81 #define	ASN_UNIVERSAL_TAG2TYPE(utag)					\
82 	(								\
83 	(((int)(utag)) < 0						\
84 	|| ((int)(utag)) >= (int)(sizeof(expr_utag2type)		\
85 		/ sizeof(expr_utag2type[0])))				\
86 		? 0							\
87 		: expr_utag2type[(int)(utag)]				\
88 	)
89 #define	ASN_UNIVERSAL_TAG2STR(utag)					\
90 	ASN_EXPR_TYPE2STR(ASN_UNIVERSAL_TAG2TYPE(utag))
91 
92 #endif	/* ASN1_PARSER_EXPR2UCLASS_H */
93