[OpenAFS-devel] gcc -Wall cleanup: src/des
nneul@umr.edu
nneul@umr.edu
Wed, 11 Apr 2001 17:04:16 -0500
Index: des/cbc_encrypt.c
===================================================================
RCS file: /cvs/openafs/src/des/cbc_encrypt.c,v
retrieving revision 1.3
diff -u -r1.3 cbc_encrypt.c
--- des/cbc_encrypt.c 2001/03/27 22:03:08 1.3
+++ des/cbc_encrypt.c 2001/04/11 22:04:10
@@ -26,6 +26,7 @@
extern int des_debug;
extern int des_debug_print();
+extern int des_ecb_encrypt();
/*
* This routine performs DES cipher-block-chaining operation, either
Index: des/cksum.c
===================================================================
RCS file: /cvs/openafs/src/des/cksum.c,v
retrieving revision 1.3
diff -u -r1.3 cksum.c
--- des/cksum.c 2001/03/27 22:03:08 1.3
+++ des/cksum.c 2001/04/11 22:04:10
@@ -33,6 +33,7 @@
extern int des_debug;
extern int des_debug_print();
+extern int des_ecb_encrypt();
/*
* This routine performs DES cipher-block-chaining checksum operation,
Index: des/des.c
===================================================================
RCS file: /cvs/openafs/src/des/des.c,v
retrieving revision 1.3
diff -u -r1.3 des.c
--- des/des.c 2001/03/27 22:03:08 1.3
+++ des/des.c 2001/04/11 22:04:10
@@ -58,8 +58,9 @@
#endif
extern int des_debug;
-extern des_cblock_print_file ();
-extern des_debug_print ();
+extern int des_cblock_print_file ();
+extern int des_debug_print ();
+extern int swap_long_bytes_bit_number(int);
#ifdef AFS_PTHREAD_ENV
pthread_mutex_t rxkad_stats_mutex;
Index: des/key_sched.c
===================================================================
RCS file: /cvs/openafs/src/des/key_sched.c,v
retrieving revision 1.1
diff -u -r1.1 key_sched.c
--- des/key_sched.c 2000/11/04 02:26:28 1.1
+++ des/key_sched.c 2001/04/11 22:04:10
@@ -36,12 +36,15 @@
#include "stats.h"
extern int des_debug;
-extern rev_swap_bit_pos_0();
+extern int rev_swap_bit_pos_0();
+extern int des_check_key_parity(des_cblock);
+extern int des_is_weak_key(des_cblock);
typedef char key[64];
/* the following are really void but cc86 doesnt allow it */
static int make_key_sched();
+
#ifdef AFS_DUX40_ENV
#pragma weak des_key_sched = afs_des_key_sched
int afs_des_key_sched(k,schedule)
@@ -246,4 +249,6 @@
fprintf(stderr,"\n");
}
#endif
+
+ return(0);
}
Index: des/make_fp.c
===================================================================
RCS file: /cvs/openafs/src/des/make_fp.c,v
retrieving revision 1.1
diff -u -r1.1 make_fp.c
--- des/make_fp.c 2000/11/04 02:26:30 1.1
+++ des/make_fp.c 2001/04/11 22:04:10
@@ -11,10 +11,13 @@
#include <mit-cpyright.h>
#include <stdio.h>
#include "des_internal.h"
+
+#define WANT_FP_TABLE
#include "tables.h"
extern unsigned int swap_bit_pos_0_to_ansi PROTOTYPE((unsigned int));
extern afs_int32 swap_long_bytes();
+extern afs_int32 swap_long_bytes_bit_number();
extern void test_set PROTOTYPE((FILE *, char const *, int,
char const *, int));
Index: des/make_ip.c
===================================================================
RCS file: /cvs/openafs/src/des/make_ip.c,v
retrieving revision 1.1
diff -u -r1.1 make_ip.c
--- des/make_ip.c 2000/11/04 02:26:31 1.1
+++ des/make_ip.c 2001/04/11 22:04:10
@@ -11,10 +11,16 @@
#include <mit-cpyright.h>
#include <stdio.h>
#include "des_internal.h"
+
+#define WANT_IP_TABLE
#include "tables.h"
extern afs_int32 swap_bit_pos_0();
extern afs_int32 rev_swap_bit_pos_0();
+extern void test_set PROTOTYPE((FILE *, char const *, int,
+ char const *, int));
+extern int swap_long_bytes_bit_number(int);
+extern int swap_bit_pos_0_to_ansi(int);
#define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
Index: des/make_keyperm.c
===================================================================
RCS file: /cvs/openafs/src/des/make_keyperm.c,v
retrieving revision 1.1
diff -u -r1.1 make_keyperm.c
--- des/make_keyperm.c 2000/11/04 02:26:31 1.1
+++ des/make_keyperm.c 2001/04/11 22:04:10
@@ -186,9 +186,10 @@
}
/* now output the resulting key permutation */
- fprintf(stream, " /* ks permutation iteration = %2d */",
+ fprintf(stream, "\n /* ks permutation iteration = %2d */",
iter);
for (i = 1; i <= 6; i++) {
+ if ( i == 1 ) fprintf(stream, "\n {");
fprintf(stream, "\n ");
for (j = 1; j <= 8; j++) {
/*
@@ -197,11 +198,16 @@
*/
fprintf(stream, "%d", ks_perm[iter][(i-1)*8+j]-1);
/* omit last comma */
- if ((j != 8) || (i != 6) || (iter != 16)) {
+ if ((j != 8) || (i != 6)) {
fprintf(stream,", ");
}
}
}
+ if ( iter != 16) {
+ fprintf(stream, "\n }, ");
+ } else {
+ fprintf(stream, "\n }");
+ }
}
fprintf(stream,"\n};\n");
}
Index: des/make_p_table.c
===================================================================
RCS file: /cvs/openafs/src/des/make_p_table.c,v
retrieving revision 1.1
diff -u -r1.1 make_p_table.c
--- des/make_p_table.c 2000/11/04 02:26:33 1.1
+++ des/make_p_table.c 2001/04/11 22:04:10
@@ -9,6 +9,8 @@
#include <mit-cpyright.h>
#include <stdio.h>
#include "des_internal.h"
+
+#define WANT_P_TABLE
#include "tables.h"
extern afs_uint32 swap_byte_bits();
@@ -25,7 +27,7 @@
#ifdef BIG
/* flip p into p_temp */
for (i = 0; i<32; i++)
- P_temp[P[rev_swap_bit_pos_0(i)]] = rev_swap_bit_pos_0(i);
+ P_temp[(int) P[rev_swap_bit_pos_0(i)]] = rev_swap_bit_pos_0(i);
/*
* now for each byte of input, figure out all possible combinations
@@ -47,11 +49,13 @@
fprintf(stream,
"\n\tstatic afs_uint32 const P_prime[4][256] = {\n\t");
for (i = 0; i < 4; i++) {
- fprintf(stream,"\n");
+ fprintf(stream,"\n{ ");
for (j = 0; j < 64; j++) {
fprintf(stream,"\n");
for (k = 0; k < 4; k++) {
fprintf(stream,"0x%08X",P_prime[i][j*4+k]);
+ if ((j == 63) && (k == 3))
+ fprintf(stream, "}");
if ((i == 3) && (j == 63) && (k == 3))
fprintf(stream,"\n};");
else
Index: des/make_s_table.c
===================================================================
RCS file: /cvs/openafs/src/des/make_s_table.c,v
retrieving revision 1.1
diff -u -r1.1 make_s_table.c
--- des/make_s_table.c 2000/11/04 02:26:33 1.1
+++ des/make_s_table.c 2001/04/11 22:04:10
@@ -8,6 +8,8 @@
#include <mit-cpyright.h>
#include <stdio.h>
#include "des_internal.h"
+
+#define WANT_S_TABLE
#include "tables.h"
extern afs_uint32 swap_bit_pos_0();
@@ -51,12 +53,16 @@
}
for (i = 0; i<=7; i++) {
- fprintf(stream,"\n");
+ fprintf(stream,"\n{ ");
k =0;
for (j = 0; j<= 3; j++) {
fprintf(stream,"\n");
for (m = 0; m <= 15; m++) {
fprintf(stream,"%2d",temp[i][k]);
+ if (k==63)
+ {
+ fprintf(stream,"\n}");
+ }
if ((k++ != 63) || (i !=7)) {
fprintf(stream,", ");
}
Index: des/misc.c
===================================================================
RCS file: /cvs/openafs/src/des/misc.c,v
retrieving revision 1.1
diff -u -r1.1 misc.c
--- des/misc.c 2000/11/04 02:26:34 1.1
+++ des/misc.c 2001/04/11 22:04:10
@@ -238,7 +238,7 @@
#endif /* LSBFIRST */
}
-swap_long_bytes_bit_number(x)
+int swap_long_bytes_bit_number(x)
afs_uint32 x;
{
/*
@@ -290,7 +290,7 @@
#include "AFS_component_version_number.c"
-main(argc, argv)
+int main(argc, argv)
int argc;
char *argv[];
{
Index: des/new_rnd_key.c
===================================================================
RCS file: /cvs/openafs/src/des/new_rnd_key.c,v
retrieving revision 1.3
diff -u -r1.3 new_rnd_key.c
--- des/new_rnd_key.c 2001/03/27 22:03:08 1.3
+++ des/new_rnd_key.c 2001/04/11 22:04:10
@@ -19,12 +19,15 @@
#ifdef AFS_PTHREAD_ENV
#include <pthread.h>
#endif
+#include <string.h>
#include <des.h>
#include "des_internal.h"
#include "stats.h"
extern void des_fixup_key_parity();
extern int des_is_weak_key();
+extern int des_ecb_encrypt();
+extern int des_key_sched();
void des_set_random_generator_seed();
static afs_int32 des_set_sequence_number(des_cblock new_sequence_number);
@@ -103,6 +106,7 @@
#include <afs/afsutil.h>
#else
#include <sys/time.h>
+#include <unistd.h>
#endif
void des_init_random_number_generator(key)
Index: des/pcbc_encrypt.c
===================================================================
RCS file: /cvs/openafs/src/des/pcbc_encrypt.c,v
retrieving revision 1.3
diff -u -r1.3 pcbc_encrypt.c
--- des/pcbc_encrypt.c 2001/03/27 22:03:08 1.3
+++ des/pcbc_encrypt.c 2001/04/11 22:04:10
@@ -30,6 +30,7 @@
extern int des_debug;
extern int des_debug_print();
+extern int des_ecb_encrypt();
/*
* pcbc_encrypt is an "error propagation chaining" encrypt operation
Index: des/read_pssword.c
===================================================================
RCS file: /cvs/openafs/src/des/read_pssword.c,v
retrieving revision 1.2
diff -u -r1.2 read_pssword.c
--- des/read_pssword.c 2001/03/27 07:07:41 1.2
+++ des/read_pssword.c 2001/04/11 22:04:10
@@ -35,6 +35,7 @@
#if defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
#include <signal.h>
+#include <unistd.h>
#endif
#ifdef AFS_HPUX_ENV
@@ -73,9 +74,11 @@
#endif
static sigtype sig_restore();
static push_signals(), pop_signals();
-int des_read_pw_string();
#endif
+int des_read_pw_string(char *, int, char *, int);
+int des_string_to_key(char *, des_cblock *);
+
/*** Routines ****************************************************** */
int
des_read_password(k,prompt,verify)
@@ -97,7 +100,9 @@
if (ok == 0)
des_string_to_key(key_string, k);
+#ifdef BSDUNIX
lose:
+#endif
bzero(key_string, sizeof (key_string));
return ok;
}
@@ -294,7 +299,9 @@
ok = 1;
}
+#ifdef BSDUNIX
lose:
+#endif
if (!ok)
bzero(s, maxa);
printf("\n");
Index: des/strng_to_key.c
===================================================================
RCS file: /cvs/openafs/src/des/strng_to_key.c,v
retrieving revision 1.2
diff -u -r1.2 strng_to_key.c
--- des/strng_to_key.c 2001/03/27 22:03:09 1.2
+++ des/strng_to_key.c 2001/04/11 22:04:10
@@ -22,6 +22,7 @@
#include <mit-cpyright.h>
#include <stdio.h>
+#include <string.h>
#include <afs/param.h>
#include <des.h>
#include "des_internal.h"
@@ -31,10 +32,13 @@
extern void des_fixup_key_parity();
extern afs_uint32 des_cbc_cksum();
+/* prototypes */
+int des_key_sched(register des_cblock *k, des_key_schedule schedule);
+
/*
* convert an arbitrary length string to a DES key
*/
-int
+void
des_string_to_key(str,key)
char *str;
register des_cblock *key;
Index: des/tables.h
===================================================================
RCS file: /cvs/openafs/src/des/tables.h,v
retrieving revision 1.1
diff -u -r1.1 tables.h
--- des/tables.h 2000/11/04 02:26:39 1.1
+++ des/tables.h 2001/04/11 22:04:10
@@ -12,6 +12,7 @@
/*
* Initial permutation, adjust to zero based subscript
*/
+#ifdef WANT_IP_TABLE
static char IP[] = {
58-1, 50-1, 42-1, 34-1, 26-1, 18-1, 10-1, 2-1,
60-1, 52-1, 44-1, 36-1, 28-1, 20-1, 12-1, 4-1,
@@ -22,10 +23,12 @@
61-1, 53-1, 45-1, 37-1, 29-1, 21-1, 13-1, 5-1,
63-1, 55-1, 47-1, 39-1, 31-1, 23-1, 15-1, 7-1,
};
+#endif
/*
* Final permutation, FP = IP^(-1) adjust to zero based subscript
*/
+#ifdef WANT_FP_TABLE
static char FP[] = {
40-1, 8-1, 48-1, 16-1, 56-1, 24-1, 64-1, 32-1,
39-1, 7-1, 47-1, 15-1, 55-1, 23-1, 63-1, 31-1,
@@ -36,8 +39,10 @@
34-1, 2-1, 42-1, 10-1, 50-1, 18-1, 58-1, 26-1,
33-1, 1-1, 41-1, 9-1, 49-1, 17-1, 57-1, 25-1,
};
+#endif
/* the E selection function, adjusted to zero based subscripts */
+#ifdef WANT_E_TABLE
static char E[] = {
32-1, 1-1, 2-1, 3-1, 4-1, 5-1,
4-1, 5-1, 6-1, 7-1, 8-1, 9-1,
@@ -48,8 +53,10 @@
24-1, 25-1, 26-1, 27-1, 28-1, 29-1,
28-1, 29-1, 30-1, 31-1, 32-1, 1-1,
};
+#endif
/* the P permutation, adjusted to zero based subscripts */
+#ifdef WANT_P_TABLE
static char P[] = {
16-1, 7-1, 20-1, 21-1,
29-1, 12-1, 28-1, 17-1,
@@ -60,46 +67,49 @@
19-1, 13-1, 30-1, 6-1,
22-1, 11-1, 4-1, 25-1,
};
+#endif
/* S tables, original form */
+#ifdef WANT_S_TABLE
static char S[8][64] = {
- 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
+{ 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
- 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
+ 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13, },
- 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
+{ 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
- 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
+ 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9, },
- 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
+{ 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
- 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
+ 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12, },
- 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
+{ 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
- 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
+ 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14, },
- 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
+{ 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
- 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
+ 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3, },
- 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
+{ 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
- 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
+ 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13, },
- 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
+{ 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
- 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
+ 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12, },
- 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
+{ 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
- 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
+ 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11 }
};
+#endif
Index: des/util.c
===================================================================
RCS file: /cvs/openafs/src/des/util.c,v
retrieving revision 1.1
diff -u -r1.1 util.c
--- des/util.c 2000/11/04 02:26:39 1.1
+++ des/util.c 2001/04/11 22:04:10
@@ -12,7 +12,7 @@
#include <sys/types.h>
#include <des.h>
-des_cblock_print_file(x, fp)
+int des_cblock_print_file(x, fp)
des_cblock *x;
FILE *fp;
{
@@ -26,6 +26,8 @@
fprintf(fp,", ");
}
fprintf(fp," }");
+
+ return(0);
}
#ifdef DEBUG
Index: des/weak_key.c
===================================================================
RCS file: /cvs/openafs/src/des/weak_key.c,v
retrieving revision 1.1
diff -u -r1.1 weak_key.c
--- des/weak_key.c 2000/11/04 02:26:40 1.1
+++ des/weak_key.c 2001/04/11 22:04:10
@@ -12,6 +12,7 @@
* Originally written 8/85 by Steve Miller, MIT Project Athena.
*/
+#include <string.h>
#include <des.h>
#include "des_internal.h"