From: Tom Yu Date: Thu, 5 Nov 2009 04:39:48 +0000 (+0000) Subject: Reformat some block comments. Refine lib/krb5/asn.1 reindent X-Git-Tag: krb5-1.8-alpha1~209 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ad66ebe05dba6709a090e70f4482b0fb499aad0a;p=krb5.git Reformat some block comments. Refine lib/krb5/asn.1 reindent exclusion into individual file exclusions. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23132 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/Makefile.in b/src/Makefile.in index 52043e57f..3a5f267a6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -673,7 +673,12 @@ BSDFILES = \ 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 diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c index e71c530d1..c2c15245a 100644 --- a/src/lib/krb5/asn.1/asn1_encode.c +++ b/src/lib/krb5/asn.1/asn1_encode.c @@ -312,15 +312,17 @@ asn1_encode_opaque(asn1buf *buf, unsigned int len, const void *val, return 0; } -/* 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. */ +/* + * 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. + */ #ifdef POINTERS_ARE_ALL_THE_SAME #define LOADPTR(PTR,TYPE) \ @@ -458,9 +460,11 @@ encode_a_field(asn1buf *buf, const void *val, 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 @@ encode_a_field(asn1buf *buf, const void *val, 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 @@ just_encode_sequence(asn1buf *buf, const void *val, 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; diff --git a/src/lib/krb5/asn.1/asn1_get.h b/src/lib/krb5/asn.1/asn1_get.h index 286764957..056ee5a71 100644 --- a/src/lib/krb5/asn.1/asn1_get.h +++ b/src/lib/krb5/asn.1/asn1_get.h @@ -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_error_code asn1_get_tag(asn1buf *buf, 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 diff --git a/src/lib/krb5/asn.1/asn1_k_decode.h b/src/lib/krb5/asn.1/asn1_k_decode.h index ffa7dbde1..3a42199f1 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.h +++ b/src/lib/krb5/asn.1/asn1_k_decode.h @@ -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 ( ), - *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 ( ), - *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 */ +/* + * requires *buf is allocated, *buf's current position points to the + * beginning of an encoding ( ), + * *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 ( ), + * *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 ( ) - 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 ( ) + * + * 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); diff --git a/src/lib/krb5/asn.1/asn1_k_encode.h b/src/lib/krb5/asn.1/asn1_k_encode.h index 9004bcdd2..b595a7e8e 100644 --- a/src/lib/krb5/asn.1/asn1_k_encode.h +++ b/src/lib/krb5/asn.1/asn1_k_encode.h @@ -33,37 +33,37 @@ #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 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 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. + */ /* PKINIT */ diff --git a/src/lib/krb5/asn.1/asn1_misc.h b/src/lib/krb5/asn.1/asn1_misc.h index e9d5e3627..db62fff4c 100644 --- a/src/lib/krb5/asn.1/asn1_misc.h +++ b/src/lib/krb5/asn.1/asn1_misc.h @@ -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 diff --git a/src/lib/krb5/asn.1/asn1buf.c b/src/lib/krb5/asn.1/asn1buf.c index 8985140d4..1b77fea7c 100644 --- a/src/lib/krb5/asn.1/asn1buf.c +++ b/src/lib/krb5/asn.1/asn1buf.c @@ -2,53 +2,57 @@ /* 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 - - 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. - */ - -/* 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. +/* + * 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. + */ - 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.)) */ +/* + * 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" @@ -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 @@ asn1_error_code asn12krb5_buf(const asn1buf *buf, krb5_data **code) -/* 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) { diff --git a/src/lib/krb5/asn.1/krb5_encode.c b/src/lib/krb5/asn.1/krb5_encode.c index ae6de7d29..eca4625c3 100644 --- a/src/lib/krb5/asn.1/krb5_encode.c +++ b/src/lib/krb5/asn.1/krb5_encode.c @@ -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;\ diff --git a/src/lib/krb5/asn.1/ldap_key_seq.c b/src/lib/krb5/asn.1/ldap_key_seq.c index a45cf3bc5..0a425384d 100644 --- a/src/lib/krb5/asn.1/ldap_key_seq.c +++ b/src/lib/krb5/asn.1/ldap_key_seq.c @@ -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 @@ -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);