kauth: don't call lcstring with a null source argument
[openafs.git] / src / kauth / authclient.c
index 9257fa5..10bef97 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 /* These routines provide a convenient interface to the AuthServer. */
 
 #include <afsconfig.h>
-#if defined(UKERNEL)
-#include "afs/param.h"
-#else
 #include <afs/param.h>
-#endif
+#include <afs/stds.h>
+
+#include <roken.h>
+#include <afs/opr.h>
 
 #ifdef IGNORE_SOME_GCC_WARNINGS
 # pragma GCC diagnostic warning "-Wstrict-prototypes"
 # pragma GCC diagnostic warning "-Wimplicit-function-declaration"
 #endif
 
+#include <hcrypto/des.h>
+
 #define UBIK_LEGACY_CALLITER 1
 
-#if defined(UKERNEL)
-#include "afs/sysincludes.h"
-#include "afsincludes.h"
-#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 "afs/afsutil.h"
-
-#include "afs/kauth.h"
-#include "afs/kautils.h"
-#include "afs/pthread_glock.h"
-
-#else /* defined(UKERNEL) */
-#include <afs/stds.h>
 #include <afs/pthread_glock.h>
-#include <sys/types.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <string.h>
-#include <stdio.h>
-#include <des.h>
-#include <des_prototypes.h>
 #include <rx/rxkad.h>
+#include <rx/rxkad_convert.h>
 #include <afs/cellconfig.h>
 #include <ubik.h>
 #include <afs/auth.h>
 #include <afs/afsutil.h>
+
 #include "kauth.h"
 #include "kautils.h"
-#endif /* defined(UKERNEL) */
 
+#ifdef UKERNEL
+#include "afs_usrops.h"
+#endif
 
 static struct afsconf_dir *conf = 0;
 static struct afsconf_cell explicit_cell_server_list;
@@ -74,13 +49,13 @@ static int debug = 0;
 #ifdef ENCRYPTIONBLOCKSIZE
 #undef ENCRYPTIONBLOCKSIZE
 #endif
-#define ENCRYPTIONBLOCKSIZE (sizeof(des_cblock))
+#define ENCRYPTIONBLOCKSIZE (sizeof(DES_cblock))
 
 /* Copy the specified list of servers into a specially know cell named
    "explicit".  The cell can then be used to debug experimental servers. */
 
 void
-ka_ExplicitCell(char *cell, afs_int32 serverList[])
+ka_ExplicitCell(char *cell, afs_uint32 serverList[])
 {
     int i;
 
@@ -129,8 +104,8 @@ ka_GetServers(char *cell, struct afsconf_cell * cellinfo)
     char cellname[MAXKTCREALMLEN];
 
     LOCK_GLOBAL_MUTEX;
-    if (cell && !strlen(cell))
-       cell = 0;
+    if (cell == NULL || strlen(cell) == 0)
+       cell = NULL;
     else
        cell = lcstring(cellname, cell, sizeof(cellname));
 
@@ -370,12 +345,10 @@ CheckTicketAnswer(ka_BBS * oanswer, afs_int32 challenge,
                  afs_int32 * pwexpires)
 {
     struct ka_ticketAnswer *answer;
-    afs_uint32 cksum;
     unsigned char tempc;
 
     answer = (struct ka_ticketAnswer *)oanswer->SeqBody;
 
-    cksum = ntohl(answer->cksum);
     if (challenge != ntohl(answer->challenge))
        return KABADPROTOCOL;
     memcpy(&token->sessionKey, &answer->sessionKey,
@@ -521,7 +494,7 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
                struct ktc_token * token, afs_int32 * pwexpires)
 {                              /* days until it expires */
     afs_int32 code;
-    des_key_schedule schedule;
+    DES_key_schedule schedule;
     Date request_time;
     struct ka_gettgtRequest request;
     struct ka_gettgtAnswer answer_old;
@@ -533,7 +506,7 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
     int version;
 
     LOCK_GLOBAL_MUTEX;
-    if ((code = des_key_sched(ktc_to_cblock(key), schedule))) {
+    if ((code = DES_key_sched(ktc_to_cblock(key), &schedule))) {
        UNLOCK_GLOBAL_MUTEX;
        return KABADKEY;
     }
@@ -554,8 +527,8 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
     memcpy(request.label, req_label, sizeof(request.label));
     arequest.SeqLen = sizeof(request);
     arequest.SeqBody = (char *)&request;
-    des_pcbc_encrypt(arequest.SeqBody, arequest.SeqBody, arequest.SeqLen,
-                    schedule, ktc_to_cblockptr(key), ENCRYPT);
+    DES_pcbc_encrypt(arequest.SeqBody, arequest.SeqBody, arequest.SeqLen,
+                    &schedule, ktc_to_cblockptr(key), ENCRYPT);
 
     oanswer.MaxSeqLen = sizeof(answer);
     oanswer.SeqLen = 0;
@@ -590,8 +563,8 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con
            return code;
        return KAUBIKCALL;
     }
-    des_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
-                    schedule, ktc_to_cblockptr(key), DECRYPT);
+    DES_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
+                    &schedule, ktc_to_cblockptr(key), DECRYPT);
 
     switch (version) {
     case 1:
@@ -659,7 +632,7 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st
     ka_BBS oanswer;
     char *strings;
     int len;
-    des_key_schedule schedule;
+    DES_key_schedule schedule;
     int version;
     afs_int32 pwexpires;
 
@@ -667,7 +640,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(ktc_to_cblock(&auth_token->sessionKey), schedule);
+    code = DES_key_sched(ktc_to_cblock(&auth_token->sessionKey), &schedule);
     if (code) {
        UNLOCK_GLOBAL_MUTEX;
        return KABADKEY;
@@ -675,7 +648,8 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st
 
     times.start = htonl(start);
     times.end = htonl(end);
-    des_ecb_encrypt(&times, &times, schedule, ENCRYPT);
+    DES_ecb_encrypt((DES_cblock *)&times, (DES_cblock *)&times, &schedule,
+                   ENCRYPT);
 
     atimes.SeqLen = sizeof(times);
     atimes.SeqBody = (char *)&times;
@@ -708,8 +682,9 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st
        return KAUBIKCALL;
     }
 
-    des_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
-                    schedule, ktc_to_cblockptr(&auth_token->sessionKey), DECRYPT);
+    DES_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
+                    &schedule, ktc_to_cblockptr(&auth_token->sessionKey),
+                    DECRYPT);
 
     switch (version) {
     case 1:
@@ -801,13 +776,8 @@ ka_ChangePassword(char *name, char *instance, struct ubik_client * conn,   /* Ubik
     afs_int32 code;
 
     LOCK_GLOBAL_MUTEX;
-#if defined(AFS_S390_LINUX20_ENV) && !defined(AFS_S390X_LINUX20_ENV)
-    code =
-       ubik_KAM_SetPassword(conn, UBIK_CALL_NEW, name, instance, 0, 0, *(EncryptionKey *)newkey);
-#else
     code =
        ubik_KAM_SetPassword(conn, UBIK_CALL_NEW, name, instance, 0, *(EncryptionKey *)newkey);
-#endif
     UNLOCK_GLOBAL_MUTEX;
     return code;
 }