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
Show more breadcrumbs
oai
asn1c
Commits
daa7d2b0
Commit
daa7d2b0
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
support for constraints
parent
d541c25a
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/19-param-OK.asn1
+1
-1
1 addition, 1 deletion
tests/19-param-OK.asn1
tests/19-param-OK.asn1.-EF
+3
-3
3 additions, 3 deletions
tests/19-param-OK.asn1.-EF
tests/19-param-OK.asn1.-P
+38
-4
38 additions, 4 deletions
tests/19-param-OK.asn1.-P
with
42 additions
and
8 deletions
tests/19-param-OK.asn1
+
1
−
1
View file @
daa7d2b0
...
...
@@ -14,7 +14,7 @@ BEGIN
SIGNED { ToBeSigned } ::= SEQUENCE {
toBeSigned ToBeSigned,
algorithm OBJECT IDENTIFIER,
signature BIT STRING
signature BIT STRING
SIZE(0..256)
}
Certificate ::= SIGNED { SEQUENCE {
...
...
This diff is collapsed.
Click to expand it.
tests/19-param-OK.asn1.-EF
+
3
−
3
View file @
daa7d2b0
ModuleTestParam {iso
(-1)
org(3) dod(6) internet(1) private(4)
ModuleTestParam {iso org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1)
19 }
DEFINITIONS ::=
...
...
@@ -8,7 +8,7 @@ BEGIN
SIGNED{ToBeSigned} ::= SEQUENCE {
toBeSigned ToBeSigned,
algorithm OBJECT IDENTIFIER,
signature BIT STRING
signature BIT STRING
SIZE(0..256)
}
Certificate ::= SEQUENCE {
...
...
@@ -18,7 +18,7 @@ Certificate ::= SEQUENCE {
issuer Name
},
algorithm OBJECT IDENTIFIER,
signature BIT STRING
signature BIT STRING
SIZE(0..256)
}
Name ::= SEQUENCE OF RelativeDistinguishedName
...
...
This diff is collapsed.
Click to expand it.
tests/19-param-OK.asn1.-P
+
38
−
4
View file @
daa7d2b0
...
...
@@ -30,6 +30,40 @@ typedef struct Certificate {
ber_dec_ctx_t _ber_dec_ctx;
} Certificate_t;
/*** <<< CODE [Certificate] >>> ***/
static int
memb_signature_1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
const BIT_STRING_t *st = sptr;
size_t size;
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(st->size > 0) {
/* Size in bits */
size = 8 * (st->size - 1) - (st->buf[0] & 0x7);
} else {
size = 0;
}
if((size <= 256)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*** <<< STAT-DEFS [Certificate] >>> ***/
static asn1_TYPE_member_t asn1_MBR_toBeSigned[] = {
...
...
@@ -108,7 +142,7 @@ static asn1_TYPE_member_t asn1_MBR_Certificate[] = {
.tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_BIT_STRING,
.memb_constraints =
0, /* Defer to actual type */
.memb_constraints =
memb_signature_1_constraint,
.name = "signature"
},
};
...
...
@@ -116,7 +150,7 @@ 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 1
8
*/
{ (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature at 1
7
*/
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* toBeSigned at 21 */
};
...
...
@@ -255,7 +289,7 @@ static int check_permitted_alphabet_1(const void *sptr) {
/*** <<< CODE [RelativeDistinguishedName] >>> ***/
static int
memb_IA5String_
1
_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
memb_IA5String_
2
_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
const IA5String_t *st = sptr;
...
...
@@ -286,7 +320,7 @@ static asn1_TYPE_member_t asn1_MBR_RelativeDistinguishedName[] = {
.tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_IA5String,
.memb_constraints = memb_IA5String_
1
_constraint,
.memb_constraints = memb_IA5String_
2
_constraint,
.name = ""
},
};
...
...
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