1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
-- $Id$ --
TEST DEFINITIONS ::=
BEGIN
IMPORTS HEIM_ANY FROM heim;
-- Check that we handle out of order definitions.
-- The compiler should emit the definition of TESTOutOfOrderBar before that of
-- TESTOutOfOrderFoo.
TESTOutOfOrderFoo ::= SEQUENCE {
bar TESTOutOfOrderBar
}
TESTOutOfOrderBar ::= SEQUENCE {
aMember INTEGER
}
-- Check that we can handle rpc.mountd style "lists". This is unnecessarily
-- inefficient in its encoding, and there's no point to using this over
-- SEQUENCE OF (arrays), but it's neat that we can do this now that we can do
-- out of order definitions.
--
-- This could be useful if we ever extend asn1_compile to also handle XDR,
-- which we well might since XDR's syntax is a dual of a strict subset of
-- ASN.1, and since XDR the encoding is fairly straightforward.
--
-- Note that the `next' member has to be OPTIONAL for this to work.
TESTCircular ::= SEQUENCE {
name UTF8String,
next TESTCircular OPTIONAL
}
TESTDefault ::= SEQUENCE {
name UTF8String DEFAULT "Heimdal",
version [0] TESTuint32 DEFAULT 8,
maxint TESTuint64 DEFAULT 9223372036854775807,
works BOOLEAN DEFAULT TRUE
}
TESTuint32 ::= INTEGER (0..4294967295)
TESTuint64 ::= INTEGER(0..9223372036854775807)
TESTint64 ::= INTEGER(-9223372036854775808..9223372036854775807)
TESTLargeTag ::= SEQUENCE {
foo[127] INTEGER (-2147483648..2147483647),
bar[128] INTEGER (-2147483648..2147483647)
}
TESTSeq ::= SEQUENCE {
tag0[0] INTEGER (-2147483648..2147483647),
tag1[1] TESTLargeTag,
tagless INTEGER (-2147483648..2147483647),
tag3[2] INTEGER (-2147483648..2147483647)
}
TESTChoice1 ::= CHOICE {
i1[1] INTEGER (-2147483648..2147483647),
i2[2] INTEGER (-2147483648..2147483647),
...
}
TESTChoice2 ::= CHOICE {
i1[1] INTEGER (-2147483648..2147483647),
...
}
TESTInteger ::= INTEGER (-2147483648..2147483647)
TESTInteger2 ::= [4] IMPLICIT TESTInteger
TESTInteger3 ::= [5] IMPLICIT TESTInteger2
TESTImplicit ::= SEQUENCE {
ti1[0] IMPLICIT INTEGER (-2147483648..2147483647),
ti2[1] IMPLICIT SEQUENCE {
foo[127] INTEGER (-2147483648..2147483647)
},
ti3[2] IMPLICIT [5] IMPLICIT [4] IMPLICIT INTEGER (-2147483648..2147483647)
}
TESTImplicit2 ::= SEQUENCE {
ti1[0] IMPLICIT TESTInteger,
-- ti2[1] IMPLICIT TESTLargeTag, this is disabled since the IMPLICT encoder does't get the types right when stepping inside an structure --
ti3[2] IMPLICIT TESTInteger3,
ti4[51] IMPLICIT TESTInteger OPTIONAL
}
TESTImplicit3 ::= CHOICE {
ti1[0] IMPLICIT INTEGER (-2147483648..2147483647),
ti2[5] IMPLICIT CHOICE { i1[1] INTEGER (-2147483648..2147483647) }
}
TESTImplicit4 ::= CHOICE {
ti1[0] IMPLICIT INTEGER (-2147483648..2147483647),
ti2[5] IMPLICIT TESTChoice2
}
TESTAllocInner ::= SEQUENCE {
ai[0] TESTInteger
}
TESTAlloc ::= SEQUENCE {
tagless TESTAllocInner OPTIONAL,
three [1] INTEGER (-2147483648..2147483647),
tagless2 HEIM_ANY OPTIONAL
}
TESTOptional ::= SEQUENCE {
zero [0] INTEGER (-2147483648..2147483647) OPTIONAL,
one [1] INTEGER (-2147483648..2147483647) OPTIONAL
}
TESTCONTAINING ::= OCTET STRING ( CONTAINING INTEGER )
TESTENCODEDBY ::= OCTET STRING ( ENCODED BY
{ joint-iso-itu-t(2) asn(1) ber-derived(2) distinguished-encoding(1) }
)
testDer OBJECT IDENTIFIER ::= {
joint-iso-itu-t(2) asn(1) ber-derived(2) distinguished-encoding(1)
}
testContainingEncodedBy ::= OCTET STRING ( CONTAINING INTEGER ENCODED BY
{ joint-iso-itu-t(2) asn(1) ber-derived(2) distinguished-encoding(1) }
)
testContainingEncodedBy2 ::= OCTET STRING (
CONTAINING INTEGER ENCODED BY testDer
)
testValue1 INTEGER ::= 1
testUserConstrained ::= OCTET STRING (CONSTRAINED BY { -- meh -- })
-- TESTUSERCONSTRAINED2 ::= OCTET STRING (CONSTRAINED BY { TESTInteger })
-- TESTUSERCONSTRAINED3 ::= OCTET STRING (CONSTRAINED BY { INTEGER })
-- TESTUSERCONSTRAINED4 ::= OCTET STRING (CONSTRAINED BY { INTEGER : 1 })
TESTSeqOf ::= SEQUENCE OF TESTInteger
TESTSeqSizeOf1 ::= SEQUENCE SIZE (2) OF TESTInteger
TESTSeqSizeOf2 ::= SEQUENCE SIZE (1..2) OF TESTInteger
TESTSeqSizeOf3 ::= SEQUENCE SIZE (1..MAX) OF TESTInteger
TESTSeqSizeOf4 ::= SEQUENCE SIZE (0..2) OF TESTInteger
TESTOSSize1 ::= OCTET STRING SIZE (1..2)
TESTSeqOfSeq ::= SEQUENCE OF SEQUENCE {
zero [0] TESTInteger
}
TESTSeqOfSeq2 ::= SEQUENCE OF SEQUENCE {
string [0] GeneralString
}
TESTSeqOfSeq3 ::= SEQUENCE OF SEQUENCE {
zero [0] TESTInteger,
string [0] GeneralString
}
TESTSeqOf2 ::= SEQUENCE {
strings SEQUENCE OF GeneralString
}
TESTSeqOf3 ::= SEQUENCE {
strings SEQUENCE OF GeneralString OPTIONAL
}
-- Larger/more complex to increase odds of out-of-bounds
-- read/writes if miscoded
TESTSeqOf4 ::= SEQUENCE {
b1 [0] SEQUENCE OF SEQUENCE {
s1 OCTET STRING,
s2 OCTET STRING,
u1 TESTuint64,
u2 TESTuint64
} OPTIONAL,
b2 [1] IMPLICIT SEQUENCE OF SEQUENCE {
u1 TESTuint64,
u2 TESTuint64,
u3 TESTuint64,
s1 OCTET STRING,
s2 OCTET STRING,
s3 OCTET STRING
} OPTIONAL,
b3 [2] IMPLICIT SEQUENCE OF SEQUENCE {
s1 OCTET STRING,
u1 TESTuint64,
s2 OCTET STRING,
u2 TESTuint64,
s3 OCTET STRING,
u3 TESTuint64,
s4 OCTET STRING,
u4 TESTuint64
} OPTIONAL
}
TESTSeqOf5 ::= SEQUENCE {
outer SEQUENCE {
inner SEQUENCE {
u0 TESTuint64,
s0 OCTET STRING,
u1 TESTuint64,
s1 OCTET STRING,
u2 TESTuint64,
s2 OCTET STRING,
u3 TESTuint64,
s3 OCTET STRING,
u4 TESTuint64,
s4 OCTET STRING,
u5 TESTuint64,
s5 OCTET STRING,
u6 TESTuint64,
s6 OCTET STRING,
u7 TESTuint64,
s7 OCTET STRING
}
}
OPTIONAL
}
TESTPreserve ::= SEQUENCE {
zero [0] TESTInteger,
one [1] TESTInteger
}
TESTBitString ::= BIT STRING {
zero(0),
eight(8),
thirtyone(31)
}
TESTBitString64 ::= BIT STRING {
zero(0),
eight(8),
thirtyone(31),
thirtytwo(32),
sixtythree(63)
}
TESTLargeBitString ::= BIT STRING {
zero(0),
eight(8),
thirtyone(31),
onehundredtwenty(120)
}
TESTMechType::= OBJECT IDENTIFIER
TESTMechTypeList ::= SEQUENCE OF TESTMechType
-- IOS stuff
_EXTENSION ::= CLASS {
&id OBJECT IDENTIFIER UNIQUE,
&ExtnType,
&Critical BOOLEAN DEFAULT FALSE
}
TESTExtension{_EXTENSION:ExtensionSet} ::= SEQUENCE {
extnID _EXTENSION.&id({ExtensionSet}),
critical BOOLEAN
-- (EXTENSION.&Critical({ExtensionSet}{@extnID}))
DEFAULT FALSE,
extnValue OCTET STRING (CONTAINING
_EXTENSION.&ExtnType({ExtensionSet}{@extnID}))
}
id-test-default OBJECT IDENTIFIER ::= { 1 2 3 4 }
testext-TESTDefault _EXTENSION ::= {
&id id-test-default,
&Critical FALSE,
&ExtnType TESTDefault
}
-- And Here's an object set for the EXTENSION CLASS collecting a bunch of
-- related extensions (here they are the extensions that certificates can
-- carry in their extensions member):
TestExtensions _EXTENSION ::= { testext-TESTDefault }
TESTExtension ::= TESTExtension { TestExtensions }
TESTExtensible ::= SEQUENCE {
version INTEGER,
extensions SEQUENCE OF TESTExtension
}
TESTDecorated ::= SEQUENCE {
version TESTuint32
-- gets decorated with varius fields (see test.opt)
}
TESTNotDecorated ::= SEQUENCE {
version TESTuint32
-- should have the same encoding as TESTDecorated
}
TESTDecoratedChoice ::= CHOICE {
version TESTuint32
-- gets decorated with varius fields (see test.opt)
}
TESTNotDecoratedChoice ::= CHOICE {
version TESTuint32
-- should have the same encoding as TESTDecoratedChoice
}
END
|