]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
kauth warning reduction
authorMarc Dionne <marc.c.dionne@gmail.com>
Mon, 27 Jul 2009 18:24:15 +0000 (14:24 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Thu, 6 Aug 2009 04:00:46 +0000 (21:00 -0700)
Warning removal for various functions that manipulates keys and use
several data types interchangeably.
Inline helpers are introduced to convert between the types and are
used when making function calls to target the appropriate type:

des_prototypes.h
cblockptr_to_cblock:  des_cblock *  to des_cblock
charptr_to_cblock:  char *  to des_cblock
charptr_to_cblockptr:  char *  to des_cblock *

rxkad_prototypes.h
ktc_to_cblock:  struct ktc_encryptionKey *  to des_cblock
ktc_to_cblockptr:  struct ktc_encryptionKey *  to des_cblock *

kauth_internal.h
EncryptionKey_to_cblock:  EncryptionKey *  to des_cblock
EncryptionKey_to_ktc:  EncryptionKey *  to struct ktc_encryptionKey *
ktc_to_EncryptionKey:  struct ktc_encryptionKey *  to EncryptionKey *

- parameters are adjusted for tkt_DecodeTicket(5), replacing the char *
key with struct ktc_encryptionKey, to match usage
- the get_key function is changed to have a void * parameter, to match
usage
- rxkad_prototypes.h includes des.h to get the des_cblock definition.
This causes conflicts for a few files where the kerberos headers are
also included - aklog/aklog_main.c and WINNT/afsd/afskfw.c
Use NO_DES_H_INCLUDE in thoses cases to skip the new parts of
rxkad_prototypes.h

Reviewed-on: http://gerrit.openafs.org/234
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
21 files changed:
Makefile.in
src/WINNT/afsd/afskfw.c
src/aklog/aklog_main.c
src/auth/authcon.c
src/bozo/bos_util.c
src/des/des_prototypes.h
src/des/strng_to_key.c
src/kauth/admin_tools.c
src/kauth/authclient.c
src/kauth/client.c
src/kauth/kaprocs.c
src/kauth/kauth_internal.h
src/kauth/kautils.c
src/kauth/kpasswd.c
src/kauth/krb_udp.c
src/kauth/read_passwd.c
src/kauth/rebuild.c
src/kauth/user.c
src/rxkad/rxkad_prototypes.h
src/rxkad/ticket.c
src/rxkad/ticket5.c

index 6f3da121ff8cfef22cd871c4f63f740fb7b8a811..c811ce2428c6c6bbe883eafee61dd3e2e97e3e39 100644 (file)
@@ -122,7 +122,7 @@ config: prelude
 procmgmt: config
        +${COMPILE_PART1} procmgmt ${COMPILE_PART2}
 
-util: procmgmt des lwp_depinstall
+util: procmgmt lwp_depinstall
        +${COMPILE_PART1} util ${COMPILE_PART2}
 
 audit: util rx rxkad
index 1836b4a11db39c53073cf8144fee188fae6c15f9..052afea5756ecd6262181bf9ec7a2ddf6267085d 100644 (file)
@@ -63,6 +63,9 @@
 #define USE_MS2MIT 1
 #define USE_LEASH 1
 
+/* Prevent inclusion of des.h to avoid conflicts with des types */
+#define NO_DES_H_INCLUDE
+
 #include "afskfw-int.h"
 #include "afskfw.h"
 #include <userenv.h>
index 7fe2cb21d20a6e551997ebd217c951704277d4da..cdf6d7790c340c8411235f66bc6d7f3edf9ff319 100644 (file)
 #ifdef AFS_SUN5_ENV
 #include <sys/ioccom.h>
 #endif
+
+/* Prevent inclusion of des.h to avoid conflicts with des types */
+#define NO_DES_H_INCLUDE
+
 #include <afs/auth.h>
 #include <afs/cellconfig.h>
 #include <afs/vice.h>
index 61c578d979f1e301534da94b98b963a0558bc81b..548b153ccd3475788fefae5ee9f9e38c8e3dcda3 100644 (file)
@@ -20,8 +20,6 @@
 #include "afsincludes.h"
 #include "afs/stds.h"
 #include "afs/pthread_glock.h"
-#include "des/des.h"
-#include "des/des_prototypes.h"
 #include "rx/rxkad.h"
 #include "rx/rx.h"
 #include "afs/cellconfig.h"
@@ -107,8 +105,8 @@ GenericAuth(struct afsconf_dir *adir,
     }
 
     /* next create random session key, using key for seed to good random */
-    des_init_random_number_generator(&key);
-    code = des_random_key(&session);
+    des_init_random_number_generator(ktc_to_cblock(&key));
+    code = des_random_key(ktc_to_cblock(&session));
     if (code) {
        return QuickAuth(astr, aindex);
     }
index ef08b5ebbefcfc1a83c6eaac1aa1dc98a30d3148..5cfb674ea5785e6571470929f477edbd7bd4583e 100644 (file)
@@ -27,6 +27,7 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <string.h>
+#include <stdio.h>
 
 #include <afs/stds.h>
 #include <afs/afsutil.h>
@@ -123,7 +124,7 @@ main(int argc, char **argv)
            printf("\nInput key mismatch\n");
            exit(1);
        }
