Convert keyblock or padata types to krb5_data without compiler warnings.
authorKen Raeburn <raeburn@mit.edu>
Sun, 25 Mar 2007 23:09:48 +0000 (23:09 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sun, 25 Mar 2007 23:09:48 +0000 (23:09 +0000)
(Added inline functions, with appropriate casts, for data conversion.)

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

src/lib/krb5/krb/gen_seqnum.c
src/lib/krb5/krb/gen_subkey.c
src/lib/krb5/krb/preauth2.c

index 3737640977065530e7b2a1a590008634c9ec7c86..06564ee4a1fae623051a7ccea8b225ab5a5514e2 100644 (file)
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
+static inline krb5_data
+key2data (krb5_keyblock k)
+{
+    krb5_data d;
+    d.magic = KV5M_DATA;
+    d.length = k.length;
+    d.data = (char *) k.contents;
+    return d;
+}
+
 krb5_error_code
 krb5_generate_seq_number(krb5_context context, const krb5_keyblock *key, krb5_ui_4 *seqno)
 {
     krb5_data seed;
     krb5_error_code retval;
 
-    seed.length = key->length;
-    seed.data = key->contents;
+    seed = key2data(*key);
     if ((retval = krb5_c_random_add_entropy(context, KRB5_C_RANDSOURCE_TRUSTEDPARTY, &seed)))
        return(retval);
 
index 7ffc91f13530434b6bee429b0a3db62accb15c20..ad8d4bba39c7c9065692c8a74099b29a1271848b 100644 (file)
 
 #include "k5-int.h"
 
+static inline krb5_data
+key2data (krb5_keyblock k)
+{
+    krb5_data d;
+    d.magic = KV5M_DATA;
+    d.length = k.length;
+    d.data = (char *) k.contents;
+    return d;
+}
+
 krb5_error_code
 krb5_generate_subkey(krb5_context context, const krb5_keyblock *key, krb5_keyblock **subkey)
 {
     krb5_error_code retval;
     krb5_data seed;
 
-    seed.length = key->length;
-    seed.data = key->contents;
+    seed = key2data(*key);
     if ((retval = krb5_c_random_add_entropy(context, KRB5_C_RANDSOURCE_TRUSTEDPARTY, &seed)))
        return(retval);
 
index 2a2756f33b3baed0e0e040eef98c9cccf52be8da..18d737c34076f3a9f3d14cb3db188de1da8c1ccd 100644 (file)
@@ -566,6 +566,16 @@ krb5_run_preauth_plugins(krb5_context kcontext,
     return 0;
 }
 
+static inline krb5_data
+padata2data(krb5_pa_data p)
+{
+    krb5_data d;
+    d.magic = KV5M_DATA;
+    d.length = p.length;
+    d.data = (char *) p.contents;
+    return d;
+}
+
 static
 krb5_error_code pa_salt(krb5_context context,
                        krb5_kdc_req *request,
@@ -579,11 +589,9 @@ krb5_error_code pa_salt(krb5_context context,
 {
     krb5_data tmp;
 
-    tmp.data = in_padata->contents;
-    tmp.length = in_padata->length;
+    tmp = padata2data(*in_padata);
     krb5_free_data_contents(context, salt);
     krb5int_copy_data_contents(context, &tmp, salt);
-    
 
     if (in_padata->pa_type == KRB5_PADATA_AFS3_SALT)
        salt->length = SALT_TYPE_AFS_LENGTH;