1 % file: .../doc/asn1-defs.tex
3 % $Header: /cvs/Darwin/src/live/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
8 % Revision 1.1.1.1 1999/03/16 18:05:51 aram
9 % Originals from SMIME Free Library.
11 % Revision 1.1 1997/01/01 22:47:47 rj
15 \chapter{The Module Data Structure ASN
.1 Definition
}
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
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.
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.
39 -- .../asn1specs/asn1module.asn1
41 -- This module describes the data structure used to represent the
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)
47 -- Mike Sample
91/
08/
29
51 Asn1Module DEFINITIONS IMPLICIT TAGS ::=
57 Modules ::=
[APPLICATION
0] IMPLICIT SEQUENCE
63 ModuleList ::= SEQUENCE OF Module
68 status ENUMERATED
{ mod-ok(
0), mod-not-linked(
1), mod-error(
2)
},
70 tagDefault ENUMERATED
{ explicit-tags(
0), implicit-tags(
1)
},
71 exportStatus ENUMERATED
{ exports-all(
0), exports-nothing(
1),
73 imports ImportModuleList,
75 valueDefs ValueDefList,
78 asn1SrcFileName MyString,
79 cHdrFileName MyString,
80 cSrcFileName MyString,
81 cxxHdrFileName MyString,
82 cxxSrcFileName MyString
84 cxxname MyString, -- META
86 idlFileName MyString, -- IDL
87 idlname MyString -- IDL
94 oid OBJECT IDENTIFIER OPTIONAL --snacc cTypeName:"OID" isPtr:"TRUE"
98 ImportModuleList ::= SEQUENCE OF ImportModule
101 ImportModule ::= SEQUENCE
104 importElmts ImportElmtList,
105 moduleRef Module, --snacc isEncDec:"FALSE"
110 ImportElmtList ::= SEQUENCE OF ImportElmt
113 ImportElmt ::= SEQUENCE
117 type
[0] TypeDef, -- not encoded
118 value
[1] ValueDef -- not encoded
121 privateScope BOOLEAN, -- true if from MODNAME.TYPE ref
125 TypeDefList ::= SEQUENCE OF TypeDef
129 oid OBJECT IDENTIFIER,
139 AnyRefList ::= SEQUENCE OF AnyRef
146 localRefCount INTEGER,
147 importRefCount INTEGER,
150 definedName MyString,
153 cxxTypeDefInfo CxxTDI,
154 attrList AttributeList,
162 tclass INTEGER, -- swap this for the BER_CLASS enum from basetypes.h
163 form INTEGER, -- swap this for the BER_FORM enum
174 defaultVal
[0] IMPLICIT NamedValue OPTIONAL,
175 subtypes
[1] Subtype OPTIONAL,
176 basicType
[2] BasicType,
179 cxxTypeRefInfo CxxTRI,
180 attrList AttributeList
183 TagList ::= SEQUENCE OF Tag
185 AttributeList ::= SEQUENCE OF MyString
187 NamedNumberList ::= ValueDefList
190 -- BasicTypes with NULL need no more info that which type it is
191 -- (this is known from the choice id)
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"
219 MacroDef ::= MyString -- just keep the text for now
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
251 AnyDefinedByType ::= SEQUENCE
253 fieldName MyString, -- name of field that its defined by
254 link NamedType OPTIONAL -- REFERENCE not encoded
258 SelectionType ::= SEQUENCE
260 fieldName MyString, -- name of field in choice
261 typeRef Type, --
[Resolved
](local/import) type ref
262 link NamedType OPTIONAL -- REFERENCE not encoded
265 NamedTypeList ::= SEQUENCE OF NamedType
267 NamedType ::= SEQUENCE
269 fieldName MyString, -- may be empty or NULL str
277 moduleName MyString, -- used for "modname.type" refs (may be null)
278 module Module, --snacc isEncDec:"FALSE"
279 link TypeDef --snacc isEncDec:"FALSE"
284 RosOperationMacroType ::= SEQUENCE
288 errors
[0] IMPLICIT TypeOrValueList OPTIONAL,
289 linkedOps
[1] IMPLICIT TypeOrValueList OPTIONAL
292 ValueList ::= SEQUENCE OF Value
294 TypeOrValueList ::= SEQUENCE OF TypeOrValue
296 TypeOrValue ::= CHOICE
298 type
[0] IMPLICIT Type,
299 value
[1] IMPLICIT Value
302 OidList ::= SEQUENCE OF OBJECT IDENTIFIER
305 RosErrorMacroType ::= SEQUENCE
310 RosBindMacroType ::= SEQUENCE
318 RosAseMacroType ::= SEQUENCE
320 operations ValueList,
321 consumerInvokes ValueList,
322 supplierInvokes ValueList
325 RosAcMacroType ::= SEQUENCE
327 nonRoElements ValueList,
329 unbindMacroType Type,
330 remoteOperations Value,
331 operationsOf ValueList,
332 initiatorConsumerOf ValueList,
333 responderConsumerOf ValueList,
334 abstractSyntaxes OidList
338 MtsasExtensionMacroType ::= SEQUENCE
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
348 MtsasExtensionsMacroType ::= SEQUENCE
353 MtsasExtensionAttributeMacroType ::= SEQUENCE
358 MtsasTokenMacroType ::= SEQUENCE
363 MtsasTokenDataMacroType ::= SEQUENCE
368 MtsasSecurityCategoryMacroType ::= SEQUENCE
373 AsnObjectMacroType ::= SEQUENCE
375 ports AsnPortList OPTIONAL
378 AsnPortList ::= SEQUENCE OF AsnPort
392 AsnPortMacroType ::= SEQUENCE
394 abstractOps
[0] IMPLICIT TypeOrValueList OPTIONAL,
395 consumerInvokes
[1] IMPLICIT TypeOrValueList OPTIONAL,
396 supplierInvokes
[2] IMPLICIT TypeOrValueList OPTIONAL
400 AsnRefineMacroType ::= INTEGER
402 AsnAbstractBindMacroType ::= SEQUENCE
404 ports
[0] IMPLICIT AsnPortList OPTIONAL,
405 type
[1] IMPLICIT Type OPTIONAL
409 SnmpObjectTypeMacroType ::= SEQUENCE
413 { snmp-read-only (
0), snmp-read-write (
1),
414 snmp-write-only (
2), snmp-not-accessible (
3)
},
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
427 single
[0] SubtypeValue,
428 and
[1] IMPLICIT SubtypeList,
429 or
[2] IMPLICIT SubtypeList,
433 SubtypeList ::= SEQUENCE OF Subtype
435 SubtypeValue ::= CHOICE
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
446 ValueRangeSubtype ::= SEQUENCE
448 lowerEndInclusive BOOLEAN,
449 upperEndInclusive BOOLEAN,
455 InnerSubtype ::= SEQUENCE
457 constraintType ENUMERATED
{ full-ct (
0), partial-ct (
1), single-ct (
2)
},
458 constraints ConstraintList
461 ConstraintList ::= SEQUENCE OF Constraint
463 Constraint ::= SEQUENCE
465 fieldRef MyString, -- not used if in single-ct, may be null
466 presenceConstraint ENUMERATED
473 valueConstraints Subtype
477 ValueDefList ::= SEQUENCE OF ValueDef
480 ValueDef ::= SEQUENCE
483 definedName MyString,
490 valueType INTEGER, -- holds one of choiceId's def'd for BasicType
491 basicValue BasicValue,
495 BasicValue ::= CHOICE
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
521 SpecialIntegerValue ::= ENUMERATED
{ min-int (
0), max-int (
1)
}
522 SpecialRealValue ::= ENUMERATED
{ minus-infinity-real (
0), plus-infinity-real (
1)
}
525 ValueRef ::= SEQUENCE
528 moduleName MyString, -- used for "modname.value" refs (may be null)
529 link ValueDef, --snacc isEncDec:"FALSE"
530 module Module --snacc isEncDec:"FALSE"
533 NamedValue ::= SEQUENCE
535 fieldName MyString, -- may be null
539 NamedValueList ::= SEQUENCE OF NamedValue
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),
545 -- C Type Def Info - info used for routine naming
546 -- and referencing from other types
549 asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId"
553 isEncDec BOOLEAN, -- if false, no routines are gen
554 -- and not included in encodings
555 isPtrForTypeDef BOOLEAN,
556 isPtrForTypeRef BOOLEAN,
557 isPtrInChoice BOOLEAN,
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
565 printRoutineName MyString,
566 encodeRoutineName MyString,
567 decodeRoutineName MyString,
568 freeRoutineName MyString,
570 genPrintRoutine BOOLEAN,
571 genEncodeRoutine BOOLEAN,
572 genDecodeRoutine BOOLEAN,
573 genFreeRoutine BOOLEAN,
579 -- CTRI (C Type Ref Info) is used for generating C typedefinitions
580 -- from the ASN
.1 types info
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
601 CNamedElmts ::= SEQUENCE OF CNamedElmt
603 CNamedElmt ::= SEQUENCE
612 asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId"
616 isPtrForTypeDef BOOLEAN,
618 isPtrInChoice BOOLEAN,
619 isPtrInSetAndSeq BOOLEAN,
621 optTestRoutineName MyString,
622 defaultFieldName MyString -- base for generating field names
633 namedElmts CNamedElmts,
634 choiceIdSymbol MyString,
635 choiceIdValue INTEGER,
636 optTestRoutineName MyString
641 asn1TypeId INTEGER, --snacc cTypeName:"enum BasicTypeChoiceId"
645 isPtrForTypeDef BOOLEAN,
647 isPtrInChoice BOOLEAN,
648 isPtrInSetAndSeq BOOLEAN,
650 optTestRoutineName MyString,
651 defaultFieldName MyString -- base for generating field names
660 namedElmts CNamedElmts,
661 choiceIdSymbol MyString,
662 choiceIdValue INTEGER,
663 optTestRoutineName MyString
666 -- use snacc compiler directives to overide the builtin types.
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.
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 *"
695 \chapter{The Type Table (TBL) Data Structure ASN
.1 Definition
}
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).
702 This file is actually compiled by Snacc to compile itself.
703 For bootstrapping purposes, an initial version is included in the distribution.
707 -- .../asn1specs/tbl.asn1
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.
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.
720 -- Copyright Mike Sample and UBC,
1992,
1993
730 TBL ::= --snacc isPdu:"TRUE" -- SEQUENCE
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
741 TBLModule ::= SEQUENCE
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
749 TBLTypeDef ::= SEQUENCE
751 typeDefId TBLTypeDefId,
752 typeName PrintableString OPTIONAL, -- I have forgotten why this is opt!
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
765 TBLTypeContent ::= CHOICE
767 primType
[0] IMPLICIT NULL,
768 elmts
[1] IMPLICIT SEQUENCE OF TBLType,
769 typeRef
[2] IMPLICIT TBLTypeRef
772 TBLTypeRef ::= SEQUENCE
774 typeDef TBLTypeDefId,
778 TBLTypeId ::= ENUMERATED
796 TBLTypeDefId ::= INTEGER
801 code INTEGER (
0..MAX)
804 TBLTagClass ::= ENUMERATED
{ universal (
0), application (
1),
805 context (
2), private (
3)
}
812 \chapter{\label{edex-files
}ASN
.1 Files for the Editor Example
}
814 The files can be found in
{\ufn \dots/tcl-example/
}.
818 --\,-- file: edex0.asn1\\
820 --\,-- SnaccEd example, simple types module\\
822 EdEx-Simple DEFINITIONS ::=\\
825 RainbowColor ::= INTEGER\\
827 \>red(
0), orange(
1), yellow(
2), green(
3), blue(
4), indigo(
5), violet(
6)\\
830 DayOfTheWeek ::= ENUMERATED\\
832 \>sunday(
0), monday(
1), tuesday(
2), wednesday(
3), thursday(
4), friday(
5), saturday(
6)\\
835 Hand ::= BIT STRING\\
837 \>thumb(
0), forefinger(
1), middle-finger(
2), ring-finger(
3), little-finger(
4)\\
840 victory Hand ::= \
{ forefinger, middle-finger \
}\\
847 --\,-- file: edex1.asn1\\
849 --\,-- SnaccEd example, structured types module\\
851 EdEx-Structured DEFINITIONS ::=\\
854 IMPORTS RainbowColor, DayOfTheWeek, Hand FROM EdEx-Simple;\\
856 RGBColor ::= SEQUENCE\\
863 Coordinate ::= CHOICE\\
865 cartesian
[0] SEQUENCE \
{ x REAL, y REAL \
},\\
866 polar
[1] SEQUENCE \
{ angle REAL, distance REAL \
}\-\\
871 name
[0] PrintableString,\\
872 contents
[1] OCTET STRING,\\
873 checksum
[2] INTEGER OPTIONAL,\\
874 read-only
[3] BOOLEAN DEFAULT FALSE\-\\
879 name PrintableString,\\
880 files SET OF File\-\\
887 day
[2] DayOfTheWeek,\\
889 color [4] RainbowColor,\\
892 str
[7] OCTET STRING,\\
893 optstr
[8] OCTET STRING OPTIONAL\-\\
898 coord
[0] Coordinate,\\
899 color [1] CHOICE \
{ rainbow RainbowColor, rgb RGBColor \
}\-\\
905 struct
[1] Structured,\\
906 recursion
[2] Various OPTIONAL\-\\