-       des_string_to_key(buf, &tkey);
+       des_string_to_key(buf, ktc_to_cblockptr(&tkey));
        code = afsconf_AddKey(tdir, kvno, &tkey, 0);
        if (code) {
            printf("bos_util: failed to set key, code %d.\n", code);
index 11322efd7673b0551857a621e6ba9d2d25918c03..6c2baf6d689f844e9588261cddf0647d1359b174 100644 (file)
@@ -17,6 +17,21 @@ extern void test_set(FILE * stream, const char *src, int testbit,
 #endif
 extern int des_debug;
 
+static_inline unsigned char *
+cblockptr_to_cblock(des_cblock *key) {
+    return (unsigned char *)key;
+}
+
+static_inline unsigned char *
+charptr_to_cblock(char *key) {
+    return (unsigned char *)key;
+}
+
+static_inline des_cblock *
+charptr_to_cblockptr(char *key) {
+    return (unsigned char (*)[])key;
+}
+
 /* cbc_encrypt.c */
 extern afs_int32 des_cbc_encrypt(void * in, void * out,
                                 register afs_int32 length,
index 1d9c5b2ed36377b75830d75c91334efe4eef093a..61fdf60c95b7d53d0022551543078388372770b9 100644 (file)
@@ -105,16 +105,16 @@ des_string_to_key(char *str, register des_cblock * key)
     }
 
     /* fix key parity */
-    des_fixup_key_parity(key);
+    des_fixup_key_parity(cblockptr_to_cblock(key));
 
     /* Now one-way encrypt it with the folded key */
-    (void)des_key_sched(key, key_sked);
-    (void)des_cbc_cksum((des_cblock *) in_str, key, length, key_sked, key);
+    des_key_sched(cblockptr_to_cblock(key), key_sked);
+    des_cbc_cksum(charptr_to_cblockptr(in_str), key, length, key_sked, key);
     /* erase key_sked */
     memset((char *)key_sked, 0, sizeof(key_sked));
 
     /* now fix up key parity again */
-    des_fixup_key_parity(key);
+    des_fixup_key_parity(cblockptr_to_cblock(key));
 
     if (des_debug)
        fprintf(stdout, "\nResulting string_to_key = 0x%x 0x%x\n",
index ccf94838b584a17eacc1b8e0a54272eedb9ef3a3..982c128f96462dced3ce7827f6e452d5c5600aa3 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdio.h>
 #include <rx/rx.h>
+#include <rx/rxkad.h>
 #include <lock.h>
 #define UBIK_LEGACY_CALLITER 1
 #include <ubik.h>
@@ -763,7 +764,7 @@ StringToKey(struct cmd_syndesc *as, void *arock)
     ka_PrintBytes((char *)&key, sizeof(key));
     printf("'.\n");
 
-    des_string_to_key(as->parms[0].items->data, &key);
+    des_string_to_key(as->parms[0].items->data, ktc_to_cblockptr(&key));
 
     printf("Converting %s with the DES string to key yields key='",
           as->parms[0].items->data);
@@ -1425,7 +1426,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
                ka_GetAdminToken(name, instance, cell, &key, KA_SIXHOURS,
                                 &token, 0 /* !new */ );
            if (code == KABADREQUEST) {
-               des_string_to_key(passwd, &key);
+               des_string_to_key(passwd, ktc_to_cblockptr(&key));
                code =
                    ka_GetAdminToken(name, instance, cell, &key, KA_SIXHOURS,
                                     &token, 0 /* !new */ );
index ef81d33ec6887cb68db69866c375c9d232251f8e..4feba287b637248de1feeec1e5087723f8745f06 100644 (file)
 #include "afs_usrops.h"
 #include "afs/stds.h"
 #include "afs/pthread_glock.h"
+#include "des.h"
+#include "des_prototypes.h"
 #include "rx/rxkad.h"
 #include "afs/cellconfig.h"
 #include "ubik.h"
 #include "afs/auth.h"
-#include "des/des.h"
 #include "afs/afsutil.h"
 
 #include "afs/kauth.h"
 #include <netinet/in.h>
 #endif
 #include <string.h>
+#include <stdio.h>
+#include <des.h>
+#include <des_prototypes.h>
 #include <rx/rxkad.h>
 #include <afs/cellconfig.h>
 #include <ubik.h>
 #include <afs/auth.h>
-#include <des.h>
 #include <afs/afsutil.h>
 #include "kauth.h"
 #include "kautils.h"
@@ -528,7 +531,7 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
     int version;
 
     LOCK_GLOBAL_MUTEX;
-    if ((code = des_key_sched(key, schedule))) {
+    if ((code = des_key_sched(ktc_to_cblock(key), schedule))) {
        UNLOCK_GLOBAL_MUTEX;
        return KABADKEY;
     }
@@ -550,7 +553,7 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
     arequest.SeqLen = sizeof(request);
     arequest.SeqBody = (char *)&request;
     des_pcbc_encrypt(arequest.SeqBody, arequest.SeqBody, arequest.SeqLen,
-                    schedule, key, ENCRYPT);
+                    schedule, ktc_to_cblockptr(key), ENCRYPT);
 
     oanswer.MaxSeqLen = sizeof(answer);
     oanswer.SeqLen = 0;
@@ -586,7 +589,7 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
        return KAUBIKCALL;
     }
     des_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
-                    schedule, key, DECRYPT);
+                    schedule, ktc_to_cblockptr(key), DECRYPT);
 
     switch (version) {
     case 1:
@@ -662,7 +665,7 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st
     aticket.SeqLen = auth_token->ticketLen;
     aticket.SeqBody = auth_token->ticket;
 
-    code = des_key_sched(&auth_token->sessionKey, schedule);
+    code = des_key_sched(ktc_to_cblock(&auth_token->sessionKey), schedule);
     if (code) {
        UNLOCK_GLOBAL_MUTEX;
        return KABADKEY;
@@ -704,7 +707,7 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st
     }
 
     des_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
-                    schedule, &auth_token->sessionKey, DECRYPT);
+                    schedule, ktc_to_cblockptr(&auth_token->sessionKey), DECRYPT);
 
     switch (version) {
     case 1:
index b489d4661160c4bf8cfa803820caecf4a61c6ad3..847a15c028b745bdcb7bdbd03c4bce37209c3207 100644 (file)
@@ -30,7 +30,7 @@
 #include "afs/kautils.h"
 #include "afs/pthread_glock.h"
 #include "des/des.h"
-#include <des_prototypes.h>
+#include "des/des_prototypes.h"
 
 #else /* defined(UKERNEL) */
 #include <afs/stds.h>
@@ -48,6 +48,8 @@
 #include <afs/cellconfig.h>
 #include <afs/auth.h>
 #include <afs/afsutil.h>
+#include <des.h>
+#include <des_prototypes.h>
 #include "kauth.h"
 #include "kautils.h"
 #endif /* defined(UKERNEL) */
@@ -97,7 +99,7 @@ Andrew_StringToKey(char *str, char *cell,     /* cell for password */
            keybytes[i] = (unsigned char)(temp << 1);
        }
     }
