Stop using krb5_typed_data structure type
authorGreg Hudson <ghudson@mit.edu>
Wed, 21 Dec 2011 22:52:52 +0000 (22:52 +0000)
committerGreg Hudson <ghudson@mit.edu>
Wed, 21 Dec 2011 22:52:52 +0000 (22:52 +0000)
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.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25601 dc483132-0cff-0310-8789-dd5450dbe970

18 files changed:
src/include/k5-int-pkinit.h
src/include/k5-int.h
src/include/krb5/krb5.hin
src/kdc/do_as_req.c
src/lib/krb5/asn.1/asn1_k_decode.c
src/lib/krb5/asn.1/asn1_k_decode.h
src/lib/krb5/asn.1/asn1_k_encode.c
src/lib/krb5/asn.1/asn1_k_encode.h
src/lib/krb5/asn.1/krb5_decode.c
src/lib/krb5/asn.1/krb5_encode.c
src/lib/krb5/krb/fast.c
src/lib/krb5/krb/kfree.c
src/lib/krb5/libkrb5.exports
src/lib/krb5/os/accessor.c
src/plugins/preauth/pkinit/pkinit.h
src/plugins/preauth/pkinit/pkinit_accessor.c
src/plugins/preauth/pkinit/pkinit_accessor.h
src/plugins/preauth/pkinit/pkinit_lib.c

index 481d6b1268a3e0f11b2ad7f8e4083c5fedfd9510..3ad5f51062319ef28685b03ed1db3dae940cc08a 100644 (file)
@@ -229,9 +229,6 @@ krb5_error_code
 encode_krb5_reply_key_pack_draft9(const krb5_reply_key_pack_draft9 *,
                                   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);
@@ -285,9 +282,6 @@ krb5_error_code
 decode_krb5_reply_key_pack_draft9(const krb5_data *,
                                   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 ***);
@@ -295,8 +289,6 @@ decode_krb5_td_trusted_certifiers(const krb5_data *,
 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 **);
 
index b25c159a75eaabfa5894850bdfe82a590aadbe58..906fb24ee59135c82068cf0e7097276d798d99ce 100644 (file)
@@ -1676,6 +1676,9 @@ encode_krb5_pwd_data(const krb5_pwd_data *rep, krb5_data **code);
 krb5_error_code
 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);
 
@@ -1903,6 +1906,9 @@ decode_krb5_pwd_data(const krb5_data *output, krb5_pwd_data **rep);
 krb5_error_code
 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);
 
@@ -2141,7 +2147,7 @@ void krb5int_free_srv_dns_data(struct srv_dns_entry *);
 /* 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 */
@@ -2224,9 +2230,6 @@ typedef struct _krb5int_access {
                                          krb5_external_principal_identifier **,
                                          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 **);
 
@@ -2270,9 +2273,6 @@ typedef struct _krb5int_access {
                                          krb5_external_principal_identifier
                                          ***);
 
-    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);
 
index d5524255e4b1bc7cb6079d288f2b9d9592962a68..a363eaff42bce20841f49c6b2ad7e714d5be8bbf 100644 (file)
@@ -1972,12 +1972,7 @@ typedef struct _krb5_pa_data {
     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;
index 61d088eb626a3990f4abaf323079531a2c1f2880..5e696532d6740c8b60f2c724014abf282de6e86c 100644 (file)
@@ -800,10 +800,9 @@ prepare_error_as (struct kdc_request_state *rstate, krb5_kdc_req *request,
     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;
index 9d052ca37fac77aeec21a1dd3c7aa21b15f4ac52..f05d9dfe7c484082f1f35f23553a59a599f6bb44 100644 (file)
@@ -1725,38 +1725,32 @@ asn1_decode_sequence_of_kdf_alg_id(asn1buf *buf, krb5_data ***val)
 
 #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);
 }
index 71eebb14ad198c6e24fd9605af7a1886f2c76bc4..34055eaddd6ff09c5adda4dfcd7cbf772131703d 100644 (file)
@@ -205,10 +205,10 @@ asn1_error_code
 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,
index 351281eeb510ac2bd6a0e2b75f76648c354990d6..82f99b12b630a94eef6daac85f938640b2e6dc5c 100644 (file)
@@ -2128,7 +2128,8 @@ encode_krb5_pkinit_supp_pub_info(const krb5_pkinit_supp_pub_info *rep,
 #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_encode_sequence_of_typed_data(asn1buf *buf, const krb5_typed_data **val,
 }
 
 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();
 }
