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

ghudson@MIT.EDU ghudson at MIT.EDU
Sun Feb 12 01:00:25 EST 2012


http://src.mit.edu/fisheye/changelog/krb5/?cs=25695
Commit By: ghudson
Log Message:
Remove unneeded ASN.1 code

Get rid of a whole bunch of ASN.1 decoder infrastructure now that
we're using the data-driven decoder for everything.  Define taginfo in
asn1_encode.h since asn1_get.h is going away.  Rewrite split_der() to
use get_tag() since it still had an unintended dependency on the
previous generation of decoder infrastructure.


Changed Files:
U   trunk/src/lib/krb5/asn.1/Makefile.in
D   trunk/src/lib/krb5/asn.1/asn1_decode.c
D   trunk/src/lib/krb5/asn.1/asn1_decode.h
U   trunk/src/lib/krb5/asn.1/asn1_encode.c
U   trunk/src/lib/krb5/asn.1/asn1_encode.h
D   trunk/src/lib/krb5/asn.1/asn1_get.c
D   trunk/src/lib/krb5/asn.1/asn1_get.h
D   trunk/src/lib/krb5/asn.1/asn1_k_decode.c
D   trunk/src/lib/krb5/asn.1/asn1_k_decode.h
D   trunk/src/lib/krb5/asn.1/asn1_k_decode_fast.c
D   trunk/src/lib/krb5/asn.1/asn1_k_decode_kdc.c
D   trunk/src/lib/krb5/asn.1/asn1_k_decode_macros.h
D   trunk/src/lib/krb5/asn.1/asn1_k_decode_sam.c
D   trunk/src/lib/krb5/asn.1/asn1_misc.c
D   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/asn1buf.h
D   trunk/src/lib/krb5/asn.1/asn1glue.h
U   trunk/src/lib/krb5/asn.1/deps
D   trunk/src/lib/krb5/asn.1/krb5_decode.c
D   trunk/src/lib/krb5/asn.1/krb5_decode_kdc.c
D   trunk/src/lib/krb5/asn.1/krb5_decode_macros.h
U   trunk/src/lib/krb5/asn.1/ldap_key_seq.c
Modified: trunk/src/lib/krb5/asn.1/Makefile.in
===================================================================
--- trunk/src/lib/krb5/asn.1/Makefile.in	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/Makefile.in	2012-02-12 06:00:24 UTC (rev 25695)
@@ -9,46 +9,21 @@
 EHDRDIR=$(BUILDTOP)/include/krb5/asn.1
 
 STLIBOBJS= \
-	asn1_decode.o\
-	asn1_k_decode.o\
-	asn1_k_decode_fast.o\
-	asn1_k_decode_kdc.o\
-	asn1_k_decode_sam.o\
 	asn1_encode.o\
-	asn1_get.o\
 	asn1buf.o\
-	krb5_decode.o\
-	krb5_decode_kdc.o\
 	asn1_k_encode.o\
 	ldap_key_seq.o\
 	asn1_misc.o
 
 SRCS= \
-	$(srcdir)/asn1_decode.c\
-	$(srcdir)/asn1_k_decode.c\
-	$(srcdir)/asn1_k_decode_fast.c\
-	$(srcdir)/asn1_k_decode_kdc.c\
-	$(srcdir)/asn1_k_decode_sam.c\
 	$(srcdir)/asn1_encode.c\
-	$(srcdir)/asn1_get.c\
 	$(srcdir)/asn1buf.c\
-	$(srcdir)/krb5_decode.c\
-	$(srcdir)/krb5_decode_kdc.c\
 	$(srcdir)/asn1_k_encode.c\
-	$(srcdir)/ldap_key_seq.c\
-	$(srcdir)/asn1_misc.c
+	$(srcdir)/ldap_key_seq.c
 
 OBJS= \
-	$(OUTPRE)asn1_decode.$(OBJEXT)\
-	$(OUTPRE)asn1_k_decode.$(OBJEXT)\
-	$(OUTPRE)asn1_k_decode_fast.$(OBJEXT)\
-	$(OUTPRE)asn1_k_decode_kdc.$(OBJEXT)\
-	$(OUTPRE)asn1_k_decode_sam.$(OBJEXT)\
 	$(OUTPRE)asn1_encode.$(OBJEXT)\
