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
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
Admin message
Maintenance operation of our GitLab server is scheduled for Wednesday, April 16, 2025, at 2PM.
Show more breadcrumbs
oai
asn1c
Commits
d35c8b56
Commit
d35c8b56
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
practical constraints have relaxed PER visibility rules
parent
51c38237
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/50-constraint-OK.asn1
+1
-0
1 addition, 0 deletions
tests/50-constraint-OK.asn1
tests/50-constraint-OK.asn1.-EFprint-constraints
+0
-0
0 additions, 0 deletions
tests/50-constraint-OK.asn1.-EFprint-constraints
tests/50-constraint-OK.asn1.-P
+89
-39
89 additions, 39 deletions
tests/50-constraint-OK.asn1.-P
with
90 additions
and
39 deletions
tests/50-constraint-OK.asn1
+
1
−
0
View file @
d35c8b56
...
...
@@ -35,6 +35,7 @@ BEGIN
Not-PER-Visible-1 ::= PER-Visible (FROM("AB") | SIZE(1..2))
Not-PER-Visible-2 ::= PER-Visible (FROM("AB",...))
Not-PER-Visible-3 ::= PER-Visible (FROM("AB"),...)
SIZE-but-not-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD",...))
SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
Neither-SIZE-nor-FROM ::= PER-Visible (SIZE(1..4) | FROM("ABCD",...))
...
...
This diff is collapsed.
Click to expand it.
tests/50-constraint-OK.asn1.-EFprint-constraints
+
0
−
0
View file @
d35c8b56
No preview for this file type
This diff is collapsed.
Click to expand it.
tests/50-constraint-OK.asn1.-P
+
89
−
39
View file @
d35c8b56
...
...
@@ -368,6 +368,7 @@ Int4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
const Int3_t *st = sptr;
long value;
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
...
...
@@ -376,15 +377,22 @@ Int4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
if(1 /* No applicable constraints whatsoever */) {
/* Nothing is here. See below */
if(asn1_INTEGER2long(st, &value)) {
_ASN_ERRLOG(app_errlog, app_key,
"%s: value too large (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
/* Make the underlying type checker permanent */
td->check_constraints = asn1_DEF_Int3.check_constraints;
return td->check_constraints
(td, sptr, app_errlog, app_key);
if((value >= 1 && value <= 10)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*
...
...
@@ -604,6 +612,7 @@ ExtensibleExtensions_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
const INTEGER_t *st = sptr;
long value;
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
...
...
@@ -612,15 +621,22 @@ ExtensibleExtensions_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
if(1 /* No applicable constraints whatsoever */) {
/* Nothing is here. See below */
if(asn1_INTEGER2long(st, &value)) {
_ASN_ERRLOG(app_errlog, app_key,
"%s: value too large (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
/* Make the underlying type checker permanent */
td->check_constraints = asn1_DEF_INTEGER.check_constraints;
return td->check_constraints
(td, sptr, app_errlog, app_key);
if((value >= 1 && value <= 256)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*
...
...
@@ -1483,6 +1499,22 @@ der_type_encoder_f Not_PER_Visible_2_encode_der;
asn_struct_print_f Not_PER_Visible_2_print;
asn_struct_free_f Not_PER_Visible_2_free;
/*** <<< CTABLES [Not-PER-Visible-2] >>> ***/
static int check_permitted_alphabet_6(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!(cv >= 65 && cv <= 66)) return -1;
}
return 0;
}
/*** <<< CODE [Not-PER-Visible-2] >>> ***/
int
...
...
@@ -1499,14 +1531,15 @@ Not_PER_Visible_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(1 /* No applicable constraints whatsoever */) {
/* Nothing is here. See below */
if(!check_permitted_alphabet_6(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
/* Make the underlying type checker permanent */
td->check_constraints = asn1_DEF_PER_Visible.check_constraints;
return td->check_constraints
(td, sptr, app_errlog, app_key);
}
/*
...
...
@@ -1597,6 +1630,22 @@ der_type_encoder_f Not_PER_Visible_3_encode_der;
asn_struct_print_f Not_PER_Visible_3_print;
asn_struct_free_f Not_PER_Visible_3_free;
/*** <<< CTABLES [Not-PER-Visible-3] >>> ***/
static int check_permitted_alphabet_7(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!(cv >= 65 && cv <= 66)) return -1;
}
return 0;
}
/*** <<< CODE [Not-PER-Visible-3] >>> ***/
int
...
...
@@ -1613,14 +1662,15 @@ Not_PER_Visible_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(1 /* No applicable constraints whatsoever */) {
/* Nothing is here. See below */
if(!check_permitted_alphabet_7(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
/* Make the underlying type checker permanent */
td->check_constraints = asn1_DEF_PER_Visible.check_constraints;
return td->check_constraints
(td, sptr, app_errlog, app_key);
}
/*
...
...
@@ -1713,7 +1763,7 @@ asn_struct_free_f SIZE_but_not_FROM_free;
/*** <<< CTABLES [SIZE-but-not-FROM] >>> ***/
static int check_permitted_alphabet_
6
(const void *sptr) {
static int check_permitted_alphabet_
8
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1721,7 +1771,7 @@ static int check_permitted_alphabet_6(const void *sptr) {
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!(cv >= 65 && cv <=
70
)) return -1;
if(!(cv >= 65 && cv <=
68
)) return -1;
}
return 0;
}
...
...
@@ -1746,7 +1796,7 @@ SIZE_but_not_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
size = st->size;
if((size >= 1 && size <= 4)
&& !check_permitted_alphabet_
6
(sptr)) {
&& !check_permitted_alphabet_
8
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1847,7 +1897,7 @@ asn_struct_free_f SIZE_and_FROM_free;
/*** <<< CTABLES [SIZE-and-FROM] >>> ***/
static int check_permitted_alphabet_
7
(const void *sptr) {
static int check_permitted_alphabet_
9
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1880,7 +1930,7 @@ SIZE_and_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
size = st->size;
if((size >= 1 && size <= 4)
&& !check_permitted_alphabet_
7
(sptr)) {
&& !check_permitted_alphabet_
9
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1981,7 +2031,7 @@ asn_struct_free_f Neither_SIZE_nor_FROM_free;
/*** <<< CTABLES [Neither-SIZE-nor-FROM] >>> ***/
static int check_permitted_alphabet_
8
(const void *sptr) {
static int check_permitted_alphabet_
10
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -2011,7 +2061,7 @@ Neither_SIZE_nor_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_
8
(sptr)) {
if(!check_permitted_alphabet_
10
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -2112,7 +2162,7 @@ asn_struct_free_f Utf8_3_free;
/*** <<< CTABLES [Utf8-3] >>> ***/
static int permitted_alphabet_table_
9
[128] = {
static int permitted_alphabet_table_
11
[128] = {
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,0,0,0,0, /* */
...
...
@@ -2123,8 +2173,8 @@ static int permitted_alphabet_table_9[128] = {
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* pqrstuvwxyz */
};
static int check_permitted_alphabet_
9
(const void *sptr) {
int *table = permitted_alphabet_table_
9
;
static int check_permitted_alphabet_
11
(const void *sptr) {
int *table = permitted_alphabet_table_
11
;
/* The underlying type is UTF8String */
const UTF8String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -2159,7 +2209,7 @@ Utf8_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
if(size == (size_t)-1) return -1;
if((size >= 1 && size <= 2)
&& !check_permitted_alphabet_
9
(sptr)) {
&& !check_permitted_alphabet_
11
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
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