index 604ca6a2115c2fd5085530fbce1ce3774fcb38ca..634105fcece58b5df309c42fa461a87ca6d207b1 100644 (file)
@@ -150,11 +150,10 @@ asn1_error_code asn1_encode_td_trusted_certifiers(
     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
index 10ebcac1cd1842c7415fc218aad5b854da3bafd0..5ac6db999dce4fcb6c156e548952f9e790fd0b60 100644 (file)
@@ -1077,9 +1077,9 @@ decode_krb5_td_dh_parameters(const krb5_data *code,
 #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);
 
index 159407c6df83c24c9eeee1e820bab5a676330964..f889683535c0b99aec3820009bdee486048f13c6 100644 (file)
@@ -169,7 +169,7 @@ encode_krb5_td_dh_parameters(const krb5_algorithm_identifier **rep,
 #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);
index 7de338b122a16edd1b2c1f3179bcca807c97a0df..612fffda3c35766b7c27fa0e4dd4274912e4bfb6 100644 (file)
@@ -478,10 +478,7 @@ krb5int_fast_process_error(krb5_context context,
             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;
             }
         }
index 2a323ec6f14896d1e2b2de9a2b56e9cebb273be5..c6dd0debe9a13f8c1596d3fc69ec204e73a8344a 100644 (file)
@@ -858,20 +858,6 @@ krb5_free_fast_finished(krb5_context context, krb5_fast_finished *val)
     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)
 {
index 5da2d23609021a7b0b508bbca27456c9e78cb088..183d5ee76dc9368cd3bc387ef491f40d49372b89 100644 (file)
@@ -339,7 +339,6 @@ krb5_free_tgt_creds
 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
index 5914e2b3fb777ea08def36ac03ad36bc4b43cbf1..52df8bccf43d04ffcc24e7a8cfc2d4d473e59f96 100644 (file)
@@ -88,7 +88,6 @@ krb5int_accessor(krb5int_access *internals, krb5_int32 version)
             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 @@ krb5int_accessor(krb5int_access *internals, krb5_int32 version)
             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),
index 7970746d958db4419eb137d061fe2510b60c46c9..8c75f1fd7dcd6de79c65b098d8c166e4647a30bb 100644 (file)
@@ -317,7 +317,6 @@ void free_krb5_pa_pk_as_rep(krb5_pa_pk_as_rep **in);
 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);
index acfbde6246cbc1ba07c0214dd488cb881d1ad51f..cf8a2f530bc810795507820f92708c1506aa2e34 100644 (file)
@@ -49,7 +49,6 @@ DEF_FUNC_PTRS(krb5_pa_pk_as_req);
 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 @@ pkinit_accessor_init(void)
     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;
index ba82533c8c553938b155cf04d0c954c34018d3e9..df40ab9eb71aba80694ed388981ac253b99cb39f 100644 (file)
@@ -53,7 +53,6 @@ DEF_EXT_FUNC_PTRS(krb5_pa_pk_as_req);
 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)
index 34416142e68daf78d3f501c2ffde35d83b2503d3..50ee044a7b55feaf8ed6a33e62ea2e26c937a292 100644 (file)
@@ -246,19 +246,6 @@ free_krb5_trusted_ca(krb5_trusted_ca ***in)
     free(*in);
 }
 
-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)
 {