-	$(OUTPRE)asn1_get.$(OBJEXT)\
 	$(OUTPRE)asn1buf.$(OBJEXT)\
-	$(OUTPRE)krb5_decode.$(OBJEXT)\
-	$(OUTPRE)krb5_decode_kdc.$(OBJEXT)\
 	$(OUTPRE)asn1_k_encode.$(OBJEXT)\
 	$(OUTPRE)ldap_key_seq.$(OBJEXT)\
 	$(OUTPRE)asn1_misc.$(OBJEXT)

Modified: trunk/src/lib/krb5/asn.1/asn1_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_encode.c	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/asn1_encode.c	2012-02-12 06:00:24 UTC (rev 25695)
@@ -646,20 +646,17 @@
 split_der(asn1buf *buf, unsigned char *const *der, size_t len,
           taginfo *tag_out)
 {
-    asn1buf der_buf;
-    krb5_data der_data = make_data(*der, len);
     asn1_error_code ret;
+    const unsigned char *contents, *remainder;
+    size_t clen, rlen;
 
-    ret = asn1buf_wrap_data(&der_buf, &der_data);
+    ret = get_tag(*der, len, tag_out, &contents, &clen, &remainder, &rlen);
     if (ret)
         return ret;
-    ret = asn1_get_tag_2(&der_buf, tag_out);
-    if (ret)
-        return ret;
-    if ((size_t)asn1buf_remains(&der_buf, 0) != tag_out->length)
-        return EINVAL;
-    return asn1buf_insert_bytestring(buf, tag_out->length,
-                                     *der + len - tag_out->length);
+    if (rlen != 0)
+        return ASN1_BAD_LENGTH;
+    tag_out->length = clen;
+    return asn1buf_insert_bytestring(buf, clen, contents);
 }
 
 /*

Modified: trunk/src/lib/krb5/asn.1/asn1_encode.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_encode.h	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/asn1_encode.h	2012-02-12 06:00:24 UTC (rev 25695)
@@ -30,9 +30,20 @@
 #include "k5-int.h"
 #include "krbasn1.h"
 #include "asn1buf.h"
-#include "asn1_get.h"
 #include <time.h>
 
+typedef struct {
+    asn1_class asn1class;
+    asn1_construction construction;
+    asn1_tagnum tagnum;
+    size_t length;
+
+    /* When decoding, stores the leading and trailing lengths of a tag.  Used
+     * by store_der(). */
+    size_t tag_len;
+    size_t tag_end_len;
+} taginfo;
+
 /* 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, asn1_intmax val,

Modified: trunk/src/lib/krb5/asn.1/asn1buf.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1buf.c	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/asn1buf.c	2012-02-12 06:00:24 UTC (rev 25695)
@@ -57,7 +57,6 @@
 #define ASN1BUF_OMIT_INLINE_FUNCS
 #include "asn1buf.h"
 #include <stdio.h>
-#include "asn1_get.h"
 
 #ifdef USE_VALGRIND
 #include <valgrind/memcheck.h>
@@ -89,82 +88,6 @@
     return 0;
 }
 
-asn1_error_code
-asn1buf_wrap_data(asn1buf *buf, const krb5_data *code)
-{
-    if (code == NULL || code->data == NULL) return ASN1_MISSING_FIELD;
-    buf->next = buf->base = code->data;
-    buf->bound = code->data + code->length - 1;
-    return 0;
-}
-
-asn1_error_code
-asn1buf_imbed(asn1buf *subbuf, const asn1buf *buf, const unsigned int length, const int indef)
-{
-    if (buf->next > buf->bound + 1) return ASN1_OVERRUN;
-    subbuf->base = subbuf->next = buf->next;
-    if (!indef) {
-        if (length > (size_t)(buf->bound + 1 - buf->next)) return ASN1_OVERRUN;
-        subbuf->bound = subbuf->base + length - 1;
-    } else /* constructed indefinite */
-        subbuf->bound = buf->bound;
-    return 0;
-}
-
-asn1_error_code
-asn1buf_sync(asn1buf *buf, asn1buf *subbuf,
-             asn1_class asn1class, asn1_tagnum lasttag,
-             unsigned int length, int indef, int seqindef)
-{
-    asn1_error_code retval;
-
-    if (!seqindef) {
-        /* sequence was encoded as definite length */
-        buf->next = subbuf->bound + 1;
-    } else if (!asn1_is_eoc(asn1class, lasttag, indef)) {
-        retval = asn1buf_skiptail(subbuf, length, indef);
-        if (retval)
-            return retval;
-    } else {
-        /* We have just read the EOC octets. */
-        buf->next = subbuf->next;
-    }
-    return 0;
-}
-
-asn1_error_code
-asn1buf_skiptail(asn1buf *buf, const unsigned int length, const int indef)
-{
-    asn1_error_code retval;
-    taginfo t;
-    int nestlevel;
-
-    nestlevel = 1 + indef;
-    if (!indef) {
-        if (length <= (size_t)(buf->bound - buf->next + 1))
-            buf->next += length;
-        else
-            return ASN1_OVERRUN;
-    }
-    while (nestlevel > 0) {
-        if (buf->bound - buf->next + 1 <= 0)
-            return ASN1_OVERRUN;
-        retval = asn1_get_tag_2(buf, &t);
-        if (retval) return retval;
-        if (!t.indef) {
-            if (t.length <= (size_t)(buf->bound - buf->next + 1))
-                buf->next += t.length;
-            else
-                return ASN1_OVERRUN;
-        }
-        if (t.indef)
-            nestlevel++;
-        if (asn1_is_eoc(t.asn1class, t.tagnum, t.indef))
-            nestlevel--;                /* got an EOC encoding */
-    }
-    return 0;
-}
-
 void
 asn1buf_destroy(asn1buf **buf)
 {
@@ -205,70 +128,7 @@
     return 0;
 }
 
