1 #include "asn1fix_internal.h"
2 #include "asn1fix_crange.h"
5 * Check that a specific constraint is compatible
6 * with the given expression type.
9 asn1constraint_compatible(asn1p_expr_type_e expr_type,
10 enum asn1p_constraint_type_e constr_type, int fbless_SIZE) {
13 * X.680-0207, Table 9.
28 case ASN_BASIC_ENUMERATED:
29 case ASN_BASIC_BOOLEAN:
31 * The ValueRange constraint is not formally
32 * applicable to the above types. However, we
33 * support it just fine.
36 case ASN_BASIC_INTEGER:
40 if(expr_type & ASN_STRING_MASK)
47 if(expr_type & ASN_STRING_MASK)
52 case ASN_BASIC_INTEGER:
53 case ASN_BASIC_ENUMERATED:
57 case ASN_BASIC_BIT_STRING:
58 case ASN_BASIC_OCTET_STRING:
59 case ASN_BASIC_CHARACTER_STRING:
60 case ASN_CONSTR_SEQUENCE_OF:
61 case ASN_CONSTR_SET_OF:
64 if(expr_type & ASN_STRING_MASK)
72 case ASN_BASIC_EXTERNAL:
73 case ASN_BASIC_EMBEDDED_PDV:
75 case ASN_BASIC_CHARACTER_STRING:
76 case ASN_CONSTR_CHOICE:
77 case ASN_CONSTR_SEQUENCE:
78 case ASN_CONSTR_SEQUENCE_OF:
80 case ASN_CONSTR_SET_OF:
87 case ACT_CT_CTNG: /* X.682, #11 */
89 case ASN_BASIC_OCTET_STRING:
90 case ASN_BASIC_BIT_STRING:
96 if(expr_type & ASN_STRING_MASK)
113 #define DECL_RANGE(foo, lb, ub, ov, pv) \
114 static asn1cnst_range_t range_##foo = { \
115 {ARE_VALUE, 0, lb}, {ARE_VALUE, 0, ub}, 0, 0, 0, 0, 0, 0, 0, ov, pv}
117 #define DECL(name, lb, ub) DECL_RANGE(name, lb, ub, 0, 0)
118 #define DECL_notOPV(name, lb, ub) DECL_RANGE(name, lb, ub, 1, 1)
121 asn1constraint_default_alphabet(asn1p_expr_type_e expr_type) {
122 DECL_notOPV(octstr, 0x00, 0xff); /* Not OER- and PER-visible */
123 DECL_notOPV(utf8, 0x00, 0x7fffffff); /* Not OER- and PER-visible */
124 DECL(bmp, 0x00, 65533); /* 64K-2 cells */
125 DECL(uint7, 0x00, 0x7f);
126 DECL(uint32, 0x00, 0xffffffff);
127 DECL(Space, 0x20, 0x20);
128 DECL(ApostropheAndParens, 0x27, 0x29);
129 DECL(PlusTillColon, 0x2b, 0x3a);
130 DECL(Equal, 0x3d, 0x3d);
131 DECL(QuestionMark, 0x3f, 0x3f);
132 DECL(Digits, 0x30, 0x39);
133 DECL(AlphaCap, 0x41, 0x5a);
134 DECL(AlphaLow, 0x61, 0x7a);
135 DECL(PlusCommaMinusDot, 0x2b, 0x2e);
136 DECL(Plus, 0x2b, 0x2b);
137 DECL(MinusDot, 0x2d, 0x2e);
139 static asn1cnst_range_t *range_NumericString_array[] = {
140 &range_Space, &range_Digits };
141 static asn1cnst_range_t *range_PrintableString_array[] = {
143 &range_ApostropheAndParens,
144 &range_PlusTillColon,
150 static asn1cnst_range_t *range_UTCTime_array[] = {
151 &range_Plus, &range_MinusDot, &range_Digits, &range_Z };
152 static asn1cnst_range_t *range_GeneralizedTime_array[] = {
153 &range_PlusCommaMinusDot, &range_Digits, &range_Z };
155 static asn1cnst_range_t range_notPERVisible = {
158 0, 0, 0, 0, 0, 0, 0, 0, 1 };
159 static asn1cnst_range_t range_NumericString = {
160 { ARE_VALUE, 0, 0x20 },
161 { ARE_VALUE, 0, 0x39 },
163 range_NumericString_array,
164 sizeof(range_NumericString_array)
165 /sizeof(range_NumericString_array[0]),
167 static asn1cnst_range_t range_PrintableString = {
168 { ARE_VALUE, 0, 0x20 },
169 { ARE_VALUE, 0, 0x7a },
171 range_PrintableString_array,
172 sizeof(range_PrintableString_array)
173 /sizeof(range_PrintableString_array[0]),
175 static asn1cnst_range_t range_VisibleString = {
176 { ARE_VALUE, 0, 0x20 },
177 { ARE_VALUE, 0, 0x7e },
178 NOT_NARROW, 0, 0, 0, 0, 0, 0, 0, 0 };
179 static asn1cnst_range_t range_UTCTime = {
180 { ARE_VALUE, 0, 0x2b },
181 { ARE_VALUE, 0, 0x5a },
184 sizeof(range_UTCTime_array)
185 /sizeof(range_UTCTime_array[0]),
187 static asn1cnst_range_t range_GeneralizedTime = {
188 { ARE_VALUE, 0, 0x2b },
189 { ARE_VALUE, 0, 0x5a },
191 range_GeneralizedTime_array,
192 sizeof(range_GeneralizedTime_array)
193 /sizeof(range_GeneralizedTime_array[0]),
197 case ASN_STRING_NumericString:
198 return &range_NumericString;
199 case ASN_STRING_PrintableString:
200 return &range_PrintableString;
201 case ASN_STRING_VisibleString:
202 return &range_VisibleString;
203 case ASN_STRING_IA5String:
205 case ASN_STRING_BMPString:
207 case ASN_STRING_UTF8String:
210 * Not a known-multipler character string type.
212 assert(range_utf8.not_OER_visible);
213 assert(range_utf8.not_PER_visible);
215 case ASN_STRING_UniversalString:
216 return &range_uint32;
217 case ASN_BASIC_UTCTime:
218 /* Permitted alphabet constraint is not applicable */
219 assert(range_UTCTime.not_PER_visible);
220 return &range_UTCTime;
221 case ASN_BASIC_GeneralizedTime:
222 /* Permitted alphabet constraint is not applicable */
223 assert(range_GeneralizedTime.not_PER_visible);
224 return &range_GeneralizedTime;
225 case ASN_BASIC_OCTET_STRING:
227 * Permitted alphabet constraint is not applicable
228 * to this type. However, we support it, albeit not
229 * in a strict PER mode.
231 assert(range_octstr.not_PER_visible);
232 return &range_octstr;
234 if(!(expr_type & ASN_STRING_MASK))
236 assert(expr_type & ASN_STRING_NKM_MASK);
239 * Not a known-multiplier character string.
241 return &range_notPERVisible;