asn1c/tests/19-param-OK.asn1.-P

367 lines
10 KiB
Plaintext
Raw Normal View History

2004-08-20 13:37:45 +00:00
/*** <<< INCLUDES [Certificate] >>> ***/
#include <OBJECT_IDENTIFIER.h>
#include <BIT_STRING.h>
#include <INTEGER.h>
#include <Name.h>
#include <constr_SEQUENCE.h>
/*** <<< DEPS [Certificate] >>> ***/
2004-09-29 13:19:37 +00:00
extern asn_TYPE_descriptor_t asn_DEF_Certificate;
2004-08-20 13:37:45 +00:00
/*** <<< TYPE-DECLS [Certificate] >>> ***/
typedef struct Certificate {
struct toBeSigned {
INTEGER_t version;
OBJECT_IDENTIFIER_t signature;
Name_t issuer;
/* Context for parsing across buffer boundaries */
2004-09-29 13:19:37 +00:00
asn_struct_ctx_t _asn_ctx;
2004-08-20 13:37:45 +00:00
} toBeSigned;
OBJECT_IDENTIFIER_t algorithm;
BIT_STRING_t signature;
/* Context for parsing across buffer boundaries */
2004-09-29 13:19:37 +00:00
asn_struct_ctx_t _asn_ctx;
2004-08-20 13:37:45 +00:00
} Certificate_t;
2004-09-05 10:37:18 +00:00
/*** <<< CODE [Certificate] >>> ***/
static int
2004-09-29 13:19:37 +00:00
memb_signature_1_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
2004-09-05 10:37:18 +00:00
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;
}
}
2004-08-20 13:37:45 +00:00
/*** <<< STAT-DEFS [Certificate] >>> ***/
2004-09-29 13:19:37 +00:00
static asn_TYPE_member_t asn_MBR_toBeSigned[] = {
{ ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version),
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_INTEGER,
2004-08-20 13:37:45 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = "version"
},
{ ATF_NOFLAGS, 0, offsetof(struct toBeSigned, signature),
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_OBJECT_IDENTIFIER,
2004-08-20 13:37:45 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = "signature"
},
{ ATF_NOFLAGS, 0, offsetof(struct toBeSigned, issuer),
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_Name,
2004-08-20 13:37:45 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = "issuer"
},
};
2004-09-29 13:19:37 +00:00
static ber_tlv_tag_t asn_DEF_toBeSigned_tags[] = {
2004-08-20 13:37:45 +00:00
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
2004-09-29 13:19:37 +00:00
static asn_TYPE_tag2member_t asn_DEF_toBeSigned_tag2el[] = {
2004-08-20 13:37:45 +00:00
{ (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 */
};
2004-09-29 13:19:37 +00:00
static asn_SEQUENCE_specifics_t asn_DEF_toBeSigned_specs = {
2004-08-20 13:37:45 +00:00
sizeof(struct toBeSigned),
2004-09-29 13:19:37 +00:00
offsetof(struct toBeSigned, _asn_ctx),
asn_DEF_toBeSigned_tag2el,
2004-08-20 13:37:45 +00:00
3, /* Count of tags in the map */
-1, /* Start extensions */
-1 /* Stop extensions */
};
2004-09-07 06:44:29 +00:00
static /* Use -fall-defs-global to expose */
2004-09-29 13:19:37 +00:00
asn_TYPE_descriptor_t asn_DEF_toBeSigned = {
2004-08-20 13:37:45 +00:00
"toBeSigned",
2004-09-22 16:06:28 +00:00
SEQUENCE_free,
SEQUENCE_print,
2004-08-20 13:37:45 +00:00
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
2004-09-22 16:06:28 +00:00
0, /* Not implemented yet */
SEQUENCE_encode_xer,
2004-08-20 13:37:45 +00:00
0, /* Use generic outmost tag fetcher */
2004-09-29 13:19:37 +00:00
asn_DEF_toBeSigned_tags,
sizeof(asn_DEF_toBeSigned_tags)
/sizeof(asn_DEF_toBeSigned_tags[0]), /* 1 */
asn_DEF_toBeSigned_tags, /* Same as above */
sizeof(asn_DEF_toBeSigned_tags)
/sizeof(asn_DEF_toBeSigned_tags[0]), /* 1 */
asn_MBR_toBeSigned,
2004-08-20 13:37:45 +00:00
3, /* Elements count */
2004-09-29 13:19:37 +00:00
&asn_DEF_toBeSigned_specs /* Additional specs */
2004-08-20 13:37:45 +00:00
};
2004-09-29 13:19:37 +00:00
static asn_TYPE_member_t asn_MBR_Certificate[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, toBeSigned),
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_toBeSigned,
2004-08-20 13:37:45 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = "toBeSigned"
},
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, algorithm),
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_OBJECT_IDENTIFIER,
2004-08-20 13:37:45 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = "algorithm"
},
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, signature),
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_BIT_STRING,
2004-09-05 10:37:18 +00:00
.memb_constraints = memb_signature_1_constraint,
2004-08-20 13:37:45 +00:00
.name = "signature"
},
};
2004-09-29 13:19:37 +00:00
static ber_tlv_tag_t asn_DEF_Certificate_tags[] = {
2004-08-20 13:37:45 +00:00
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
2004-09-29 13:19:37 +00:00
static asn_TYPE_tag2member_t asn_DEF_Certificate_tag2el[] = {
2004-09-05 10:37:18 +00:00
{ (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature at 17 */
2004-08-20 13:37:45 +00:00
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* toBeSigned at 21 */
};
2004-09-29 13:19:37 +00:00
static asn_SEQUENCE_specifics_t asn_DEF_Certificate_specs = {
2004-08-20 13:37:45 +00:00
sizeof(struct Certificate),
2004-09-29 13:19:37 +00:00
offsetof(struct Certificate, _asn_ctx),
asn_DEF_Certificate_tag2el,
2004-08-20 13:37:45 +00:00
3, /* Count of tags in the map */
-1, /* Start extensions */
-1 /* Stop extensions */
};
2004-09-29 13:19:37 +00:00
asn_TYPE_descriptor_t asn_DEF_Certificate = {
2004-08-20 13:37:45 +00:00
"Certificate",
2004-09-22 16:06:28 +00:00
SEQUENCE_free,
SEQUENCE_print,
2004-08-20 13:37:45 +00:00
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
2004-09-22 16:06:28 +00:00
0, /* Not implemented yet */
SEQUENCE_encode_xer,
2004-08-20 13:37:45 +00:00
0, /* Use generic outmost tag fetcher */
2004-09-29 13:19:37 +00:00
asn_DEF_Certificate_tags,
sizeof(asn_DEF_Certificate_tags)
/sizeof(asn_DEF_Certificate_tags[0]), /* 1 */
asn_DEF_Certificate_tags, /* Same as above */
sizeof(asn_DEF_Certificate_tags)
/sizeof(asn_DEF_Certificate_tags[0]), /* 1 */
asn_MBR_Certificate,
2004-08-20 13:37:45 +00:00
3, /* Elements count */
2004-09-29 13:19:37 +00:00
&asn_DEF_Certificate_specs /* Additional specs */
2004-08-20 13:37:45 +00:00
};
/*** <<< INCLUDES [Name] >>> ***/
#include <RelativeDistinguishedName.h>
#include <asn_SEQUENCE_OF.h>
#include <constr_SEQUENCE_OF.h>
/*** <<< DEPS [Name] >>> ***/
2004-09-29 13:19:37 +00:00
extern asn_TYPE_descriptor_t asn_DEF_Name;
2004-08-20 13:37:45 +00:00
/*** <<< TYPE-DECLS [Name] >>> ***/
typedef struct Name {
2004-09-17 06:32:12 +00:00
A_SEQUENCE_OF(RelativeDistinguishedName_t) list;
2004-08-20 13:37:45 +00:00
/* Context for parsing across buffer boundaries */
2004-09-29 13:19:37 +00:00
asn_struct_ctx_t _asn_ctx;
2004-08-20 13:37:45 +00:00
} Name_t;
/*** <<< STAT-DEFS [Name] >>> ***/
2004-09-29 13:19:37 +00:00
static asn_TYPE_member_t asn_MBR_Name[] = {
{ ATF_NOFLAGS, 0, 0,
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_RelativeDistinguishedName,
2004-08-20 13:37:45 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = ""
},
};
2004-09-29 13:19:37 +00:00
static ber_tlv_tag_t asn_DEF_Name_tags[] = {
2004-08-20 13:37:45 +00:00
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
2004-09-29 13:19:37 +00:00
static asn_SET_OF_specifics_t asn_DEF_Name_specs = {
2004-08-20 13:37:45 +00:00
sizeof(struct Name),
2004-09-29 13:19:37 +00:00
offsetof(struct Name, _asn_ctx),
2004-09-22 16:06:28 +00:00
0, /* XER encoding is XMLDelimitedItemList */
2004-08-20 13:37:45 +00:00
};
2004-09-29 13:19:37 +00:00
asn_TYPE_descriptor_t asn_DEF_Name = {
2004-08-20 13:37:45 +00:00
"Name",
2004-09-22 16:06:28 +00:00
SEQUENCE_OF_free,
SEQUENCE_OF_print,
2004-08-20 13:37:45 +00:00
SEQUENCE_OF_constraint,
SEQUENCE_OF_decode_ber,
SEQUENCE_OF_encode_der,
2004-09-22 16:06:28 +00:00
0, /* Not implemented yet */
SEQUENCE_OF_encode_xer,
2004-08-20 13:37:45 +00:00
0, /* Use generic outmost tag fetcher */
2004-09-29 13:19:37 +00:00
asn_DEF_Name_tags,
sizeof(asn_DEF_Name_tags)
/sizeof(asn_DEF_Name_tags[0]), /* 1 */
asn_DEF_Name_tags, /* Same as above */
sizeof(asn_DEF_Name_tags)
/sizeof(asn_DEF_Name_tags[0]), /* 1 */
asn_MBR_Name,
2004-08-20 13:37:45 +00:00
1, /* Single element */
2004-09-29 13:19:37 +00:00
&asn_DEF_Name_specs /* Additional specs */
2004-08-20 13:37:45 +00:00
};
/*** <<< INCLUDES [RelativeDistinguishedName] >>> ***/
#include <IA5String.h>
#include <asn_SET_OF.h>
#include <constr_SET_OF.h>
/*** <<< DEPS [RelativeDistinguishedName] >>> ***/
2004-09-29 13:19:37 +00:00
extern asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName;
2004-08-20 13:37:45 +00:00
/*** <<< TYPE-DECLS [RelativeDistinguishedName] >>> ***/
typedef struct RelativeDistinguishedName {
A_SET_OF(IA5String_t) list;
/* Context for parsing across buffer boundaries */
2004-09-29 13:19:37 +00:00
asn_struct_ctx_t _asn_ctx;
2004-08-20 13:37:45 +00:00
} 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 */
2004-08-21 07:34:17 +00:00
const IA5String_t *st = sptr;
2004-08-22 03:19:00 +00:00
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
2004-08-20 13:37:45 +00:00
for(; ch < end; ch++) {
uint8_t cv = *ch;
2004-08-22 12:47:03 +00:00
if(!table[cv]) return -1;
2004-08-20 13:37:45 +00:00
}
2004-08-22 12:47:03 +00:00
return 0;
2004-08-20 13:37:45 +00:00
}
/*** <<< CODE [RelativeDistinguishedName] >>> ***/
static int
2004-09-29 13:19:37 +00:00
memb_IA5String_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
2004-08-20 13:37:45 +00:00
asn_app_consume_bytes_f *app_errlog, void *app_key) {
2004-08-22 03:19:00 +00:00
const IA5String_t *st = sptr;
2004-08-20 13:37:45 +00:00
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
2004-08-22 13:47:59 +00:00
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
2004-08-20 13:37:45 +00:00
return -1;
}
2004-08-22 13:11:40 +00:00
if(!check_permitted_alphabet_1(sptr)) {
2004-08-20 13:37:45 +00:00
/* Constraint check succeeded */
2004-08-22 12:47:03 +00:00
return 0;
2004-08-20 13:37:45 +00:00
} else {
_ASN_ERRLOG(app_errlog, app_key,
2004-08-22 13:47:59 +00:00
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
2004-08-20 13:37:45 +00:00
return -1;
}
}
/*** <<< STAT-DEFS [RelativeDistinguishedName] >>> ***/
2004-09-29 13:19:37 +00:00
static asn_TYPE_member_t asn_MBR_RelativeDistinguishedName[] = {
{ ATF_NOFLAGS, 0, 0,
2004-08-20 13:37:45 +00:00
.tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_IA5String,
2004-09-05 10:37:18 +00:00
.memb_constraints = memb_IA5String_2_constraint,
2004-08-20 13:37:45 +00:00
.name = ""
},
};
2004-09-29 13:19:37 +00:00
static ber_tlv_tag_t asn_DEF_RelativeDistinguishedName_tags[] = {
2004-08-20 13:37:45 +00:00
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
2004-09-29 13:19:37 +00:00
static asn_SET_OF_specifics_t asn_DEF_RelativeDistinguishedName_specs = {
2004-08-20 13:37:45 +00:00
sizeof(struct RelativeDistinguishedName),
2004-09-29 13:19:37 +00:00
offsetof(struct RelativeDistinguishedName, _asn_ctx),
2004-09-22 16:06:28 +00:00
0, /* XER encoding is XMLDelimitedItemList */
2004-08-20 13:37:45 +00:00
};
2004-09-29 13:19:37 +00:00
asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName = {
2004-08-20 13:37:45 +00:00
"RelativeDistinguishedName",
2004-09-22 16:06:28 +00:00
SET_OF_free,
SET_OF_print,
2004-08-20 13:37:45 +00:00
SET_OF_constraint,
SET_OF_decode_ber,
SET_OF_encode_der,
2004-09-22 16:06:28 +00:00
0, /* Not implemented yet */
SET_OF_encode_xer,
2004-08-20 13:37:45 +00:00
0, /* Use generic outmost tag fetcher */
2004-09-29 13:19:37 +00:00
asn_DEF_RelativeDistinguishedName_tags,
sizeof(asn_DEF_RelativeDistinguishedName_tags)
/sizeof(asn_DEF_RelativeDistinguishedName_tags[0]), /* 1 */
asn_DEF_RelativeDistinguishedName_tags, /* Same as above */
sizeof(asn_DEF_RelativeDistinguishedName_tags)
/sizeof(asn_DEF_RelativeDistinguishedName_tags[0]), /* 1 */
asn_MBR_RelativeDistinguishedName,
2004-08-20 13:37:45 +00:00
1, /* Single element */
2004-09-29 13:19:37 +00:00
&asn_DEF_RelativeDistinguishedName_specs /* Additional specs */
2004-08-20 13:37:45 +00:00
};