-
-#undef asn1buf_remove_octet
-asn1_error_code asn1buf_remove_octet(asn1buf *buf, asn1_octet *o)
-{
-    if (buf->next > buf->bound) return ASN1_OVERRUN;
-    *o = (asn1_octet)(*((buf->next)++));
-    return 0;
-}
-
 asn1_error_code
-asn1buf_remove_octetstring(asn1buf *buf, const unsigned int len, asn1_octet **s)
-{
-    unsigned int i;
-
-    if (buf->next > buf->bound + 1) return ASN1_OVERRUN;
-    if (len > (size_t)(buf->bound + 1 - buf->next)) return ASN1_OVERRUN;
-    if (len == 0) {
-        *s = 0;
-        return 0;
-    }
-    *s = (asn1_octet*)malloc(len*sizeof(asn1_octet));
-    if (*s == NULL)
-        return ENOMEM;
-    for (i=0; i<len; i++)
-        (*s)[i] = (asn1_octet)(buf->next)[i];
-    buf->next += len;
-    return 0;
-}
-
-asn1_error_code
-asn1buf_remove_charstring(asn1buf *buf, const unsigned int len, char **s)
-{
-    unsigned int i;
-
-    if (buf->next > buf->bound + 1) return ASN1_OVERRUN;
-    if (len > (size_t)(buf->bound + 1 - buf->next)) return ASN1_OVERRUN;
-    if (len == 0) {
-        *s = 0;
-        return 0;
-    }
-    *s = (char*)malloc(len*sizeof(char));
-    if (*s == NULL) return ENOMEM;
-    for (i=0; i<len; i++)
-        (*s)[i] = (char)(buf->next)[i];
-    buf->next += len;
-    return 0;
-}
-
-int
-asn1buf_remains(asn1buf *buf, int indef)
-{
-    int remain;
-    if (buf == NULL || buf->base == NULL) return 0;
-    remain = buf->bound - buf->next +1;
-    if (remain <= 0) return remain;
-    /*
-     * Two 0 octets means the end of an indefinite encoding.
-     */
-    if (indef && remain >= 2 && !*(buf->next) && !*(buf->next + 1))
-        return 0;
-    else return remain;
-}
-
-asn1_error_code
 asn12krb5_buf(const asn1buf *buf, krb5_data **code)
 {
     unsigned int i;
@@ -293,68 +153,6 @@
     return 0;
 }
 
