Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asn1c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
qwebaby3
asn1c
Commits
006de1c0
Commit
006de1c0
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
new test files
parent
59004fad
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/19-param-OK.asn1.-EF
+28
-0
28 additions, 0 deletions
tests/19-param-OK.asn1.-EF
tests/19-param-OK.asn1.-P
+315
-0
315 additions, 0 deletions
tests/19-param-OK.asn1.-P
tests/50-constraint-OK.asn1.-P
+2446
-0
2446 additions, 0 deletions
tests/50-constraint-OK.asn1.-P
with
2789 additions
and
0 deletions
tests/19-param-OK.asn1.-EF
0 → 100644
+
28
−
0
View file @
006de1c0
ModuleTestParam {iso(-1) org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
19 }
DEFINITIONS ::=
BEGIN
SIGNED{ToBeSigned} ::= SEQUENCE {
toBeSigned ToBeSigned,
algorithm OBJECT IDENTIFIER,
signature BIT STRING
}
Certificate ::= SEQUENCE {
toBeSigned SEQUENCE {
version INTEGER,
signature OBJECT IDENTIFIER,
issuer Name
},
algorithm OBJECT IDENTIFIER,
signature BIT STRING
}
Name ::= SEQUENCE OF RelativeDistinguishedName
RelativeDistinguishedName ::= SET SIZE(1..MAX) OF IA5String (FROM("A".."Z" | "a".."z" | "0-9" | ",-."))
END
This diff is collapsed.
Click to expand it.
tests/19-param-OK.asn1.-P
0 → 100644
+
315
−
0
View file @
006de1c0
/*** <<< INCLUDES [Certificate] >>> ***/
#include <OBJECT_IDENTIFIER.h>
#include <BIT_STRING.h>
#include <INTEGER.h>
#include <Name.h>
#include <constr_SEQUENCE.h>
/*** <<< DEPS [Certificate] >>> ***/
extern asn1_TYPE_descriptor_t asn1_DEF_Certificate;
/*** <<< TYPE-DECLS [Certificate] >>> ***/
typedef struct Certificate {
struct toBeSigned {
INTEGER_t version;
OBJECT_IDENTIFIER_t signature;
Name_t issuer;
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} toBeSigned;
OBJECT_IDENTIFIER_t algorithm;
BIT_STRING_t signature;
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} Certificate_t;
/*** <<< STAT-DEFS [Certificate] >>> ***/
static asn1_TYPE_member_t asn1_MBR_toBeSigned[] = {
{ 0, offsetof(struct toBeSigned, version),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_INTEGER,
.memb_constraints = 0, /* Defer to actual type */
.name = "version"
},
{ 0, offsetof(struct toBeSigned, signature),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_OBJECT_IDENTIFIER,
.memb_constraints = 0, /* Defer to actual type */
.name = "signature"
},
{ 0, offsetof(struct toBeSigned, issuer),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_Name,
.memb_constraints = 0, /* Defer to actual type */
.name = "issuer"
},
};
static ber_tlv_tag_t asn1_DEF_toBeSigned_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn1_TYPE_tag2member_t asn1_DEF_toBeSigned_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* version at 21 */
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* signature at 22 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 2, 0, 0 }, /* issuer at 24 */
};
static asn1_SEQUENCE_specifics_t asn1_DEF_toBeSigned_specs = {
sizeof(struct toBeSigned),
offsetof(struct toBeSigned, _ber_dec_ctx),
asn1_DEF_toBeSigned_tag2el,
3, /* Count of tags in the map */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn1_TYPE_descriptor_t asn1_DEF_toBeSigned = {
"toBeSigned",
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_print,
SEQUENCE_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_toBeSigned_tags,
sizeof(asn1_DEF_toBeSigned_tags)
/sizeof(asn1_DEF_toBeSigned_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_toBeSigned,
3, /* Elements count */
&asn1_DEF_toBeSigned_specs /* Additional specs */
};
static asn1_TYPE_member_t asn1_MBR_Certificate[] = {
{ 0, offsetof(struct Certificate, toBeSigned),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_toBeSigned,
.memb_constraints = 0, /* Defer to actual type */
.name = "toBeSigned"
},
{ 0, offsetof(struct Certificate, algorithm),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_OBJECT_IDENTIFIER,
.memb_constraints = 0, /* Defer to actual type */
.name = "algorithm"
},
{ 0, offsetof(struct Certificate, signature),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_BIT_STRING,
.memb_constraints = 0, /* Defer to actual type */
.name = "signature"
},
};
static ber_tlv_tag_t asn1_DEF_Certificate_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn1_TYPE_tag2member_t asn1_DEF_Certificate_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature at 18 */
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* toBeSigned at 21 */
};
static asn1_SEQUENCE_specifics_t asn1_DEF_Certificate_specs = {
sizeof(struct Certificate),
offsetof(struct Certificate, _ber_dec_ctx),
asn1_DEF_Certificate_tag2el,
3, /* Count of tags in the map */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn1_TYPE_descriptor_t asn1_DEF_Certificate = {
"Certificate",
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_print,
SEQUENCE_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_Certificate_tags,
sizeof(asn1_DEF_Certificate_tags)
/sizeof(asn1_DEF_Certificate_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_Certificate,
3, /* Elements count */
&asn1_DEF_Certificate_specs /* Additional specs */
};
/*** <<< INCLUDES [Name] >>> ***/
#include <RelativeDistinguishedName.h>
#include <asn_SEQUENCE_OF.h>
#include <constr_SEQUENCE_OF.h>
/*** <<< DEPS [Name] >>> ***/
extern asn1_TYPE_descriptor_t asn1_DEF_Name;
/*** <<< TYPE-DECLS [Name] >>> ***/
typedef struct Name {
A_SEQUENCE_OF(struct RelativeDistinguishedName) list;
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} Name_t;
/*** <<< STAT-DEFS [Name] >>> ***/
static asn1_TYPE_member_t asn1_MBR_Name[] = {
{ 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_RelativeDistinguishedName,
.memb_constraints = 0, /* Defer to actual type */
.name = ""
},
};
static ber_tlv_tag_t asn1_DEF_Name_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn1_SET_OF_specifics_t asn1_DEF_Name_specs = {
sizeof(struct Name),
offsetof(struct Name, _ber_dec_ctx),
};
asn1_TYPE_descriptor_t asn1_DEF_Name = {
"Name",
SEQUENCE_OF_constraint,
SEQUENCE_OF_decode_ber,
SEQUENCE_OF_encode_der,
SEQUENCE_OF_print,
SEQUENCE_OF_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_Name_tags,
sizeof(asn1_DEF_Name_tags)
/sizeof(asn1_DEF_Name_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_Name,
1, /* Single element */
&asn1_DEF_Name_specs /* Additional specs */
};
/*** <<< INCLUDES [RelativeDistinguishedName] >>> ***/
#include <IA5String.h>
#include <asn_SET_OF.h>
#include <constr_SET_OF.h>
/*** <<< DEPS [RelativeDistinguishedName] >>> ***/
extern asn1_TYPE_descriptor_t asn1_DEF_RelativeDistinguishedName;
/*** <<< TYPE-DECLS [RelativeDistinguishedName] >>> ***/
typedef struct RelativeDistinguishedName {
A_SET_OF(IA5String_t) list;
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} RelativeDistinguishedName_t;
/*** <<< CTABLES [RelativeDistinguishedName] >>> ***/
static int permitted_alphabet_table_1[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, /* ,-. */
1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0, /* 0 9 */
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ABCDEFGHIJKLMNO */
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* PQRSTUVWXYZ */
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* abcdefghijklmno */
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* pqrstuvwxyz */
};
static int check_permitted_alphabet_1(const void *sptr) {
int *table = permitted_alphabet_table_1;
/* The underlying type is IA5String */
const (null)_t *st = sptr;
uint8_t *ch = st->buf;
uint8_t *end = ch + st->size;
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!table[cv]) return 0;
}
return 1;
}
/*** <<< CODE [RelativeDistinguishedName] >>> ***/
static int
memb_IA5String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
const (null)_t *st = sptr;
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
"%s: value not given", td->name);
return -1;
}
if(check_permitted_alphabet_1(sptr)) {
/* Constraint check succeeded */
return 1;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed", td->name);
return -1;
}
}
/*** <<< STAT-DEFS [RelativeDistinguishedName] >>> ***/
static asn1_TYPE_member_t asn1_MBR_RelativeDistinguishedName[] = {
{ 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_IA5String,
.memb_constraints = memb_IA5String_constraint,
.name = ""
},
};
static ber_tlv_tag_t asn1_DEF_RelativeDistinguishedName_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn1_SET_OF_specifics_t asn1_DEF_RelativeDistinguishedName_specs = {
sizeof(struct RelativeDistinguishedName),
offsetof(struct RelativeDistinguishedName, _ber_dec_ctx),
};
asn1_TYPE_descriptor_t asn1_DEF_RelativeDistinguishedName = {
"RelativeDistinguishedName",
SET_OF_constraint,
SET_OF_decode_ber,
SET_OF_encode_der,
SET_OF_print,
SET_OF_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_RelativeDistinguishedName_tags,
sizeof(asn1_DEF_RelativeDistinguishedName_tags)
/sizeof(asn1_DEF_RelativeDistinguishedName_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_RelativeDistinguishedName,
1, /* Single element */
&asn1_DEF_RelativeDistinguishedName_specs /* Additional specs */
};
This diff is collapsed.
Click to expand it.
tests/50-constraint-OK.asn1.-P
0 → 100644
+
2446
−
0
View file @
006de1c0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment