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

tlyu@MIT.EDU tlyu at MIT.EDU
Wed Nov 4 23:39:48 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=23132
Commit By: tlyu
Log Message:
Reformat some block comments.  Refine lib/krb5/asn.1 reindent
exclusion into individual file exclusions.


Changed Files:
U   trunk/src/Makefile.in
U   trunk/src/lib/krb5/asn.1/asn1_encode.c
U   trunk/src/lib/krb5/asn.1/asn1_get.h
U   trunk/src/lib/krb5/asn.1/asn1_k_decode.h
U   trunk/src/lib/krb5/asn.1/asn1_k_encode.h
U   trunk/src/lib/krb5/asn.1/asn1_misc.h
U   trunk/src/lib/krb5/asn.1/asn1buf.c
U   trunk/src/lib/krb5/asn.1/krb5_encode.c
U   trunk/src/lib/krb5/asn.1/ldap_key_seq.c
Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/Makefile.in	2009-11-05 04:39:48 UTC (rev 23132)
@@ -673,7 +673,12 @@
 	lib/krb5/krb/strptime.c
 
 OTHEREXCLUDES = \
-	lib/krb5/asn.1 \
+	lib/krb5/asn.1/asn1_decode.h \
+	lib/krb5/asn.1/asn1_encode.h \
+	lib/krb5/asn.1/asn1_k_encode.c \
+	lib/krb5/asn.1/asn1_make.h \
+	lib/krb5/asn.1/asn1buf.h \
+	lib/krb5/asn.1/krb5_decode.c \
 	lib/krb5/krb/deltat.c \
 	lib/krb5/unicode
 

Modified: trunk/src/lib/krb5/asn.1/asn1_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_encode.c	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/asn1_encode.c	2009-11-05 04:39:48 UTC (rev 23132)
@@ -312,16 +312,18 @@
     return 0;
 }
 
-/* ASN.1 constructed type encoder engine
+/*
+ * ASN.1 constructed type encoder engine
+ *
+ * Two entry points here:
+ *
+ * krb5int_asn1_encode_a_thing: Incrementally adds the partial
+ * encoding of an object to an already-initialized asn1buf.
+ *
+ * krb5int_asn1_do_full_encode: Returns a completed encoding, in the
+ * correct byte order, in an allocated krb5_data.
+ */
 
-   Two entry points here:
-
-   krb5int_asn1_encode_a_thing: Incrementally adds the partial
-   encoding of an object to an already-initialized asn1buf.
-
-   krb5int_asn1_do_full_encode: Returns a completed encoding, in the
-   correct byte order, in an allocated krb5_data.  */
-
 #ifdef POINTERS_ARE_ALL_THE_SAME
 #define LOADPTR(PTR,TYPE)       \
     (assert((TYPE)->loadptr != NULL), (TYPE)->loadptr(PTR))
@@ -458,9 +460,11 @@
         unsigned int length;
         const struct atype_info *a;
 
-        /* The field holds a pointer to the array of objects.  So the
-           address we compute is a pointer-to-pointer, and that's what
-           field->atype must help us dereference.  */
+        /*
+         * The field holds a pointer to the array of objects.  So the
+         * address we compute is a pointer-to-pointer, and that's what
+         * field->atype must help us dereference.
+         */
         dataptr = (const char *)val + field->dataoff;
         lenptr = (const char *)val + field->lenoff;
         assert(field->atype->type == atype_ptr);
@@ -547,8 +551,10 @@
             return EINVAL;
         if (dataptr == NULL && slen != 0)
             return ASN1_MISSING_FIELD;
-        /* Currently our string encoders want "unsigned int" for
-           lengths.  */
+        /*
+         * Currently our string encoders want "unsigned int" for
+         * lengths.
+         */
         if (slen != (unsigned int) slen)
             return EINVAL;
         assert(a->enclen != NULL);
@@ -622,8 +628,10 @@
     if (seq->optional)
         optional = seq->optional(val);
     else