-
-
-/*
- * 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)
-{
-    free(*s);
-    if (buf == NULL) {
-        *s = strdup("<NULL>");
-        if (*s == NULL) return ENOMEM;
-    } else if (buf->base == NULL) {
-        *s = strdup("<EMPTY>");
-        if (*s == NULL) return ENOMEM;
-    } else {
-        unsigned int length = asn1buf_len(buf);
-        unsigned int i;
-
-        *s = calloc(length+1, sizeof(char));
-        if (*s == NULL) return ENOMEM;
-        (*s)[length] = '\0';
-        for (i=0; i<length; i++) ;
-/*      OLDDECLARG( (*s)[i] = , (buf->base)[length-i-1]) */
-    }
-    return 0;
-}
-
-asn1_error_code
-asn1buf_hex_unparse(const asn1buf *buf, char **s)
-{
-#define hexchar(d) ((d)<=9 ? ('0'+(d)) :        \
-                    ((d)<=15 ? ('A'+(d)-10) :   \
-                     'X'))
-
-    free(*s);
-
-    if (buf == NULL) {
-        *s = strdup("<NULL>");
-        if (*s == NULL) return ENOMEM;
-    } else if (buf->base == NULL) {
-        *s = strdup("<EMPTY>");
-        if (*s == NULL) return ENOMEM;
-    } else {
-        unsigned int length = asn1buf_len(buf);
-        int i;
-
-        *s = malloc(3*length);
-        if (*s == NULL) return ENOMEM;
-        for (i = length-1; i >= 0; i--) {
-            (*s)[3*(length-i-1)] = hexchar(((buf->base)[i]&0xF0)>>4);
-            (*s)[3*(length-i-1)+1] = hexchar((buf->base)[i]&0x0F);
-            (*s)[3*(length-i-1)+2] = ' ';
-        }
-        (*s)[3*length-1] = '\0';
-    }
-    return 0;
-}
-
 /****************************************************************/
 /* Private Procedures */
 

Modified: trunk/src/lib/krb5/asn.1/asn1buf.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1buf.h	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/asn1buf.h	2012-02-12 06:00:24 UTC (rev 25695)
@@ -99,45 +99,6 @@
  *           Returns ENOMEM if the buffer can't be created.
  */
 
-asn1_error_code asn1buf_wrap_data(asn1buf *buf, const krb5_data *code);
-/*
- * requires  *buf has already been allocated
- * effects   Turns *buf into a "wrapper" for *code.  i.e. *buf is set up
- *            such that its bottom is the beginning of *code, and its top
- *            is the top of *code.
- *           Returns ASN1_MISSING_FIELD if code is empty.
- */
-
-asn1_error_code asn1buf_imbed(asn1buf *subbuf, const asn1buf *buf,
-                              const unsigned int length,
-                              const int indef);
-/*
- * requires  *subbuf and *buf are allocated
- * effects   *subbuf becomes a sub-buffer of *buf.  *subbuf begins
- *            at *buf's current position and is length octets long.
- *            (Unless this would exceed the bounds of *buf -- in
- *            that case, ASN1_OVERRUN is returned)  *subbuf's current
- *            position starts at the beginning of *subbuf.
- */
-
-asn1_error_code asn1buf_sync(asn1buf *buf, asn1buf *subbuf, asn1_class Class,
-                             asn1_tagnum lasttag,
-                             unsigned int length, int indef,
-                             int seqindef);
-/*
- * requires  *subbuf is a sub-buffer of *buf, as created by asn1buf_imbed.
- *           lasttag is the last tagnumber read.
- * effects   Synchronizes *buf's current position to match that of *subbuf.
- */
-
-asn1_error_code asn1buf_skiptail(asn1buf *buf, const unsigned int length,
-                                 const int indef);
-/*
- * requires  *buf is a subbuffer used in a decoding of a
- *           constructed indefinite sequence.
- * effects   skips trailing fields.
- */
-
 void asn1buf_destroy(asn1buf **buf);
 /* effects   Deallocates **buf, sets *buf to NULL. */
 
@@ -174,69 +135,11 @@
  */
 
 #define asn1buf_insert_octetstring asn1buf_insert_bytestring
-#define asn1buf_insert_charstring  asn1buf_insert_bytestring
 
