svn rev #25601: trunk/src/ include/ include/krb5/ kdc/ lib/krb5/ lib/krb5/asn.1/ ...

ghudson@MIT.EDU ghudson at MIT.EDU
Wed Dec 21 17:52:52 EST 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25601
Commit By: ghudson
Log Message:
Stop using krb5_typed_data structure type

Use the krb5_pa_data structure type when encoding or decoding
TYPED-DATA.  Leave the krb5_typed_data structure definition in krb5.h
with a comment saying not to use it.  Remove krb5_free_typed_data
(which was never declared in krb5.h).  Remove some vestigial accessor
stuff related to PKINIT encoding and decoding TYPED-DATA, which was
unneeded since r25483.  Bump the accessor structure version to 19
accordingly.


Changed Files:
U   trunk/src/include/k5-int-pkinit.h
U   trunk/src/include/k5-int.h
U   trunk/src/include/krb5/krb5.hin
U   trunk/src/kdc/do_as_req.c
U   trunk/src/lib/krb5/asn.1/asn1_k_decode.c
U   trunk/src/lib/krb5/asn.1/asn1_k_decode.h
U   trunk/src/lib/krb5/asn.1/asn1_k_encode.c
U   trunk/src/lib/krb5/asn.1/asn1_k_encode.h
U   trunk/src/lib/krb5/asn.1/krb5_decode.c
U   trunk/src/lib/krb5/asn.1/krb5_encode.c
U   trunk/src/lib/krb5/krb/fast.c
U   trunk/src/lib/krb5/krb/kfree.c
U   trunk/src/lib/krb5/libkrb5.exports
U   trunk/src/lib/krb5/os/accessor.c
U   trunk/src/plugins/preauth/pkinit/pkinit.h
U   trunk/src/plugins/preauth/pkinit/pkinit_accessor.c
U   trunk/src/plugins/preauth/pkinit/pkinit_accessor.h
U   trunk/src/plugins/preauth/pkinit/pkinit_lib.c
Modified: trunk/src/include/k5-int-pkinit.h
===================================================================
--- trunk/src/include/k5-int-pkinit.h	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/include/k5-int-pkinit.h	2011-12-21 22:52:52 UTC (rev 25601)
@@ -230,9 +230,6 @@
                                   krb5_data **code);
 
 krb5_error_code
-encode_krb5_typed_data(const krb5_typed_data **, krb5_data **code);
-
-krb5_error_code
 encode_krb5_td_trusted_certifiers(const krb5_external_principal_identifier **,
                                   krb5_data **code);
 
@@ -286,17 +283,12 @@
                                   krb5_reply_key_pack_draft9 **);
 
 krb5_error_code
-decode_krb5_typed_data(const krb5_data *, krb5_typed_data ***);
-
-krb5_error_code
 decode_krb5_td_trusted_certifiers(const krb5_data *,
                                   krb5_external_principal_identifier ***);
 
 krb5_error_code
 decode_krb5_td_dh_parameters(const krb5_data *, krb5_algorithm_identifier ***);
 
-void krb5_free_typed_data(krb5_context, krb5_typed_data **);
-
 krb5_error_code
 encode_krb5_enc_data(const krb5_enc_data *, krb5_data **);
 

Modified: trunk/src/include/k5-int.h
===================================================================
--- trunk/src/include/k5-int.h	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/include/k5-int.h	2011-12-21 22:52:52 UTC (rev 25601)
@@ -1677,6 +1677,9 @@
 encode_krb5_padata_sequence(krb5_pa_data *const *rep, krb5_data **code);
 
 krb5_error_code
+encode_krb5_typed_data(const krb5_pa_data *const *rep, krb5_data **code);
+
+krb5_error_code
 encode_krb5_alt_method(const krb5_alt_method *, krb5_data **code);
 
 krb5_error_code
@@ -1904,6 +1907,9 @@
 decode_krb5_padata_sequence(const krb5_data *output, krb5_pa_data ***rep);
 
 krb5_error_code
