]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/doc/asn1-defs.tex
Security-54.1.tar.gz
[apple/security.git] / SecuritySNACCRuntime / doc / asn1-defs.tex
1 % file: .../doc/asn1-defs.tex
2
3 % $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/doc/asn1-defs.tex,v 1.1.1.1 2001/05/18 23:14:10 mb Exp $
4 % $Log: asn1-defs.tex,v $
5 % Revision 1.1.1.1 2001/05/18 23:14:10 mb
6 % Move from private repository to open source repository
7 %
8 % Revision 1.1.1.1 1999/03/16 18:05:51 aram
9 % Originals from SMIME Free Library.
10 %
11 % Revision 1.1 1997/01/01 22:47:47 rj
12 % first check-in
13 %
14
15 \chapter{The Module Data Structure ASN.1 Definition}
16
17 The ASN.1 modules are parsed into an internal data structure. The
18 data structure was initially defined in ASN.1 with the idea that if
19 we needed to write a parsed module to disk, the ASN.1 encoding
20 routines could be used. No file format was needed so the ASN.1 was
21 merely an exercise.
22
23 This procedure highlighted the problem with circular links and index
24 like links in ASN.1 data structures. BER does not support this type
25 of linking; to handle it, the offending links can be made optional
26 and not encoded. After decoding, these links need to be
27 re-established. See the type table data structure for a format
28 suitable for writing to files.
29
30 The following is the ASN.1 definition of the Module data structure.
31 The C translation (as generated by an early version of Snacc) can be
32 found in {\ufn \dots/compiler/core/asn1module.h}\footnote{
33 The {\ufn asn1module.h} that is produced by a current version of Snacc cannot be compiled because its type definitions are in the wrong order.
34 This may be caused by the {\ASN --\,--snacc cTypeName} compiler directives, since one of the affected types is BasicTypeChoiceId, but i'm not really sure.
35 ---rj
36 }.
37 \begin{small}
38 \begin{verbatim}
39 -- .../asn1specs/asn1module.asn1
40 --
41 -- This module describes the data structure used to represent the
42 -- compiled ASN.1.
43 -- Using ASN.1 for the internal data structure allows writing
44 -- (encoding) to disk for storage (not done yet due to recursive
45 -- refs back to the module)
46 --
47 -- Mike Sample 91/08/29
48 -- Modifed 92/05 MS
49 --
50
51 Asn1Module DEFINITIONS IMPLICIT TAGS ::=
52 BEGIN
53
54 -- exports everything
55 -- imports nothing
56
57 Modules ::= [APPLICATION 0] IMPLICIT SEQUENCE
58 {
59 creationTime INTEGER,
60 modules ModuleList
61 }
62
63 ModuleList ::= SEQUENCE OF Module
64
65
66 Module ::= SEQUENCE
67 {
68 status ENUMERATED { mod-ok(0), mod-not-linked(1), mod-error(2) },
69 modId ModuleId,
70 tagDefault ENUMERATED { explicit-tags(0), implicit-tags(1) },
71 exportStatus ENUMERATED { exports-all(0), exports-nothing(1),
72 exports-some(2) },
73 imports ImportModuleList,
74 typeDefs TypeDefList,
75 valueDefs ValueDefList,
76 hasAnys BOOLEAN,
77
78 asn1SrcFileName MyString,
79 cHdrFileName MyString,
80 cSrcFileName MyString,
81 cxxHdrFileName MyString,
82 cxxSrcFileName MyString
83
84 cxxname MyString, -- META
85
86 idlFileName MyString, -- IDL
87 idlname MyString -- IDL
88 }
89
90
91 ModuleId ::= SEQUENCE
92 {
93 name MyString,
94 oid OBJECT IDENTIFIER OPTIONAL --snacc cTypeName:"OID" isPtr:"TRUE"
95 }
96
97
98 ImportModuleList ::= SEQUENCE OF ImportModule
99
100
101 ImportModule ::= SEQUENCE
102 {
103 modId ModuleId,
104 importElmts ImportElmtList,
105 moduleRef Module, --snacc isEncDec:"FALSE"
106 lineNo INTEGER
107 }
108
109
110 ImportElmtList ::= SEQUENCE OF ImportElmt
111
112
113 ImportElmt ::= SEQUENCE
114 {
115 resolvedRef CHOICE
116 {
117 type [0] TypeDef, -- not encoded
118 value [1] ValueDef -- not encoded
119 } OPTIONAL,
120 name MyString,
121 privateScope BOOLEAN, -- true if from MODNAME.TYPE ref
122 lineNo INTEGER
123 }
124
125 TypeDefList ::= SEQUENCE OF TypeDef
126
127 OidOrInt ::= CHOICE
128 {
129 oid OBJECT IDENTIFIER,
130 intId INTEGER
131 }
132
133 AnyRef ::= SEQUENCE
134 {
135 anyIdName MyString,
136 id OidOrInt
137 }
138
139 AnyRefList ::= SEQUENCE OF AnyRef
140
141 TypeDef ::= SEQUENCE
142 {
143 exported BOOLEAN,
144 recursive BOOLEAN,
145 isPdu BOOLEAN,
146 localRefCount INTEGER,
147 importRefCount INTEGER,
148 tmpRefCount INTEGER,
149 visited BOOLEAN,
150 definedName MyString,
151 type Type,
152 cTypeDefInfo CTDI,
153 cxxTypeDefInfo CxxTDI,
154 attrList AttributeList,
155 refList TypeDefList,
156 anyRefs AnyRefList
157 }
158
159
160 Tag ::= SEQUENCE
161 {
162 tclass INTEGER, -- swap this for the BER_CLASS enum from basetypes.h
163 form INTEGER, -- swap this for the BER_FORM enum
164 code INTEGER,
165 explicit BOOLEAN,
166 valueRef Value
167 }
168
169 Type ::= SEQUENCE
170 {
171 optional BOOLEAN,
172 implicit BOOLEAN,
173 tags TagList,
174 defaultVal [0] IMPLICIT NamedValue OPTIONAL,
175 subtypes [1] Subtype OPTIONAL,
176 basicType [2] BasicType,
177 lineNo INTEGER,
178 cTypeRefInfo CTRI,
179 cxxTypeRefInfo CxxTRI,
180 attrList AttributeList
181 }
182
183 TagList ::= SEQUENCE OF Tag
184
185 AttributeList ::= SEQUENCE OF MyString
186
187 NamedNumberList ::= ValueDefList
188
189
190 -- BasicTypes with NULL need no more info that which type it is
191 -- (this is known from the choice id)
192
193 BasicType ::= CHOICE
194 {
195 unknown [0] IMPLICIT NULL,
196 boolean [1] IMPLICIT NULL,
197 integer [2] IMPLICIT NamedNumberList,
198 bitString [3] IMPLICIT NamedNumberList,
199 octetString [4] IMPLICIT NULL,
200 null [5] IMPLICIT NULL,
201 oid [6] IMPLICIT NULL,
202 real [7] IMPLICIT NULL,
203 enumerated [8] IMPLICIT NamedNumberList,
204 sequence [9] IMPLICIT NamedTypeList,
205 sequenceOf [10] IMPLICIT Type,
206 set [11] IMPLICIT NamedTypeList,
207 setOf [12] IMPLICIT Type,
208 choice [13] IMPLICIT NamedTypeList,
209 selection [14] IMPLICIT SelectionType,
210 componentsOf [15] IMPLICIT Type, -- [Resolved](local/import) type ref
211 any [16] IMPLICIT NULL,
212 anyDefinedBy [17] IMPLICIT AnyDefinedByType,
213 localTypeRef [19] IMPLICIT TypeRef,
214 importTypeRef [20] IMPLICIT TypeRef,
215 macroType [21] MacroType,
216 macroDef [22] IMPLICIT MacroDef --snacc isPtr:"FALSE"
217 }
218
219 MacroDef ::= MyString -- just keep the text for now
220
221 MacroType ::= CHOICE
222 {
223 rosOperation [0] IMPLICIT RosOperationMacroType,
224 rosError [1] IMPLICIT RosErrorMacroType,
225 rosBind [2] IMPLICIT RosBindMacroType,
226 rosUnbind [3] IMPLICIT RosBindMacroType,
227 rosAse [4] IMPLICIT RosAseMacroType,
228 rosAc [5] IMPLICIT RosAcMacroType,
229 mtsasExtension [6] IMPLICIT MtsasExtensionMacroType,
230 mtsasExtensions [7] IMPLICIT MtsasExtensionsMacroType,
231 mtsasExtensionAttribute [8] IMPLICIT MtsasExtensionAttributeMacroType,
232 mtsasToken [9] IMPLICIT MtsasTokenMacroType,
233 mtsasTokenData [10] IMPLICIT MtsasTokenDataMacroType,
234 mtsasSecurityCategory [11] IMPLICIT MtsasSecurityCategoryMacroType,
235 asnObject [12] IMPLICIT AsnObjectMacroType,
236 asnPort [13] IMPLICIT AsnPortMacroType,
237 asnRefine [14] IMPLICIT AsnRefineMacroType,
238 asnAbstractBind [15] IMPLICIT AsnAbstractBindMacroType,
239 asnAbstractUnbind [16] IMPLICIT AsnAbstractBindMacroType,
240 asnAbstractOperation [17] IMPLICIT RosOperationMacroType,
241 asnAbstractError [18] IMPLICIT RosErrorMacroType,
242 afAlgorithm [19] IMPLICIT Type,
243 afEncrypted [20] IMPLICIT Type,
244 afProtected [21] IMPLICIT Type,
245 afSignature [22] IMPLICIT Type,
246 afSigned [23] IMPLICIT Type,
247 snmpObjectType [24] IMPLICIT SnmpObjectTypeMacroType
248 }
249
250
251 AnyDefinedByType ::= SEQUENCE
252 {
253 fieldName MyString, -- name of field that its defined by
254 link NamedType OPTIONAL -- REFERENCE not encoded
255 }
256
257
258 SelectionType ::= SEQUENCE
259 {
260 fieldName MyString, -- name of field in choice
261 typeRef Type, -- [Resolved](local/import) type ref
262 link NamedType OPTIONAL -- REFERENCE not encoded
263 }
264
265 NamedTypeList ::= SEQUENCE OF NamedType
266
267 NamedType ::= SEQUENCE
268 {
269 fieldName MyString, -- may be empty or NULL str
270 type Type
271 }
272
273
274 TypeRef ::= SEQUENCE
275 {
276 typeName MyString,
277 moduleName MyString, -- used for "modname.type" refs (may be null)
278 module Module, --snacc isEncDec:"FALSE"
279 link TypeDef --snacc isEncDec:"FALSE"
280 }
281
282
283
284 RosOperationMacroType ::= SEQUENCE
285 {
286 arguments NamedType,
287 result NamedType,
288 errors [0] IMPLICIT TypeOrValueList OPTIONAL,
289 linkedOps [1] IMPLICIT TypeOrValueList OPTIONAL
290 }
291
292 ValueList ::= SEQUENCE OF Value
293
294 TypeOrValueList ::= SEQUENCE OF TypeOrValue
295
296 TypeOrValue ::= CHOICE
297 {
298 type [0] IMPLICIT Type,
299 value [1] IMPLICIT Value
300 }
301
302 OidList ::= SEQUENCE OF OBJECT IDENTIFIER
303
304
305 RosErrorMacroType ::= SEQUENCE
306 {
307 parameter NamedType
308 }
309
310 RosBindMacroType ::= SEQUENCE
311 {
312 argument NamedType,
313 result NamedType,
314 error NamedType
315 }
316
317
318 RosAseMacroType ::= SEQUENCE
319 {
320 operations ValueList,
321 consumerInvokes ValueList,
322 supplierInvokes ValueList
323 }
324
325 RosAcMacroType ::= SEQUENCE
326 {
327 nonRoElements ValueList,
328 bindMacroType Type,
329 unbindMacroType Type,
330 remoteOperations Value,
331 operationsOf ValueList,
332 initiatorConsumerOf ValueList,
333 responderConsumerOf ValueList,
334 abstractSyntaxes OidList
335 }
336
337
338 MtsasExtensionMacroType ::= SEQUENCE
339 {
340 elmtType [0] IMPLICIT NamedType OPTIONAL,
341 defaultValue [1] IMPLICIT Value OPTIONAL,
342 criticalForSubmission [2] IMPLICIT BOOLEAN OPTIONAL,
343 criticalForTransfer [3] IMPLICIT BOOLEAN OPTIONAL,
344 criticalForDelivery [4] IMPLICIT BOOLEAN OPTIONAL
345 }
346
347
348 MtsasExtensionsMacroType ::= SEQUENCE
349 {
350 extensions ValueList
351 }
352
353 MtsasExtensionAttributeMacroType ::= SEQUENCE
354 {
355 type Type OPTIONAL
356 }
357
358 MtsasTokenMacroType ::= SEQUENCE
359 {
360 type Type OPTIONAL
361 }
362
363 MtsasTokenDataMacroType ::= SEQUENCE
364 {
365 type Type OPTIONAL
366 }
367
368 MtsasSecurityCategoryMacroType ::= SEQUENCE
369 {
370 type Type OPTIONAL
371 }
372
373 AsnObjectMacroType ::= SEQUENCE
374 {
375 ports AsnPortList OPTIONAL
376 }
377
378 AsnPortList ::= SEQUENCE OF AsnPort
379
380 AsnPort ::= SEQUENCE
381 {
382 portValue Value,
383 portType ENUMERATED
384 {
385 consumer-port (0),
386 supplier-port (1),
387 symmetric-port (2)
388 }
389 }
390
391
392 AsnPortMacroType ::= SEQUENCE
393 {
394 abstractOps [0] IMPLICIT TypeOrValueList OPTIONAL,
395 consumerInvokes [1] IMPLICIT TypeOrValueList OPTIONAL,
396 supplierInvokes [2] IMPLICIT TypeOrValueList OPTIONAL
397 }
398
399
400 AsnRefineMacroType ::= INTEGER
401
402 AsnAbstractBindMacroType ::= SEQUENCE
403 {
404 ports [0] IMPLICIT AsnPortList OPTIONAL,
405 type [1] IMPLICIT Type OPTIONAL
406 }
407
408
409 SnmpObjectTypeMacroType ::= SEQUENCE
410 {
411 syntax Type,
412 access ENUMERATED
413 { snmp-read-only (0), snmp-read-write (1),
414 snmp-write-only (2), snmp-not-accessible (3)},
415 status ENUMERATED
416 { snmp-mandatory (0), snmp-optional (1),
417 snmp-obsolete (2), snmp-deprecated (3)},
418 description [0] IMPLICIT Value OPTIONAL,
419 reference [1] IMPLICIT Value OPTIONAL,
420 index [2] IMPLICIT TypeOrValueList OPTIONAL,
421 defVal [3] IMPLICIT Value OPTIONAL
422 }
423
424
425 Subtype ::= CHOICE
426 {
427 single [0] SubtypeValue,
428 and [1] IMPLICIT SubtypeList,
429 or [2] IMPLICIT SubtypeList,
430 not [3] Subtype
431 }
432
433 SubtypeList ::= SEQUENCE OF Subtype
434
435 SubtypeValue ::= CHOICE
436 {
437 singleValue [0] IMPLICIT Value,
438 contained [1] IMPLICIT Type,
439 valueRange [2] IMPLICIT ValueRangeSubtype,
440 permittedAlphabet [3] Subtype, -- only valuerange or singleval
441 sizeConstraint [4] Subtype, -- only single value ints or val range
442 innerSubtype [5] IMPLICIT InnerSubtype
443 }
444
445
446 ValueRangeSubtype ::= SEQUENCE
447 {
448 lowerEndInclusive BOOLEAN,
449 upperEndInclusive BOOLEAN,
450 lowerEndValue Value,
451 upperEndValue Value
452 }
453
454
455 InnerSubtype ::= SEQUENCE
456 {
457 constraintType ENUMERATED { full-ct (0), partial-ct (1), single-ct (2) },
458 constraints ConstraintList
459 }
460
461 ConstraintList ::= SEQUENCE OF Constraint
462
463 Constraint ::= SEQUENCE
464 {
465 fieldRef MyString, -- not used if in single-ct, may be null
466 presenceConstraint ENUMERATED
467 {
468 present-ct (0),
469 absent-ct (1),
470 empty-ct (2),
471 optional-ct (3)
472 },
473 valueConstraints Subtype
474 }
475
476
477 ValueDefList ::= SEQUENCE OF ValueDef
478
479
480 ValueDef ::= SEQUENCE
481 {
482 exported BOOLEAN,
483 definedName MyString,
484 value Value
485 }
486
487 Value ::= SEQUENCE
488 {
489 type Type OPTIONAL,
490 valueType INTEGER, -- holds one of choiceId's def'd for BasicType
491 basicValue BasicValue,
492 lineNo INTEGER
493 }
494
495 BasicValue ::= CHOICE
496 {
497 unknown [0] IMPLICIT NULL,
498 empty [1] IMPLICIT NULL,
499 integer [2] IMPLICIT INTEGER,
500 specialInteger [3] IMPLICIT SpecialIntegerValue,
501 longInteger [4] IMPLICIT INTEGER, -- put LONG before INTGEGER
502 boolean [5] IMPLICIT BOOLEAN,
503 real [6] IMPLICIT REAL,
504 specialReal [7] IMPLICIT SpecialRealValue,
505 asciiText [8] IMPLICIT OCTET STRING,
506 asciiHex [9] IMPLICIT OCTET STRING,
507 asciiBitString [10] IMPLICIT OCTET STRING,
508 oid [11] IMPLICIT OBJECT IDENTIFIER,
509 linkedOid [12] IMPLICIT OBJECT IDENTIFIER, --snacc cTypeName:"OID"
510 berValue [13] IMPLICIT OCTET STRING,
511 perValue [14] IMPLICIT OCTET STRING,
512 namedValue [15] IMPLICIT NamedValue,
513 null [16] IMPLICIT NULL,
514 localValueRef [17] IMPLICIT ValueRef,
515 importValueRef [18] IMPLICIT ValueRef,
516 valueNotation [19] IMPLICIT OCTET STRING
517 }
518
519
520
521 SpecialIntegerValue ::= ENUMERATED { min-int (0), max-int (1) }
522 SpecialRealValue ::= ENUMERATED { minus-infinity-real (0), plus-infinity-real (1) }
523
524
525 ValueRef ::= SEQUENCE
526 {
527 valueName MyString,
528 moduleName MyString, -- used for "modname.value" refs (may be null)
529 link ValueDef, --snacc isEncDec:"FALSE"
530 module Module --snacc isEncDec:"FALSE"
531 }
532
533 NamedValue ::= SEQUENCE
534 {
535 fieldName MyString, -- may be null
536 value Value
537 }
538
539 NamedValueList ::= SEQUENCE OF NamedValue
540
541 CTypeId ::= ENUMERATED { c-choice (0), c-list (1), c-any (2), c-anydefinedby (3),
542 c-lib (4), c-struct (5), c-typeref (6), c-no-type (7),
543 c-typedef (8) }
544
545 -- C Type Def Info - info used for routine naming
546 -- and referencing from other types
547 CTDI ::= SEQUENCE
548 {
549 asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId"
550 cTypeId CTypeId,
551 cTypeName MyString,
552 isPdu BOOLEAN,
553 isEncDec BOOLEAN, -- if false, no routines are gen
554 -- and not included in encodings
555 isPtrForTypeDef BOOLEAN,
556 isPtrForTypeRef BOOLEAN,
557 isPtrInChoice BOOLEAN,
558 isPtrForOpt BOOLEAN,
559
560 -- defines these names, used by references
561 optTestRoutineName MyString, -- routine/macro to check whether
562 -- opt type is present
563 defaultFieldName MyString, -- base for generating field names
564
565 printRoutineName MyString,
566 encodeRoutineName MyString,
567 decodeRoutineName MyString,
568 freeRoutineName MyString,
569
570 genPrintRoutine BOOLEAN,
571 genEncodeRoutine BOOLEAN,
572 genDecodeRoutine BOOLEAN,
573 genFreeRoutine BOOLEAN,
574 genTypeDef BOOLEAN
575 }
576
577
578 --
579 -- CTRI (C Type Ref Info) is used for generating C typedefinitions
580 -- from the ASN.1 types info
581 CTRI ::= SEQUENCE
582 {
583 cTypeId CTypeId,
584 cFieldName MyString,
585 cTypeName MyString,
586 isPtr BOOLEAN,
587 -- isEndCType BOOLEAN, -- false for struct/union def
588 cNamedElmts CNamedElmts OPTIONAL, -- for C_LIB bits/int/enums
589 choiceIdValue INTEGER, -- enum value of this c field
590 choiceIdSymbol MyString, -- this fields sym in choiceId enum
591 choiceIdEnumName MyString,
592 choiceIdEnumFieldName MyString,
593 optTestRoutineName MyString, -- these names are gained from refd type def
594 printRoutineName MyString, -- or are over-ridden snacc attribute comment
595 encodeRoutineName MyString,
596 decodeRoutineName MyString,
597 freeRoutineName MyString,
598 isEncDec BOOLEAN -- whether part of enc value
599 }
600
601 CNamedElmts ::= SEQUENCE OF CNamedElmt
602
603 CNamedElmt ::= SEQUENCE
604 {
605 name MyString,
606 value INTEGER
607 }
608
609
610 CxxTDI ::= SEQUENCE
611 {
612 asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId"
613 className MyString,
614 isPdu BOOLEAN,
615 isEnc BOOLEAN,
616 isPtrForTypeDef BOOLEAN,
617 isPtrForOpt BOOLEAN,
618 isPtrInChoice BOOLEAN,
619 isPtrInSetAndSeq BOOLEAN,
620 isPtrInList BOOLEAN,
621 optTestRoutineName MyString,
622 defaultFieldName MyString -- base for generating field names
623 }
624
625
626
627 CxxTRI ::= SEQUENCE
628 {
629 isEnc BOOLEAN,
630 className MyString,
631 fieldName MyString,
632 isPtr BOOLEAN,
633 namedElmts CNamedElmts,
634 choiceIdSymbol MyString,
635 choiceIdValue INTEGER,
636 optTestRoutineName MyString
637 }
638
639 IDLTDI ::= SEQUENCE
640 {
641 asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId"
642 typeName MyString,
643 isPdu BOOLEAN,
644 isEnc BOOLEAN,
645 isPtrForTypeDef BOOLEAN,
646 isPtrForOpt BOOLEAN,
647 isPtrInChoice BOOLEAN,
648 isPtrInSetAndSeq BOOLEAN,
649 isPtrInList BOOLEAN,
650 optTestRoutineName MyString,
651 defaultFieldName MyString -- base for generating field names
652 }
653
654 IDLTRI ::= SEQUENCE
655 {
656 isEnc BOOLEAN,
657 typeName MyString,
658 fieldName MyString,
659 isPtr BOOLEAN,
660 namedElmts CNamedElmts,
661 choiceIdSymbol MyString,
662 choiceIdValue INTEGER,
663 optTestRoutineName MyString
664 }
665
666 -- use snacc compiler directives to overide the builtin types.
667 --
668 -- All strings used in module data struct are null terminated so
669 -- can just use a char *
670 -- Note the snacc comments before the PrintableString
671 -- bind with the MyString TypeDef and the ones after PrintableString
672 -- bind with the PrintableString Type ref.
673
674
675 MyString ::= --snacc isPtrForTypeDef:"FALSE"
676 --snacc isPtrForTypeRef:"FALSE"
677 --snacc isPtrInChoice:"FALSE"
678 --snacc isPtrForOpt:"FALSE"
679 --snacc optTestRoutineName:"MYSTRING_NON_NULL"
680 --snacc genPrintRoutine:"FALSE"
681 --snacc genEncodeRoutine:"FALSE"
682 --snacc genDecodeRoutine:"FALSE"
683 --snacc genFreeRoutine:"FALSE"
684 --snacc printRoutineName:"printMyString"
685 --snacc encodeRoutineName:"EncMyString"
686 --snacc decodeRoutineName:"DecMyString"
687 --snacc freeRoutineName:"FreeMyString"
688 PrintableString --snacc cTypeName:"char *"
689
690 END
691 \end{verbatim}
692 \end{small}
693
694
695 \chapter{The Type Table (TBL) Data Structure ASN.1 Definition}
696
697 The following is the type table data structure that Snacc uses for
698 type table values. Using ASN.1 gives a representation suitable for
699 saving tables to files or sending them over a network to reconfigure a
700 device (e.g. SNMP mib).
701
702 This file is actually compiled by Snacc to compile itself.
703 For bootstrapping purposes, an initial version is included in the distribution.
704
705 \begin{small}
706 \begin{verbatim}
707 -- .../asn1specs/tbl.asn1
708 --
709 -- TBL types describe ASN.1 data structures.
710 -- These can be used in generic, interpretive encoders/decoders.
711 -- Interpretive decoders are typically slower, but don't eat memory
712 -- with type-specific encoding and decoding code.
713 -- The tbl types can also be sent over the network
714 -- and allow dynamic re-configuration of encoders/decoders.
715 --
716 -- This definition is fairly small so it should be reasonable easy
717 -- to understand. To learn more about semantics of this data
718 -- struct, look in snacc/tbl-tools/print-tbl/pasn1.c.
719 --
720 -- Copyright Mike Sample and UBC, 1992, 1993
721 --
722
723 TBL DEFINITIONS ::=
724 BEGIN
725
726
727 -- imports nothing
728 -- exports nothing
729
730 TBL ::= --snacc isPdu:"TRUE" -- SEQUENCE
731 {
732 totalNumModules INTEGER, -- these totals can help allocation
733 totalNumTypeDefs INTEGER, -- when decoding (ie use arrays)
734 totalNumTypes INTEGER,
735 totalNumTags INTEGER,
736 totalNumStrings INTEGER,
737 totalLenStrings INTEGER,
738 modules SEQUENCE OF TBLModule
739 }
740
741 TBLModule ::= SEQUENCE
742 {
743 name [0] IMPLICIT PrintableString,
744 id [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
745 isUseful [2] IMPLICIT BOOLEAN, -- true if useful types module
746 typeDefs [3] IMPLICIT SEQUENCE OF TBLTypeDef
747 }
748
749 TBLTypeDef ::= SEQUENCE
750 {
751 typeDefId TBLTypeDefId,
752 typeName PrintableString OPTIONAL, -- I have forgotten why this is opt!
753 type TBLType
754 }
755
756 TBLType ::= SEQUENCE
757 {
758 typeId [0] IMPLICIT TBLTypeId,
759 optional [1] IMPLICIT BOOLEAN,
760 tagList [2] IMPLICIT SEQUENCE OF TBLTag OPTIONAL,
761 content [3] TBLTypeContent,
762 fieldName [4] IMPLICIT PrintableString OPTIONAL
763 }
764
765 TBLTypeContent ::= CHOICE
766 {
767 primType [0] IMPLICIT NULL,
768 elmts [1] IMPLICIT SEQUENCE OF TBLType,
769 typeRef [2] IMPLICIT TBLTypeRef
770 }
771
772 TBLTypeRef ::= SEQUENCE
773 {
774 typeDef TBLTypeDefId,
775 implicit BOOLEAN
776 }
777
778 TBLTypeId ::= ENUMERATED
779 {
780 tbl-boolean (0),
781 tbl-integer (1),
782 tbl-bitstring (2),
783 tbl-octetstring (3),
784 tbl-null (4),
785 tbl-oid (5),
786 tbl-real (6),
787 tbl-enumerated (7),
788 tbl-sequence (8),
789 tbl-set (9),
790 tbl-sequenceof (10),
791 tbl-setof (11),
792 tbl-choice (12),
793 tbl-typeref (13)
794 }
795
796 TBLTypeDefId ::= INTEGER
797
798 TBLTag ::= SEQUENCE
799 {
800 tclass TBLTagClass,
801 code INTEGER (0..MAX)
802 }
803
804 TBLTagClass ::= ENUMERATED { universal (0), application (1),
805 context (2), private (3)}
806
807 END
808
809 \end{verbatim}
810 \end{small}
811
812 \chapter{\label{edex-files}ASN.1 Files for the Editor Example}
813
814 The files can be found in {\ufn \dots/tcl-example/}.
815
816 \begin{ASNcode}
817 \label{edex0.asn1}%
818 --\,-- file: edex0.asn1\\
819 --\,--\\
820 --\,-- SnaccEd example, simple types module\\
821 \\
822 EdEx-Simple DEFINITIONS ::=\\
823 BEGIN\\
824 \\
825 RainbowColor ::= INTEGER\\
826 \{\\
827 \>red(0), orange(1), yellow(2), green(3), blue(4), indigo(5), violet(6)\\
828 \}\\
829 \\
830 DayOfTheWeek ::= ENUMERATED\\
831 \{\\
832 \>sunday(0), monday(1), tuesday(2), wednesday(3), thursday(4), friday(5), saturday(6)\\
833 \}\\
834 \\
835 Hand ::= BIT STRING\\
836 \{\\
837 \>thumb(0), forefinger(1), middle-finger(2), ring-finger(3), little-finger(4)\\
838 \}\\
839 \\
840 victory Hand ::= \{ forefinger, middle-finger \}\\
841 \\
842 END
843 \end{ASNcode}
844
845 \begin{ASNcode}
846 \label{edex1.asn1}%
847 --\,-- file: edex1.asn1\\
848 --\,--\\
849 --\,-- SnaccEd example, structured types module\\
850 \\
851 EdEx-Structured DEFINITIONS ::=\\
852 BEGIN\\
853 \\
854 IMPORTS RainbowColor, DayOfTheWeek, Hand FROM EdEx-Simple;\\
855 \\
856 RGBColor ::= SEQUENCE\\
857 \{\+\\
858 red INTEGER,\\
859 green INTEGER,\\
860 blue INTEGER\-\\
861 \}\\
862 \\
863 Coordinate ::= CHOICE\\
864 \{\+\\
865 cartesian [0] SEQUENCE \{ x REAL, y REAL \},\\
866 polar [1] SEQUENCE \{ angle REAL, distance REAL \}\-\\
867 \}\\
868 \\
869 File ::= SET\\
870 \{\+\\
871 name [0] PrintableString,\\
872 contents [1] OCTET STRING,\\
873 checksum [2] INTEGER OPTIONAL,\\
874 read-only [3] BOOLEAN DEFAULT FALSE\-\\
875 \}\\
876 \\
877 Directory ::= SET\\
878 \{\+\\
879 name PrintableString,\\
880 files SET OF File\-\\
881 \}\\
882 \\
883 Simple ::= SET\\
884 \{\+\\
885 null [0] NULL,\\
886 bool [1] BOOLEAN,\\
887 day [2] DayOfTheWeek,\\
888 int [3] INTEGER,\\
889 color [4] RainbowColor,\\
890 real [5] REAL,\\
891 bits [6] Hand,\\
892 str [7] OCTET STRING,\\
893 optstr [8] OCTET STRING OPTIONAL\-\\
894 \}\\
895 \\
896 Structured ::= SET\\
897 \{\+\\
898 coord [0] Coordinate,\\
899 color [1] CHOICE \{ rainbow RainbowColor, rgb RGBColor \}\-\\
900 \}\\
901 \\
902 Various ::= SET\\
903 \{\+\\
904 simple [0] Simple,\\
905 struct [1] Structured,\\
906 recursion [2] Various OPTIONAL\-\\
907 \}\\
908 \\
909 END
910 \end{ASNcode}