-asn1_error_code asn1buf_remove_octet(asn1buf *buf, asn1_octet *o);
-/*
- * requires  *buf is allocated
- * effects   Returns *buf's current octet in *o and advances to
- *            the next octet.
- *           Returns ASN1_OVERRUN if *buf has already been exhausted.
- */
-#define asn1buf_remove_octet(buf,o)                     \
-    (((buf)->next > (buf)->bound)                       \
-     ? ASN1_OVERRUN                                     \
-     : ((*(o) = (asn1_octet)(*(((buf)->next)++))),0))
-
-asn1_error_code
-asn1buf_remove_octetstring(
-    asn1buf *buf,
-    const unsigned int len,
-    asn1_octet **s);
-/*
- * requires  *buf is allocated
- * effects   Removes the next len octets of *buf and returns them in **s.
- *           Returns ASN1_OVERRUN if there are fewer than len unread octets
- *            left in *buf.
- *           Returns ENOMEM if *s could not be allocated.
- */
-
-asn1_error_code
-asn1buf_remove_charstring(asn1buf *buf, const unsigned int len, char **s);
-/*
- * requires  *buf is allocated
- * effects   Removes the next len octets of *buf and returns them in **s.
- *           Returns ASN1_OVERRUN if there are fewer than len unread octets
- *            left in *buf.
- *           Returns ENOMEM if *s could not be allocated.
- */
-
-asn1_error_code asn1buf_unparse(const asn1buf *buf, char **s);
-/*
- * modifies  *s
- * effects   Returns a human-readable representation of *buf in *s,
- *           where each octet in *buf is represented by a character in *s.
- */
-
-asn1_error_code asn1buf_hex_unparse(const asn1buf *buf, char **s);
-/*
- * modifies  *s
- * effects   Returns a human-readable representation of *buf in *s,
- *           where each octet in *buf is represented by a 2-digit
- *           hexadecimal number in *s.
- */
-
 asn1_error_code asn12krb5_buf(const asn1buf *buf, krb5_data **code);
 /*
  * modifies  *code
  * effects   Instantiates **code with the krb5_data representation of **buf.
  */
 
-int asn1buf_remains(asn1buf *buf, int indef);
-/*
- * requires  *buf is a buffer containing an asn.1 structure or array
- * modifies  *buf
- * effects   Returns the number of unprocessed octets remaining in *buf.
- */
-
 #endif

Modified: trunk/src/lib/krb5/asn.1/deps
===================================================================
--- trunk/src/lib/krb5/asn.1/deps	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/deps	2012-02-12 06:00:24 UTC (rev 25695)
@@ -1,70 +1,6 @@
 # 
 # Generated makefile dependencies follow.
 #
-asn1_decode.so asn1_decode.po $(OUTPRE)asn1_decode.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.c \
-  asn1_decode.h asn1_get.h asn1buf.h krbasn1.h
-asn1_k_decode.so asn1_k_decode.po $(OUTPRE)asn1_k_decode.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.h \
-  asn1_get.h asn1_k_decode.c asn1_k_decode.h asn1_k_decode_macros.h \
-  asn1_misc.h asn1buf.h krbasn1.h
-asn1_k_decode_fast.so asn1_k_decode_fast.po $(OUTPRE)asn1_k_decode_fast.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.h \
-  asn1_get.h asn1_k_decode.h asn1_k_decode_fast.c asn1_k_decode_macros.h \
-  asn1_misc.h asn1buf.h krbasn1.h
-asn1_k_decode_kdc.so asn1_k_decode_kdc.po $(OUTPRE)asn1_k_decode_kdc.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.h \
-  asn1_get.h asn1_k_decode.h asn1_k_decode_kdc.c asn1_k_decode_macros.h \
-  asn1_misc.h asn1buf.h krbasn1.h
-asn1_k_decode_sam.so asn1_k_decode_sam.po $(OUTPRE)asn1_k_decode_sam.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.h \
-  asn1_get.h asn1_k_decode.h asn1_k_decode_macros.h asn1_k_decode_sam.c \
-  asn1_misc.h asn1buf.h krbasn1.h
 asn1_encode.so asn1_encode.po $(OUTPRE)asn1_encode.$(OBJEXT): \
   $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
   $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
@@ -76,19 +12,7 @@
   $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
   $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
   $(top_srcdir)/include/socket-utils.h asn1_encode.c \