+decode_krb5_typed_data(const krb5_data *, krb5_pa_data ***);
+
+krb5_error_code
 decode_krb5_alt_method(const krb5_data *output, krb5_alt_method **rep);
 
 krb5_error_code
@@ -2141,7 +2147,7 @@
 /* To keep happy libraries which are (for now) accessing internal stuff */
 
 /* Make sure to increment by one when changing the struct */
-#define KRB5INT_ACCESS_STRUCT_VERSION 18
+#define KRB5INT_ACCESS_STRUCT_VERSION 19
 
 #ifndef ANAME_SZ
 struct ktext;                   /* from krb.h, for krb524 support */
@@ -2225,9 +2231,6 @@
                                          krb5_data **code);
 
     krb5_error_code
-    (*encode_krb5_typed_data)(const krb5_typed_data **, krb5_data **code);
-
-    krb5_error_code
     (*decode_krb5_auth_pack)(const krb5_data *, krb5_auth_pack **);
 
     krb5_error_code
@@ -2271,9 +2274,6 @@
                                          ***);
 
     krb5_error_code
-    (*decode_krb5_typed_data)(const krb5_data *, krb5_typed_data ***);
-
-    krb5_error_code
     (*decode_krb5_as_req)(const krb5_data *output, krb5_kdc_req **rep);
 
     krb5_error_code

Modified: trunk/src/include/krb5/krb5.hin
===================================================================
--- trunk/src/include/krb5/krb5.hin	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/include/krb5/krb5.hin	2011-12-21 22:52:52 UTC (rev 25601)
@@ -1972,12 +1972,7 @@
     krb5_octet *contents;       /**< Data */
 } krb5_pa_data;
 