-        /* In this case, none of the field descriptors should indicate
-           that we examine any bits of this value.  */
+        /*
+         * In this case, none of the field descriptors should indicate
+         * that we examine any bits of this value.
+         */
         optional = 0;
     {
         unsigned int length;

Modified: trunk/src/lib/krb5/asn.1/asn1_get.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_get.h	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/asn1_get.h	2009-11-05 04:39:48 UTC (rev 23132)
@@ -35,10 +35,13 @@
 #include "asn1buf.h"
 
 typedef struct {
-#if 1 /* Smaller run-time storage, and on x86 the compiler can use
-         byte loads, stores, and compares, but on other platforms the
-         compiler may need to load and widen before comparing... see
-         how this works out. */
+#if 1
+  /*
+   * Smaller run-time storage, and on x86 the compiler can use byte
+   * loads, stores, and compares, but on other platforms the compiler
+   * may need to load and widen before comparing... see how this works
+   * out.
+   */
     unsigned int asn1class : 8, construction : 8;
 #else
     asn1_class asn1class;
@@ -63,21 +66,27 @@
                              asn1_construction *construction,
                              asn1_tagnum *tagnum,
                              unsigned int *retlen);
-/* requires  *buf is allocated
-   effects   Decodes the tag in *buf.  If class != NULL, returns
-              the class in *Class.  Similarly, the construction,
-              tag number, and length are returned in *construction,
-              *tagnum, and *retlen, respectively.
-             If *buf is empty to begin with,
-              *tagnum is set to ASN1_TAGNUM_CEILING.
-             Returns ASN1_OVERRUN if *buf is exhausted during the parse. */
+/*
+ * requires  *buf is allocated
+ * effects   Decodes the tag in *buf.  If class != NULL, returns
+ *           the class in *Class.  Similarly, the construction,
+ *           tag number, and length are returned in *construction,
+ *           *tagnum, and *retlen, respectively.
+ *
+ *           If *buf is empty to begin with, *tagnum is set to
+ *           ASN1_TAGNUM_CEILING.
+ *
+ *           Returns ASN1_OVERRUN if *buf is exhausted during the
+ *           parse.
+ */
 #endif
 
 asn1_error_code asn1_get_sequence(asn1buf *buf, unsigned int *retlen,
                                   int *indef);
-/* requires  *buf is allocated
-   effects   Decodes a tag from *buf and returns ASN1_BAD_ID if it
-              doesn't have a sequence ID.  If retlen != NULL, the
-              associated length is returned in *retlen. */
-
+/*
+ * requires  *buf is allocated
+ * effects   Decodes a tag from *buf and returns ASN1_BAD_ID if it
+ *           doesn't have a sequence ID.  If retlen != NULL, the
+ *           associated length is returned in *retlen.
+ */
 #endif

Modified: trunk/src/lib/krb5/asn.1/asn1_k_decode.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_decode.h	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/asn1_k_decode.h	2009-11-05 04:39:48 UTC (rev 23132)
@@ -33,39 +33,57 @@
 #include "asn1buf.h"
 
 /* asn1_error_code asn1_decode_scalar_type(asn1buf *buf, krb5_scalar *val); */
-/* requires  *buf is allocated, *buf's current position points to the
-              beginning of an encoding (<id> <len> <contents>),
-              *val is allocated
-   effects   Decodes the encoding in *buf, returning the result in *val.
-             Returns ASN1_BAD_ID if the encoded id does not
-              indicate the proper type.
-             Returns ASN1_OVERRUN if the encoded length exceeds
-              the bounds of *buf */
+/*
+ * requires  *buf is allocated, *buf's current position points to the
+ *            beginning of an encoding (<id> <len> <contents>),
+ *            *val is allocated
+ *
+ * effects   Decodes the encoding in *buf, returning the result in *val.
+ *
+ *           Returns ASN1_BAD_ID if the encoded id does not indicate
+ *           the proper type.
+ *
+ *           Returns ASN1_OVERRUN if the encoded length exceeds
+ *           the bounds of *buf
+ */
 
 
-/* asn1_error_code asn1_decode_structure_type(asn1buf *buf,
-                                              krb5_structure *val); */
-/* requires  *buf is allocated, *buf's current position points to the
-              beginning of an encoding (<id> <len> <contents>),
-              *val is allocated
-             Assumes that *val is a freshly-allocated structure (i.e.
-              does not attempt to clean up or free *val).
-   effects   Decodes the encoding in *buf, returning the result in *val.
-             Returns ASN1_BAD_ID if the encoded id does not
-              indicate the proper type.
-             Returns ASN1_OVERRUN if the encoded length exceeds
-              the bounds of *buf */
+/*
+ * asn1_error_code asn1_decode_structure_type(asn1buf *buf,
+ *                                            krb5_structure *val);
+ */
+/*
+ * requires  *buf is allocated, *buf's current position points to the
+ *            beginning of an encoding (<id> <len> <contents>),
+ *            *val is allocated
+ *
+ *           Assumes that *val is a freshly-allocated structure (i.e.
+ *            does not attempt to clean up or free *val).
+ * effects   Decodes the encoding in *buf, returning the result in *val.
+ *
+ *           Returns ASN1_BAD_ID if the encoded id does not indicate
+ *           the proper type.
+ *
+ *           Returns ASN1_OVERRUN if the encoded length exceeds the
+ *           bounds of *buf
+ */
 
 /* asn1_error_code asn1_decode_array_type(asn1buf *buf, krb5_scalar ***val); */
-/* requires  *buf is allocated, *buf's current position points to the
-              beginning of an encoding (<id> <len> <contents>)
-             Assumes that *val is empty (i.e. does not attempt to
-              clean up or free *val).
-   effects   Decodes the encoding in *buf, returning the result in *val.
-             Returns ASN1_BAD_ID if the encoded id does not
-              indicate the proper type.
-             Returns ASN1_OVERRUN if the encoded length exceeds
-              the bounds of *buf */
+/*
+ * requires  *buf is allocated, *buf's current position points to the
+ *           beginning of an encoding (<id> <len> <contents>)
+ *
+ *           Assumes that *val is empty (i.e. does not attempt to
+ *           clean up or free *val).
+ *
+ * effects   Decodes the encoding in *buf, returning the result in *val.
+ *
+ *           Returns ASN1_BAD_ID if the encoded id does not indicate
+ *           the proper type.
+ *
+ *           Returns ASN1_OVERRUN if the encoded length exceeds the
+ *           bounds of *buf
+ */
 
 /* scalars */
 asn1_error_code asn1_decode_int(asn1buf *buf, int *val);

Modified: trunk/src/lib/krb5/asn.1/asn1_k_encode.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_encode.h	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/asn1_k_encode.h	2009-11-05 04:39:48 UTC (rev 23132)
@@ -33,38 +33,38 @@
 #include "asn1buf.h"
 
 /*
-**** for simple val's ****
-asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
-                                      const krb5_type val,
-                                      int *retlen);
-   requires  *buf is allocated
-   effects   Inserts the encoding of val into *buf and
-              returns the length of this encoding in *retlen.
-             Returns ASN1_MISSING_FIELD if a required field is empty in val.
-             Returns ENOMEM if memory runs out.
+ * **** for simple val's ****
+ * asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
+ *                                       const krb5_type val,
+ *                                       int *retlen);
+ *    requires  *buf is allocated
+ *    effects   Inserts the encoding of val into *buf and
+ *               returns the length of this encoding in *retlen.
+ *              Returns ASN1_MISSING_FIELD if a required field is empty in val.
+ *              Returns ENOMEM if memory runs out.
+ *
+ * **** for struct val's ****
+ * asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
+ *                                       const krb5_type *val,
+ *                                       int *retlen);
+ *    requires  *buf is allocated
+ *    effects   Inserts the encoding of *val into *buf and
+ *               returns the length of this encoding in *retlen.
+ *              Returns ASN1_MISSING_FIELD if a required field is empty in val.
+ *              Returns ENOMEM if memory runs out.
+ *
+ * **** for array val's ****
+ * asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
+ *                                       const krb5_type **val,
+ *                                       int *retlen);
+ *    requires  *buf is allocated, **val != NULL, *val[0] != NULL,
+ *               **val is a NULL-terminated array of pointers to krb5_type
+ *    effects   Inserts the encoding of **val into *buf and
+ *               returns the length of this encoding in *retlen.
+ *              Returns ASN1_MISSING_FIELD if a required field is empty in val.
+ *              Returns ENOMEM if memory runs out.
+ */
 
-**** for struct val's ****
-asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
-                                      const krb5_type *val,
-                                      int *retlen);
-   requires  *buf is allocated
-   effects   Inserts the encoding of *val into *buf and
-              returns the length of this encoding in *retlen.
-             Returns ASN1_MISSING_FIELD if a required field is empty in val.
-             Returns ENOMEM if memory runs out.
-
-**** for array val's ****
-asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
-                                      const krb5_type **val,
-                                      int *retlen);
-   requires  *buf is allocated, **val != NULL, *val[0] != NULL,
-              **val is a NULL-terminated array of pointers to krb5_type
-   effects   Inserts the encoding of **val into *buf and
-              returns the length of this encoding in *retlen.
-             Returns ASN1_MISSING_FIELD if a required field is empty in val.
-             Returns ENOMEM if memory runs out.
-*/
-
 /* PKINIT */
 
 asn1_error_code asn1_encode_pk_authenticator(asn1buf *buf,

Modified: trunk/src/lib/krb5/asn.1/asn1_misc.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_misc.h	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/asn1_misc.h	2009-11-05 04:39:48 UTC (rev 23132)
@@ -33,8 +33,10 @@
 
 asn1_error_code asn1_krb5_realm_copy(krb5_principal target,
                                      krb5_principal source);
-/* requires  target, source, and source->realm are allocated
-   effects   Copies source->realm into target->realm.
-             Returns ENOMEM if memory is exhausted. */
+/*
+ * requires  target, source, and source->realm are allocated
+ * effects   Copies source->realm into target->realm.
+ *           Returns ENOMEM if memory is exhausted.
+ */
 
 #endif

Modified: trunk/src/lib/krb5/asn.1/asn1buf.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1buf.c	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/asn1buf.c	2009-11-05 04:39:48 UTC (rev 23132)
@@ -2,54 +2,58 @@
 /* Coding Buffer Implementation */
 
 /*
-  Implementation
+ *  Implementation
+ *
+ *    Encoding mode
+ *
+ *    The encoding buffer is filled from bottom (lowest address) to top
+ *    (highest address).  This makes it easier to expand the buffer,
+ *    since realloc preserves the existing portion of the buffer.
+ *
+ *    Note: Since ASN.1 encoding must be done in reverse, this means
+ *    that you can't simply memcpy out the buffer data, since it will be
+ *    backwards.  You need to reverse-iterate through it, instead.
+ *
+ *    ***This decision may have been a mistake.  In practice, the
+ *    implementation will probably be tuned such that reallocation is
+ *    rarely necessary.  Also, the realloc probably has recopy the
+ *    buffer itself, so we don't really gain that much by avoiding an
+ *    explicit copy of the buffer.  --Keep this in mind for future reference.
+ *
+ *
+ *    Decoding mode
+ *
+ *    The decoding buffer is in normal order and is created by wrapping
+ *    an asn1buf around a krb5_data structure.
+ */
 
-    Encoding mode
+/*
+ * Abstraction Function
+ *
+ *   Programs should use just pointers to asn1buf's (e.g. asn1buf *mybuf).
+ *   These pointers must always point to a valid, allocated asn1buf
+ *   structure or be NULL.
+ *
+ *   The contents of the asn1buf represent an octet string.  This string
+ *   begins at base and continues to the octet immediately preceding next.
+ *   If next == base or mybuf == NULL, then the asn1buf represents an empty
+ *   octet string.
+ */
 
-    The encoding buffer is filled from bottom (lowest address) to top
-    (highest address).  This makes it easier to expand the buffer,
-    since realloc preserves the existing portion of the buffer.
+/*
+ * Representation Invariant
+ *
+ *   Pointers to asn1buf's must always point to a valid, allocated
+ *   asn1buf structure or be NULL.
+ *
+ *   base points to a valid, allocated octet array or is NULL
+ *   bound, if non-NULL, points to the last valid octet
+ *   next >= base
+ *   next <= bound+2  (i.e. next should be able to step just past the bound,
+ *                     but no further.  (The bound should move out in response
+ *                     to being crossed by next.))
+ */
 
-    Note: Since ASN.1 encoding must be done in reverse, this means
-    that you can't simply memcpy out the buffer data, since it will be
-    backwards.  You need to reverse-iterate through it, instead.
-
-    ***This decision may have been a mistake.  In practice, the
-    implementation will probably be tuned such that reallocation is
-    rarely necessary.  Also, the realloc probably has recopy the
-    buffer itself, so we don't really gain that much by avoiding an
-    explicit copy of the buffer.  --Keep this in mind for future reference.
-
-
-    Decoding mode
-
-    The decoding buffer is in normal order and is created by wrapping
-    an asn1buf around a krb5_data structure.
-  */
-
-/* Abstraction Function
-
-   Programs should use just pointers to asn1buf's (e.g. asn1buf *mybuf).
-   These pointers must always point to a valid, allocated asn1buf
-   structure or be NULL.
-
-   The contents of the asn1buf represent an octet string.  This string
-   begins at base and continues to the octet immediately preceding next.
-   If next == base or mybuf == NULL, then the asn1buf represents an empty
-   octet string. */
-
-/* Representation Invariant
-
-   Pointers to asn1buf's must always point to a valid, allocated
-   asn1buf structure or be NULL.
-
-   base points to a valid, allocated octet array or is NULL
-   bound, if non-NULL, points to the last valid octet
-   next >= base
-   next <= bound+2  (i.e. next should be able to step just past the bound,
-                     but no further.  (The bound should move out in response
-                     to being crossed by next.)) */
-
 #define ASN1BUF_OMIT_INLINE_FUNCS
 #include "asn1buf.h"
 #include <stdio.h>
@@ -62,8 +66,10 @@
 #endif
 
 #if !defined(__GNUC__) || defined(CONFIG_SMALL)
-/* Declare private procedures as static if they're not used for inline
-   expansion of other stuff elsewhere.  */
+/*
+ * Declare private procedures as static if they're not used for inline
+ * expansion of other stuff elsewhere.
+ */
 static unsigned int asn1buf_free(const asn1buf *);
 static asn1_error_code asn1buf_ensure_space(asn1buf *, unsigned int);
 static asn1_error_code asn1buf_expand(asn1buf *, unsigned int);
@@ -278,8 +284,11 @@
 
 
 
-/* These parse and unparse procedures should be moved out. They're
-   useful only for debugging and superfluous in the production version. */
+/*
+ * These parse and unparse procedures should be moved out. They're
+ * useful only for debugging and superfluous in the production
+ * version.
+ */
 
 asn1_error_code asn1buf_unparse(const asn1buf *buf, char **s)
 {

Modified: trunk/src/lib/krb5/asn.1/krb5_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/krb5_encode.c	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/krb5_encode.c	2009-11-05 04:39:48 UTC (rev 23132)
@@ -34,11 +34,13 @@
 
 /**************** Macros (these save a lot of typing) ****************/
 
-/* setup() -- create and initialize bookkeeping variables
-     retval: stores error codes returned from subroutines
-     buf: the coding buffer
-     length: length of the most-recently produced encoding
-     sum: cumulative length of the entire encoding */
+/*
+ * setup() -- create and initialize bookkeeping variables
+ *     retval: stores error codes returned from subroutines
+ *     buf: the coding buffer
+ *     length: length of the most-recently produced encoding
+ *     sum: cumulative length of the entire encoding
+ */
 #define krb5_setup()\
   asn1_error_code retval;\
   unsigned int length, sum = 0;\

Modified: trunk/src/lib/krb5/asn.1/ldap_key_seq.c
===================================================================
--- trunk/src/lib/krb5/asn.1/ldap_key_seq.c	2009-11-05 03:26:25 UTC (rev 23131)
+++ trunk/src/lib/krb5/asn.1/ldap_key_seq.c	2009-11-05 04:39:48 UTC (rev 23132)
@@ -1,34 +1,35 @@
 /* -*- mode: c; indent-tabs-mode: nil -*- */
 /* ... copyright ... */
 
-/* Novell key-format scheme:
-
-   KrbKeySet ::= SEQUENCE {
-   attribute-major-vno       [0] UInt16,
-   attribute-minor-vno       [1] UInt16,
-   kvno                      [2] UInt32,
-   mkvno                     [3] UInt32 OPTIONAL,
-   keys                      [4] SEQUENCE OF KrbKey,
-   ...
-   }
-
-   KrbKey ::= SEQUENCE {
-   salt      [0] KrbSalt OPTIONAL,
-   key       [1] EncryptionKey,
-   s2kparams [2] OCTET STRING OPTIONAL,
-    ...
-   }
-
-   KrbSalt ::= SEQUENCE {
-   type      [0] Int32,
-   salt      [1] OCTET STRING OPTIONAL
-   }
-
-   EncryptionKey ::= SEQUENCE {
-   keytype   [0] Int32,
-   keyvalue  [1] OCTET STRING
-   }
-
+/*
+ * Novell key-format scheme:
+ *
+ * KrbKeySet ::= SEQUENCE {
+ * attribute-major-vno       [0] UInt16,
+ * attribute-minor-vno       [1] UInt16,
+ * kvno                      [2] UInt32,
+ * mkvno                     [3] UInt32 OPTIONAL,
+ * keys                      [4] SEQUENCE OF KrbKey,
+ * ...
+ * }
+ *
+ * KrbKey ::= SEQUENCE {
+ * salt      [0] KrbSalt OPTIONAL,
+ * key       [1] EncryptionKey,
+ * s2kparams [2] OCTET STRING OPTIONAL,
+ *  ...
+ * }
+ *
+ * KrbSalt ::= SEQUENCE {
+ * type      [0] Int32,
+ * salt      [1] OCTET STRING OPTIONAL
+ * }
+ *
+ * EncryptionKey ::= SEQUENCE {
+ * keytype   [0] Int32,
+ * keyvalue  [1] OCTET STRING
+ * }
+ *
  */
 
 #include <k5-int.h>
@@ -47,8 +48,10 @@
 /* Encode the Principal's keys                                          */
 /************************************************************************/
 
-/* Imports from asn1_k_encode.c.
-   XXX Must be manually synchronized for now.  */
+/*
+ * Imports from asn1_k_encode.c.
+ * XXX Must be manually synchronized for now.
+ */
 IMPORT_TYPE(octetstring, unsigned char *);
 IMPORT_TYPE(int32, krb5_int32);
 




More information about the cvs-krb5 mailing list