-  asn1_encode.h asn1_get.h asn1buf.h krbasn1.h
-asn1_get.so asn1_get.po $(OUTPRE)asn1_get.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_get.c asn1_get.h \
-  asn1buf.h krbasn1.h
+  asn1_encode.h asn1buf.h krbasn1.h
 asn1buf.so asn1buf.po $(OUTPRE)asn1buf.$(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 \
@@ -99,33 +23,7 @@
   $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
   $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
   $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  asn1_get.h asn1buf.c asn1buf.h krbasn1.h
-krb5_decode.so krb5_decode.po $(OUTPRE)krb5_decode.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.h \
-  asn1_get.h asn1_k_decode.h asn1_misc.h asn1buf.h krb5_decode.c \
-  krb5_decode_macros.h krbasn1.h
-krb5_decode_kdc.so krb5_decode_kdc.po $(OUTPRE)krb5_decode_kdc.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_decode.h \
-  asn1_get.h asn1_k_decode.h asn1_misc.h asn1buf.h krb5_decode_kdc.c \
-  krb5_decode_macros.h krbasn1.h
+  asn1buf.c asn1buf.h krbasn1.h
 asn1_k_encode.so asn1_k_encode.po $(OUTPRE)asn1_k_encode.$(OBJEXT): \
   $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
   $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
@@ -137,7 +35,7 @@
   $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
   $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
   $(top_srcdir)/include/socket-utils.h asn1_encode.h \
-  asn1_get.h asn1_k_encode.c asn1buf.h krbasn1.h
+  asn1_k_encode.c asn1buf.h krbasn1.h
 ldap_key_seq.so ldap_key_seq.po $(OUTPRE)ldap_key_seq.$(OBJEXT): \
   $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
   $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
@@ -149,17 +47,4 @@
   $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
   $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
   $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
-  asn1_decode.h asn1_encode.h asn1_get.h asn1buf.h krbasn1.h \
-  ldap_key_seq.c
-asn1_misc.so asn1_misc.po $(OUTPRE)asn1_misc.$(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/krb5.h \
-  $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
-  $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
-  $(top_srcdir)/include/socket-utils.h asn1_misc.c asn1_misc.h \
-  krbasn1.h
+  asn1_encode.h asn1buf.h krbasn1.h ldap_key_seq.c

Modified: trunk/src/lib/krb5/asn.1/ldap_key_seq.c
===================================================================
--- trunk/src/lib/krb5/asn.1/ldap_key_seq.c	2012-02-12 05:25:22 UTC (rev 25694)
+++ trunk/src/lib/krb5/asn.1/ldap_key_seq.c	2012-02-12 06:00:24 UTC (rev 25695)
@@ -37,8 +37,6 @@
 
 #include "krbasn1.h"
 #include "asn1_encode.h"
-#include "asn1_decode.h"
-#include "asn1_get.h"
 
 #ifdef ENABLE_LDAP
 
@@ -112,285 +110,4 @@
 MAKE_ENCODER(krb5int_ldap_encode_sequence_of_keys, ldap_key_seq);
 MAKE_DECODER(krb5int_ldap_decode_sequence_of_keys, ldap_key_seq);
 
-#if 0
-/************************************************************************/
-/* Decode the Principal's keys                                          */
-/************************************************************************/
-
-#define cleanup(err)                            \
-    {                                           \
-        ret = err;                              \
-        goto last;                              \
-    }
-
-#define checkerr                                \
-    if (ret != 0)                               \
-        goto last
-
-#define safe_syncbuf(outer,inner,buflen)                \
-    if (! ((inner)->next == (inner)->bound + 1 &&       \
-           (inner)->next == (outer)->next + buflen))    \
-        cleanup (ASN1_BAD_LENGTH);                      \
-    asn1buf_sync((outer), (inner), 0, 0, 0, 0, 0);
-
-static asn1_error_code
-decode_tagged_integer (asn1buf *buf, asn1_tagnum expectedtag, long *val)
-{
-    int buflen;
-    asn1_error_code ret = 0;
-    asn1buf tmp, subbuf;
-    taginfo t;
-
-    /* Work on a copy of 'buf' */
-    ret = asn1buf_imbed(&tmp, buf, 0, 1); checkerr;
-    ret = asn1_get_tag_2(&tmp, &t); checkerr;
-    if (t.tagnum != expectedtag)
-        cleanup (ASN1_MISSING_FIELD);
-
-    buflen = t.length;
-    ret = asn1buf_imbed(&subbuf, &tmp, t.length, 0); checkerr;
-    ret = asn1_decode_integer(&subbuf, val); checkerr;
-
-    safe_syncbuf(&tmp, &subbuf, buflen);
-    *buf = tmp;
-
-last:
-    return ret;
-}
-
-#if 0 /* not currently used */
-static asn1_error_code
-decode_tagged_unsigned_integer (asn1buf *buf, int expectedtag, unsigned long *val)
-{
-    int buflen;
-    asn1_error_code ret = 0;
-    asn1buf tmp, subbuf;
-    taginfo t;
-
-    /* Work on a copy of 'buf' */
-    ret = asn1buf_imbed(&tmp, buf, 0, 1); checkerr;
-    ret = asn1_get_tag_2(&tmp, &t); checkerr;
-    if (t.tagnum != expectedtag)
-        cleanup (ASN1_MISSING_FIELD);
-
-    buflen = t.length;
-    ret = asn1buf_imbed(&subbuf, &tmp, t.length, 0); checkerr;
-    ret = asn1_decode_unsigned_integer(&subbuf, val); checkerr;
-
-    safe_syncbuf(&tmp, &subbuf, buflen);
-    *buf = tmp;
-
-last:
-    return ret;
-}
 #endif
-
-static asn1_error_code
-decode_tagged_octetstring (asn1buf *buf, asn1_tagnum expectedtag,
-                           unsigned int *len,
-                           asn1_octet **val)
-{
-    int buflen;
-    asn1_error_code ret = 0;
-    asn1buf tmp, subbuf;
-    taginfo t;
-
-    *val = NULL;
-
-    /* Work on a copy of 'buf' */
-    ret = asn1buf_imbed(&tmp, buf, 0, 1); checkerr;
-    ret = asn1_get_tag_2(&tmp, &t); checkerr;
-    if (t.tagnum != expectedtag)
-        cleanup (ASN1_MISSING_FIELD);
-
-    buflen = t.length;
-    ret = asn1buf_imbed(&subbuf, &tmp, t.length, 0); checkerr;
-    ret = asn1_decode_octetstring (&subbuf, len, val); checkerr;
-
-    safe_syncbuf(&tmp, &subbuf, buflen);
-    *buf = tmp;
-
-last:
-    if (ret != 0)
-        free (*val);
-    return ret;
-}
-
-static asn1_error_code
-asn1_decode_key(asn1buf *buf, krb5_key_data *key)
-{
-    int full_buflen, seqindef;
-    unsigned int length;
-    asn1_error_code ret;
-    asn1buf subbuf;
-    taginfo t;
-
-    key->key_data_contents[0] = NULL;
-    key->key_data_contents[1] = NULL;
-
-    ret = asn1_get_sequence(buf, &length, &seqindef); checkerr;
-    full_buflen = length;
-    ret = asn1buf_imbed(&subbuf, buf, length, seqindef); checkerr;
-
-    asn1_get_tag_2(&subbuf, &t);
-    /* Salt */
-    if (t.tagnum == 0) {
-        int salt_buflen;
-        asn1buf slt;
-        long keytype;
-        unsigned int keylen;
-
-        key->key_data_ver = 2;
-        asn1_get_sequence(&subbuf, &length, &seqindef);
-        salt_buflen = length;
-        asn1buf_imbed(&slt, &subbuf, length, seqindef);
-
-        ret = decode_tagged_integer (&slt, 0, &keytype);
-        key->key_data_type[1] = keytype; /* XXX range check?? */
-        checkerr;
-
-        if (asn1buf_remains(&slt, 0) != 0) { /* Salt value is optional */
-            ret = decode_tagged_octetstring (&slt, 1, &keylen,
-                                             &key->key_data_contents[1]);
-            checkerr;
-        } else
-            keylen = 0;
-        safe_syncbuf (&subbuf, &slt, salt_buflen);
-        key->key_data_length[1] = keylen; /* XXX range check?? */
-
-        ret = asn1_get_tag_2(&subbuf, &t); checkerr;
-    } else
-        key->key_data_ver = 1;
-
-    /* Key */
-    {
-        int key_buflen;
-        asn1buf kbuf;
-        long lval;
-        unsigned int ival;
-
-        if (t.tagnum != 1)
-            cleanup (ASN1_MISSING_FIELD);
-
-        ret = asn1_get_sequence(&subbuf, &length, &seqindef); checkerr;
-        key_buflen = length;
-        ret = asn1buf_imbed(&kbuf, &subbuf, length, seqindef); checkerr;
-
-        ret = decode_tagged_integer (&kbuf, 0, &lval);
-        checkerr;
-        key->key_data_type[0] = lval; /* XXX range check? */
-
-        ret = decode_tagged_octetstring (&kbuf, 1, &ival,
-                                         &key->key_data_contents[0]); checkerr;
-        key->key_data_length[0] = ival; /* XXX range check? */
-
-        safe_syncbuf (&subbuf, &kbuf, key_buflen);
-    }
-
-    safe_syncbuf (buf, &subbuf, full_buflen);
-
-last:
-    if (ret != 0) {
-        free (key->key_data_contents[0]);
-        key->key_data_contents[0] = NULL;
-        free (key->key_data_contents[1]);
-        key->key_data_contents[1] = NULL;
-    }
-    return ret;
-}
-
-krb5_error_code
-krb5int_ldap_decode_sequence_of_keys (krb5_data *in, ldap_seqof_key_data **rep)
-{
-    ldap_seqof_key_data *repval;
-    krb5_key_data **out;
-    krb5_int16 *n_key_data;
-    int *mkvno;
-
-    asn1_error_code ret;
-    asn1buf buf, subbuf;
-    int seqindef;
-    unsigned int length;
-    taginfo t;
-    int kvno, maj, min;
-    long lval;
-
-    repval = calloc(1,sizeof(ldap_seqof_key_data));
-    *rep = repval;
-    out = &repval->key_data;
-    n_key_data = &repval->n_key_data;
-    mkvno = &repval->mkvno;
-
-    *n_key_data = 0;
-    *out = NULL;
-
-    ret = asn1buf_wrap_data(&buf, in); checkerr;
-
-    ret = asn1_get_sequence(&buf, &length, &seqindef); checkerr;
-    ret = asn1buf_imbed(&subbuf, &buf, length, seqindef); checkerr;
-
-    /* attribute-major-vno */
-    ret = decode_tagged_integer (&subbuf, 0, &lval); checkerr;
-    maj = lval;                 /* XXX range check? */
-
-    /* attribute-minor-vno */
-    ret = decode_tagged_integer (&subbuf, 1, &lval); checkerr;
-    min = lval;                 /* XXX range check? */
-
-    if (maj != 1 || min != 1)
-        cleanup (ASN1_BAD_FORMAT);
-
-    /* kvno (assuming all keys in array have same version) */
-    ret = decode_tagged_integer (&subbuf, 2, &lval); checkerr;
-    kvno = lval;                /* XXX range check? */
-
-    /* mkvno (optional) */
-    ret = decode_tagged_integer (&subbuf, 3, &lval); checkerr;
-    *mkvno = lval;              /* XXX range check? */
-
-    ret = asn1_get_tag_2(&subbuf, &t); checkerr;
-
-    /* Sequence of keys */
-    {
-        int i, seq_buflen;
-        asn1buf keyseq;
-        if (t.tagnum != 4)
-            cleanup (ASN1_MISSING_FIELD);
-        ret = asn1_get_sequence(&subbuf, &length, &seqindef); checkerr;
-        seq_buflen = length;
-        ret = asn1buf_imbed(&keyseq, &subbuf, length, seqindef); checkerr;
-        for (i = 1, *out = NULL; ; i++) {
-            krb5_key_data *tmp;
-            tmp = (krb5_key_data *) realloc (*out, i * sizeof (krb5_key_data));
-            if (tmp == NULL)
-                cleanup (ENOMEM);
-            *out = tmp;
-            (*out)[i - 1].key_data_kvno = kvno;
-            ret = asn1_decode_key(&keyseq, &(*out)[i - 1]); checkerr;
-            (*n_key_data)++;
-            if (asn1buf_remains(&keyseq, 0) == 0)
-                break; /* Not freeing the last key structure */
-        }
-        safe_syncbuf (&subbuf, &keyseq, seq_buflen);
-    }
-
-    /*
-     * There could be other data inside the outermost sequence ... tags we don't
-     * know about. So, not invoking "safe_syncbuf(&buf,&subbuf)"
-     */
-
-last:
-    if (ret != 0) {
-        int i;
-        for (i = 0; i < *n_key_data; i++) {
-            free ((*out)[i].key_data_contents[0]);
-            free ((*out)[i].key_data_contents[1]);
-        }
-        free (*out);
-        *out = NULL;
-    }
-
-    return ret;
-}
-#endif
-#endif



More information about the cvs-krb5 mailing list