linux-warning-reduction-20090318
[openafs.git] / src / rxkad / domestic / fcrypt.c
index 0820e93..d27ea7f 100644 (file)
@@ -26,6 +26,9 @@ RCSID
 #ifdef KERNEL
 #ifndef UKERNEL
 #include "afs/stds.h"
+#if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV) || defined(AFS_SUN5_ENV) 
+#include "h/systm.h"
+#endif
 #include "h/types.h"
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_OBSD_ENV)
 #include "netinet/in.h"
@@ -38,12 +41,11 @@ RCSID
 #include <asm/byteorder.h>
 #endif
 
-#include "afs/longc_procs.h"
-
 #else /* KERNEL */
 
 #include <afs/stds.h>
 #include <sys/types.h>
+#include <string.h>
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
 #else
@@ -55,7 +57,7 @@ RCSID
 #include "sboxes.h"
 #include "fcrypt.h"
 #include "rxkad.h"
-
+#include <des/stats.h>
 
 #ifdef TCRYPT
 int ROUNDS = 16;
@@ -102,24 +104,22 @@ fc_keysched(struct ktc_encryptionKey *key, fc_KeySchedule schedule)
        kword[1] = (kword[1] >> 11) | (temp << (56 - 32 - 11));
        schedule[i] = kword[0];
     }
-    LOCK_RXKAD_STATS;
-    rxkad_stats.fc_key_scheds++;
-    UNLOCK_RXKAD_STATS;
+    INC_RXKAD_STATS(fc_key_scheds);
     return 0;
 }
 
 /* IN int encrypt; * 0 ==> decrypt, else encrypt */
 afs_int32
 fc_ecb_encrypt(void * clear, void * cipher,
-              fc_KeySchedule schedule, int encrypt)
+              const fc_KeySchedule schedule, int encrypt)
 {
     afs_uint32 L, R;
-    afs_uint32 S, P;
-    unsigned char *Pchar = (unsigned char *)&P;
-    unsigned char *Schar = (unsigned char *)&S;
+    volatile afs_uint32 S, P;
+    volatile unsigned char *Pchar = (unsigned char *)&P;
+    volatile unsigned char *Schar = (unsigned char *)&S;
     int i;
 
-#if defined(vax) || (defined(mips) && defined(MIPSEL)) || defined(AFSLITTLE_ENDIAN)
+#ifndef WORDS_BIGENDIAN
 #define Byte0 3
 #define Byte1 2
 #define Byte2 1
@@ -140,9 +140,7 @@ fc_ecb_encrypt(void * clear, void * cipher,
 #endif
 
     if (encrypt) {
-       LOCK_RXKAD_STATS;
-       rxkad_stats.fc_encrypts[ENCRYPT]++;
-       UNLOCK_RXKAD_STATS;
+       INC_RXKAD_STATS(fc_encrypts[ENCRYPT]);
        for (i = 0; i < (ROUNDS / 2); i++) {
            S = *schedule++ ^ R;        /* xor R with key bits from schedule */
            Pchar[Byte2] = sbox0[Schar[Byte0]]; /* do 8-bit S Box subst. */
@@ -160,9 +158,7 @@ fc_ecb_encrypt(void * clear, void * cipher,
            R ^= P;
        }
     } else {
-       LOCK_RXKAD_STATS;
-       rxkad_stats.fc_encrypts[DECRYPT]++;
-       UNLOCK_RXKAD_STATS;
+       INC_RXKAD_STATS(fc_encrypts[DECRYPT]);
        schedule = &schedule[ROUNDS - 1];       /* start at end of key schedule */
        for (i = 0; i < (ROUNDS / 2); i++) {
            S = *schedule-- ^ L;        /* xor R with key bits from schedule */
@@ -204,7 +200,7 @@ fc_ecb_encrypt(void * clear, void * cipher,
 */
 afs_int32
 fc_cbc_encrypt(void *input, void *output, afs_int32 length,
-              fc_KeySchedule key, afs_uint32 * xor, int encrypt)
+              const fc_KeySchedule key, afs_uint32 * xor, int encrypt)
 {
     afs_uint32 i, j;
     afs_uint32 t_input[2];
@@ -215,7 +211,7 @@ fc_cbc_encrypt(void *input, void *output, afs_int32 length,
        for (i = 0; length > 0; i++, length -= 8) {
            /* get input */
            memcpy(t_input, input, sizeof(t_input));
-           (char *)input += sizeof(t_input);
+           input=((char *)input) + sizeof(t_input);
 
            /* zero pad */
            for (j = length; j <= 7; j++)
@@ -229,7 +225,7 @@ fc_cbc_encrypt(void *input, void *output, afs_int32 length,
 
            /* copy temp output and save it for cbc */
            memcpy(output, t_output, sizeof(t_output));
-           (char *)output += sizeof(t_output);
+           output=(char *)output + sizeof(t_output);
 
            /* calculate xor value for next round from plain & cipher text */
            xor[0] = t_input[0] ^ t_output[0];
@@ -244,7 +240,7 @@ fc_cbc_encrypt(void *input, void *output, afs_int32 length,
        for (i = 0; length > 0; i++, length -= 8) {
            /* get input */
            memcpy(t_input, input, sizeof(t_input));
-           (char *)input += sizeof(t_input);
+           input=((char *)input) + sizeof(t_input);
 
            /* no padding for decrypt */
            fc_ecb_encrypt(t_input, t_output, key, encrypt);
@@ -255,7 +251,7 @@ fc_cbc_encrypt(void *input, void *output, afs_int32 length,
 
            /* copy temp output */
            memcpy(output, t_output, sizeof(t_output));
-           (char *)output += sizeof(t_output);
+           output=((char *)output) + sizeof(t_output);
 
            /* calculate xor value for next round from plain & cipher text */
            xor[0] = t_input[0] ^ t_output[0];