summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/asn.1
diff options
context:
space:
mode:
authorSam Hartman <hartmans@mit.edu>2011-09-19 00:34:40 +0000
committerSam Hartman <hartmans@mit.edu>2011-09-19 00:34:40 +0000
commit1e1b5d76c466978c53dc8f1e79517243d78f8361 (patch)
treee1a001c43721418a22b50964ec87febd23d913a0 /src/lib/krb5/asn.1
parentf79ba7eca6846552fcd00d42f4b8f67e05af2e40 (diff)
downloadkrb5-1e1b5d76c466978c53dc8f1e79517243d78f8361.tar.gz
krb5-1e1b5d76c466978c53dc8f1e79517243d78f8361.tar.xz
krb5-1e1b5d76c466978c53dc8f1e79517243d78f8361.zip
asn1_encode.{c,h}: support DEFOCTETWRAPTYPE
Support a way of defining a type that indicates that the DER encoding of some other type is wrapped inside an octet string in a produced encoding. To support this, support encoding of tagged things where the class is not constructed; in this case it will be primitive. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25187 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5/asn.1')
-rw-r--r--src/lib/krb5/asn.1/asn1_encode.c2
-rw-r--r--src/lib/krb5/asn.1/asn1_encode.h20
2 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c
index a9077093d..d31cefa5f 100644
--- a/src/lib/krb5/asn.1/asn1_encode.c
+++ b/src/lib/krb5/asn.1/asn1_encode.c
@@ -408,7 +408,7 @@ krb5int_asn1_encode_a_thing(asn1buf *buf, const void *val,
retval = krb5int_asn1_encode_a_thing(buf, val, a->basetype, &length);
if (retval) return retval;
sum = length;
- retval = asn1_make_etag(buf, a->tagtype, a->tagval, sum, &length);
+ retval = asn1_make_tag(buf, a->tagtype, a->construction, a->tagval, sum, &length);
if (retval) return retval;
sum += length;
*retlen = sum;
diff --git a/src/lib/krb5/asn.1/asn1_encode.h b/src/lib/krb5/asn.1/asn1_encode.h
index a17a20cb2..04d92fc90 100644
--- a/src/lib/krb5/asn.1/asn1_encode.h
+++ b/src/lib/krb5/asn.1/asn1_encode.h
@@ -294,8 +294,8 @@ struct atype_info {
/* atype_field */
const struct field_info *field;
/* atype_tagged_thing */
- unsigned int tagval : 8, tagtype : 8;
- /* atype_[u]int */
+ unsigned int tagval : 8, tagtype : 8, construction:8;
+ /* atype_[u]int */
asn1_intmax (*loadint)(const void *);
asn1_uintmax (*loaduint)(const void *);
};
@@ -404,7 +404,7 @@ struct atype_info {
return *(const aux_typedefname_##DESCNAME *)p; \
} \
const struct atype_info krb5int_asn1type_##DESCNAME = { \
- atype_int, sizeof(CTYPENAME), 0, 0, 0, 0, 0, 0, 0, 0, \
+ atype_int, sizeof(CTYPENAME), 0, 0, 0, 0, 0, 0, 0, 0, 0, \
loadint_##DESCNAME, 0, \
}
#define DEFUINTTYPE(DESCNAME, CTYPENAME) \
@@ -416,7 +416,7 @@ struct atype_info {
} \
const struct atype_info krb5int_asn1type_##DESCNAME = { \
atype_uint, sizeof(CTYPENAME), 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, loaduint_##DESCNAME, \
+ 0, 0, loaduint_##DESCNAME, \
}
/* Pointers to other types, to be encoded as those other types. */
#ifdef POINTERS_ARE_ALL_THE_SAME
@@ -488,7 +488,17 @@ struct atype_info {
typedef aux_typedefname_##BASEDESC aux_typedefname_##DESCNAME; \
const struct atype_info krb5int_asn1type_##DESCNAME = { \
atype_tagged_thing, sizeof(aux_typedefname_##DESCNAME), \
- 0, 0, 0, &krb5int_asn1type_##BASEDESC, 0, 0, TAG, APPLICATION \
+ 0, 0, 0, &krb5int_asn1type_##BASEDESC, 0, 0, TAG, APPLICATION, CONSTRUCTED \
+ }
+
+/**
+ * An encoding wrapped in an octet string
+ */
+#define DEFOCTETWRAPTYPE(DESCNAME, BASEDESC) \
+ typedef aux_typedefname_##BASEDESC aux_typedefname_##DESCNAME; \
+ const struct atype_info krb5int_asn1type_##DESCNAME = { \
+ atype_tagged_thing, sizeof(aux_typedefname_##DESCNAME), \
+ 0, 0, 0, &krb5int_asn1type_##BASEDESC, 0, 0, ASN1_OCTETSTRING, UNIVERSAL, PRIMITIVE \
}
/*