svn rev #25187: trunk/src/lib/krb5/asn.1/

hartmans@MIT.EDU hartmans at MIT.EDU
Sun Sep 18 20:34:41 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25187
Commit By: hartmans
Log Message:
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.


Changed Files:
U   trunk/src/lib/krb5/asn.1/asn1_encode.c
U   trunk/src/lib/krb5/asn.1/asn1_encode.h
Modified: trunk/src/lib/krb5/asn.1/asn1_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_encode.c	2011-09-19 00:34:36 UTC (rev 25186)
+++ trunk/src/lib/krb5/asn.1/asn1_encode.c	2011-09-19 00:34:40 UTC (rev 25187)
@@ -408,7 +408,7 @@
         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;

Modified: trunk/src/lib/krb5/asn.1/asn1_encode.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_encode.h	2011-09-19 00:34:36 UTC (rev 25186)
+++ trunk/src/lib/krb5/asn.1/asn1_encode.h	2011-09-19 00:34:40 UTC (rev 25187)
@@ -294,8 +294,8 @@
     /* 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 @@
         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 @@
     }                                                           \
     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,9 +488,19 @@
     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 \
+    }
+
 /*
  * Declare an externally-defined type.  This is a hack we should do
  * away with once we move to generating code from a script.  For now,




More information about the cvs-krb5 mailing list