-    des_fixup_key_parity(key);
+    des_fixup_key_parity(ktc_to_cblock(key));
 }
 
 static void
@@ -105,7 +107,7 @@ StringToKey(char *str, char *cell,  /* cell for password */
            struct ktc_encryptionKey *key)
 {
     des_key_schedule schedule;
-    char temp_key[8];
+    unsigned char temp_key[8];
     char ivec[8];
     char password[BUFSIZ];
     int passlen;
@@ -120,14 +122,14 @@ StringToKey(char *str, char *cell,        /* cell for password */
     memcpy(temp_key, "kerberos", 8);
     des_fixup_key_parity(temp_key);
     des_key_sched(temp_key, schedule);
-    des_cbc_cksum(password, ivec, passlen, schedule, ivec);
+    des_cbc_cksum(charptr_to_cblockptr(password), charptr_to_cblockptr(ivec), passlen, schedule, charptr_to_cblockptr(ivec));
 
     memcpy(temp_key, ivec, 8);
     des_fixup_key_parity(temp_key);
     des_key_sched(temp_key, schedule);
-    des_cbc_cksum(password, key, passlen, schedule, ivec);
+    des_cbc_cksum(charptr_to_cblockptr(password), ktc_to_cblockptr(key), passlen, schedule, charptr_to_cblockptr(ivec));
 
-    des_fixup_key_parity(key);
+    des_fixup_key_parity(ktc_to_cblock(key));
 }
 
 void
index 9674673298f36d2078416c5c0ddff193c172977b..ec23611638cedd309f4d58723a200cb5280aee68 100644 (file)
@@ -26,6 +26,8 @@
 #include <lock.h>
 #include <ubik.h>
 #include <lwp.h>
+#include <des.h>
+#include <des_prototypes.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rxkad.h>
@@ -35,8 +37,6 @@
 #include <netinet/in.h>
 #endif
 #include <string.h>
-#include <des.h>
-#include <des_prototypes.h>
 #include <afs/cellconfig.h>
 #include <afs/auth.h>
 #include <afs/com_err.h>
@@ -149,12 +149,12 @@ get_time(Date *timeP,
        if (to) {               /* check if auto cpw is disabled */
            if (!(ntohl(tentry.flags) & KAFNOCPW)) {
                memcpy(&key, &random_value[0], sizeof(key));
-               des_fixup_key_parity(&key);
+               des_fixup_key_parity(ktc_to_cblock(&key));
                code =
                    set_password(tt, KA_ADMIN_NAME, KA_ADMIN_INST, &key, 0,
                                 0);
                if (code == 0) {
-                   des_init_random_number_generator(&key);
+                   des_init_random_number_generator(ktc_to_cblock(&key));
                    ka_ConvertBytes(buf, sizeof(buf), (char *)&key,
                                    sizeof(key));
                    es_Report("New Admin key is %s\n", buf);
@@ -173,7 +173,7 @@ get_time(Date *timeP,
        if (to) {               /* check if auto cpw is disabled */
            if (!(ntohl(tentry.flags) & KAFNOCPW)) {
                memcpy(&key, &random_value[2], sizeof(key));
-               des_fixup_key_parity(&key);
+               des_fixup_key_parity(ktc_to_cblock(&key));
                code = set_password(tt, KA_TGS_NAME, lrealm, &key, 0, 0);
                if (code == 0) {
                    ka_ConvertBytes(buf, sizeof(buf), (char *)&key,
@@ -220,14 +220,14 @@ initialize_database(struct ubik_trans *tt)
     int code;
 
     gettimeofday((struct timeval *)&key, 0);   /* this is just a cheap seed key */
-    des_fixup_key_parity(&key);
-    des_init_random_number_generator(&key);
-    if ((code = des_random_key(&key))
+    des_fixup_key_parity(ktc_to_cblock(&key));
+    des_init_random_number_generator(ktc_to_cblock(&key));
+    if ((code = des_random_key(ktc_to_cblock(&key)))
        || (code =
            create_user(tt, KA_ADMIN_NAME, KA_ADMIN_INST, &key, 0,
                        KAFNORMAL | KAFNOSEAL | KAFNOTGS)))
        return code;
-    if ((code = des_random_key(&key))
+    if ((code = des_random_key(ktc_to_cblock(&key)))
        || (code =
            create_user(tt, KA_TGS_NAME, lrealm, &key, 0,
                        KAFNORMAL | KAFNOSEAL | KAFNOTGS)))
@@ -291,7 +291,7 @@ init_kaprocs(const char *lclpath, int initFlags)
             code);
        return code;
     }
-    des_init_random_number_generator(&key);
+    des_init_random_number_generator(ktc_to_cblock(&key));
 
     code = ubik_EndTrans(tt);
     if (code) {
@@ -629,7 +629,7 @@ kamCreateUser(struct rx_call *call, char *aname, char *ainstance,
     afs_int32 caller;          /* Disk offset of caller's entry */
 
     COUNT_REQ(CreateUser);
-    if (!des_check_key_parity(&ainitpw) || des_is_weak_key(&ainitpw))
+    if (!des_check_key_parity(EncryptionKey_to_cblock(&ainitpw)) || des_is_weak_key(EncryptionKey_to_cblock(&ainitpw)))
        return KABADKEY;
     if (!name_instance_legal(aname, ainstance))
        return KABADNAME;
@@ -641,7 +641,7 @@ kamCreateUser(struct rx_call *call, char *aname, char *ainstance,
        ubik_AbortTrans(tt);
        return code;
     }
-    code = create_user(tt, aname, ainstance, &ainitpw, caller, KAFNORMAL);
+    code = create_user(tt, aname, ainstance, EncryptionKey_to_ktc(&ainitpw), caller, KAFNORMAL);
     if (code) {
        COUNT_ABO;
        ubik_AbortTrans(tt);
@@ -702,11 +702,11 @@ ChangePassWord(struct rx_call *call, char *aname, char *ainstance,
     }
 
     /* decrypt request w/ user password */
-    if ((code = des_key_sched(&tentry.key, user_schedule)))
+    if ((code = des_key_sched(ktc_to_cblock(&tentry.key), user_schedule)))
        es_Report("In KAChangePassword: key_sched returned %d\n", code);
     des_pcbc_encrypt(arequest->SeqBody, &request,
                     min(arequest->SeqLen, sizeof(request)), user_schedule,
-                    &tentry.key, DECRYPT);
+                    ktc_to_cblockptr(&tentry.key), DECRYPT);
 
     /* validate the request */
     request_time = ntohl(request.time);        /* reorder date */
@@ -719,7 +719,7 @@ ChangePassWord(struct rx_call *call, char *aname, char *ainstance,
     /* check to see if the new password was used before, or if there has
      * not been sufficient time since the last password change
      */
-    code = impose_reuse_limits(&request.newpw, &tentry);
+    code = impose_reuse_limits(ktc_to_EncryptionKey(&request.newpw), &tentry);
     if (code) {
        goto abort;
     }
@@ -738,7 +738,7 @@ ChangePassWord(struct rx_call *call, char *aname, char *ainstance,
     memcpy(answer, KA_CPW_ANS_LABEL, KA_LABELSIZE);
 
     des_pcbc_encrypt(oanswer->SeqBody, oanswer->SeqBody, answer_len,
-                    user_schedule, &tentry.key, ENCRYPT);
+                    user_schedule, ktc_to_cblockptr(&tentry.key), ENCRYPT);
 
     code = set_password(tt, aname, ainstance, &request.newpw, kvno, 0);
     if (code) {
@@ -889,7 +889,7 @@ kamSetPassword(struct rx_call *call, char *aname, char *ainstance,
     COUNT_REQ(SetPassword);
     if (akvno > MAXKAKVNO)
        return KABADARGUMENT;
-    if (!des_check_key_parity(&apassword) || des_is_weak_key(&apassword))
+    if (!des_check_key_parity(EncryptionKey_to_cblock(&apassword)) || des_is_weak_key(EncryptionKey_to_cblock(&apassword)))
        return KABADKEY;
 
     if (!name_instance_legal(aname, ainstance))
@@ -900,7 +900,7 @@ kamSetPassword(struct rx_call *call, char *aname, char *ainstance,
     if (code) {
        goto abort;
     }
-    if ((code = karead(tt, caller, &tentry, sizeof(tentry)))) {
+    if ((code = karead(tt, caller, (char *)&tentry, sizeof(tentry)))) {
        code = KAIO;
        goto abort;
     }
@@ -913,10 +913,10 @@ kamSetPassword(struct rx_call *call, char *aname, char *ainstance,
            code = impose_reuse_limits(&apassword, &tentry);
            if (!code)
                code =
-                   set_password(tt, aname, ainstance, &apassword, akvno, 0);
+                   set_password(tt, aname, ainstance, EncryptionKey_to_ktc(&apassword), akvno, 0);
        }
     } else if (ntohl(tentry.flags) & KAFADMIN) {
-       code = set_password(tt, aname, ainstance, &apassword, akvno, caller);
+       code = set_password(tt, aname, ainstance, EncryptionKey_to_ktc(&apassword), akvno, caller);
     } else
        code = KANOAUTH;
     if (code)
@@ -1100,11 +1100,11 @@ Authenticate(int version, struct rx_call *call, char *aname, char *ainstance,
     save_principal(authPrincipal, aname, ainstance, 0);
 
     /* decrypt request w/ user password */
-    if ((code = des_key_sched(&tentry.key, user_schedule)))
+    if ((code = des_key_sched(ktc_to_cblock(&tentry.key), user_schedule)))
        es_Report("In KAAuthenticate: key_sched returned %d\n", code);
     des_pcbc_encrypt(arequest->SeqBody, &request,
                     min(arequest->SeqLen, sizeof(request)), user_schedule,
-                    &tentry.key, DECRYPT);
+                    ktc_to_cblockptr(&tentry.key), DECRYPT);
 
     request.time = ntohl(request.time);        /* reorder date */
     tgt = !strncmp(request.label, KA_GETTGT_REQ_LABEL, sizeof(request.label));
@@ -1166,7 +1166,7 @@ Authenticate(int version, struct rx_call *call, char *aname, char *ainstance,
     tgskvno = ntohl(server.key_version);
     memcpy(&tgskey, &server.key, sizeof(tgskey));
 
-    code = des_random_key(&sessionKey);
+    code = des_random_key(ktc_to_cblock(&sessionKey));
     if (code) {
        code = KANOKEYS;
        goto abort;
@@ -1244,7 +1244,7 @@ Authenticate(int version, struct rx_call *call, char *aname, char *ainstance,
        goto abort;
     }
     des_pcbc_encrypt(oanswer->SeqBody, oanswer->SeqBody, oanswer->SeqLen,
-                    user_schedule, &tentry.key, ENCRYPT);
+                    user_schedule, ktc_to_cblockptr(&tentry.key), ENCRYPT);
     code = ubik_EndTrans(tt);
     KALOG(aname, ainstance, sname, sinst, NULL, call->conn->peer->host,
          LOG_AUTHENTICATE);
@@ -1588,7 +1588,7 @@ kamGetEntry(struct rx_call *call,
        code = KANOENT;
        goto abort;
     } else {
-       if ((code = karead(tt, callerIndex, &caller, sizeof(caller)))) {
+       if ((code = karead(tt, callerIndex, (char *)&caller, sizeof(caller)))) {
            code = KAIO;
            goto abort;
        }
@@ -1647,7 +1647,7 @@ kamGetEntry(struct rx_call *call,
     /* Now get entry of user who last modified this entry */
     if (ntohl(tentry.modification_id)) {
        temp = ntohl(tentry.modification_id);
-       code = karead(tt, temp, &tentry, sizeof(tentry));
+       code = karead(tt, temp, (char *)&tentry, sizeof(tentry));
        if (code) {
            code = KAIO;
            goto abort;
@@ -1800,7 +1800,7 @@ GetTicket(int version,
            code = KANOAUTH;
        goto abort;
     }
-    code = des_key_sched(&authSessionKey, schedule);
+    code = des_key_sched(ktc_to_cblock(&authSessionKey), schedule);
     if (code) {
        code = KANOAUTH;
        goto abort;
@@ -1855,7 +1855,7 @@ GetTicket(int version,
     }
     save_principal(tgsServerPrincipal, sname, sinstance, 0);
 
-    code = des_random_key(&sessionKey);
+    code = des_random_key(ktc_to_cblock(&sessionKey));
     if (code) {
        code = KANOKEYS;
        goto abort;
@@ -1929,7 +1929,7 @@ GetTicket(int version,
        goto abort;
     }
     des_pcbc_encrypt(oanswer->SeqBody, oanswer->SeqBody, oanswer->SeqLen,
-                    schedule, &authSessionKey, ENCRYPT);
+                    schedule, ktc_to_cblockptr(&authSessionKey), ENCRYPT);
     code = ubik_EndTrans(tt);
     KALOG(name, instance, sname, sinstance, (import ? authDomain : NULL),
          call->conn->peer->host, LOG_GETTICKET);
@@ -2145,7 +2145,7 @@ kamGetRandomKey(struct rx_call *call, EncryptionKey *key)
     COUNT_REQ(GetRandomKey);
     if ((code = AwaitInitialization()))
        return code;
-    code = des_random_key(key);
+    code = des_random_key(EncryptionKey_to_cblock(key));
     if (code)
        return KANOKEYS;
     return 0;
@@ -2304,7 +2304,7 @@ SKAM_LockStatus(struct rx_call *call,
        goto abort;
 
     if (!noAuthenticationRequired && callerIndex) {
-       if (karead(tt, callerIndex, &caller, sizeof(caller))) {
+       if (karead(tt, callerIndex, (char *)&caller, sizeof(caller))) {
            code = KAIO;
            goto abort;
        }
index 8356f9336349a09291b9c3f29a7be72b01236e1c..1b77b19f365a30dcaa876575c60bb3bf3a026bee 100644 (file)
@@ -26,3 +26,18 @@ extern afs_int32 ka_NewKey(struct ubik_trans *tt, afs_int32 tentryaddr,
                           struct ktc_encryptionKey *key);
 
 extern int name_instance_legal(char *name, char *instance);
+
+static inline unsigned char *
+EncryptionKey_to_cblock(EncryptionKey *key) {
+    return (unsigned char *)key;
+}
+
+static inline struct ktc_encryptionKey *
+EncryptionKey_to_ktc(EncryptionKey *key) {
+    return (struct ktc_encryptionKey *)key;
+}
+
+static inline EncryptionKey *
+ktc_to_EncryptionKey(struct ktc_encryptionKey *key) {
+    return (EncryptionKey *)key;
+}
index f48fbf14f3572428cb83b8e68d0b842794261137..8dc507d9ea2ddf582f70cb784b49c50bb876e2d9 100644 (file)
@@ -143,13 +143,13 @@ afs_int32
 ka_KeyCheckSum(char *key, afs_uint32 * cksumP)
 {
     des_key_schedule s;
-    char block[8];
+    unsigned char block[8];
     afs_uint32 cksum;
     afs_int32 code;
 
     *cksumP = 0;
     memset(block, 0, 8);
-    code = des_key_sched(key, s);
+    code = des_key_sched(charptr_to_cblock(key), s);
     if (code)
        return KABADKEY;
     des_ecb_encrypt(block, block, s, ENCRYPT);
index e40fdd320e6f0e057615c1e9359baf216be09876..e5437439642a8ee4f71bfc7746ce8be2eae1e7a9 100644 (file)
 #endif
 #include <string.h>
 #include <signal.h>
+#include <des.h>
+#include <des_prototypes.h>
 #include <afs/com_err.h>
 #include <afs/auth.h>
 #include <afs/cellconfig.h>
 #include <afs/cmd.h>
-#include <des.h>
-#include <des_prototypes.h>
 #include "kauth.h"
 #include "kautils.h"
 #include "kkids.h"
@@ -406,7 +406,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
        }
     }
     ka_StringToKey(passwd, realm, &key);
-    des_string_to_key(passwd, &mitkey);
+    des_string_to_key(passwd, ktc_to_cblockptr(&mitkey));
     give_to_child(passwd);
 
     /* Get new password if it wasn't provided. */
@@ -453,7 +453,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
        npasswd[8] = 0;         /* in case the password was exactly 8 chars long */
 #endif
     ka_StringToKey(npasswd, realm, &newkey);
-    des_string_to_key(npasswd, &newmitkey);
+    des_string_to_key(npasswd, ktc_to_cblockptr(&newmitkey));
     memset(npasswd, 0, sizeof(npasswd));
 
     if (lexplicit)
index c51c4857f7cf8275a2e1f3c6371c3dc44146d0aa..dad0a74ce4a0ce9f4f4c73a786f7075a3823fef6 100644 (file)
 #include <afs/com_err.h>
 #include <lwp.h>
 #include <des.h>
+#include <des_prototypes.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rxkad.h>
 #include <afs/auth.h>
-#include <des.h>
-#include <des_prototypes.h>
 #include <ubik.h>
 
 #include "kauth.h"
@@ -163,9 +162,9 @@ create_cipher(char *cipher, int *cipherLen,
        printf("\n");
     }
 
-    if ((code = des_key_sched(key, schedule)))
+    if ((code = des_key_sched(ktc_to_cblock(key), schedule)))
        printf("In KAAuthenticate: key_sched returned %d\n", code);
-    des_pcbc_encrypt(cipher, cipher, len, schedule, key, ENCRYPT);
+    des_pcbc_encrypt(cipher, cipher, len, schedule, ktc_to_cblockptr(key), ENCRYPT);
     *cipherLen = round_up_to_ebs(len);
 
     if (krb_udp_debug) {
@@ -223,8 +222,8 @@ check_auth(struct packet *pkt, char *auth, int authLen,
     afs_int32 time_sec;
     int byteOrder = pkt->byteOrder;
 
-    des_key_sched(key, schedule);
-    des_pcbc_encrypt(auth, auth, authLen, schedule, key, DECRYPT);
+    des_key_sched(ktc_to_cblock(key), schedule);
+    des_pcbc_encrypt(auth, auth, authLen, schedule, ktc_to_cblockptr(key), DECRYPT);
     packet = auth;
     if (strcmp(packet, name) != 0)
        return KABADTICKET;
@@ -322,7 +321,7 @@ UDP_Authenticate(int ksoc, struct sockaddr_in *client, char *name,
        }
 
        /* make the ticket */
-       code = des_random_key(&sessionKey);
+       code = des_random_key(ktc_to_cblock(&sessionKey));
        if (code) {
            code = KERB_ERR_NULL_KEY;   /* was KANOKEYS */
            goto abort;
@@ -535,7 +534,7 @@ UDP_GetTicket(int ksoc, struct packet *pkt, afs_int32 kvno,
     if (ntohl(server.flags) & KAFNOSEAL)
        return KABADSERVER;
 
-    code = des_random_key(&sessionKey);
+    code = des_random_key(ktc_to_cblock(&sessionKey));
     if (code) {
        code = KERB_ERR_NULL_KEY;       /* was KANOKEYS */
        goto fail;
index 746f693808c632cf52b33c15a2c008e7c644da52..49a7c44a76162832c618d5867f7e48c02fbac455 100644 (file)
 
 
 #include <mit-cpyright.h>
-#include <des.h>
 
 #include <stdio.h>
+#include <des.h>
+#include <des_prototypes.h>
 #ifdef BSDUNIX
 #include <strings.h>
 #include <sys/ioctl.h>
index 987d9d4094d88dbf99af28e0c687a6858e16e9ec..760deeeedc7d9caf0a4a3413b7aa11774893a62d 100644 (file)
@@ -29,6 +29,7 @@
 #include <afs/cmd.h>
 #include <des.h>
 #include <des_prototypes.h>
+#include <rx/rxkad.h>
 
 #include <afs/com_err.h>
 
@@ -469,8 +470,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                    printf("Entry %d has zero length name\n", i);
                continue;
            }
-           if (!des_check_key_parity(&entry.key)
-               || des_is_weak_key(&entry.key)) {
+           if (!des_check_key_parity(ktc_to_cblock(&entry.key))
+               || des_is_weak_key(ktc_to_cblock(&entry.key))) {
                fprintf(stderr, "Entry %d, %s, has bad key\n", i,
                        EntryName(&entry));
                continue;
index 0f0a274455654355270d4584aa0bfbac42d964c7..20d6b2b058dd3ce0e10bf48f4f57091d54ba8a74 100644 (file)
@@ -35,7 +35,6 @@
 #include "afs/kautils.h"
 #include "afs/afsutil.h"
 #include "afs/ptuser.h"
-#include "des.h"
 #else /* defined(UKERNEL) */
 #include <afs/stds.h>
 #include <signal.h>
@@ -47,6 +46,7 @@
 #include <unistd.h>
 #endif
 #include <string.h>
+#include <stdio.h>
 #include <afs/cellconfig.h>
 #include <afs/auth.h>
 #include <afs/ptint.h>
 #include <afs/ptserver.h>
 #include <afs/afsutil.h>
 #include <afs/sys_prototypes.h>
+#include <des.h>
+#include <des_prototypes.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 #include <rx/rxkad.h>          /* max ticket lifetime */
-#include <des.h>
-#include <des_prototypes.h>
 #include "kauth.h"
 #include "kautils.h"
 #endif /* defined(UKERNEL) */
@@ -205,7 +205,7 @@ ka_UserAuthenticateGeneral(afs_int32 flags, char *name, char *instance,
     if (flags & KA_USERAUTH_ONLY_VERIFY) {
        code = ka_VerifyUserToken(name, instance, realm, &key);
        if (code == KABADREQUEST) {
-           des_string_to_key(password, &key);
+           des_string_to_key(password, ktc_to_cblockptr(&key));
            code = ka_VerifyUserToken(name, instance, realm, &key);
        }
     } else {
@@ -230,7 +230,7 @@ ka_UserAuthenticateGeneral(afs_int32 flags, char *name, char *instance,
            GetTickets(name, instance, realm, &key, lifetime,
                       password_expires, dosetpag);
        if (code == KABADREQUEST) {
-           des_string_to_key(password, &key);
+           des_string_to_key(password, ktc_to_cblockptr(&key));
            code =
                GetTickets(name, instance, realm, &key, lifetime,
                           password_expires, dosetpag);
index 7db7bc24fa4f6e3a8af1cd6566c33c55d9379e04..0fead049dabef7472c88d489a799aaf850d21a0e 100644 (file)
 #include "fcrypt.h"
 #include "rx/rx.h"
 
+/* Don't include des.h where it can cause conflict with krb4 headers */
+#if !defined(NO_DES_H_INCLUDE)
+#include <des.h>
+#endif
+
 /* domestic/crypt_conn.c */
 extern afs_int32 rxkad_DecryptPacket(const struct rx_connection *conn,
                                     const fc_KeySchedule * schedule,
@@ -129,7 +134,7 @@ extern afs_int32 rxkad_SetConfiguration(struct rx_securityClass *aobj,
 /* ticket.c */
 extern int tkt_DecodeTicket(char *asecret, afs_int32 ticketLen,
                            struct ktc_encryptionKey *key, char *name,
-                           char *inst, char *cell, char *sessionKey,
+                           char *inst, char *cell, struct ktc_encryptionKey *sessionKey,
                            afs_int32 * host, afs_int32 * start,
                            afs_int32 * end);
 extern int tkt_MakeTicket(char *ticket, int *ticketLen,
@@ -145,11 +150,24 @@ extern unsigned char time_to_life(afs_uint32 start, afs_uint32 end);
 
 /* ticket5.c */
 extern int tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len,
-                            int (*get_key) (char *, int,
+                            int (*get_key) (void *, int,
                                             struct ktc_encryptionKey *),
                             char *get_key_rock, int serv_kvno, char *name,
-                            char *inst, char *cell, char *session_key,
+                            char *inst, char *cell, struct ktc_encryptionKey *session_key,
                             afs_int32 * host, afs_int32 * start,
                             afs_int32 * end, afs_int32 disableDotCheck);
 
+#if !defined(NO_DES_H_INCLUDE)
+static_inline unsigned char *
+ktc_to_cblock(struct ktc_encryptionKey *key) {
+    return (unsigned char *)key;
+}
+
+static_inline des_cblock *
+ktc_to_cblockptr(struct ktc_encryptionKey *key) {
+    return (des_cblock *)key;
+}
+#endif
+
+
 #endif
index 7b6392910c5f2eabca91f1886b8568d58b8fbc25..0b6628c508b5af6937ca118b41109b216222d3cc 100644 (file)
@@ -14,6 +14,7 @@
 #include <afs/param.h>
 #endif
 
+#include <stdio.h>
 
 #if defined(UKERNEL)
 #include "afs/sysincludes.h"
@@ -21,8 +22,9 @@
 #include "afs/stds.h"
 #include "rx/xdr.h"
 #include "rx/rx.h"
-#include "des/des.h"
 #include "rxkad/lifetimes.h"
+#include "des.h"
+#include "des/des_prototypes.h"
 #include "rx/rxkad.h"
 #else /* defined(UKERNEL) */
 #include <afs/stds.h>
 #include <netinet/in.h>
 #endif
 #include <string.h>
+#include <des.h>
+#include <des_prototypes.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <des.h>
 #include "lifetimes.h"
 #include "rxkad.h"
 #endif /* defined(UKERNEL) */
@@ -113,7 +116,7 @@ decode_athena_ticket(char *ticket, int ticketLen, char *name, char *inst,
 int
 tkt_DecodeTicket(char *asecret, afs_int32 ticketLen,
                 struct ktc_encryptionKey *key, char *name, char *inst,
-                char *cell, char *sessionKey, afs_int32 * host,
+                char *cell, struct ktc_encryptionKey *sessionKey, afs_int32 * host,
                 afs_int32 * start, afs_int32 * end)
 {
     char clear_ticket[MAXKTCTICKETLEN];
@@ -128,15 +131,15 @@ tkt_DecodeTicket(char *asecret, afs_int32 ticketLen,
        ((ticketLen) % 8 != 0)) /* enc. part must be (0 mod 8) bytes */
        return RXKADBADTICKET;
 
-    if (key_sched(key, schedule.schedule))
+    if (key_sched(ktc_to_cblock(key), schedule.schedule))
        return RXKADBADKEY;
 
     ticket = clear_ticket;
-    pcbc_encrypt(asecret, ticket, ticketLen, schedule.schedule, key, DECRYPT);
+    pcbc_encrypt(asecret, ticket, ticketLen, schedule.schedule, ktc_to_cblockptr(key), DECRYPT);
 
     code =
        decode_athena_ticket(ticket, ticketLen, name, inst, cell, host,
-                            sessionKey, start, end);
+                            (struct ktc_encryptionKey *)sessionKey, start, end);
 
     if (code)
        return RXKADBADTICKET;
@@ -226,11 +229,11 @@ tkt_MakeTicket(char *ticket, int *ticketLen, struct ktc_encryptionKey *key,
        return -1;
 
     /* encrypt ticket */
-    if ((code = key_sched(key, schedule.schedule))) {
+    if ((code = key_sched(ktc_to_cblock(key), schedule.schedule))) {
        printf("In tkt_MakeTicket: key_sched returned %d\n", code);
        return RXKADBADKEY;
     }
-    pcbc_encrypt(ticket, ticket, *ticketLen, schedule.schedule, key, ENCRYPT);
+    pcbc_encrypt(ticket, ticket, *ticketLen, schedule.schedule, ktc_to_cblockptr(key), ENCRYPT);
     return 0;
 }
 
index a83f7fed89bb31ac45122805c2d73fc941da304d..9b4300c2a5b4573f3df17acc277116ed099278d7 100644 (file)
@@ -68,7 +68,6 @@
 #include "../afs/stds.h"
 #include "../rx/xdr.h"
 #include "../rx/rx.h"
-#include "../des/des.h"
 #include "../afs/lifetimes.h"
 #include "../afs/rxkad.h"
 #else /* defined(UKERNEL) */
@@ -82,7 +81,6 @@
 #include <string.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <des.h>
 #include "lifetimes.h"
 #include "rxkad.h"
 #endif /* defined(UKERNEL) */
  * bug with MIT by sending mail to krb5-bugs@mit.edu.
  */
 
+extern afs_int32 des_cbc_encrypt(void * in, void * out,
+                                 register afs_int32 length,
+                                 des_key_schedule key, des_cblock *iv,
+                                 int encrypt);
+extern int des_key_sched(register des_cblock k, des_key_schedule schedule);
+
 struct krb_convert {
     char *v4_str;
     char *v5_str;
@@ -190,9 +194,9 @@ static int
 
 int
 tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len,
-                 int (*get_key) (char *, int, struct ktc_encryptionKey *),
+                 int (*get_key) (void *, int, struct ktc_encryptionKey *),
                  char *get_key_rock, int serv_kvno, char *name, char *inst,
-                 char *cell, char *session_key, afs_int32 * host,
+                 char *cell, struct ktc_encryptionKey *session_key, afs_int32 * host,
                  afs_int32 * start, afs_int32 * end, afs_int32 disableCheckdot)
 {
     char plain[MAXKRB5TICKETLEN];
@@ -446,7 +450,7 @@ krb5_des_decrypt(struct ktc_encryptionKey *key, int etype, void *in,
 
     cksum_func = NULL;
 
-    des_key_sched(key, &s);
+    des_key_sched(ktc_to_cblock(key), (struct des_ks_struct *)&s);
 
 #define CONFOUNDERSZ 8