-/*
- * The FAST error handling logic currently assumes that pointers to this
- * structure and krb5_pa_data can be safely cast to each other.  If this
- * structure changes, that code needs to be updated to copy.
- */
-/** Typed data */
+/* Don't use this; use krb5_pa_data instead. */
 typedef struct _krb5_typed_data {
     krb5_magic magic;
     krb5_int32 type;

Modified: trunk/src/kdc/do_as_req.c
===================================================================
--- trunk/src/kdc/do_as_req.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/kdc/do_as_req.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -800,10 +800,9 @@
     errpkt.text = string2data((char *)status);
 
     if (e_data != NULL) {
-        if (typed_e_data) {
-            retval = encode_krb5_typed_data((const krb5_typed_data **)e_data,
-                                            &e_data_asn1);
-        } else
+        if (typed_e_data)
+            retval = encode_krb5_typed_data(e_data, &e_data_asn1);
+        else
             retval = encode_krb5_padata_sequence(e_data, &e_data_asn1);
         if (retval)
             goto cleanup;

Modified: trunk/src/lib/krb5/asn.1/asn1_k_decode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_decode.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/asn.1/asn1_k_decode.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -1725,38 +1725,32 @@
 
 #endif /* DISABLE_PKINIT */
 
-static void free_typed_data(void *dummy, krb5_typed_data *val)
-{
-    free(val->data);
-    free(val);
-}
-
 asn1_error_code
-asn1_decode_sequence_of_typed_data(asn1buf *buf, krb5_typed_data ***val)
+asn1_decode_sequence_of_typed_data(asn1buf *buf, krb5_pa_data ***val)
 {
-    decode_array_body(krb5_typed_data,asn1_decode_typed_data_ptr,
-                      free_typed_data);
+    decode_array_body(krb5_pa_data,asn1_decode_typed_data_ptr,
+                      free_pa_data);
 }
 
 asn1_error_code
-asn1_decode_typed_data(asn1buf *buf, krb5_typed_data *val)
+asn1_decode_typed_data(asn1buf *buf, krb5_pa_data *val)
 {
     setup();
-    val->data = NULL;
+    val->contents = NULL;
     { begin_structure();
-        get_field(val->type,0,asn1_decode_int32);
-        get_lenfield(val->length,val->data,1,asn1_decode_octetstring);
+        get_field(val->pa_type,0,asn1_decode_int32);
+        get_lenfield(val->length,val->contents,1,asn1_decode_octetstring);
         end_structure();
     }
     return 0;
 error_out:
-    free(val->data);
-    val->data = NULL;
+    free(val->contents);
+    val->contents = NULL;
     return retval;
 }
 
 asn1_error_code
-asn1_decode_typed_data_ptr(asn1buf *buf, krb5_typed_data **valptr)
+asn1_decode_typed_data_ptr(asn1buf *buf, krb5_pa_data **valptr)
 {
-    decode_ptr(krb5_typed_data *, asn1_decode_typed_data);
+    decode_ptr(krb5_pa_data *, asn1_decode_typed_data);
 }

Modified: trunk/src/lib/krb5/asn.1/asn1_k_decode.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_decode.h	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/asn.1/asn1_k_decode.h	2011-12-21 22:52:52 UTC (rev 25601)
@@ -205,10 +205,10 @@
 asn1_decode_reply_key_pack_draft9(asn1buf *buf,
                                   krb5_reply_key_pack_draft9 *val);
 asn1_error_code
-asn1_decode_sequence_of_typed_data(asn1buf *buf, krb5_typed_data ***val);
-asn1_error_code asn1_decode_typed_data(asn1buf *buf, krb5_typed_data *val);
+asn1_decode_sequence_of_typed_data(asn1buf *buf, krb5_pa_data ***val);
+asn1_error_code asn1_decode_typed_data(asn1buf *buf, krb5_pa_data *val);
 asn1_error_code asn1_decode_typed_data_ptr(asn1buf *buf,
-                                           krb5_typed_data **valptr);
+                                           krb5_pa_data **valptr);
 
 /* arrays */
 asn1_error_code asn1_decode_authorization_data(asn1buf *buf,

Modified: trunk/src/lib/krb5/asn.1/asn1_k_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_encode.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/asn.1/asn1_k_encode.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -2128,7 +2128,8 @@
 #endif /* not DISABLE_PKINIT */
 
 asn1_error_code
-asn1_encode_sequence_of_typed_data(asn1buf *buf, const krb5_typed_data **val,
+asn1_encode_sequence_of_typed_data(asn1buf *buf,
+                                   const krb5_pa_data *const *val,
                                    unsigned int *retlen)
 {
     asn1_setup();
@@ -2150,12 +2151,12 @@
 }
 
 asn1_error_code
-asn1_encode_typed_data(asn1buf *buf, const krb5_typed_data *val,
+asn1_encode_typed_data(asn1buf *buf, const krb5_pa_data *val,
                        unsigned int *retlen)
 {
     asn1_setup();
-    asn1_addlenfield(val->length, val->data, 1, asn1_encode_octetstring);
-    asn1_addfield(val->type, 0, asn1_encode_integer);
+    asn1_addlenfield(val->length, val->contents, 1, asn1_encode_octetstring);
+    asn1_addfield(val->pa_type, 0, asn1_encode_integer);
     asn1_makeseq();
     asn1_cleanup();
 }

Modified: trunk/src/lib/krb5/asn.1/asn1_k_encode.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_encode.h	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/asn.1/asn1_k_encode.h	2011-12-21 22:52:52 UTC (rev 25601)
@@ -150,11 +150,10 @@
     unsigned int *retlen);
 
 asn1_error_code asn1_encode_typed_data(asn1buf *buf,
-                                       const krb5_typed_data *val,
+                                       const krb5_pa_data *val,
                                        unsigned int *retlen);
 
-asn1_error_code asn1_encode_sequence_of_typed_data(asn1buf *buf,
-                                                   const krb5_typed_data **val,
-                                                   unsigned int *retlen);
+asn1_error_code asn1_encode_sequence_of_typed_data(
+    asn1buf *buf, const krb5_pa_data *const *val, unsigned int *retlen);
 
 #endif

Modified: trunk/src/lib/krb5/asn.1/krb5_decode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/krb5_decode.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/asn.1/krb5_decode.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -1077,9 +1077,9 @@
 #endif /* DISABLE_PKINIT */
 
 krb5_error_code
-decode_krb5_typed_data(const krb5_data *code, krb5_typed_data ***repptr)
+decode_krb5_typed_data(const krb5_data *code, krb5_pa_data ***repptr)
 {
-    setup_buf_only(krb5_typed_data **);
+    setup_buf_only(krb5_pa_data **);
     retval = asn1_decode_sequence_of_typed_data(&buf, &rep);
     if (retval) clean_return(retval);
 

Modified: trunk/src/lib/krb5/asn.1/krb5_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/krb5_encode.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/asn.1/krb5_encode.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -169,7 +169,7 @@
 #endif /* DISABLE_PKINIT */
 
 krb5_error_code
-encode_krb5_typed_data(const krb5_typed_data **rep, krb5_data **code)
+encode_krb5_typed_data(const krb5_pa_data *const *rep, krb5_data **code)
 {
     krb5_setup();
     retval = asn1_encode_sequence_of_typed_data(buf,rep,&length);

Modified: trunk/src/lib/krb5/krb/fast.c
===================================================================
--- trunk/src/lib/krb5/krb/fast.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/krb/fast.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -478,10 +478,7 @@
             retval = decode_krb5_padata_sequence(&err_reply->e_data,
                                                  out_padata);
             if (retval != 0) {
-                krb5_typed_data **tdata;
-                /* krb5_typed data and krb5_pa_data are compatible. */
-                if (decode_krb5_typed_data(&err_reply->e_data, &tdata) == 0)
-                    *out_padata = (krb5_pa_data **)tdata;
+                (void)decode_krb5_typed_data(&err_reply->e_data, out_padata);
                 retval = 0;
             }
         }

Modified: trunk/src/lib/krb5/krb/kfree.c
===================================================================
--- trunk/src/lib/krb5/krb/kfree.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/krb/kfree.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -858,20 +858,6 @@
     free(val);
 }
 
-void
-krb5_free_typed_data(krb5_context context, krb5_typed_data **in)
-{
-    int i = 0;
-    if (in == NULL) return;
-    while (in[i] != NULL) {
-        if (in[i]->data != NULL)
-            free(in[i]->data);
-        free(in[i]);
-        i++;
-    }
-    free(in);
-}
-
 void KRB5_CALLCONV
 krb5_free_fast_armored_req(krb5_context context, krb5_fast_armored_req *val)
 {

Modified: trunk/src/lib/krb5/libkrb5.exports
===================================================================
--- trunk/src/lib/krb5/libkrb5.exports	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/libkrb5.exports	2011-12-21 22:52:52 UTC (rev 25601)
@@ -339,7 +339,6 @@
 krb5_free_ticket
 krb5_free_tickets
 krb5_free_tkt_authent
-krb5_free_typed_data
 krb5_free_unparsed_name
 krb5_fwd_tgt_creds
 krb5_gen_portaddr

Modified: trunk/src/lib/krb5/os/accessor.c
===================================================================
--- trunk/src/lib/krb5/os/accessor.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/lib/krb5/os/accessor.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -88,7 +88,6 @@
             SC (encode_krb5_kdc_dh_key_info, encode_krb5_kdc_dh_key_info),
             SC (encode_krb5_reply_key_pack, encode_krb5_reply_key_pack),
             SC (encode_krb5_reply_key_pack_draft9, encode_krb5_reply_key_pack_draft9),
-            SC (encode_krb5_typed_data, encode_krb5_typed_data),
             SC (encode_krb5_td_trusted_certifiers, encode_krb5_td_trusted_certifiers),
             SC (encode_krb5_td_dh_parameters, encode_krb5_td_dh_parameters),
             SC (decode_krb5_pa_pk_as_req, decode_krb5_pa_pk_as_req),
@@ -101,7 +100,6 @@
             SC (decode_krb5_principal_name, decode_krb5_principal_name),
             SC (decode_krb5_reply_key_pack, decode_krb5_reply_key_pack),
             SC (decode_krb5_reply_key_pack_draft9, decode_krb5_reply_key_pack_draft9),
-            SC (decode_krb5_typed_data, decode_krb5_typed_data),
             SC (decode_krb5_td_trusted_certifiers, decode_krb5_td_trusted_certifiers),
             SC (decode_krb5_td_dh_parameters, decode_krb5_td_dh_parameters),
             SC (decode_krb5_as_req, decode_krb5_as_req),

Modified: trunk/src/plugins/preauth/pkinit/pkinit.h
===================================================================
--- trunk/src/plugins/preauth/pkinit/pkinit.h	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/plugins/preauth/pkinit/pkinit.h	2011-12-21 22:52:52 UTC (rev 25601)
@@ -317,7 +317,6 @@
 void free_krb5_pa_pk_as_rep_draft9(krb5_pa_pk_as_rep_draft9 **in);
 void free_krb5_external_principal_identifier(krb5_external_principal_identifier ***in);
 void free_krb5_trusted_ca(krb5_trusted_ca ***in);
-void free_krb5_typed_data(krb5_typed_data ***in);
 void free_krb5_algorithm_identifiers(krb5_algorithm_identifier ***in);
 void free_krb5_algorithm_identifier(krb5_algorithm_identifier *in);
 void free_krb5_kdc_dh_key_info(krb5_kdc_dh_key_info **in);

Modified: trunk/src/plugins/preauth/pkinit/pkinit_accessor.c
===================================================================
--- trunk/src/plugins/preauth/pkinit/pkinit_accessor.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/plugins/preauth/pkinit/pkinit_accessor.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -49,7 +49,6 @@
 DEF_FUNC_PTRS(krb5_pa_pk_as_req_draft9);
 DEF_FUNC_PTRS(krb5_reply_key_pack);
 DEF_FUNC_PTRS(krb5_reply_key_pack_draft9);
-DEF_FUNC_PTRS_ARRAY(krb5_typed_data);
 
 /* special cases... */
 krb5_error_code
@@ -116,7 +115,6 @@
     SET_PTRS(krb5_reply_key_pack_draft9);
     SET_PTRS(krb5_td_dh_parameters);
     SET_PTRS(krb5_td_trusted_certifiers);
-    SET_PTRS(krb5_typed_data);
 
     /* special cases... */
     k5int_decode_krb5_principal_name = k5int.decode_krb5_principal_name;

Modified: trunk/src/plugins/preauth/pkinit/pkinit_accessor.h
===================================================================
--- trunk/src/plugins/preauth/pkinit/pkinit_accessor.h	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/plugins/preauth/pkinit/pkinit_accessor.h	2011-12-21 22:52:52 UTC (rev 25601)
@@ -53,7 +53,6 @@
 DEF_EXT_FUNC_PTRS(krb5_pa_pk_as_req_draft9);
 DEF_EXT_FUNC_PTRS(krb5_reply_key_pack);
 DEF_EXT_FUNC_PTRS(krb5_reply_key_pack_draft9);
-DEF_EXT_FUNC_PTRS_ARRAY(krb5_typed_data);
 
 /* special cases... */
 extern krb5_error_code (*k5int_decode_krb5_principal_name)

Modified: trunk/src/plugins/preauth/pkinit/pkinit_lib.c
===================================================================
--- trunk/src/plugins/preauth/pkinit/pkinit_lib.c	2011-12-21 22:52:43 UTC (rev 25600)
+++ trunk/src/plugins/preauth/pkinit/pkinit_lib.c	2011-12-21 22:52:52 UTC (rev 25601)
@@ -247,19 +247,6 @@
 }
 
 void
-free_krb5_typed_data(krb5_typed_data ***in)
-{
-    int i = 0;
-    if (*in == NULL) return;
-    while ((*in)[i] != NULL) {
-        free((*in)[i]->data);
-        free((*in)[i]);
-        i++;
-    }
-    free(*in);
-}
-
-void
 free_krb5_algorithm_identifier(krb5_algorithm_identifier *in)
 {
     if (in == NULL)



More information about the cvs-krb5 mailing list