Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
449f8324
Commit
449f8324
authored
Aug 20, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new constraints model
parent
e64460f6
Changes
36
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
244 additions
and
215 deletions
+244
-215
skeletons/BIT_STRING.c
skeletons/BIT_STRING.c
+1
-0
skeletons/BMPString.c
skeletons/BMPString.c
+1
-0
skeletons/BOOLEAN.c
skeletons/BOOLEAN.c
+1
-0
skeletons/ENUMERATED.c
skeletons/ENUMERATED.c
+1
-0
skeletons/GeneralString.c
skeletons/GeneralString.c
+1
-0
skeletons/GeneralizedTime.c
skeletons/GeneralizedTime.c
+1
-0
skeletons/GraphicString.c
skeletons/GraphicString.c
+1
-0
skeletons/IA5String.c
skeletons/IA5String.c
+1
-0
skeletons/INTEGER.c
skeletons/INTEGER.c
+1
-0
skeletons/ISO646String.c
skeletons/ISO646String.c
+1
-0
skeletons/NULL.c
skeletons/NULL.c
+1
-0
skeletons/NativeEnumerated.c
skeletons/NativeEnumerated.c
+2
-0
skeletons/NativeInteger.c
skeletons/NativeInteger.c
+1
-0
skeletons/NumericString.c
skeletons/NumericString.c
+1
-0
skeletons/OBJECT_IDENTIFIER.c
skeletons/OBJECT_IDENTIFIER.c
+1
-0
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+1
-0
skeletons/ObjectDescriptor.c
skeletons/ObjectDescriptor.c
+1
-0
skeletons/PrintableString.c
skeletons/PrintableString.c
+1
-0
skeletons/RELATIVE-OID.c
skeletons/RELATIVE-OID.c
+1
-0
skeletons/T61String.c
skeletons/T61String.c
+1
-0
skeletons/TeletexString.c
skeletons/TeletexString.c
+1
-0
skeletons/UTCTime.c
skeletons/UTCTime.c
+1
-0
skeletons/UTF8String.c
skeletons/UTF8String.c
+1
-0
skeletons/UniversalString.c
skeletons/UniversalString.c
+1
-0
skeletons/VideotexString.c
skeletons/VideotexString.c
+1
-0
skeletons/VisibleString.c
skeletons/VisibleString.c
+1
-0
skeletons/constr_CHOICE.c
skeletons/constr_CHOICE.c
+48
-34
skeletons/constr_CHOICE.h
skeletons/constr_CHOICE.h
+0
-18
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+51
-43
skeletons/constr_SEQUENCE.h
skeletons/constr_SEQUENCE.h
+0
-18
skeletons/constr_SEQUENCE_OF.c
skeletons/constr_SEQUENCE_OF.c
+7
-8
skeletons/constr_SET.c
skeletons/constr_SET.c
+47
-37
skeletons/constr_SET.h
skeletons/constr_SET.h
+0
-18
skeletons/constr_SET_OF.c
skeletons/constr_SET_OF.c
+43
-28
skeletons/constr_SET_OF.h
skeletons/constr_SET_OF.h
+0
-10
skeletons/constr_TYPE.h
skeletons/constr_TYPE.h
+21
-1
No files found.
skeletons/BIT_STRING.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING = {
/
sizeof
(
asn1_DEF_BIT_STRING_tags
[
0
]),
/
sizeof
(
asn1_DEF_BIT_STRING_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
(
void
*
)
-
1
/* Special indicator that this is a BIT STRING */
(
void
*
)
-
1
/* Special indicator that this is a BIT STRING */
};
};
...
...
skeletons/BMPString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BMPString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BMPString = {
/
sizeof
(
asn1_DEF_BMPString_tags
[
0
]),
/
sizeof
(
asn1_DEF_BMPString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/BOOLEAN.c
View file @
449f8324
...
@@ -22,6 +22,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = {
...
@@ -22,6 +22,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = {
sizeof
(
asn1_DEF_BOOLEAN_tags
)
/
sizeof
(
asn1_DEF_BOOLEAN_tags
[
0
]),
sizeof
(
asn1_DEF_BOOLEAN_tags
)
/
sizeof
(
asn1_DEF_BOOLEAN_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/ENUMERATED.c
View file @
449f8324
...
@@ -22,6 +22,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ENUMERATED = {
...
@@ -22,6 +22,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ENUMERATED = {
sizeof
(
asn1_DEF_ENUMERATED_tags
)
/
sizeof
(
asn1_DEF_ENUMERATED_tags
[
0
]),
sizeof
(
asn1_DEF_ENUMERATED_tags
)
/
sizeof
(
asn1_DEF_ENUMERATED_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Primitive */
0
,
/* Primitive */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/GeneralString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralString = {
/
sizeof
(
asn1_DEF_GeneralString_tags
[
0
]),
/
sizeof
(
asn1_DEF_GeneralString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/GeneralizedTime.c
View file @
449f8324
...
@@ -88,6 +88,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime = {
...
@@ -88,6 +88,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime = {
/
sizeof
(
asn1_DEF_GeneralizedTime_tags
[
0
]),
/
sizeof
(
asn1_DEF_GeneralizedTime_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/GraphicString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GraphicString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GraphicString = {
/
sizeof
(
asn1_DEF_GraphicString_tags
[
0
]),
/
sizeof
(
asn1_DEF_GraphicString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/IA5String.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_IA5String = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_IA5String = {
/
sizeof
(
asn1_DEF_IA5String_tags
[
0
]),
/
sizeof
(
asn1_DEF_IA5String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/INTEGER.c
View file @
449f8324
...
@@ -24,6 +24,7 @@ asn1_TYPE_descriptor_t asn1_DEF_INTEGER = {
...
@@ -24,6 +24,7 @@ asn1_TYPE_descriptor_t asn1_DEF_INTEGER = {
sizeof
(
asn1_DEF_INTEGER_tags
)
/
sizeof
(
asn1_DEF_INTEGER_tags
[
0
]),
sizeof
(
asn1_DEF_INTEGER_tags
)
/
sizeof
(
asn1_DEF_INTEGER_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/ISO646String.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ISO646String = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ISO646String = {
/
sizeof
(
asn1_DEF_ISO646String_tags
[
0
]),
/
sizeof
(
asn1_DEF_ISO646String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/NULL.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NULL = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NULL = {
sizeof
(
asn1_DEF_NULL_tags
)
/
sizeof
(
asn1_DEF_NULL_tags
[
0
]),
sizeof
(
asn1_DEF_NULL_tags
)
/
sizeof
(
asn1_DEF_NULL_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/NativeEnumerated.c
View file @
449f8324
...
@@ -29,5 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeEnumerated = {
...
@@ -29,5 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeEnumerated = {
sizeof
(
asn1_DEF_NativeEnumerated_tags
)
/
sizeof
(
asn1_DEF_NativeEnumerated_tags
[
0
]),
sizeof
(
asn1_DEF_NativeEnumerated_tags
)
/
sizeof
(
asn1_DEF_NativeEnumerated_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/NativeInteger.c
View file @
449f8324
...
@@ -31,6 +31,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeInteger = {
...
@@ -31,6 +31,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeInteger = {
sizeof
(
asn1_DEF_NativeInteger_tags
)
/
sizeof
(
asn1_DEF_NativeInteger_tags
[
0
]),
sizeof
(
asn1_DEF_NativeInteger_tags
)
/
sizeof
(
asn1_DEF_NativeInteger_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/NumericString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NumericString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NumericString = {
/
sizeof
(
asn1_DEF_NumericString_tags
[
0
]),
/
sizeof
(
asn1_DEF_NumericString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/OBJECT_IDENTIFIER.c
View file @
449f8324
...
@@ -26,6 +26,7 @@ asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER = {
...
@@ -26,6 +26,7 @@ asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER = {
/
sizeof
(
asn1_DEF_OBJECT_IDENTIFIER_tags
[
0
]),
/
sizeof
(
asn1_DEF_OBJECT_IDENTIFIER_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/OCTET_STRING.c
View file @
449f8324
...
@@ -25,6 +25,7 @@ asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = {
...
@@ -25,6 +25,7 @@ asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = {
/
sizeof
(
asn1_DEF_OCTET_STRING_tags
[
0
]),
/
sizeof
(
asn1_DEF_OCTET_STRING_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine (primitive and constructed) */
-
1
,
/* Both ways are fine (primitive and constructed) */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/ObjectDescriptor.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ObjectDescriptor = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ObjectDescriptor = {
/
sizeof
(
asn1_DEF_ObjectDescriptor_tags
[
0
]),
/
sizeof
(
asn1_DEF_ObjectDescriptor_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/PrintableString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_PrintableString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_PrintableString = {
/
sizeof
(
asn1_DEF_PrintableString_tags
[
0
]),
/
sizeof
(
asn1_DEF_PrintableString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/RELATIVE-OID.c
View file @
449f8324
...
@@ -26,6 +26,7 @@ asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = {
...
@@ -26,6 +26,7 @@ asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = {
/
sizeof
(
asn1_DEF_RELATIVE_OID_tags
[
0
]),
/
sizeof
(
asn1_DEF_RELATIVE_OID_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
,
/* Always in primitive form */
0
,
/* Always in primitive form */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/T61String.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_T61String = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_T61String = {
/
sizeof
(
asn1_DEF_T61String_tags
[
0
]),
/
sizeof
(
asn1_DEF_T61String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/TeletexString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_TeletexString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_TeletexString = {
/
sizeof
(
asn1_DEF_TeletexString_tags
[
0
]),
/
sizeof
(
asn1_DEF_TeletexString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/UTCTime.c
View file @
449f8324
...
@@ -29,6 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTCTime = {
...
@@ -29,6 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTCTime = {
/
sizeof
(
asn1_DEF_UTCTime_tags
[
0
]),
/
sizeof
(
asn1_DEF_UTCTime_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/UTF8String.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTF8String = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTF8String = {
/
sizeof
(
asn1_DEF_UTF8String_tags
[
0
]),
/
sizeof
(
asn1_DEF_UTF8String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/UniversalString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UniversalString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UniversalString = {
/
sizeof
(
asn1_DEF_UniversalString_tags
[
0
]),
/
sizeof
(
asn1_DEF_UniversalString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/VideotexString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_VideotexString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_VideotexString = {
/
sizeof
(
asn1_DEF_VideotexString_tags
[
0
]),
/
sizeof
(
asn1_DEF_VideotexString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
skeletons/VisibleString.c
View file @
449f8324
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_VisibleString = {
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_VisibleString = {
/
sizeof
(
asn1_DEF_VisibleString_tags
[
0
]),
/
sizeof
(
asn1_DEF_VisibleString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
-
1
,
/* Both ways are fine */
0
,
0
,
/* No members */
0
/* No specifics */
0
/* No specifics */
};
};
...
...
skeletons/constr_CHOICE.c
View file @
449f8324
...
@@ -93,13 +93,13 @@ _search4tag(const void *ap, const void *bp) {
...
@@ -93,13 +93,13 @@ _search4tag(const void *ap, const void *bp) {
* The decoder of the CHOICE type.
* The decoder of the CHOICE type.
*/
*/
ber_dec_rval_t
ber_dec_rval_t
CHOICE_decode_ber
(
asn1_TYPE_descriptor_t
*
s
d
,
CHOICE_decode_ber
(
asn1_TYPE_descriptor_t
*
t
d
,
void
**
struct_ptr
,
void
*
ptr
,
size_t
size
,
int
tag_mode
)
{
void
**
struct_ptr
,
void
*
ptr
,
size_t
size
,
int
tag_mode
)
{
/*
/*
* Bring closer parts of structure description.
* Bring closer parts of structure description.
*/
*/
asn1_CHOICE_specifics_t
*
specs
=
(
asn1_CHOICE_specifics_t
*
)
s
d
->
specifics
;
asn1_CHOICE_specifics_t
*
specs
=
(
asn1_CHOICE_specifics_t
*
)
t
d
->
specifics
;
asn1_
CHOICE_element_t
*
elements
=
specs
->
elements
;
asn1_
TYPE_member_t
*
elements
=
td
->
elements
;
/*
/*
* Parts of the structure being constructed.
* Parts of the structure being constructed.
...
@@ -114,7 +114,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -114,7 +114,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
ASN_DEBUG
(
"Decoding %s as CHOICE"
,
s
d
->
name
);
ASN_DEBUG
(
"Decoding %s as CHOICE"
,
t
d
->
name
);
/*
/*
* Create the target structure if it is not present already.
* Create the target structure if it is not present already.
...
@@ -142,12 +142,12 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -142,12 +142,12 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
* perfectly fits our expectations.
* perfectly fits our expectations.
*/
*/
if
(
tag_mode
||
s
d
->
tags_count
)
{
if
(
tag_mode
||
t
d
->
tags_count
)
{
rval
=
ber_check_tags
(
s
d
,
ctx
,
ptr
,
size
,
rval
=
ber_check_tags
(
t
d
,
ctx
,
ptr
,
size
,
tag_mode
,
&
ctx
->
left
,
0
);
tag_mode
,
&
ctx
->
left
,
0
);
if
(
rval
.
code
!=
RC_OK
)
{
if
(
rval
.
code
!=
RC_OK
)
{
ASN_DEBUG
(
"%s tagging check failed: %d"
,
ASN_DEBUG
(
"%s tagging check failed: %d"
,
s
d
->
name
,
rval
.
code
);
t
d
->
name
,
rval
.
code
);
consumed_myself
+=
rval
.
consumed
;
consumed_myself
+=
rval
.
consumed
;
RETURN
(
rval
.
code
);
RETURN
(
rval
.
code
);
}
}
...
@@ -172,7 +172,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -172,7 +172,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
* Fetch the T from TLV.
* Fetch the T from TLV.
*/
*/
tag_len
=
ber_fetch_tag
(
ptr
,
LEFT
,
&
tlv_tag
);
tag_len
=
ber_fetch_tag
(
ptr
,
LEFT
,
&
tlv_tag
);
ASN_DEBUG
(
"In %s CHOICE tag length %d"
,
s
d
->
name
,
(
int
)
tag_len
);
ASN_DEBUG
(
"In %s CHOICE tag length %d"
,
t
d
->
name
,
(
int
)
tag_len
);
switch
(
tag_len
)
{
switch
(
tag_len
)
{
case
0
:
if
(
!
SIZE_VIOLATION
)
RETURN
(
RC_WMORE
);
case
0
:
if
(
!
SIZE_VIOLATION
)
RETURN
(
RC_WMORE
);
/* Fall through */
/* Fall through */
...
@@ -197,7 +197,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -197,7 +197,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
}
else
if
(
specs
->
extensible
==
0
)
{
}
else
if
(
specs
->
extensible
==
0
)
{
ASN_DEBUG
(
"Unexpected tag %s "
ASN_DEBUG
(
"Unexpected tag %s "
"in non-extensible CHOICE %s"
,
"in non-extensible CHOICE %s"
,
ber_tlv_tag_string
(
tlv_tag
),
s
d
->
name
);
ber_tlv_tag_string
(
tlv_tag
),
t
d
->
name
);
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
else
{
}
else
{
/* Skip this tag */
/* Skip this tag */
...
@@ -227,7 +227,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -227,7 +227,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
* Read in the element.
* Read in the element.
*/
*/
do
{
do
{
asn1_
CHOICE_element_t
*
elm
;
/* CHOICE's element */
asn1_
TYPE_member_t
*
elm
;
/* CHOICE's element */
void
*
memb_ptr
;
/* Pointer to the member */
void
*
memb_ptr
;
/* Pointer to the member */
void
**
memb_ptr2
;
/* Pointer to that pointer */
void
**
memb_ptr2
;
/* Pointer to that pointer */
...
@@ -252,6 +252,9 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -252,6 +252,9 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
/*
/*
* Invoke the member fetch routine according to member's type
* Invoke the member fetch routine according to member's type
*/
*/
printf
(
"elm->name = %s
\n
"
,
elm
->
name
);
printf
(
"elm->td = %p
\n
"
,
elm
->
type
);
printf
(
"elm->td->name = %s
\n
"
,
elm
->
type
->
name
);
rval
=
elm
->
type
->
ber_decoder
(
elm
->
type
,
rval
=
elm
->
type
->
ber_decoder
(
elm
->
type
,
memb_ptr2
,
ptr
,
LEFT
,
memb_ptr2
,
ptr
,
LEFT
,
elm
->
tag_mode
);
elm
->
tag_mode
);
...
@@ -278,8 +281,8 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -278,8 +281,8 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
/* Fall through */
/* Fall through */
case
3
:
case
3
:
ASN_DEBUG
(
"CHOICE %s Leftover: %ld, size = %ld, tm=%d, tc=%d"
,
ASN_DEBUG
(
"CHOICE %s Leftover: %ld, size = %ld, tm=%d, tc=%d"
,
s
d
->
name
,
(
long
)
ctx
->
left
,
(
long
)
size
,
t
d
->
name
,
(
long
)
ctx
->
left
,
(
long
)
size
,
tag_mode
,
s
d
->
tags_count
);
tag_mode
,
t
d
->
tags_count
);
if
(
ctx
->
left
>
0
)
{
if
(
ctx
->
left
>
0
)
{
/*
/*
...
@@ -290,7 +293,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -290,7 +293,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
}
}
if
(
ctx
->
left
==
-
1
if
(
ctx
->
left
==
-
1
&&
!
(
tag_mode
||
s
d
->
tags_count
))
{
&&
!
(
tag_mode
||
t
d
->
tags_count
))
{
/*
/*
* This is an untagged CHOICE.
* This is an untagged CHOICE.
* It doesn't contain nothing
* It doesn't contain nothing
...
@@ -331,7 +334,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -331,7 +334,7 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
}
}
}
else
{
}
else
{
ASN_DEBUG
(
"Unexpected continuation in %s"
,
ASN_DEBUG
(
"Unexpected continuation in %s"
,
s
d
->
name
);
t
d
->
name
);
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
...
@@ -349,19 +352,19 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -349,19 +352,19 @@ CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd,
}
}
der_enc_rval_t
der_enc_rval_t
CHOICE_encode_der
(
asn1_TYPE_descriptor_t
*
s
d
,
CHOICE_encode_der
(
asn1_TYPE_descriptor_t
*
t
d
,
void
*
struct_ptr
,
void
*
struct_ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn1_CHOICE_specifics_t
*
specs
=
(
asn1_CHOICE_specifics_t
*
)
s
d
->
specifics
;
asn1_CHOICE_specifics_t
*
specs
=
(
asn1_CHOICE_specifics_t
*
)
t
d
->
specifics
;
asn1_
CHOICE_element
_t
*
elm
;
/* CHOICE element */
asn1_
TYPE_member
_t
*
elm
;
/* CHOICE element */
der_enc_rval_t
erval
;
der_enc_rval_t
erval
;
void
*
memb_ptr
;
void
*
memb_ptr
;
size_t
computed_size
=
0
;
size_t
computed_size
=
0
;
int
present
;
int
present
;
ASN_DEBUG
(
"%s %s as CHOICE"
,
ASN_DEBUG
(
"%s %s as CHOICE"
,
cb
?
"Encoding"
:
"Estimating"
,
s
d
->
name
);
cb
?
"Encoding"
:
"Estimating"
,
t
d
->
name
);
present
=
_fetch_present_idx
(
struct_ptr
,
present
=
_fetch_present_idx
(
struct_ptr
,
specs
->
pres_offset
,
specs
->
pres_size
);
specs
->
pres_offset
,
specs
->
pres_size
);
...
@@ -370,14 +373,14 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -370,14 +373,14 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
* If the structure was not initialized, it cannot be encoded:
* If the structure was not initialized, it cannot be encoded:
* can't deduce what to encode in the choice type.
* can't deduce what to encode in the choice type.
*/
*/
if
(
present
<=
0
||
present
>
specs
->
elements_count
)
{
if
(
present
<=
0
||
present
>
td
->
elements_count
)
{
if
(
present
==
0
&&
specs
->
elements_count
==
0
)
{
if
(
present
==
0
&&
td
->
elements_count
==
0
)
{
/* The CHOICE is empty?! */
/* The CHOICE is empty?! */
erval
.
encoded
=
0
;
erval
.
encoded
=
0
;
return
erval
;
return
erval
;
}
}
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
struct_ptr
;
erval
.
structure_ptr
=
struct_ptr
;
return
erval
;
return
erval
;
}
}
...
@@ -385,7 +388,7 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -385,7 +388,7 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
/*
/*
* Seek over the present member of the structure.
* Seek over the present member of the structure.
*/
*/
elm
=
&
specs
->
elements
[
present
-
1
];
elm
=
&
td
->
elements
[
present
-
1
];
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
memb_ptr
=
*
(
void
**
)((
char
*
)
struct_ptr
+
elm
->
memb_offset
);
memb_ptr
=
*
(
void
**
)((
char
*
)
struct_ptr
+
elm
->
memb_offset
);
if
(
memb_ptr
==
0
)
{
if
(
memb_ptr
==
0
)
{
...
@@ -401,7 +404,7 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -401,7 +404,7 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
* T ::= [2] EXPLICIT CHOICE { ... }
* T ::= [2] EXPLICIT CHOICE { ... }
* Then emit the appropriate tags.
* Then emit the appropriate tags.
*/
*/
if
(
tag_mode
==
1
||
s
d
->
tags_count
)
{
if
(
tag_mode
==
1
||
t
d
->
tags_count
)
{
/*
/*
* For this, we need to pre-compute the member.
* For this, we need to pre-compute the member.
*/
*/
...
@@ -414,11 +417,11 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -414,11 +417,11 @@ CHOICE_encode_der(asn1_TYPE_descriptor_t *sd,
return
erval
;
return
erval
;
/* Encode CHOICE with parent or my own tag */
/* Encode CHOICE with parent or my own tag */
ret
=
der_write_tags
(
s
d
,
erval
.
encoded
,
tag_mode
,
tag
,
ret
=
der_write_tags
(
t
d
,
erval
.
encoded
,
tag_mode
,
tag
,
cb
,
app_key
);
cb
,
app_key
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
struct_ptr
;
erval
.
structure_ptr
=
struct_ptr
;
return
erval
;
return
erval
;
}
}
...
@@ -454,8 +457,8 @@ CHOICE_outmost_tag(asn1_TYPE_descriptor_t *td, const void *ptr, int tag_mode, be
...
@@ -454,8 +457,8 @@ CHOICE_outmost_tag(asn1_TYPE_descriptor_t *td, const void *ptr, int tag_mode, be
*/
*/
present
=
_fetch_present_idx
(
ptr
,
specs
->
pres_offset
,
specs
->
pres_size
);
present
=
_fetch_present_idx
(
ptr
,
specs
->
pres_offset
,
specs
->
pres_size
);
if
(
present
>
0
||
present
<=
specs
->
elements_count
)
{
if
(
present
>
0
||
present
<=
td
->
elements_count
)
{
asn1_
CHOICE_element_t
*
elm
=
&
specs
->
elements
[
present
-
1
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
present
-
1
];
const
void
*
memb_ptr
;
const
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
...
@@ -489,8 +492,8 @@ CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -489,8 +492,8 @@ CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
* Figure out which CHOICE element is encoded.
* Figure out which CHOICE element is encoded.
*/
*/
present
=
_fetch_present_idx
(
sptr
,
specs
->
pres_offset
,
specs
->
pres_size
);
present
=
_fetch_present_idx
(
sptr
,
specs
->
pres_offset
,
specs
->
pres_size
);
if
(
present
>
0
&&
present
<=
specs
->
elements_count
)
{
if
(
present
>
0
&&
present
<=
td
->
elements_count
)
{
asn1_
CHOICE_element_t
*
elm
=
&
specs
->
elements
[
present
-
1
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
present
-
1
];
const
void
*
memb_ptr
;
const
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
...
@@ -500,8 +503,19 @@ CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -500,8 +503,19 @@ CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
memb_ptr
=
(
const
void
*
)((
const
char
*
)
sptr
+
elm
->
memb_offset
);
memb_ptr
=
(
const
void
*
)((
const
char
*
)
sptr
+
elm
->
memb_offset
);
}
}
return
elm
->
type
->
check_constraints
(
elm
->
type
,
memb_ptr
,
if
(
elm
->
memb_constraints
)
{
return
elm
->
memb_constraints
(
elm
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
app_errlog
,
app_key
);
}
else
{
int
ret
=
elm
->
type
->
check_constraints
(
elm
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
/*
* Cannot inherit it eralier:
* need to make sure we get the updated version.
*/
elm
->
memb_constraints
=
elm
->
type
->
check_constraints
;
return
ret
;
}
}
else
{
}
else
{
_ASN_ERRLOG
(
app_errlog
,
app_key
,
_ASN_ERRLOG
(
app_errlog
,
app_key
,
"%s: no CHOICE element given"
,
td
->
name
);
"%s: no CHOICE element given"
,
td
->
name
);
...
@@ -525,8 +539,8 @@ CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
...
@@ -525,8 +539,8 @@ CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
/*
/*
* Free that element.
* Free that element.
*/
*/
if
(
present
>
0
&&
present
<=
specs
->
elements_count
)
{
if
(
present
>
0
&&
present
<=
td
->
elements_count
)
{
asn1_
CHOICE_element_t
*
elm
=
&
specs
->
elements
[
present
-
1
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
present
-
1
];
const
void
*
memb_ptr
;
const
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
...
@@ -566,8 +580,8 @@ CHOICE_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
...
@@ -566,8 +580,8 @@ CHOICE_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
/*
/*
* Free that element.
* Free that element.
*/
*/
if
(
present
>
0
&&
present
<=
specs
->
elements_count
)
{
if
(
present
>
0
&&
present
<=
td
->
elements_count
)
{
asn1_
CHOICE_element_t
*
elm
=
&
specs
->
elements
[
present
-
1
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
present
-
1
];
void
*
memb_ptr
;
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
...
...
skeletons/constr_CHOICE.h
View file @
449f8324
...
@@ -7,18 +7,6 @@
...
@@ -7,18 +7,6 @@
#include <constr_TYPE.h>
#include <constr_TYPE.h>
/*
* A single element of the CHOICE type.
*/
typedef
struct
asn1_CHOICE_element_s
{
int
memb_offset
;
/* Offset of the element */
int
optional
;
/* Whether the element is optional */
ber_tlv_tag_t
tag
;
/* Outmost (most immediate) tag */
int
tag_mode
;
/* IMPLICIT/no/EXPLICIT tag at current level */
asn1_TYPE_descriptor_t
*
type
;
/* Member type descriptor */
char
*
name
;
/* ASN.1 identifier of the element */
}
asn1_CHOICE_element_t
;
typedef
struct
asn1_CHOICE_specifics_s
{
typedef
struct
asn1_CHOICE_specifics_s
{
/*
/*
* Target structure description.
* Target structure description.
...
@@ -28,12 +16,6 @@ typedef struct asn1_CHOICE_specifics_s {
...
@@ -28,12 +16,6 @@ typedef struct asn1_CHOICE_specifics_s {
int
pres_offset
;
/* Identifier of the present member */
int
pres_offset
;
/* Identifier of the present member */
int
pres_size
;
/* Size of the identifier (enum) */
int
pres_size
;
/* Size of the identifier (enum) */
/*
* Members of the CHOICE structure.
*/
asn1_CHOICE_element_t
*
elements
;
int
elements_count
;
/*
/*
* Tags to members mapping table.
* Tags to members mapping table.
*/
*/
...
...
skeletons/constr_SEQUENCE.c
View file @
449f8324
This diff is collapsed.
Click to expand it.
skeletons/constr_SEQUENCE.h
View file @
449f8324
...
@@ -7,18 +7,6 @@
...
@@ -7,18 +7,6 @@
#include <constr_TYPE.h>
#include <constr_TYPE.h>
/*
* A single element of the SEQUENCE type.
*/
typedef
struct
asn1_SEQUENCE_element_s
{
int
memb_offset
;
/* Offset of the element */
int
optional
;
/* Whether the element is optional */
ber_tlv_tag_t
tag
;
/* Outmost (most immediate) tag */
int
tag_mode
;
/* IMPLICIT/no/EXPLICIT tag at current level */
asn1_TYPE_descriptor_t
*
type
;
/* Member type descriptor */
char
*
name
;
/* ASN.1 identifier of the element */
}
asn1_SEQUENCE_element_t
;
typedef
struct
asn1_SEQUENCE_specifics_s
{
typedef
struct
asn1_SEQUENCE_specifics_s
{
/*
/*
* Target structure description.
* Target structure description.
...
@@ -26,12 +14,6 @@ typedef struct asn1_SEQUENCE_specifics_s {
...
@@ -26,12 +14,6 @@ typedef struct asn1_SEQUENCE_specifics_s {
int
struct_size
;
/* Size of the target structure. */
int
struct_size
;
/* Size of the target structure. */
int
ctx_offset
;
/* Offset of the ber_dec_ctx_t member */
int
ctx_offset
;
/* Offset of the ber_dec_ctx_t member */
/*
* Members of the SEQUENCE structure.
*/
asn1_SEQUENCE_element_t
*
elements
;
int
elements_count
;
/*
/*
* Tags to members mapping table (sorted).
* Tags to members mapping table (sorted).
*/
*/
...
...
skeletons/constr_SEQUENCE_OF.c
View file @
449f8324
...
@@ -9,18 +9,17 @@
...
@@ -9,18 +9,17 @@
* The DER encoder of the SEQUENCE OF type.
* The DER encoder of the SEQUENCE OF type.
*/
*/
der_enc_rval_t
der_enc_rval_t
SEQUENCE_OF_encode_der
(
asn1_TYPE_descriptor_t
*
s
d
,
void
*
ptr
,
SEQUENCE_OF_encode_der
(
asn1_TYPE_descriptor_t
*
t
d
,
void
*
ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn1_SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
sd
->
specifics
;
asn1_TYPE_member_t
*
elm
=
td
->
elements
;
asn1_SET_OF_element_t
*
elm
=
specs
->
element
;
A_SEQUENCE_OF
(
void
)
*
list
;
A_SEQUENCE_OF
(
void
)
*
list
;
size_t
computed_size
=
0
;
size_t
computed_size
=
0
;
ssize_t
encoding_size
=
0
;
ssize_t
encoding_size
=
0
;
der_enc_rval_t
erval
;
der_enc_rval_t
erval
;
int
edx
;
int
edx
;
ASN_DEBUG
(
"Estimating size of SEQUENCE OF %s"
,
s
d
->
name
);
ASN_DEBUG
(
"Estimating size of SEQUENCE OF %s"
,
t
d
->
name
);
/*
/*
* Gather the length of the underlying members sequence.
* Gather the length of the underlying members sequence.
...
@@ -39,11 +38,11 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -39,11 +38,11 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
/*
/*
* Encode the TLV for the sequence itself.
* Encode the TLV for the sequence itself.
*/
*/
encoding_size
=
der_write_tags
(
s
d
,
computed_size
,
tag_mode
,
tag
,
encoding_size
=
der_write_tags
(
t
d
,
computed_size
,
tag_mode
,
tag
,
cb
,
app_key
);
cb
,
app_key
);
if
(
encoding_size
==
-
1
)
{
if
(
encoding_size
==
-
1
)
{
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
return
erval
;
}
}
...
@@ -54,7 +53,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -54,7 +53,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
return
erval
;
return
erval
;
}
}
ASN_DEBUG
(
"Encoding members of SEQUENCE OF %s"
,
s
d
->
name
);
ASN_DEBUG
(
"Encoding members of SEQUENCE OF %s"
,
t
d
->
name
);
/*
/*
* Encode all members.
* Encode all members.
...
@@ -74,7 +73,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -74,7 +73,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
* Encoded size is not equal to the computed size.
* Encoded size is not equal to the computed size.
*/
*/
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
}
else
{
}
else
{
erval
.
encoded
=
computed_size
;
erval
.
encoded
=
computed_size
;
...
...
skeletons/constr_SET.c
View file @
449f8324
...
@@ -93,13 +93,13 @@ _t2e_cmp(const void *ap, const void *bp) {
...
@@ -93,13 +93,13 @@ _t2e_cmp(const void *ap, const void *bp) {
* The decoder of the SET type.
* The decoder of the SET type.
*/
*/
ber_dec_rval_t
ber_dec_rval_t
SET_decode_ber
(
asn1_TYPE_descriptor_t
*
s
d
,
SET_decode_ber
(
asn1_TYPE_descriptor_t
*
t
d
,
void
**
struct_ptr
,
void
*
ptr
,
size_t
size
,
int
tag_mode
)
{
void
**
struct_ptr
,
void
*
ptr
,
size_t
size
,
int
tag_mode
)
{
/*
/*
* Bring closer parts of structure description.
* Bring closer parts of structure description.
*/
*/
asn1_SET_specifics_t
*
specs
=
(
asn1_SET_specifics_t
*
)
s
d
->
specifics
;
asn1_SET_specifics_t
*
specs
=
(
asn1_SET_specifics_t
*
)
t
d
->
specifics
;
asn1_
SET_element_t
*
elements
=
specs
->
elements
;
asn1_
TYPE_member_t
*
elements
=
td
->
elements
;
/*
/*
* Parts of the structure being constructed.
* Parts of the structure being constructed.
...
@@ -114,7 +114,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -114,7 +114,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
int
edx
;
/* SET element's index */
int
edx
;
/* SET element's index */
ASN_DEBUG
(
"Decoding %s as SET"
,
s
d
->
name
);
ASN_DEBUG
(
"Decoding %s as SET"
,
t
d
->
name
);
/*
/*
* Create the target structure if it is not present already.
* Create the target structure if it is not present already.
...
@@ -142,11 +142,11 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -142,11 +142,11 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
* perfectly fits our expectations.
* perfectly fits our expectations.
*/
*/
rval
=
ber_check_tags
(
s
d
,
ctx
,
ptr
,
size
,
rval
=
ber_check_tags
(
t
d
,
ctx
,
ptr
,
size
,
tag_mode
,
&
ctx
->
left
,
0
);
tag_mode
,
&
ctx
->
left
,
0
);
if
(
rval
.
code
!=
RC_OK
)
{
if
(
rval
.
code
!=
RC_OK
)
{
ASN_DEBUG
(
"%s tagging check failed: %d"
,
ASN_DEBUG
(
"%s tagging check failed: %d"
,
s
d
->
name
,
rval
.
code
);
t
d
->
name
,
rval
.
code
);
consumed_myself
+=
rval
.
consumed
;
consumed_myself
+=
rval
.
consumed
;
RETURN
(
rval
.
code
);
RETURN
(
rval
.
code
);
}
}
...
@@ -176,7 +176,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -176,7 +176,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
* canonical order of their tags. So, there is a room
* canonical order of their tags. So, there is a room
* for optimization.
* for optimization.
*/
*/
for
(
edx
=
(
ctx
->
step
>>
1
);
edx
<
specs
->
elements_count
;
for
(
edx
=
(
ctx
->
step
>>
1
);
edx
<
td
->
elements_count
;
ctx
->
step
=
(
ctx
->
step
&
~
1
)
+
2
,
ctx
->
step
=
(
ctx
->
step
&
~
1
)
+
2
,
edx
=
(
ctx
->
step
>>
1
))
{
edx
=
(
ctx
->
step
>>
1
))
{
void
*
memb_ptr
;
/* Pointer to the member */
void
*
memb_ptr
;
/* Pointer to the member */
...
@@ -247,7 +247,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -247,7 +247,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
}
else
if
(
specs
->
extensible
==
0
)
{
}
else
if
(
specs
->
extensible
==
0
)
{
ASN_DEBUG
(
"Unexpected tag %s "
ASN_DEBUG
(
"Unexpected tag %s "
"in non-extensible SET %s"
,
"in non-extensible SET %s"
,
ber_tlv_tag_string
(
tlv_tag
),
s
d
->
name
);
ber_tlv_tag_string
(
tlv_tag
),
t
d
->
name
);
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
else
{
}
else
{
/* Skip this tag */
/* Skip this tag */
...
@@ -285,7 +285,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -285,7 +285,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
*/
*/
if
(
ASN_SET_ISPRESENT2
((
char
*
)
st
+
specs
->
pres_offset
,
edx
))
{
if
(
ASN_SET_ISPRESENT2
((
char
*
)
st
+
specs
->
pres_offset
,
edx
))
{
ASN_DEBUG
(
"SET %s: Duplicate element %s (%d)"
,
ASN_DEBUG
(
"SET %s: Duplicate element %s (%d)"
,
s
d
->
name
,
elements
[
edx
].
name
,
edx
);
t
d
->
name
,
elements
[
edx
].
name
,
edx
);
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
...
@@ -335,7 +335,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -335,7 +335,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
case
3
:
case
3
:
case
4
:
/* Only 00 is expected */
case
4
:
/* Only 00 is expected */
ASN_DEBUG
(
"SET %s Leftover: %ld, size = %ld"
,
ASN_DEBUG
(
"SET %s Leftover: %ld, size = %ld"
,
s
d
->
name
,
(
long
)
ctx
->
left
,
(
long
)
size
);
t
d
->
name
,
(
long
)
ctx
->
left
,
(
long
)
size
);
/*
/*
* Skip everything until the end of the SET.
* Skip everything until the end of the SET.
...
@@ -374,7 +374,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -374,7 +374,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
if
(
specs
->
extensible
==
0
||
ctx
->
phase
==
4
)
{
if
(
specs
->
extensible
==
0
||
ctx
->
phase
==
4
)
{
ASN_DEBUG
(
"Unexpected continuation "
ASN_DEBUG
(
"Unexpected continuation "
"of a non-extensible type %s"
,
"of a non-extensible type %s"
,
s
d
->
name
);
t
d
->
name
);
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
...
@@ -395,7 +395,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -395,7 +395,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
/*
/*
* Check that all mandatory elements are present.
* Check that all mandatory elements are present.
*/
*/
for
(
edx
=
0
;
edx
<
specs
->
elements_count
;
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
+=
(
8
*
sizeof
(
specs
->
_mandatory_elements
[
0
])))
{
edx
+=
(
8
*
sizeof
(
specs
->
_mandatory_elements
[
0
])))
{
unsigned
int
midx
,
pres
,
must
;
unsigned
int
midx
,
pres
,
must
;
...
@@ -411,7 +411,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -411,7 +411,7 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
ASN_DEBUG
(
"One or more mandatory elements "
ASN_DEBUG
(
"One or more mandatory elements "
"of a SET %s %d (%08x.%08x)=%08x "
"of a SET %s %d (%08x.%08x)=%08x "
"are not present"
,
"are not present"
,
s
d
->
name
,
t
d
->
name
,
midx
,
midx
,
pres
,
pres
,
must
,
must
,
...
@@ -431,13 +431,13 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -431,13 +431,13 @@ SET_decode_ber(asn1_TYPE_descriptor_t *sd,
* The DER encoder of the SET type.
* The DER encoder of the SET type.
*/
*/
der_enc_rval_t
der_enc_rval_t
SET_encode_der
(
asn1_TYPE_descriptor_t
*
s
d
,
SET_encode_der
(
asn1_TYPE_descriptor_t
*
t
d
,
void
*
ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
void
*
ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn1_SET_specifics_t
*
specs
=
(
asn1_SET_specifics_t
*
)
s
d
->
specifics
;
asn1_SET_specifics_t
*
specs
=
(
asn1_SET_specifics_t
*
)
t
d
->
specifics
;
size_t
computed_size
=
0
;
size_t
computed_size
=
0
;
der_enc_rval_t
my_erval
;
der_enc_rval_t
my_erval
;
int
t2m_build_own
=
(
specs
->
tag2el_count
!=
specs
->
elements_count
);
int
t2m_build_own
=
(
specs
->
tag2el_count
!=
td
->
elements_count
);
asn1_TYPE_tag2member_t
*
t2m
;
asn1_TYPE_tag2member_t
*
t2m
;
int
t2m_count
;
int
t2m_count
;
ssize_t
ret
;
ssize_t
ret
;
...
@@ -447,10 +447,10 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -447,10 +447,10 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
* Use existing, or build our own tags map.
* Use existing, or build our own tags map.
*/
*/
if
(
t2m_build_own
)
{
if
(
t2m_build_own
)
{
(
void
*
)
t2m
=
alloca
(
specs
->
elements_count
*
sizeof
(
t2m
[
0
]));
(
void
*
)
t2m
=
alloca
(
td
->
elements_count
*
sizeof
(
t2m
[
0
]));
if
(
!
t2m
)
{
/* There are such platforms */
if
(
!
t2m
)
{
/* There are such platforms */
my_erval
.
encoded
=
-
1
;
my_erval
.
encoded
=
-
1
;
my_erval
.
failed_type
=
s
d
;
my_erval
.
failed_type
=
t
d
;
my_erval
.
structure_ptr
=
ptr
;
my_erval
.
structure_ptr
=
ptr
;
return
my_erval
;
return
my_erval
;
}
}
...
@@ -467,8 +467,8 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -467,8 +467,8 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
/*
/*
* Gather the length of the underlying members sequence.
* Gather the length of the underlying members sequence.
*/
*/
for
(
edx
=
0
;
edx
<
specs
->
elements_count
;
edx
++
)
{
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn1_
SET_element_t
*
elm
=
&
specs
->
elements
[
edx
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
der_enc_rval_t
erval
;
der_enc_rval_t
erval
;
void
*
memb_ptr
;
void
*
memb_ptr
;
...
@@ -513,7 +513,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -513,7 +513,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
/*
/*
* Finalize order of the components.
* Finalize order of the components.
*/
*/
assert
(
t2m_count
==
specs
->
elements_count
);
assert
(
t2m_count
==
td
->
elements_count
);
if
(
t2m_build_own
)
{
if
(
t2m_build_own
)
{
/*
/*
* Sort the underlying members according to their
* Sort the underlying members according to their
...
@@ -529,10 +529,10 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -529,10 +529,10 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
/*
/*
* Encode the TLV for the sequence itself.
* Encode the TLV for the sequence itself.
*/
*/
ret
=
der_write_tags
(
s
d
,
computed_size
,
tag_mode
,
tag
,
cb
,
app_key
);
ret
=
der_write_tags
(
t
d
,
computed_size
,
tag_mode
,
tag
,
cb
,
app_key
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
my_erval
.
encoded
=
-
1
;
my_erval
.
encoded
=
-
1
;
my_erval
.
failed_type
=
s
d
;
my_erval
.
failed_type
=
t
d
;
my_erval
.
structure_ptr
=
ptr
;
my_erval
.
structure_ptr
=
ptr
;
return
my_erval
;
return
my_erval
;
}
}
...
@@ -543,13 +543,13 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -543,13 +543,13 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
/*
/*
* Encode all members.
* Encode all members.
*/
*/
for
(
edx
=
0
;
edx
<
specs
->
elements_count
;
edx
++
)
{
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn1_
SET_element
_t
*
elm
;
asn1_
TYPE_member
_t
*
elm
;
der_enc_rval_t
erval
;
der_enc_rval_t
erval
;
void
*
memb_ptr
;
void
*
memb_ptr
;
/* Encode according to the tag order */
/* Encode according to the tag order */
elm
=
&
specs
->
elements
[
t2m
[
edx
].
el_no
];
elm
=
&
td
->
elements
[
t2m
[
edx
].
el_no
];
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
memb_ptr
=
*
(
void
**
)((
char
*
)
ptr
+
elm
->
memb_offset
);
memb_ptr
=
*
(
void
**
)((
char
*
)
ptr
+
elm
->
memb_offset
);
...
@@ -570,7 +570,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -570,7 +570,7 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
* Encoded size is not equal to the computed size.
* Encoded size is not equal to the computed size.
*/
*/
my_erval
.
encoded
=
-
1
;
my_erval
.
encoded
=
-
1
;
my_erval
.
failed_type
=
s
d
;
my_erval
.
failed_type
=
t
d
;
my_erval
.
structure_ptr
=
ptr
;
my_erval
.
structure_ptr
=
ptr
;
}
}
...
@@ -580,7 +580,6 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
...
@@ -580,7 +580,6 @@ SET_encode_der(asn1_TYPE_descriptor_t *sd,
int
int
SET_print
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
SET_print
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn1_SET_specifics_t
*
specs
=
(
asn1_SET_specifics_t
*
)
td
->
specifics
;
int
edx
;
int
edx
;
int
ret
;
int
ret
;
...
@@ -591,8 +590,8 @@ SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
...
@@ -591,8 +590,8 @@ SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
||
cb
(
" ::= {
\n
"
,
7
,
app_key
))
||
cb
(
" ::= {
\n
"
,
7
,
app_key
))
return
-
1
;
return
-
1
;
for
(
edx
=
0
;
edx
<
specs
->
elements_count
;
edx
++
)
{
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn1_
SET_element_t
*
elm
=
&
specs
->
elements
[
edx
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
const
void
*
memb_ptr
;
const
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
...
@@ -627,7 +626,6 @@ SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
...
@@ -627,7 +626,6 @@ SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
void
void
SET_free
(
asn1_TYPE_descriptor_t
*
td
,
void
*
ptr
,
int
contents_only
)
{
SET_free
(
asn1_TYPE_descriptor_t
*
td
,
void
*
ptr
,
int
contents_only
)
{
asn1_SET_specifics_t
*
specs
=
(
asn1_SET_specifics_t
*
)
td
->
specifics
;
int
edx
;
int
edx
;
if
(
!
td
||
!
ptr
)
if
(
!
td
||
!
ptr
)
...
@@ -635,8 +633,8 @@ SET_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
...
@@ -635,8 +633,8 @@ SET_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
ASN_DEBUG
(
"Freeing %s as SET"
,
td
->
name
);
ASN_DEBUG
(
"Freeing %s as SET"
,
td
->
name
);
for
(
edx
=
0
;
edx
<
specs
->
elements_count
;
edx
++
)
{
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn1_
SET_element_t
*
elm
=
&
specs
->
elements
[
edx
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
void
*
memb_ptr
;
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
memb_ptr
=
*
(
void
**
)((
char
*
)
ptr
+
elm
->
memb_offset
);
memb_ptr
=
*
(
void
**
)((
char
*
)
ptr
+
elm
->
memb_offset
);
...
@@ -668,8 +666,8 @@ SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -668,8 +666,8 @@ SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
/*
/*
* Iterate over structure members and check their validity.
* Iterate over structure members and check their validity.
*/
*/
for
(
edx
=
0
;
edx
<
specs
->
elements_count
;
edx
++
)
{
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
asn1_
SET_element_t
*
elm
=
&
specs
->
elements
[
edx
];
asn1_
TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
const
void
*
memb_ptr
;
const
void
*
memb_ptr
;
if
(
elm
->
optional
)
{
if
(
elm
->
optional
)
{
...
@@ -689,8 +687,20 @@ SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -689,8 +687,20 @@ SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
memb_ptr
=
(
const
void
*
)((
const
char
*
)
sptr
+
elm
->
memb_offset
);
memb_ptr
=
(
const
void
*
)((
const
char
*
)
sptr
+
elm
->
memb_offset
);
}
}
return
elm
->
type
->
check_constraints
(
elm
->
type
,
memb_ptr
,
if
(
elm
->
memb_constraints
)
{
int
ret
=
elm
->
memb_constraints
(
elm
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
app_errlog
,
app_key
);
if
(
ret
)
return
ret
;
}
else
{
int
ret
=
elm
->
type
->
check_constraints
(
elm
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
if
(
ret
)
return
ret
;
/*
* Cannot inherit it earlier:
* need to make sure we get the updated version.
*/
elm
->
memb_constraints
=
elm
->
type
->
check_constraints
;
}
}
}
return
0
;
return
0
;
...
...
skeletons/constr_SET.h
View file @
449f8324
...
@@ -7,18 +7,6 @@
...
@@ -7,18 +7,6 @@
#include <constr_TYPE.h>
#include <constr_TYPE.h>
/*
* Description of a single element of the SET type.
*/
typedef
struct
asn1_SET_element_s
{
int
memb_offset
;
/* Offset of the element */
int
optional
;
/* Whether the element is optional */
ber_tlv_tag_t
tag
;
/* Outmost (most immediate) tag */
int
tag_mode
;
/* IMPLICIT/no/EXPLICIT tag at current level */
asn1_TYPE_descriptor_t
*
type
;
/* Member type descriptor */
char
*
name
;
/* ASN.1 identifier of the element */
}
asn1_SET_element_t
;
typedef
struct
asn1_SET_specifics_s
{
typedef
struct
asn1_SET_specifics_s
{
/*
/*
...
@@ -28,12 +16,6 @@ typedef struct asn1_SET_specifics_s {
...
@@ -28,12 +16,6 @@ typedef struct asn1_SET_specifics_s {
int
ctx_offset
;
/* Offset of the ber_dec_ctx_t member */
int
ctx_offset
;
/* Offset of the ber_dec_ctx_t member */
int
pres_offset
;
/* Offset of _presence_map member */
int
pres_offset
;
/* Offset of _presence_map member */
/*
* Members of the SET structure.
*/
asn1_SET_element_t
*
elements
;
int
elements_count
;
/*
/*
* Tags to members mapping table (sorted).
* Tags to members mapping table (sorted).
*/
*/
...
...
skeletons/constr_SET_OF.c
View file @
449f8324
...
@@ -60,13 +60,13 @@
...
@@ -60,13 +60,13 @@
* The decoder of the SET OF type.
* The decoder of the SET OF type.
*/
*/
ber_dec_rval_t
ber_dec_rval_t
SET_OF_decode_ber
(
asn1_TYPE_descriptor_t
*
s
d
,
SET_OF_decode_ber
(
asn1_TYPE_descriptor_t
*
t
d
,
void
**
struct_ptr
,
void
*
ptr
,
size_t
size
,
int
tag_mode
)
{
void
**
struct_ptr
,
void
*
ptr
,
size_t
size
,
int
tag_mode
)
{
/*
/*
* Bring closer parts of structure description.
* Bring closer parts of structure description.
*/
*/
asn1_SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
s
d
->
specifics
;
asn1_SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
t
d
->
specifics
;
asn1_
SET_OF_element_t
*
element
=
specs
->
element
;
asn1_
TYPE_member_t
*
element
=
td
->
elements
;
/* Single one */
/*
/*
* Parts of the structure being constructed.
* Parts of the structure being constructed.
...
@@ -80,7 +80,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -80,7 +80,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
ASN_DEBUG
(
"Decoding %s as SET OF"
,
s
d
->
name
);
ASN_DEBUG
(
"Decoding %s as SET OF"
,
t
d
->
name
);
/*
/*
* Create the target structure if it is not present already.
* Create the target structure if it is not present already.
...
@@ -108,11 +108,11 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -108,11 +108,11 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
* perfectly fits our expectations.
* perfectly fits our expectations.
*/
*/
rval
=
ber_check_tags
(
s
d
,
ctx
,
ptr
,
size
,
rval
=
ber_check_tags
(
t
d
,
ctx
,
ptr
,
size
,
tag_mode
,
&
ctx
->
left
,
0
);
tag_mode
,
&
ctx
->
left
,
0
);
if
(
rval
.
code
!=
RC_OK
)
{
if
(
rval
.
code
!=
RC_OK
)
{
ASN_DEBUG
(
"%s tagging check failed: %d"
,
ASN_DEBUG
(
"%s tagging check failed: %d"
,
s
d
->
name
,
rval
.
code
);
t
d
->
name
,
rval
.
code
);
consumed_myself
+=
rval
.
consumed
;
consumed_myself
+=
rval
.
consumed
;
RETURN
(
rval
.
code
);
RETURN
(
rval
.
code
);
}
}
...
@@ -143,7 +143,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -143,7 +143,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
*/
*/
if
(
ctx
->
left
==
0
)
{
if
(
ctx
->
left
==
0
)
{
ASN_DEBUG
(
"End of SET OF %s"
,
s
d
->
name
);
ASN_DEBUG
(
"End of SET OF %s"
,
t
d
->
name
);
/*
/*
* No more things to decode.
* No more things to decode.
* Exit out of here.
* Exit out of here.
...
@@ -185,9 +185,9 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -185,9 +185,9 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
*/
*/
}
else
{
}
else
{
ASN_DEBUG
(
"Unexpected tag %s fixed SET OF %s"
,
ASN_DEBUG
(
"Unexpected tag %s fixed SET OF %s"
,
ber_tlv_tag_string
(
tlv_tag
),
s
d
->
name
);
ber_tlv_tag_string
(
tlv_tag
),
t
d
->
name
);
ASN_DEBUG
(
"%s SET OF has tag %s"
,
ASN_DEBUG
(
"%s SET OF has tag %s"
,
s
d
->
name
,
ber_tlv_tag_string
(
element
->
tag
));
t
d
->
name
,
ber_tlv_tag_string
(
element
->
tag
));
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
}
}
...
@@ -204,7 +204,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
...
@@ -204,7 +204,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
rval
=
element
->
type
->
ber_decoder
(
element
->
type
,
rval
=
element
->
type
->
ber_decoder
(
element
->
type
,
&
ctx
->
ptr
,
ptr
,
LEFT
,
0
);
&
ctx
->
ptr
,
ptr
,
LEFT
,
0
);
ASN_DEBUG
(
"In %s SET OF %s code %d consumed %d"
,
ASN_DEBUG
(
"In %s SET OF %s code %d consumed %d"
,
s
d
->
name
,
element
->
type
->
name
,
t
d
->
name
,
element
->
type
->
name
,
rval
.
code
,
(
int
)
rval
.
consumed
);
rval
.
code
,
(
int
)
rval
.
consumed
);
switch
(
rval
.
code
)
{
switch
(
rval
.
code
)
{
case
RC_OK
:
case
RC_OK
:
...
@@ -305,11 +305,10 @@ static int _el_buf_cmp(const void *ap, const void *bp) {
...
@@ -305,11 +305,10 @@ static int _el_buf_cmp(const void *ap, const void *bp) {
* The DER encoder of the SET OF type.
* The DER encoder of the SET OF type.
*/
*/
der_enc_rval_t
der_enc_rval_t
SET_OF_encode_der
(
asn1_TYPE_descriptor_t
*
s
d
,
void
*
ptr
,
SET_OF_encode_der
(
asn1_TYPE_descriptor_t
*
t
d
,
void
*
ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
int
tag_mode
,
ber_tlv_tag_t
tag
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn1_SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
sd
->
specifics
;
asn1_TYPE_member_t
*
elm
=
td
->
elements
;
asn1_SET_OF_element_t
*
elm
=
specs
->
element
;
asn1_TYPE_descriptor_t
*
elm_type
=
elm
->
type
;
asn1_TYPE_descriptor_t
*
elm_type
=
elm
->
type
;
der_type_encoder_f
*
der_encoder
=
elm_type
->
der_encoder
;
der_type_encoder_f
*
der_encoder
=
elm_type
->
der_encoder
;
A_SET_OF
(
void
)
*
list
;
A_SET_OF
(
void
)
*
list
;
...
@@ -321,7 +320,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -321,7 +320,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
int
ret
;
int
ret
;
int
edx
;
int
edx
;
ASN_DEBUG
(
"Estimating size for SET OF %s"
,
s
d
->
name
);
ASN_DEBUG
(
"Estimating size for SET OF %s"
,
t
d
->
name
);
/*
/*
* Gather the length of the underlying members sequence.
* Gather the length of the underlying members sequence.
...
@@ -342,11 +341,11 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -342,11 +341,11 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
/*
/*
* Encode the TLV for the sequence itself.
* Encode the TLV for the sequence itself.
*/
*/
encoding_size
=
der_write_tags
(
s
d
,
computed_size
,
tag_mode
,
tag
,
encoding_size
=
der_write_tags
(
t
d
,
computed_size
,
tag_mode
,
tag
,
cb
,
app_key
);
cb
,
app_key
);
if
(
encoding_size
==
-
1
)
{
if
(
encoding_size
==
-
1
)
{
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
return
erval
;
}
}
...
@@ -365,12 +364,12 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -365,12 +364,12 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
(
void
*
)
encoded_els
=
MALLOC
(
list
->
count
*
sizeof
(
encoded_els
[
0
]));
(
void
*
)
encoded_els
=
MALLOC
(
list
->
count
*
sizeof
(
encoded_els
[
0
]));
if
(
encoded_els
==
NULL
)
{
if
(
encoded_els
==
NULL
)
{
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
return
erval
;
}
}
ASN_DEBUG
(
"Encoding members of %s SET OF"
,
s
d
->
name
);
ASN_DEBUG
(
"Encoding members of %s SET OF"
,
t
d
->
name
);
/*
/*
* Encode all members.
* Encode all members.
...
@@ -391,7 +390,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -391,7 +390,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
FREEMEM
(
encoded_els
[
edx
].
buf
);
FREEMEM
(
encoded_els
[
edx
].
buf
);
FREEMEM
(
encoded_els
);
FREEMEM
(
encoded_els
);
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
return
erval
;
}
}
...
@@ -436,7 +435,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -436,7 +435,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
* encoded size is not equal to the computed size.
* encoded size is not equal to the computed size.
*/
*/
erval
.
encoded
=
-
1
;
erval
.
encoded
=
-
1
;
erval
.
failed_type
=
s
d
;
erval
.
failed_type
=
t
d
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
}
else
{
}
else
{
erval
.
encoded
=
computed_size
;
erval
.
encoded
=
computed_size
;
...
@@ -448,8 +447,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
...
@@ -448,8 +447,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
int
int
SET_OF_print
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
SET_OF_print
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn1_SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
td
->
specifics
;
asn1_TYPE_member_t
*
element
=
td
->
elements
;
asn1_SET_OF_element_t
*
element
=
specs
->
element
;
const
A_SET_OF
(
void
)
*
list
;
const
A_SET_OF
(
void
)
*
list
;
int
ret
;
int
ret
;
int
i
;
int
i
;
...
@@ -486,8 +484,7 @@ SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
...
@@ -486,8 +484,7 @@ SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
void
void
SET_OF_free
(
asn1_TYPE_descriptor_t
*
td
,
void
*
ptr
,
int
contents_only
)
{
SET_OF_free
(
asn1_TYPE_descriptor_t
*
td
,
void
*
ptr
,
int
contents_only
)
{
if
(
td
&&
ptr
)
{
if
(
td
&&
ptr
)
{
asn1_SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
td
->
specifics
;
asn1_TYPE_member_t
*
element
=
td
->
elements
;
asn1_SET_OF_element_t
*
element
=
specs
->
element
;
A_SET_OF
(
void
)
*
list
;
A_SET_OF
(
void
)
*
list
;
int
i
;
int
i
;
...
@@ -514,8 +511,8 @@ SET_OF_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
...
@@ -514,8 +511,8 @@ SET_OF_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
int
int
SET_OF_constraint
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
SET_OF_constraint
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
asn_app_consume_bytes_f
*
app_errlog
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
app_errlog
,
void
*
app_key
)
{
asn1_
SET_OF_specifics_t
*
specs
=
(
asn1_SET_OF_specifics_t
*
)
td
->
specific
s
;
asn1_
TYPE_member_t
*
element
=
td
->
element
s
;
asn
1_SET_OF_element_t
*
element
=
specs
->
element
;
asn
_constr_check_f
*
constr
;
const
A_SET_OF
(
void
)
*
list
;
const
A_SET_OF
(
void
)
*
list
;
int
i
;
int
i
;
...
@@ -526,12 +523,30 @@ SET_OF_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -526,12 +523,30 @@ SET_OF_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
}
(
const
void
*
)
list
=
sptr
;
(
const
void
*
)
list
=
sptr
;
constr
=
element
->
memb_constraints
;
if
(
!
constr
)
constr
=
element
->
type
->
check_constraints
;
/*
* Iterate over the members of an array.
* Validate each in turn, until one fails.
*/
for
(
i
=
0
;
i
<
list
->
count
;
i
++
)
{
for
(
i
=
0
;
i
<
list
->
count
;
i
++
)
{
const
void
*
memb_ptr
=
list
->
array
[
i
];
const
void
*
memb_ptr
=
list
->
array
[
i
];
int
ret
;
if
(
!
memb_ptr
)
continue
;
if
(
!
memb_ptr
)
continue
;
return
element
->
type
->
check_constraints
(
element
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
ret
=
constr
(
element
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
if
(
ret
)
return
ret
;
}
}
/*
* Cannot inherit it eralier:
* need to make sure we get the updated version.
*/
if
(
!
element
->
memb_constraints
)
element
->
memb_constraints
=
element
->
type
->
check_constraints
;
return
0
;
return
0
;
}
}
skeletons/constr_SET_OF.h
View file @
449f8324
...
@@ -7,22 +7,12 @@
...
@@ -7,22 +7,12 @@
#include <constr_TYPE.h>
#include <constr_TYPE.h>
typedef
struct
asn1_SET_OF_element_s
{
ber_tlv_tag_t
tag
;
/* Outmost (most immediate) tag */
asn1_TYPE_descriptor_t
*
type
;
/* Member type descriptor */
}
asn1_SET_OF_element_t
;
typedef
struct
asn1_SET_OF_specifics_s
{
typedef
struct
asn1_SET_OF_specifics_s
{
/*
/*
* Target structure description.
* Target structure description.
*/
*/
int
struct_size
;
/* Size of the target structure. */
int
struct_size
;
/* Size of the target structure. */
int
ctx_offset
;
/* Offset of the ber_dec_ctx_t member */
int
ctx_offset
;
/* Offset of the ber_dec_ctx_t member */
/*
* Members of the SET OF list.
*/
asn1_SET_OF_element_t
*
element
;
}
asn1_SET_OF_specifics_t
;
}
asn1_SET_OF_specifics_t
;
/*
/*
...
...
skeletons/constr_TYPE.h
View file @
449f8324
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <constraints.h>
#include <constraints.h>
struct
asn1_TYPE_descriptor_s
;
/* Forward declaration */
struct
asn1_TYPE_descriptor_s
;
/* Forward declaration */
struct
asn1_TYPE_member_s
;
/* Forward declaration */
/*
/*
* Free the structure according to its specification.
* Free the structure according to its specification.
...
@@ -43,7 +44,7 @@ typedef int (asn_struct_print_f)(
...
@@ -43,7 +44,7 @@ typedef int (asn_struct_print_f)(
typedef
ber_tlv_tag_t
(
asn_outmost_tag_f
)(
typedef
ber_tlv_tag_t
(
asn_outmost_tag_f
)(
struct
asn1_TYPE_descriptor_s
*
type_descriptor
,
struct
asn1_TYPE_descriptor_s
*
type_descriptor
,
const
void
*
struct_ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
);
const
void
*
struct_ptr
,
int
tag_mode
,
ber_tlv_tag_t
tag
);
/* The instance of the above function type */
/* The instance of the above function type
; used internally.
*/
asn_outmost_tag_f
asn1_TYPE_outmost_tag
;
asn_outmost_tag_f
asn1_TYPE_outmost_tag
;
...
@@ -76,6 +77,12 @@ typedef struct asn1_TYPE_descriptor_s {
...
@@ -76,6 +77,12 @@ typedef struct asn1_TYPE_descriptor_s {
int
tags_impl_skip
;
/* Tags to skip in implicit mode */
int
tags_impl_skip
;
/* Tags to skip in implicit mode */
int
last_tag_form
;
/* Acceptable form of the tag (prim, constr) */
int
last_tag_form
;
/* Acceptable form of the tag (prim, constr) */
/*
* An ASN.1 production type members (members of SEQUENCE, SET, CHOICE).
*/
struct
asn1_TYPE_member_s
*
elements
;
int
elements_count
;
/*
/*
* Additional information describing the type, used by appropriate
* Additional information describing the type, used by appropriate
* functions above.
* functions above.
...
@@ -83,6 +90,19 @@ typedef struct asn1_TYPE_descriptor_s {
...
@@ -83,6 +90,19 @@ typedef struct asn1_TYPE_descriptor_s {
void
*
specifics
;
void
*
specifics
;
}
asn1_TYPE_descriptor_t
;
}
asn1_TYPE_descriptor_t
;
/*
* An element of the constructed type, i.e. SEQUENCE, SET, CHOICE.
*/
typedef
struct
asn1_TYPE_member_s
{
int
optional
;
/* Whether the element is optional */
int
memb_offset
;
/* Offset of the element */
ber_tlv_tag_t
tag
;
/* Outmost (most immediate) tag */
int
tag_mode
;
/* IMPLICIT/no/EXPLICIT tag at current level */
asn1_TYPE_descriptor_t
*
type
;
/* Member type descriptor */
asn_constr_check_f
*
memb_constraints
;
/* Constraints validator */
char
*
name
;
/* ASN.1 identifier of the element */
}
asn1_TYPE_member_t
;
/*
/*
* BER tag to element number mapping.
* BER tag to element number mapping.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment