[30141] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Use stdint types in ASN.1 code

daemon@ATHENA.MIT.EDU (Greg Hudson)
Tue Mar 27 14:55:53 2018

Date: Tue, 27 Mar 2018 14:55:45 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201803271855.w2RItjcZ030090@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/c80ce2682015be863c73fbebdaeb919d34930073
commit c80ce2682015be863c73fbebdaeb919d34930073
Author: Greg Hudson <ghudson@mit.edu>
Date:   Wed Mar 21 11:04:32 2018 -0400

    Use stdint types in ASN.1 code
    
    Replace krb5 fixed-width typedef names with [u]int{16,32}_t, and use
    uint8_t in place of unsigned char and asn1_octet.  Use krb5_error_code
    in place of asn1_error_code, and remove dependencies on internal ASN.1
    headers from the tests.

 src/lib/krb5/asn.1/README.asn1     |   10 +-
 src/lib/krb5/asn.1/asn1_encode.c   |  254 ++++++++++++++++++------------------
 src/lib/krb5/asn.1/asn1_encode.h   |   61 ++++-----
 src/lib/krb5/asn.1/asn1_k_encode.c |   98 +++++++-------
 src/lib/krb5/asn.1/asn1buf.c       |   23 ++--
 src/lib/krb5/asn.1/asn1buf.h       |   16 +-
 src/lib/krb5/asn.1/krbasn1.h       |    1 -
 src/lib/krb5/asn.1/ldap_key_seq.c  |   10 +-
 src/tests/asn.1/Makefile.in        |    2 -
 src/tests/asn.1/deps               |   70 +++++-----
 src/tests/asn.1/utility.c          |   29 +----
 src/tests/asn.1/utility.h          |    6 +-
 12 files changed, 267 insertions(+), 313 deletions(-)

diff --git a/src/lib/krb5/asn.1/README.asn1 b/src/lib/krb5/asn.1/README.asn1
index fcc7b78..dcc48c4 100644
--- a/src/lib/krb5/asn.1/README.asn1
+++ b/src/lib/krb5/asn.1/README.asn1
@@ -109,7 +109,7 @@ DEFUINTTYPE if it is an unsigned type.  (For booleans, the distinction
 is unimportant since all integer types can hold the values 0 and 1.)
 We don't generally define integer mappings for every typedef name of
 an integer type.  For example, we use the type descriptor int32, which
-maps an ASN.1 INTEGER to a krb5_int32, for krb5_enctype values.
+maps an ASN.1 INTEGER to an int32_t, for krb5_enctype values.
 
 String types are a little more complicated.  Our practice is to store
 strings in a krb5_data structure (rather than a zero-terminated C
@@ -126,8 +126,8 @@ detail later) with something like:
 The first parameter is an identifier you make up.  The second and
 third parameters are the C types of the pointer and integer holding
 the string; for a krb5_data object, those should be the types in the
-example.  The pointer type must be char * or unsigned char *.  The
-fourth and fifth parameters reference primitive encoder and decoder
+example.  The pointer type must be char * or uint8_t *.  The fourth
+and fifth parameters reference primitive encoder and decoder
 functions; these should almost always be the ones in the example,
 unless the ASN.1 type is BIT STRING.  The sixth parameter is the
 universal tag number of the ASN.1 type, as defined in krbasn1.h.
@@ -299,9 +299,9 @@ pointer wrapper for the sequence element type (*not* the element type
 itself).  For example, an array of 32-bit signed integers is defined
 as:
 
-  DEFINTTYPE(int32, krb5_int32);
+  DEFINTTYPE(int32, int32_t);
   DEFPTRTYPE(int32_ptr, int32);
-  DEFCOUNTEDSEQOFTYPE(cseqof_int32, krb5_int32, int32_ptr);
+  DEFCOUNTEDSEQOFTYPE(cseqof_int32, int32_t, int32_ptr);
 
 To use a counted sequence-of type in a sequence, use DEFCOUNTEDTYPE:
 
diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c
index a7423b6..a7a5a2f 100644
--- a/src/lib/krb5/asn.1/asn1_encode.c
+++ b/src/lib/krb5/asn.1/asn1_encode.c
@@ -28,19 +28,19 @@
 
 /**** Functions for encoding primitive types ****/
 
-asn1_error_code
+krb5_error_code
 k5_asn1_encode_bool(asn1buf *buf, intmax_t val, size_t *len_out)
 {
-    asn1_octet bval = val ? 0xFF : 0x00;
+    uint8_t bval = val ? 0xFF : 0x00;
 
     *len_out = 1;
     return asn1buf_insert_octet(buf, bval);
 }
 
-asn1_error_code
+krb5_error_code
 k5_asn1_encode_int(asn1buf *buf, intmax_t val, size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     size_t len = 0;
     long valcopy;
     int digit;
@@ -72,10 +72,10 @@ k5_asn1_encode_int(asn1buf *buf, intmax_t val, size_t *len_out)
     return 0;
 }
 
-asn1_error_code
+krb5_error_code
 k5_asn1_encode_uint(asn1buf *buf, uintmax_t val, size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     size_t len = 0;
     uintmax_t valcopy;
     int digit;
@@ -101,8 +101,8 @@ k5_asn1_encode_uint(asn1buf *buf, uintmax_t val, size_t *len_out)
     return 0;
 }
 
-asn1_error_code
-k5_asn1_encode_bytestring(asn1buf *buf, unsigned char *const *val, size_t len,
+krb5_error_code
+k5_asn1_encode_bytestring(asn1buf *buf, uint8_t *const *val, size_t len,
                           size_t *len_out)
 {
     if (len > 0 && val == NULL)
@@ -111,12 +111,12 @@ k5_asn1_encode_bytestring(asn1buf *buf, unsigned char *const *val, size_t len,
     return asn1buf_insert_octetstring(buf, len, *val);
 }
 
-asn1_error_code
+krb5_error_code
 k5_asn1_encode_generaltime(asn1buf *buf, time_t val, size_t *len_out)
 {
     struct tm *gtime, gtimebuf;
     char s[16];
-    unsigned char *sp;
+    uint8_t *sp;
     time_t gmt_time = val;
     int len;
 
@@ -124,7 +124,7 @@ k5_asn1_encode_generaltime(asn1buf *buf, time_t val, size_t *len_out)
      * Time encoding: YYYYMMDDhhmmssZ
      */
     if (gmt_time == 0) {
-        sp = (unsigned char *)"19700101000000Z";
+        sp = (uint8_t *)"19700101000000Z";
     } else {
         /*
          * Sanity check this just to be paranoid, as gmtime can return NULL,
@@ -157,17 +157,17 @@ k5_asn1_encode_generaltime(asn1buf *buf, time_t val, size_t *len_out)
         if (SNPRINTF_OVERFLOW(len, sizeof(s)))
             /* Shouldn't be possible given above tests.  */
             return ASN1_BAD_GMTIME;
-        sp = (unsigned char *)s;
+        sp = (uint8_t *)s;
     }
 
     return k5_asn1_encode_bytestring(buf, &sp, 15, len_out);
 }
 
-asn1_error_code
-k5_asn1_encode_bitstring(asn1buf *buf, unsigned char *const *val, size_t len,
+krb5_error_code
+k5_asn1_encode_bitstring(asn1buf *buf, uint8_t *const *val, size_t len,
                          size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
 
     ret = asn1buf_insert_octetstring(buf, len, *val);
     if (ret)
@@ -178,8 +178,8 @@ k5_asn1_encode_bitstring(asn1buf *buf, unsigned char *const *val, size_t len,
 
 /**** Functions for decoding primitive types ****/
 
-asn1_error_code
-k5_asn1_decode_bool(const unsigned char *asn1, size_t len, intmax_t *val)
+krb5_error_code
+k5_asn1_decode_bool(const uint8_t *asn1, size_t len, intmax_t *val)
 {
     if (len != 1)
         return ASN1_BAD_LENGTH;
@@ -189,8 +189,8 @@ k5_asn1_decode_bool(const unsigned char *asn1, size_t len, intmax_t *val)
 
 /* Decode asn1/len as the contents of a DER integer, placing the signed result
  * in val. */
-asn1_error_code
-k5_asn1_decode_int(const unsigned char *asn1, size_t len, intmax_t *val)
+krb5_error_code
+k5_asn1_decode_int(const uint8_t *asn1, size_t len, intmax_t *val)
 {
     intmax_t n;
     size_t i;
@@ -209,8 +209,8 @@ k5_asn1_decode_int(const unsigned char *asn1, size_t len, intmax_t *val)
 
 /* Decode asn1/len as the contents of a DER integer, placing the unsigned
  * result in val. */
-asn1_error_code
-k5_asn1_decode_uint(const unsigned char *asn1, size_t len, uintmax_t *val)
+krb5_error_code
+k5_asn1_decode_uint(const uint8_t *asn1, size_t len, uintmax_t *val)
 {
     uintmax_t n;
     size_t i;
@@ -226,11 +226,11 @@ k5_asn1_decode_uint(const unsigned char *asn1, size_t len, uintmax_t *val)
     return 0;
 }
 
-asn1_error_code
-k5_asn1_decode_bytestring(const unsigned char *asn1, size_t len,
-                          unsigned char **str_out, size_t *len_out)
+krb5_error_code
+k5_asn1_decode_bytestring(const uint8_t *asn1, size_t len,
+                          uint8_t **str_out, size_t *len_out)
 {
-    unsigned char *str;
+    uint8_t *str;
 
     *str_out = NULL;
     *len_out = 0;
@@ -245,9 +245,8 @@ k5_asn1_decode_bytestring(const unsigned char *asn1, size_t len,
     return 0;
 }
 
-asn1_error_code
-k5_asn1_decode_generaltime(const unsigned char *asn1, size_t len,
-                           time_t *time_out)
+krb5_error_code
+k5_asn1_decode_generaltime(const uint8_t *asn1, size_t len, time_t *time_out)
 {
     const char *s = (char *)asn1;
     struct tm ts;
@@ -284,11 +283,11 @@ k5_asn1_decode_generaltime(const unsigned char *asn1, size_t len,
  * number of bits is not a multiple of 8 we effectively round up to the next
  * multiple of 8.
  */
-asn1_error_code
-k5_asn1_decode_bitstring(const unsigned char *asn1, size_t len,
-                         unsigned char **bits_out, size_t *len_out)
+krb5_error_code
+k5_asn1_decode_bitstring(const uint8_t *asn1, size_t len,
+                         uint8_t **bits_out, size_t *len_out)
 {
-    unsigned char unused, *bits;
+    uint8_t unused, *bits;
 
     *bits_out = NULL;
     *len_out = 0;
@@ -315,10 +314,10 @@ k5_asn1_decode_bitstring(const unsigned char *asn1, size_t len,
 
 /* Encode a DER tag into buf with the tag parameters in t and the content
  * length len.  Place the length of the encoded tag in *retlen. */
-static asn1_error_code
+static krb5_error_code
 make_tag(asn1buf *buf, const taginfo *t, size_t len, size_t *retlen)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     asn1_tagnum tag_copy;
     size_t sum = 0, length, len_copy;
 
@@ -390,14 +389,14 @@ make_tag(asn1buf *buf, const taginfo *t, size_t len, size_t *retlen)
  * really ancient implementations we handle the indefinite length form in tags.
  * However, we still insist on the primitive form of string types.)
  */
-static asn1_error_code
-get_tag(const unsigned char *asn1, size_t len, taginfo *tag_out,
-        const unsigned char **contents_out, size_t *clen_out,
-        const unsigned char **remainder_out, size_t *rlen_out)
+static krb5_error_code
+get_tag(const uint8_t *asn1, size_t len, taginfo *tag_out,
+        const uint8_t **contents_out, size_t *clen_out,
+        const uint8_t **remainder_out, size_t *rlen_out)
 {
-    asn1_error_code ret;
-    unsigned char o;
-    const unsigned char *c, *p, *tag_start = asn1;
+    krb5_error_code ret;
+    uint8_t o;
+    const uint8_t *c, *p, *tag_start = asn1;
     size_t clen, llen, i;
     taginfo t;
 
@@ -505,11 +504,11 @@ get_nullterm_sequence_len(const void *valp, const struct atype_info *seq)
     }
     return i;
 }
-static asn1_error_code
+static krb5_error_code
 encode_sequence_of(asn1buf *buf, size_t seqlen, const void *val,
                    const struct atype_info *eltinfo, size_t *len_out);
 
-static asn1_error_code
+static krb5_error_code
 encode_nullterm_sequence_of(asn1buf *buf, const void *val,
                             const struct atype_info *type,
                             int can_be_empty, size_t *len_out)
@@ -525,9 +524,9 @@ static intmax_t
 load_int(const void *val, size_t size)
 {
     switch (size) {
-    case 1: return *(signed char *)val;
-    case 2: return *(krb5_int16 *)val;
-    case 4: return *(krb5_int32 *)val;
+    case 1: return *(int8_t *)val;
+    case 2: return *(int16_t *)val;
+    case 4: return *(int32_t *)val;
     case 8: return *(int64_t *)val;
     default: abort();
     }
@@ -537,15 +536,15 @@ static uintmax_t
 load_uint(const void *val, size_t size)
 {
     switch (size) {
-    case 1: return *(unsigned char *)val;
-    case 2: return *(krb5_ui_2 *)val;
-    case 4: return *(krb5_ui_4 *)val;
+    case 1: return *(uint8_t *)val;
+    case 2: return *(uint16_t *)val;
+    case 4: return *(uint32_t *)val;
     case 8: return *(uint64_t *)val;
     default: abort();
     }
 }
 
-static asn1_error_code
+static krb5_error_code
 load_count(const void *val, const struct counted_info *counted,
            size_t *count_out)
 {
@@ -566,24 +565,24 @@ load_count(const void *val, const struct counted_info *counted,
     return 0;
 }
 
-static asn1_error_code
+static krb5_error_code
 store_int(intmax_t intval, size_t size, void *val)
 {
     switch (size) {
     case 1:
-        if ((signed char)intval != intval)
+        if ((int8_t)intval != intval)
             return ASN1_OVERFLOW;
-        *(signed char *)val = intval;
+        *(int8_t *)val = intval;
         return 0;
     case 2:
-        if ((krb5_int16)intval != intval)
+        if ((int16_t)intval != intval)
             return ASN1_OVERFLOW;
-        *(krb5_int16 *)val = intval;
+        *(int16_t *)val = intval;
         return 0;
     case 4:
-        if ((krb5_int32)intval != intval)
+        if ((int32_t)intval != intval)
             return ASN1_OVERFLOW;
-        *(krb5_int32 *)val = intval;
+        *(int32_t *)val = intval;
         return 0;
     case 8:
         if ((int64_t)intval != intval)
@@ -595,24 +594,24 @@ store_int(intmax_t intval, size_t size, void *val)
     }
 }
 
-static asn1_error_code
+static krb5_error_code
 store_uint(uintmax_t intval, size_t size, void *val)
 {
     switch (size) {
     case 1:
-        if ((unsigned char)intval != intval)
+        if ((uint8_t)intval != intval)
             return ASN1_OVERFLOW;
-        *(unsigned char *)val = intval;
+        *(uint8_t *)val = intval;
         return 0;
     case 2:
-        if ((krb5_ui_2)intval != intval)
+        if ((uint16_t)intval != intval)
             return ASN1_OVERFLOW;
-        *(krb5_ui_2 *)val = intval;
+        *(uint16_t *)val = intval;
         return 0;
     case 4:
-        if ((krb5_ui_4)intval != intval)
+        if ((uint32_t)intval != intval)
             return ASN1_OVERFLOW;
-        *(krb5_ui_4 *)val = intval;
+        *(uint32_t *)val = intval;
         return 0;
     case 8:
         if ((uint64_t)intval != intval)
@@ -626,7 +625,7 @@ store_uint(uintmax_t intval, size_t size, void *val)
 
 /* Store a count value in an integer field of a structure.  If count is
  * SIZE_MAX and the target is a signed field, store -1. */
-static asn1_error_code
+static krb5_error_code
 store_count(size_t count, const struct counted_info *counted, void *val)
 {
     void *countptr = (char *)val + counted->lenoff;
@@ -644,12 +643,12 @@ store_count(size_t count, const struct counted_info *counted, void *val)
 
 /* Split a DER encoding into tag and contents.  Insert the contents into buf,
  * then return the length of the contents and the tag. */
-static asn1_error_code
-split_der(asn1buf *buf, unsigned char *const *der, size_t len,
+static krb5_error_code
+split_der(asn1buf *buf, uint8_t *const *der, size_t len,
           taginfo *tag_out, size_t *len_out)
 {
-    asn1_error_code ret;
-    const unsigned char *contents, *remainder;
+    krb5_error_code ret;
+    const uint8_t *contents, *remainder;
     size_t clen, rlen;
 
     ret = get_tag(*der, len, tag_out, &contents, &clen, &remainder, &rlen);
@@ -663,14 +662,14 @@ split_der(asn1buf *buf, unsigned char *const *der, size_t len,
 
 /*
  * Store the DER encoding given by t and asn1/len into the char * or
- * unsigned char * pointed to by val.  Set *count_out to the length of the
+ * uint8_t * pointed to by val.  Set *count_out to the length of the
  * DER encoding.
  */
-static asn1_error_code
-store_der(const taginfo *t, const unsigned char *asn1, size_t len, void *val,
+static krb5_error_code
+store_der(const taginfo *t, const uint8_t *asn1, size_t len, void *val,
           size_t *count_out)
 {
-    unsigned char *der;
+    uint8_t *der;
     size_t der_len;
 
     *count_out = 0;
@@ -679,25 +678,25 @@ store_der(const taginfo *t, const unsigned char *asn1, size_t len, void *val,
     if (der == NULL)
         return ENOMEM;
     memcpy(der, asn1 - t->tag_len, der_len);
-    *(unsigned char **)val = der;
+    *(uint8_t **)val = der;
     *count_out = der_len;
     return 0;
 }
 
-static asn1_error_code
+static krb5_error_code
 encode_sequence(asn1buf *buf, const void *val, const struct seq_info *seq,
                 size_t *len_out);
-static asn1_error_code
+static krb5_error_code
 encode_cntype(asn1buf *buf, const void *val, size_t len,
               const struct cntype_info *c, taginfo *tag_out, size_t *len_out);
 
 /* Encode a value (contents only, no outer tag) according to a type, and return
  * its encoded tag information. */
-static asn1_error_code
+static krb5_error_code
 encode_atype(asn1buf *buf, const void *val, const struct atype_info *a,
              taginfo *tag_out, size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
 
     if (val == NULL)
         return ASN1_MISSING_FIELD;
@@ -821,12 +820,12 @@ encode_atype(asn1buf *buf, const void *val, const struct atype_info *a,
     return 0;
 }
 
-static asn1_error_code
+static krb5_error_code
 encode_atype_and_tag(asn1buf *buf, const void *val, const struct atype_info *a,
                      size_t *len_out)
 {
     taginfo t;
-    asn1_error_code ret;
+    krb5_error_code ret;
     size_t clen, tlen;
 
     ret = encode_atype(buf, val, a, &t, &clen);
@@ -844,11 +843,11 @@ encode_atype_and_tag(asn1buf *buf, const void *val, const struct atype_info *a,
  * pointer to the object being encoded, which in most cases is itself a
  * pointer (but is a union in the cntype_choice case).
  */
-static asn1_error_code
+static krb5_error_code
 encode_cntype(asn1buf *buf, const void *val, size_t count,
               const struct cntype_info *c, taginfo *tag_out, size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
 
     switch (c->type) {
     case cntype_string: {
@@ -894,11 +893,11 @@ encode_cntype(asn1buf *buf, const void *val, size_t count,
     return 0;
 }
 
-static asn1_error_code
+static krb5_error_code
 encode_sequence(asn1buf *buf, const void *val, const struct seq_info *seq,
                 size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     size_t i, len, sum = 0;
 
     for (i = seq->n_fields; i > 0; i--) {
@@ -913,11 +912,11 @@ encode_sequence(asn1buf *buf, const void *val, const struct seq_info *seq,
     return 0;
 }
 
-static asn1_error_code
+static krb5_error_code
 encode_sequence_of(asn1buf *buf, size_t seqlen, const void *val,
                    const struct atype_info *eltinfo, size_t *len_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     size_t sum = 0, i, len;
     const void *eltptr;
 
@@ -1187,27 +1186,27 @@ check_atype_tag(const struct atype_info *a, const taginfo *t)
     }
 }
 
-static asn1_error_code
-decode_cntype(const taginfo *t, const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_cntype(const taginfo *t, const uint8_t *asn1, size_t len,
               const struct cntype_info *c, void *val, size_t *count_out);
-static asn1_error_code
-decode_atype_to_ptr(const taginfo *t, const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_atype_to_ptr(const taginfo *t, const uint8_t *asn1, size_t len,
                     const struct atype_info *basetype, void **ptr_out);
-static asn1_error_code
-decode_sequence(const unsigned char *asn1, size_t len,
-                const struct seq_info *seq, void *val);
-static asn1_error_code
-decode_sequence_of(const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_sequence(const uint8_t *asn1, size_t len, const struct seq_info *seq,
+                void *val);
+static krb5_error_code
+decode_sequence_of(const uint8_t *asn1, size_t len,
                    const struct atype_info *elemtype, void **seq_out,
                    size_t *count_out);
 
 /* Given the enclosing tag t, decode from asn1/len the contents of the ASN.1
  * type specified by a, placing the result into val (caller-allocated). */
-static asn1_error_code
-decode_atype(const taginfo *t, const unsigned char *asn1,
-             size_t len, const struct atype_info *a, void *val)
+static krb5_error_code
+decode_atype(const taginfo *t, const uint8_t *asn1, size_t len,
+             const struct atype_info *a, void *val)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
 
     switch (a->type) {
     case atype_fn: {
@@ -1256,7 +1255,7 @@ decode_atype(const taginfo *t, const unsigned char *asn1,
         const struct tagged_info *tag = a->tinfo;
         taginfo inner_tag;
         const taginfo *tp = t;
-        const unsigned char *rem;
+        const uint8_t *rem;
         size_t rlen;
         if (!tag->implicit) {
             ret = get_tag(asn1, len, &inner_tag, &asn1, &len, &rem, &rlen);
@@ -1318,11 +1317,11 @@ decode_atype(const taginfo *t, const unsigned char *asn1,
  * If the resulting count should be -1 (for an unknown union distinguisher),
  * set *count_out to SIZE_MAX.
  */
-static asn1_error_code
-decode_cntype(const taginfo *t, const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_cntype(const taginfo *t, const uint8_t *asn1, size_t len,
               const struct cntype_info *c, void *val, size_t *count_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
 
     switch (c->type) {
     case cntype_string: {
@@ -1371,7 +1370,7 @@ decode_cntype(const taginfo *t, const unsigned char *asn1, size_t len,
 
 /* Add a null pointer to the end of a sequence.  ptr is consumed on success
  * (to be replaced by *ptr_out), left alone on failure. */
-static asn1_error_code
+static krb5_error_code
 null_terminate(const struct atype_info *eltinfo, void *ptr, size_t count,
                void **ptr_out)
 {
@@ -1388,12 +1387,11 @@ null_terminate(const struct atype_info *eltinfo, void *ptr, size_t count,
     return 0;
 }
 
-static asn1_error_code
-decode_atype_to_ptr(const taginfo *t, const unsigned char *asn1,
-                    size_t len, const struct atype_info *a,
-                    void **ptr_out)
+static krb5_error_code
+decode_atype_to_ptr(const taginfo *t, const uint8_t *asn1, size_t len,
+                    const struct atype_info *a, void **ptr_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     void *ptr;
     size_t count;
 
@@ -1429,7 +1427,7 @@ decode_atype_to_ptr(const taginfo *t, const unsigned char *asn1,
 
 /* Initialize a C object when the corresponding ASN.1 type was omitted within a
  * sequence.  If the ASN.1 type is not optional, return ASN1_MISSING_FIELD. */
-static asn1_error_code
+static krb5_error_code
 omit_atype(const struct atype_info *a, void *val)
 {
     switch (a->type)
@@ -1468,12 +1466,12 @@ omit_atype(const struct atype_info *a, void *val)
 }
 
 /* Decode an ASN.1 sequence into a C object. */
-static asn1_error_code
-decode_sequence(const unsigned char *asn1, size_t len,
-                const struct seq_info *seq, void *val)
+static krb5_error_code
+decode_sequence(const uint8_t *asn1, size_t len, const struct seq_info *seq,
+                void *val)
 {
-    asn1_error_code ret;
-    const unsigned char *contents;
+    krb5_error_code ret;
+    const uint8_t *contents;
     size_t i, j, clen;
     taginfo t;
 
@@ -1525,14 +1523,14 @@ error:
     return ret;
 }
 
-static asn1_error_code
-decode_sequence_of(const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_sequence_of(const uint8_t *asn1, size_t len,
                    const struct atype_info *elemtype, void **seq_out,
                    size_t *count_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     void *seq = NULL, *elem, *newseq;
-    const unsigned char *contents;
+    const uint8_t *contents;
     size_t clen, count = 0;
     taginfo t;
 
@@ -1572,16 +1570,16 @@ error:
 /* These three entry points are only needed for the kdc_req_body hack and may
  * go away at some point.  Define them here so we can use short names above. */
 
-asn1_error_code
+krb5_error_code
 k5_asn1_encode_atype(asn1buf *buf, const void *val, const struct atype_info *a,
                      taginfo *tag_out, size_t *len_out)
 {
     return encode_atype(buf, val, a, tag_out, len_out);
 }
 
-asn1_error_code
-k5_asn1_decode_atype(const taginfo *t, const unsigned char *asn1,
-                     size_t len, const struct atype_info *a, void *val)
+krb5_error_code
+k5_asn1_decode_atype(const taginfo *t, const uint8_t *asn1, size_t len,
+                     const struct atype_info *a, void *val)
 {
     return decode_atype(t, asn1, len, a, val);
 }
@@ -1591,7 +1589,7 @@ k5_asn1_full_encode(const void *rep, const struct atype_info *a,
                     krb5_data **code_out)
 {
     size_t len;
-    asn1_error_code ret;
+    krb5_error_code ret;
     asn1buf *buf = NULL;
     krb5_data *d;
 
@@ -1614,17 +1612,17 @@ cleanup:
     return ret;
 }
 
-asn1_error_code
+krb5_error_code
 k5_asn1_full_decode(const krb5_data *code, const struct atype_info *a,
                     void **retrep)
 {
-    asn1_error_code ret;
-    const unsigned char *contents, *remainder;
+    krb5_error_code ret;
+    const uint8_t *contents, *remainder;
     size_t clen, rlen;
     taginfo t;
 
     *retrep = NULL;
-    ret = get_tag((unsigned char *)code->data, code->length, &t, &contents,
+    ret = get_tag((uint8_t *)code->data, code->length, &t, &contents,
                   &clen, &remainder, &rlen);
     if (ret)
         return ret;
diff --git a/src/lib/krb5/asn.1/asn1_encode.h b/src/lib/krb5/asn.1/asn1_encode.h
index d95f654..1e17075 100644
--- a/src/lib/krb5/asn.1/asn1_encode.h
+++ b/src/lib/krb5/asn.1/asn1_encode.h
@@ -45,37 +45,33 @@ typedef struct {
 
 /* These functions are referenced by encoder structures.  They handle the
  * encoding of primitive ASN.1 types. */
-asn1_error_code k5_asn1_encode_bool(asn1buf *buf, intmax_t val,
+krb5_error_code k5_asn1_encode_bool(asn1buf *buf, intmax_t val,
                                     size_t *len_out);
-asn1_error_code k5_asn1_encode_int(asn1buf *buf, intmax_t val,
+krb5_error_code k5_asn1_encode_int(asn1buf *buf, intmax_t val,
                                    size_t *len_out);
-asn1_error_code k5_asn1_encode_uint(asn1buf *buf, uintmax_t val,
+krb5_error_code k5_asn1_encode_uint(asn1buf *buf, uintmax_t val,
                                     size_t *len_out);
-asn1_error_code k5_asn1_encode_bytestring(asn1buf *buf,
-                                          unsigned char *const *val,
+krb5_error_code k5_asn1_encode_bytestring(asn1buf *buf, uint8_t *const *val,
                                           size_t len, size_t *len_out);
-asn1_error_code k5_asn1_encode_bitstring(asn1buf *buf,
-                                         unsigned char *const *val,
+krb5_error_code k5_asn1_encode_bitstring(asn1buf *buf, uint8_t *const *val,
                                          size_t len, size_t *len_out);
-asn1_error_code k5_asn1_encode_generaltime(asn1buf *buf, time_t val,
+krb5_error_code k5_asn1_encode_generaltime(asn1buf *buf, time_t val,
                                            size_t *len_out);
 
 /* These functions are referenced by encoder structures.  They handle the
  * decoding of primitive ASN.1 types. */
-asn1_error_code k5_asn1_decode_bool(const unsigned char *asn1, size_t len,
+krb5_error_code k5_asn1_decode_bool(const uint8_t *asn1, size_t len,
                                     intmax_t *val);
-asn1_error_code k5_asn1_decode_int(const unsigned char *asn1, size_t len,
+krb5_error_code k5_asn1_decode_int(const uint8_t *asn1, size_t len,
                                    intmax_t *val);
-asn1_error_code k5_asn1_decode_uint(const unsigned char *asn1, size_t len,
+krb5_error_code k5_asn1_decode_uint(const uint8_t *asn1, size_t len,
                                     uintmax_t *val);
-asn1_error_code k5_asn1_decode_generaltime(const unsigned char *asn1,
-                                           size_t len, time_t *time_out);
-asn1_error_code k5_asn1_decode_bytestring(const unsigned char *asn1,
-                                          size_t len, unsigned char **str_out,
-                                          size_t *len_out);
-asn1_error_code k5_asn1_decode_bitstring(const unsigned char *asn1, size_t len,
-                                         unsigned char **bits_out,
-                                         size_t *len_out);
+krb5_error_code k5_asn1_decode_generaltime(const uint8_t *asn1, size_t len,
+                                           time_t *time_out);
+krb5_error_code k5_asn1_decode_bytestring(const uint8_t *asn1, size_t len,
+                                          uint8_t **str_out, size_t *len_out);
+krb5_error_code k5_asn1_decode_bitstring(const uint8_t *asn1, size_t len,
+                                         uint8_t **bits_out, size_t *len_out);
 
 /*
  * An atype_info structure specifies how to map a C object to an ASN.1 value.
@@ -152,9 +148,8 @@ struct atype_info {
 };
 
 struct fn_info {
-    asn1_error_code (*enc)(asn1buf *, const void *, taginfo *, size_t *);
-    asn1_error_code (*dec)(const taginfo *, const unsigned char *, size_t,
-                           void *);
+    krb5_error_code (*enc)(asn1buf *, const void *, taginfo *, size_t *);
+    krb5_error_code (*dec)(const taginfo *, const uint8_t *, size_t, void *);
     int (*check_tag)(const taginfo *);
     void (*free_func)(void *);
 };
@@ -191,7 +186,7 @@ struct tagged_info {
 
 struct immediate_info {
     intmax_t val;
-    asn1_error_code err;
+    krb5_error_code err;
 };
 
 /* A cntype_info structure specifies how to map a C object and count (length or
@@ -202,7 +197,7 @@ enum cntype_type {
 
     /*
      * Apply an encoder function (contents only) and wrap it in a universal
-     * primitive tag.  The C object must be a char * or unsigned char *.  tinfo
+     * primitive tag.  The C object must be a char * or uint8_t *.  tinfo
      * is a struct string_info *.
      */
     cntype_string,
@@ -231,10 +226,8 @@ struct cntype_info {
 };
 
 struct string_info {
-    asn1_error_code (*enc)(asn1buf *, unsigned char *const *, size_t,
-                           size_t *);
-    asn1_error_code (*dec)(const unsigned char *, size_t, unsigned char **,
-                           size_t *);
+    krb5_error_code (*enc)(asn1buf *, uint8_t *const *, size_t, size_t *);
+    krb5_error_code (*dec)(const uint8_t *, size_t, uint8_t **, size_t *);
     unsigned int tagval : 5;
 };
 
@@ -532,22 +525,22 @@ struct seq_info {
 
 /* Partially encode the contents of a type and return its tag information.
  * Used only by kdc_req_body. */
-asn1_error_code
+krb5_error_code
 k5_asn1_encode_atype(asn1buf *buf, const void *val, const struct atype_info *a,
                      taginfo *tag_out, size_t *len_out);
 
 /* Decode the tag and contents of a type, storing the result in the
  * caller-allocated C object val.  Used only by kdc_req_body. */
-asn1_error_code
-k5_asn1_decode_atype(const taginfo *t, const unsigned char *asn1,
-                     size_t len, const struct atype_info *a, void *val);
+krb5_error_code
+k5_asn1_decode_atype(const taginfo *t, const uint8_t *asn1, size_t len,
+                     const struct atype_info *a, void *val);
 
 /* Returns a completed encoding, with tag and in the correct byte order, in an
  * allocated krb5_data. */
 extern krb5_error_code
 k5_asn1_full_encode(const void *rep, const struct atype_info *a,
                     krb5_data **code_out);
-asn1_error_code
+krb5_error_code
 k5_asn1_full_decode(const krb5_data *code, const struct atype_info *a,
                     void **rep_out);
 
@@ -563,7 +556,7 @@ k5_asn1_full_decode(const krb5_data *code, const struct atype_info *a,
     krb5_error_code                                                     \
     FNAME(const krb5_data *code, aux_type_##DESC **rep_out)             \
     {                                                                   \
-        asn1_error_code ret;                                            \
+        krb5_error_code ret;                                            \
         void *rep;                                                      \
         *rep_out = NULL;                                                \
         ret = k5_asn1_full_decode(code, &k5_atype_##DESC, &rep);        \
diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c
index 29f6b90..0b6003b 100644
--- a/src/lib/krb5/asn.1/asn1_k_encode.c
+++ b/src/lib/krb5/asn.1/asn1_k_encode.c
@@ -32,25 +32,25 @@ DEFINT_IMMEDIATE(krb5_version, KVNO, KRB5KDC_ERR_BAD_PVNO);
 static int
 int32_not_minus1(const void *p)
 {
-    return (*(krb5_int32 *)p != -1);
+    return *(int32_t *)p != -1;
 }
 
 static void
 init_int32_minus1(void *p)
 {
-    *(krb5_int32 *)p = -1;
+    *(int32_t *)p = -1;
 }
 
 DEFBOOLTYPE(boolean, krb5_boolean);
-DEFINTTYPE(int32, krb5_int32);
+DEFINTTYPE(int32, int32_t);
 DEFPTRTYPE(int32_ptr, int32);
-DEFCOUNTEDSEQOFTYPE(cseqof_int32, krb5_int32, int32_ptr);
+DEFCOUNTEDSEQOFTYPE(cseqof_int32, int32_t, int32_ptr);
 DEFOPTIONALZEROTYPE(opt_int32, int32);
 DEFOPTIONALTYPE(opt_int32_minus1, int32_not_minus1, init_int32_minus1, int32);
 
 DEFUINTTYPE(uint, unsigned int);
 DEFUINTTYPE(octet, krb5_octet);
-DEFUINTTYPE(ui_4, krb5_ui_4);
+DEFUINTTYPE(uint32, uint32_t);
 DEFOPTIONALZEROTYPE(opt_uint, uint);
 
 static int
@@ -64,7 +64,7 @@ DEFCOUNTEDDERTYPE(der, char *, unsigned int);
 DEFCOUNTEDTYPE(der_data, krb5_data, data, length, der);
 DEFOPTIONALTYPE(opt_der_data, nonempty_data, NULL, der_data);
 
-DEFCOUNTEDSTRINGTYPE(octetstring, unsigned char *, unsigned int,
+DEFCOUNTEDSTRINGTYPE(octetstring, uint8_t *, unsigned int,
                      k5_asn1_encode_bytestring, k5_asn1_decode_bytestring,
                      ASN1_OCTETSTRING);
 DEFCOUNTEDSTRINGTYPE(s_octetstring, char *, unsigned int,
@@ -78,13 +78,13 @@ DEFOPTIONALZEROTYPE(opt_ostring_data_ptr, ostring_data_ptr);
 DEFCOUNTEDSTRINGTYPE(generalstring, char *, unsigned int,
                      k5_asn1_encode_bytestring, k5_asn1_decode_bytestring,
                      ASN1_GENERALSTRING);
-DEFCOUNTEDSTRINGTYPE(u_generalstring, unsigned char *, unsigned int,
+DEFCOUNTEDSTRINGTYPE(u_generalstring, uint8_t *, unsigned int,
                      k5_asn1_encode_bytestring, k5_asn1_decode_bytestring,
                      ASN1_GENERALSTRING);
 DEFCOUNTEDTYPE(gstring_data, krb5_data, data, length, generalstring);
 DEFOPTIONALTYPE(opt_gstring_data, nonempty_data, NULL, gstring_data);
 DEFPTRTYPE(gstring_data_ptr, gstring_data);
-DEFCOUNTEDSEQOFTYPE(cseqof_gstring_data, krb5_int32, gstring_data_ptr);
+DEFCOUNTEDSEQOFTYPE(cseqof_gstring_data, int32_t, gstring_data_ptr);
 
 DEFCOUNTEDSTRINGTYPE(utf8string, char *, unsigned int,
                      k5_asn1_encode_bytestring, k5_asn1_decode_bytestring,
@@ -116,31 +116,31 @@ DEFPTRTYPE(principal, principal_data);
 DEFOPTIONALZEROTYPE(opt_principal, principal);
 
 /*
- * Define the seqno type, which is an ASN.1 integer represented in a krb5_ui_4.
+ * Define the seqno type, which is an ASN.1 integer represented in a uint32_t.
  * When decoding, negative 32-bit numbers are accepted for interoperability
  * with old implementations.
  */
-static asn1_error_code
+static krb5_error_code
 encode_seqno(asn1buf *buf, const void *p, taginfo *rettag, size_t *len_out)
 {
-    krb5_ui_4 val = *(krb5_ui_4 *)p;
+    uint32_t val = *(uint32_t *)p;
     rettag->asn1class = UNIVERSAL;
     rettag->construction = PRIMITIVE;
     rettag->tagnum = ASN1_INTEGER;
     return k5_asn1_encode_uint(buf, val, len_out);
 }
-static asn1_error_code
-decode_seqno(const taginfo *t, const unsigned char *asn1, size_t len, void *p)
+static krb5_error_code
+decode_seqno(const taginfo *t, const uint8_t *asn1, size_t len, void *p)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     intmax_t val;
     ret = k5_asn1_decode_int(asn1, len, &val);
     if (ret)
         return ret;
-    if (val < KRB5_INT32_MIN || val > 0xFFFFFFFF)
+    if (val < INT32_MIN || val > 0xFFFFFFFF)
         return ASN1_OVERFLOW;
-    /* Negative values will cast correctly to krb5_ui_4. */
-    *(krb5_ui_4 *)p = val;
+    /* Negative values will cast correctly to uint32_t. */
+    *(uint32_t *)p = val;
     return 0;
 }
 static int
@@ -149,12 +149,12 @@ check_seqno(const taginfo *t)
     return (t->asn1class == UNIVERSAL && t->construction == PRIMITIVE &&
             t->tagnum == ASN1_INTEGER);
 }
-DEFFNTYPE(seqno, krb5_ui_4, encode_seqno, decode_seqno, check_seqno, NULL);
+DEFFNTYPE(seqno, uint32_t, encode_seqno, decode_seqno, check_seqno, NULL);
 DEFOPTIONALZEROTYPE(opt_seqno, seqno);
 
 /* Define the kerberos_time type, which is an ASN.1 generaltime represented in
  * a krb5_timestamp. */
-static asn1_error_code
+static krb5_error_code
 encode_kerberos_time(asn1buf *buf, const void *p, taginfo *rettag,
                      size_t *len_out)
 {
@@ -164,11 +164,11 @@ encode_kerberos_time(asn1buf *buf, const void *p, taginfo *rettag,
     rettag->tagnum = ASN1_GENERALTIME;
     return k5_asn1_encode_generaltime(buf, val, len_out);
 }
-static asn1_error_code
-decode_kerberos_time(const taginfo *t, const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_kerberos_time(const taginfo *t, const uint8_t *asn1, size_t len,
                      void *p)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     time_t val;
     ret = k5_asn1_decode_generaltime(asn1, len, &val);
     if (ret)
@@ -228,25 +228,24 @@ DEFOPTIONALTYPE(opt_encrypted_data, nonempty_enc_data, NULL, encrypted_data);
 
 /* Define the krb5_flags type, which is an ASN.1 bit string represented in a
  * 32-bit integer. */
-static asn1_error_code
+static krb5_error_code
 encode_krb5_flags(asn1buf *buf, const void *p, taginfo *rettag,
                   size_t *len_out)
 {
-    unsigned char cbuf[4], *cptr = cbuf;
-    store_32_be((krb5_ui_4)*(const krb5_flags *)p, cbuf);
+    uint8_t cbuf[4], *cptr = cbuf;
+    store_32_be((uint32_t)*(const krb5_flags *)p, cbuf);
     rettag->asn1class = UNIVERSAL;
     rettag->construction = PRIMITIVE;
     rettag->tagnum = ASN1_BITSTRING;
     return k5_asn1_encode_bitstring(buf, &cptr, 4, len_out);
 }
-static asn1_error_code
-decode_krb5_flags(const taginfo *t, const unsigned char *asn1, size_t len,
-                  void *val)
+static krb5_error_code
+decode_krb5_flags(const taginfo *t, const uint8_t *asn1, size_t len, void *val)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     size_t i, blen;
     krb5_flags f = 0;
-    unsigned char *bits;
+    uint8_t *bits;
     ret = k5_asn1_decode_bitstring(asn1, len, &bits, &blen);
     if (ret)
         return ret;
@@ -314,34 +313,33 @@ DEFNULLTERMSEQOFTYPE(seqof_checksum, checksum_ptr);
 DEFPTRTYPE(ptr_seqof_checksum, seqof_checksum);
 DEFOPTIONALZEROTYPE(opt_checksum_ptr, checksum_ptr);
 
-/* Define the last_req_type type, which is a krb5_int32 with some massaging
- * on decode for backward compatibility. */
-static asn1_error_code
+/* Define the last_req_type type, which is an int32_t with some massaging on
+ * decode for backward compatibility. */
+static krb5_error_code
 encode_lr_type(asn1buf *buf, const void *p, taginfo *rettag, size_t *len_out)
 {
-    krb5_int32 val = *(krb5_int32 *)p;
+    int32_t val = *(int32_t *)p;
     rettag->asn1class = UNIVERSAL;
     rettag->construction = PRIMITIVE;
     rettag->tagnum = ASN1_INTEGER;
     return k5_asn1_encode_int(buf, val, len_out);
 }
-static asn1_error_code
-decode_lr_type(const taginfo *t, const unsigned char *asn1, size_t len,
-               void *p)
+static krb5_error_code
+decode_lr_type(const taginfo *t, const uint8_t *asn1, size_t len, void *p)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     intmax_t val;
     ret = k5_asn1_decode_int(asn1, len, &val);
     if (ret)
         return ret;
-    if (val > KRB5_INT32_MAX || val < KRB5_INT32_MIN)
+    if (val > INT32_MAX || val < INT32_MIN)
         return ASN1_OVERFLOW;
 #ifdef KRB5_GENEROUS_LR_TYPE
     /* If type is in the 128-255 range, treat it as a negative 8-bit value. */
     if (val >= 128 && val <= 255)
         val -= 256;
 #endif
-    *(krb5_int32 *)p = val;
+    *(int32_t *)p = val;
     return 0;
 }
 static int
@@ -350,7 +348,7 @@ check_lr_type(const taginfo *t)
     return (t->asn1class == UNIVERSAL && t->construction == PRIMITIVE &&
             t->tagnum == ASN1_INTEGER);
 }
-DEFFNTYPE(last_req_type, krb5_int32, encode_lr_type, decode_lr_type,
+DEFFNTYPE(last_req_type, int32_t, encode_lr_type, decode_lr_type,
           check_lr_type, NULL);
 
 DEFFIELD(last_req_0, krb5_last_req_entry, lr_type, 0, last_req_type);
@@ -473,7 +471,7 @@ static const struct atype_info *kdc_req_hack_fields[] = {
     &k5_atype_req_body_9, &k5_atype_req_body_10, &k5_atype_req_body_11
 };
 DEFSEQTYPE(kdc_req_body_hack, kdc_req_hack, kdc_req_hack_fields);
-static asn1_error_code
+static krb5_error_code
 encode_kdc_req_body(asn1buf *buf, const void *p, taginfo *tag_out,
                     size_t *len_out)
 {
@@ -503,11 +501,11 @@ free_kdc_req_body(void *val)
     free(req->authorization_data.ciphertext.data);
     krb5_free_tickets(NULL, req->second_ticket);
 }
-static asn1_error_code
-decode_kdc_req_body(const taginfo *t, const unsigned char *asn1, size_t len,
+static krb5_error_code
+decode_kdc_req_body(const taginfo *t, const uint8_t *asn1, size_t len,
                     void *val)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     kdc_req_hack h;
     krb5_kdc_req *b = val;
     memset(&h, 0, sizeof(h));
@@ -925,7 +923,7 @@ DEFFIELD(error_2, krb5_error, ctime, 2, opt_kerberos_time);
 DEFFIELD(error_3, krb5_error, cusec, 3, opt_int32);
 DEFFIELD(error_4, krb5_error, stime, 4, kerberos_time);
 DEFFIELD(error_5, krb5_error, susec, 5, int32);
-DEFFIELD(error_6, krb5_error, error, 6, ui_4);
+DEFFIELD(error_6, krb5_error, error, 6, uint32);
 DEFFIELD(error_7, krb5_error, client, 7, opt_realm_of_principal);
 DEFFIELD(error_8, krb5_error, client, 8, opt_principal);
 DEFFIELD(error_9, krb5_error, server, 9, realm_of_principal);
@@ -1172,7 +1170,7 @@ krb5_error_code
 decode_krb5_enc_kdc_rep_part(const krb5_data *code,
                              krb5_enc_kdc_rep_part **rep_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     krb5_enc_kdc_rep_part *rep;
     void *rep_ptr;
     krb5_msgtype msg_type = KRB5_TGS_REP;
@@ -1223,7 +1221,7 @@ krb5_error_code
 decode_krb5_safe_with_body(const krb5_data *code, krb5_safe **rep_out,
                            krb5_data **body_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     void *swb_ptr, *safe_ptr;
     struct krb5_safe_with_body *swb;
     krb5_safe *safe;
@@ -1290,7 +1288,7 @@ krb5_error_code
 decode_krb5_setpw_req(const krb5_data *code, krb5_data **password_out,
                       krb5_principal *target_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     void *req_ptr;
     struct krb5_setpw_req *req;
     krb5_data *data;
@@ -1347,7 +1345,7 @@ krb5int_get_authdata_containee_types(krb5_context context,
                                      unsigned int *num_out,
                                      krb5_authdatatype **types_out)
 {
-    asn1_error_code ret;
+    krb5_error_code ret;
     struct authdata_types *atypes;
     void *atypes_ptr;
     krb5_data d = make_data(authdata->contents, authdata->length);
diff --git a/src/lib/krb5/asn.1/asn1buf.c b/src/lib/krb5/asn.1/asn1buf.c
index b937530..c27bfb9 100644
--- a/src/lib/krb5/asn.1/asn1buf.c
+++ b/src/lib/krb5/asn.1/asn1buf.c
@@ -70,14 +70,14 @@
  * 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);
+static krb5_error_code asn1buf_ensure_space(asn1buf *, unsigned int);
+static krb5_error_code asn1buf_expand(asn1buf *, unsigned int);
 #endif
 
 #define asn1_is_eoc(class, num, indef)                  \
     ((class) == UNIVERSAL && !(num) && !(indef))
 
-asn1_error_code
+krb5_error_code
 asn1buf_create(asn1buf **buf)
 {
     *buf = (asn1buf*)malloc(sizeof(asn1buf));
@@ -101,10 +101,10 @@ asn1buf_destroy(asn1buf **buf)
 #ifdef asn1buf_insert_octet
 #undef asn1buf_insert_octet
 #endif
-asn1_error_code
+krb5_error_code
 asn1buf_insert_octet(asn1buf *buf, const int o)
 {
-    asn1_error_code retval;
+    krb5_error_code retval;
 
     retval = asn1buf_ensure_space(buf,1U);
     if (retval) return retval;
@@ -113,10 +113,10 @@ asn1buf_insert_octet(asn1buf *buf, const int o)
     return 0;
 }
 
-asn1_error_code
+krb5_error_code
 asn1buf_insert_bytestring(asn1buf *buf, const unsigned int len, const void *sv)
 {
-    asn1_error_code retval;
+    krb5_error_code retval;
     unsigned int length;
     const char *s = sv;
 
@@ -128,7 +128,7 @@ asn1buf_insert_bytestring(asn1buf *buf, const unsigned int len, const void *sv)
     return 0;
 }
 
-asn1_error_code
+krb5_error_code
 asn12krb5_buf(const asn1buf *buf, krb5_data **code)
 {
     unsigned int i;
@@ -172,7 +172,7 @@ asn1buf_free(const asn1buf *buf)
 }
 
 #undef asn1buf_ensure_space
-asn1_error_code
+krb5_error_code
 asn1buf_ensure_space(asn1buf *buf, const unsigned int amount)
 {
     unsigned int avail = asn1buf_free(buf);
@@ -181,7 +181,7 @@ asn1buf_ensure_space(asn1buf *buf, const unsigned int amount)
     return asn1buf_expand(buf, amount-avail);
 }
 
-asn1_error_code
+krb5_error_code
 asn1buf_expand(asn1buf *buf, unsigned int inc)
 {
 #define STANDARD_INCREMENT 200
@@ -193,8 +193,7 @@ asn1buf_expand(asn1buf *buf, unsigned int inc)
     if (inc < STANDARD_INCREMENT)
         inc = STANDARD_INCREMENT;
 
-    buf->base = realloc(buf->base,
-                        (asn1buf_size(buf)+inc) * sizeof(asn1_octet));
+    buf->base = realloc(buf->base, asn1buf_size(buf) + inc);
     if (buf->base == NULL) return ENOMEM; /* XXX leak */
     buf->bound = (buf->base) + bound_offset + inc;
     buf->next = (buf->base) + next_offset;
diff --git a/src/lib/krb5/asn.1/asn1buf.h b/src/lib/krb5/asn.1/asn1buf.h
index 0d7138d..494417f 100644
--- a/src/lib/krb5/asn.1/asn1buf.h
+++ b/src/lib/krb5/asn.1/asn1buf.h
@@ -25,7 +25,7 @@ unsigned int asn1buf_free(const asn1buf *buf);
      : (unsigned int)((buf)->bound - (buf)->next + 1))
 
 
-asn1_error_code asn1buf_ensure_space(asn1buf *buf, const unsigned int amount);
+krb5_error_code asn1buf_ensure_space(asn1buf *buf, const unsigned int amount);
 /*
  * requires  *buf is allocated
  * modifies  *buf
@@ -38,7 +38,7 @@ asn1_error_code asn1buf_ensure_space(asn1buf *buf, const unsigned int amount);
      ? (asn1buf_expand((buf), (amount)-asn1buf_free(buf)))      \
      : 0)
 
-asn1_error_code asn1buf_expand(asn1buf *buf, unsigned int inc);
+krb5_error_code asn1buf_expand(asn1buf *buf, unsigned int inc);
 /*
  * requires  *buf is allocated
  * modifies  *buf
@@ -93,7 +93,7 @@ int asn1buf_len(const asn1buf *buf);
  *  (asn1buf_len)
  */
 
-asn1_error_code asn1buf_create(asn1buf **buf);
+krb5_error_code asn1buf_create(asn1buf **buf);
 /*
  * effects   Creates a new encoding buffer pointed to by *buf.
  *           Returns ENOMEM if the buffer can't be created.
@@ -108,10 +108,10 @@ void asn1buf_destroy(asn1buf **buf);
  *           necessary.  Returns ENOMEM memory is exhausted.
  */
 #if ((__GNUC__ >= 2) && !defined(ASN1BUF_OMIT_INLINE_FUNCS)) && !defined(CONFIG_SMALL)
-static inline asn1_error_code
+static inline krb5_error_code
 asn1buf_insert_octet(asn1buf *buf, const int o)
 {
-    asn1_error_code retval;
+    krb5_error_code retval;
 
     retval = asn1buf_ensure_space(buf,1U);
     if (retval) return retval;
@@ -120,10 +120,10 @@ asn1buf_insert_octet(asn1buf *buf, const int o)
     return 0;
 }
 #else
-asn1_error_code asn1buf_insert_octet(asn1buf *buf, const int o);
+krb5_error_code asn1buf_insert_octet(asn1buf *buf, const int o);
 #endif
 
-asn1_error_code
+krb5_error_code
 asn1buf_insert_bytestring(
     asn1buf *buf,
     const unsigned int len,
@@ -138,7 +138,7 @@ asn1buf_insert_bytestring(
 
 #define asn1buf_insert_octetstring asn1buf_insert_bytestring
 
-asn1_error_code asn12krb5_buf(const asn1buf *buf, krb5_data **code);
+krb5_error_code asn12krb5_buf(const asn1buf *buf, krb5_data **code);
 /*
  * modifies  *code
  * effects   Instantiates **code with the krb5_data representation of **buf.
diff --git a/src/lib/krb5/asn.1/krbasn1.h b/src/lib/krb5/asn.1/krbasn1.h
index 1755784..cfc24ad 100644
--- a/src/lib/krb5/asn.1/krbasn1.h
+++ b/src/lib/krb5/asn.1/krbasn1.h
@@ -27,7 +27,6 @@
  */
 #define KRB5_GENEROUS_LR_TYPE
 
-typedef krb5_octet asn1_octet;
 typedef krb5_error_code asn1_error_code;
 
 typedef enum { PRIMITIVE = 0x00, CONSTRUCTED = 0x20 } asn1_construction;
diff --git a/src/lib/krb5/asn.1/ldap_key_seq.c b/src/lib/krb5/asn.1/ldap_key_seq.c
index 74569d9..9734e99 100644
--- a/src/lib/krb5/asn.1/ldap_key_seq.c
+++ b/src/lib/krb5/asn.1/ldap_key_seq.c
@@ -48,12 +48,12 @@
  * Imports from asn1_k_encode.c.
  * XXX Must be manually synchronized for now.
  */
-IMPORT_TYPE(int32, krb5_int32);
+IMPORT_TYPE(int32, int32_t);
 
-DEFINTTYPE(int16, krb5_int16);
-DEFINTTYPE(uint16, krb5_ui_2);
+DEFINTTYPE(int16, int16_t);
+DEFINTTYPE(uint16, uint16_t);
 
-DEFCOUNTEDSTRINGTYPE(ui2_octetstring, unsigned char *, krb5_ui_2,
+DEFCOUNTEDSTRINGTYPE(ui2_octetstring, uint8_t *, uint16_t,
                      k5_asn1_encode_bytestring, k5_asn1_decode_bytestring,
                      ASN1_OCTETSTRING);
 
@@ -104,7 +104,7 @@ static const struct atype_info *key_data_fields[] = {
 };
 DEFSEQTYPE(key_data, krb5_key_data, key_data_fields);
 DEFPTRTYPE(ptr_key_data, key_data);
-DEFCOUNTEDSEQOFTYPE(cseqof_key_data, krb5_int16, ptr_key_data);
+DEFCOUNTEDSEQOFTYPE(cseqof_key_data, int16_t, ptr_key_data);
 
 DEFINT_IMMEDIATE(one, 1, ASN1_BAD_FORMAT);
 DEFCTAGGEDTYPE(ldap_key_seq_0, 0, one);
diff --git a/src/tests/asn.1/Makefile.in b/src/tests/asn.1/Makefile.in
index ec9c674..eabe0bd 100644
--- a/src/tests/asn.1/Makefile.in
+++ b/src/tests/asn.1/Makefile.in
@@ -13,8 +13,6 @@ ASN1SRCS= $(srcdir)/krb5.asn1 $(srcdir)/pkix.asn1 $(srcdir)/otp.asn1 \
 
 all: krb5_encode_test krb5_decode_test krb5_decode_leak t_trval
 
-LOCALINCLUDES = -I$(srcdir)/../../lib/krb5/asn.1
-
 ENCOBJS = krb5_encode_test.o ktest.o ktest_equal.o utility.o trval.o
 
 krb5_encode_test: $(ENCOBJS) $(KRB5_BASE_DEPLIBS)
diff --git a/src/tests/asn.1/deps b/src/tests/asn.1/deps
index 3d45bb5..0b44f44 100644
--- a/src/tests/asn.1/deps
+++ b/src/tests/asn.1/deps
@@ -3,67 +3,67 @@
 #
 $(OUTPRE)krb5_encode_test.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../lib/krb5/asn.1/asn1buf.h \
-  $(srcdir)/../../lib/krb5/asn.1/krbasn1.h $(top_srcdir)/include/k5-buf.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
-  $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
-  $(top_srcdir)/include/kdb.h $(top_srcdir)/include/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  debug.h krb5_encode_test.c ktest.h utility.h
+  $(top_srcdir)/include/k5-spake.h $(top_srcdir)/include/k5-thread.h \
+  $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/kdb.h \
+  $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+  $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/port-sockets.h \
+  $(top_srcdir)/include/socket-utils.h debug.h krb5_encode_test.c \
+  ktest.h utility.h
 $(OUTPRE)krb5_decode_test.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../lib/krb5/asn.1/asn1buf.h \
-  $(srcdir)/../../lib/krb5/asn.1/krbasn1.h $(top_srcdir)/include/k5-buf.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
-  $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
-  $(top_srcdir)/include/kdb.h $(top_srcdir)/include/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  debug.h krb5_decode_test.c ktest.h ktest_equal.h utility.h
+  $(top_srcdir)/include/k5-spake.h $(top_srcdir)/include/k5-thread.h \
+  $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/kdb.h \
+  $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+  $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/port-sockets.h \
+  $(top_srcdir)/include/socket-utils.h debug.h krb5_decode_test.c \
+  ktest.h ktest_equal.h utility.h
 $(OUTPRE)krb5_decode_leak.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../lib/krb5/asn.1/asn1buf.h \
-  $(srcdir)/../../lib/krb5/asn.1/krbasn1.h $(top_srcdir)/include/k5-buf.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
-  $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
-  $(top_srcdir)/include/kdb.h $(top_srcdir)/include/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  debug.h krb5_decode_leak.c ktest.h utility.h
+  $(top_srcdir)/include/k5-spake.h $(top_srcdir)/include/k5-thread.h \
+  $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/kdb.h \
+  $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+  $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/port-sockets.h \
+  $(top_srcdir)/include/socket-utils.h debug.h krb5_decode_leak.c \
+  ktest.h utility.h
 $(OUTPRE)ktest.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../lib/krb5/asn.1/asn1buf.h \
-  $(srcdir)/../../lib/krb5/asn.1/krbasn1.h $(top_srcdir)/include/k5-buf.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
-  $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
-  $(top_srcdir)/include/kdb.h $(top_srcdir)/include/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  ktest.c ktest.h utility.h
+  $(top_srcdir)/include/k5-spake.h $(top_srcdir)/include/k5-thread.h \
+  $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/kdb.h \
+  $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+  $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/port-sockets.h \
+  $(top_srcdir)/include/socket-utils.h ktest.c ktest.h \
+  utility.h
 $(OUTPRE)ktest_equal.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
   $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
-  $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
-  $(top_srcdir)/include/kdb.h $(top_srcdir)/include/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  ktest_equal.c ktest_equal.h
+  $(top_srcdir)/include/k5-spake.h $(top_srcdir)/include/k5-thread.h \
+  $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/kdb.h \
+  $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+  $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/port-sockets.h \
+  $(top_srcdir)/include/socket-utils.h ktest_equal.c \
+  ktest_equal.h
 $(OUTPRE)utility.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../lib/krb5/asn.1/asn1buf.h \
-  $(srcdir)/../../lib/krb5/asn.1/krbasn1.h $(top_srcdir)/include/k5-buf.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
diff --git a/src/tests/asn.1/utility.c b/src/tests/asn.1/utility.c
index db1a9c0..b1eb902 100644
--- a/src/tests/asn.1/utility.c
+++ b/src/tests/asn.1/utility.c
@@ -95,7 +95,7 @@ krb5_data_parse(krb5_data *d, const char *s)
     memcpy(d->data, s, d->length);
 }
 
-asn1_error_code
+krb5_error_code
 krb5_data_hex_parse(krb5_data *d, const char *s)
 {
     int lo;
@@ -130,33 +130,6 @@ krb5_data_hex_parse(krb5_data *d, const char *s)
     return 0;
 }
 
-#if 0
-void
-asn1buf_print(const asn1buf *buf)
-{
-    asn1buf bufcopy;
-    char *s=NULL;
-    int length;
-    int i;
-
-    bufcopy.base = bufcopy.next = buf->next;
-    bufcopy.bound = buf->bound;
-    length = asn1buf_len(&bufcopy);
-
-    s = calloc(3*length, sizeof(char));
-    if (s == NULL) return;
-    for (i=0; i<length; i++) {
-        s[3*i] = hexchar(((bufcopy.base)[i]&0xF0)>>4);
-        s[3*i+1] = hexchar((bufcopy.base)[i]&0x0F);
-        s[3*i+2] = ' ';
-    }
-    s[3*length-1] = '\0';
-
-    printf("%s\n",s);
-    free(s);
-}
-#endif
-
 void
 init_access(const char *progname)
 {
diff --git a/src/tests/asn.1/utility.h b/src/tests/asn.1/utility.h
index f1cd458..e14507a 100644
--- a/src/tests/asn.1/utility.h
+++ b/src/tests/asn.1/utility.h
@@ -28,8 +28,6 @@
 #define __UTILITY_H__
 
 #include "k5-int.h"
-#include "krbasn1.h"
-#include "asn1buf.h"
 
 /* Aborts on failure.  ealloc returns zero-filled memory. */
 void *ealloc(size_t size);
@@ -48,13 +46,11 @@ void asn1_krb5_data_unparse(const krb5_data *code, char **s);
 void krb5_data_parse(krb5_data *d, const char *s);
 /* effects  Parses character string *s into krb5_data *d. */
 
-asn1_error_code krb5_data_hex_parse(krb5_data *d, const char *s);
+krb5_error_code krb5_data_hex_parse(krb5_data *d, const char *s);
 /* requires  *s is the string representation of a sequence of
               hexadecimal octets.  (e.g. "02 01 00")
    effects  Parses *s into krb5_data *d. */
 
-void asn1buf_print(const asn1buf *buf);
-
 extern krb5int_access acc;
 extern void init_access(const char *progname);
 
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post