aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2004-08-25 02:08:08 +0000
committerLev Walkin <vlm@lionet.info>2004-08-25 02:08:08 +0000
commitd35c8b56c092bb4c8396c0ef4a58a8a54dfd7dd0 (patch)
treedb0305527f71cf1adbeef57ad6f4e7bd3427843a
parent51c38237b38cd7c2a77a7ce296d60a6257c5794c (diff)
practical constraints have relaxed PER visibility rules
-rw-r--r--tests/50-constraint-OK.asn11
-rw-r--r--tests/50-constraint-OK.asn1.-EFprint-constraintsbin3624 -> 5033 bytes
-rw-r--r--tests/50-constraint-OK.asn1.-P128
3 files changed, 90 insertions, 39 deletions
diff --git a/tests/50-constraint-OK.asn1 b/tests/50-constraint-OK.asn1
index 0ae7689c..210c69de 100644
--- a/tests/50-constraint-OK.asn1
+++ b/tests/50-constraint-OK.asn1
@@ -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",...))
diff --git a/tests/50-constraint-OK.asn1.-EFprint-constraints b/tests/50-constraint-OK.asn1.-EFprint-constraints
index 11e8d3d3..2c957548 100644
--- a/tests/50-constraint-OK.asn1.-EFprint-constraints
+++ b/tests/50-constraint-OK.asn1.-EFprint-constraints
Binary files differ
diff --git a/tests/50-constraint-OK.asn1.-P b/tests/50-constraint-OK.asn1.-P
index 059f64e3..591ce0f9 100644
--- a/tests/50-constraint-OK.asn1.-P
+++ b/tests/50-constraint-OK.asn1.-P
@@ -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 {