From e7f718fc4794b8739716b6ef565b2e13ca1864e8 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Sat, 5 Oct 1996 00:49:37 +0000 Subject: [PATCH] merged in code from d93-jka for WIN32 git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@829 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/des/des.c | 3 +++ lib/des/des.h | 9 +++++++++ lib/des/des_locl.h | 7 +++++-- lib/des/destest.c | 4 ++++ lib/des/rand_key.c | 5 ++++- lib/des/read_pwd.c | 18 ++++++++++++++++-- lib/des/rnd_keys.c | 30 ++++++++++++++++++++++++++---- lib/des/speed.c | 4 +++- 8 files changed, 70 insertions(+), 10 deletions(-) diff --git a/lib/des/des.c b/lib/des/des.c index d060b664c..dc3d3b191 100644 --- a/lib/des/des.c +++ b/lib/des/des.c @@ -55,6 +55,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_IO_H +#include +#endif #include #include "version.h" diff --git a/lib/des/des.h b/lib/des/des.h index e0af5688e..7a9396a7b 100644 --- a/lib/des/des.h +++ b/lib/des/des.h @@ -119,6 +119,10 @@ typedef des_key_schedule bit_64; extern int des_check_key; /* defaults to false */ extern int des_rw_mode; /* defaults to DES_PCBC_MODE */ +#ifdef cplusplus +extern "C" { +#endif + /* The next line is used to disable full ANSI prototypes, if your * compiler has problems with the prototypes, make sure this line always * evaluates to true :-) */ @@ -255,4 +259,9 @@ void des_generate_random_block(); void des_rand_data(); #endif + +#ifdef cplusplus +} +#endif + #endif diff --git a/lib/des/des_locl.h b/lib/des/des_locl.h index 55c66f937..e0ee9cc25 100644 --- a/lib/des/des_locl.h +++ b/lib/des/des_locl.h @@ -72,9 +72,12 @@ #define HEADER_DES_LOCL_H #include #include -#ifndef MSDOS +#ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_IO_H +#include +#endif #include "des.h" /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING @@ -101,7 +104,7 @@ #undef NOPROTO #endif -#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) +#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) || defined(WIN32) #include #endif diff --git a/lib/des/destest.c b/lib/des/destest.c index 6526c02af..3123a0db4 100644 --- a/lib/des/destest.c +++ b/lib/des/destest.c @@ -55,6 +55,10 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_IO_H +#include +#endif + #include "des.h" /* tisk tisk - the test keys don't all have odd parity :-( */ diff --git a/lib/des/rand_key.c b/lib/des/rand_key.c index d7aa71540..7bc47c3cd 100644 --- a/lib/des/rand_key.c +++ b/lib/des/rand_key.c @@ -58,6 +58,8 @@ des_cblock key; seed=1; } +/* Old source */ +/* void des_random_key(ret) unsigned char *ret; { @@ -70,7 +72,7 @@ unsigned char *ret; DES_LONG t; int i; -#ifdef MSDOS +#if defined(MSDOS) || defined(WIN32) pid=1; #else if (!pid) pid=getpid(); @@ -105,3 +107,4 @@ unsigned char *ret; memset(ks,0,sizeof(ks)); t=0; } +*/ diff --git a/lib/des/read_pwd.c b/lib/des/read_pwd.c index 627c8404f..974bc1ca8 100644 --- a/lib/des/read_pwd.c +++ b/lib/des/read_pwd.c @@ -51,10 +51,17 @@ #include #include +#ifdef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ +#include "winlocl/passwd_dlg.h" +#endif /* WIN32 */ + /* There are 5 types of terminal interface supported, * TERMIO, TERMIOS, VMS, MSDOS and SGTTY */ +/* Now there are also support for Windows95/NT inteface + * d93-jka 960530 + */ #if defined(sgi) || defined(__sgi) #define TERMIOS #undef TERMIO @@ -65,7 +72,7 @@ #define TERMIO #endif -#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) +#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(WIN32) #define SGTTY #endif @@ -93,7 +100,7 @@ #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) #endif -#if !defined(_LIBC) && !defined(MSDOS) +#if !defined(_LIBC) && !defined(MSDOS) && !defined(WIN32) #include #endif @@ -205,6 +212,9 @@ int size; char *prompt; int verify; { +#ifdef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ + return pwd_dialog(buf, size); +#else /* !WIN32 */ #ifdef VMS struct IOSB iosb; $DESCRIPTOR(terminal,"TT"); @@ -321,8 +331,10 @@ error: status = SYS$DASSGN(channel); #endif return(!ok); +#endif /* !WIN32 */ } +#ifndef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ static void pushsig() { int i; @@ -348,6 +360,8 @@ int i; #endif } +#endif /* !WIN32 */ + #ifdef MSDOS static int noecho_fgets(buf,size,tty) char *buf; diff --git a/lib/des/rnd_keys.c b/lib/des/rnd_keys.c index 0c24788f4..3ad25bb4f 100644 --- a/lib/des/rnd_keys.c +++ b/lib/des/rnd_keys.c @@ -6,10 +6,18 @@ RCSID("$Id$"); #endif #include +#include #include #include + +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_IO_H +#include +#endif + #include #include #include @@ -102,6 +110,8 @@ static volatile unsigned char *gdata; /* Global data */ static volatile int igdata; /* Index into global data */ static int gsize; +#ifndef WIN32 /* Visual C++ 4.0 (Windows95/NT) */ + static RETSIGTYPE sigALRM(int sig) @@ -112,9 +122,14 @@ sigALRM(int sig) SIGRETURN(0); } -#ifdef HAVE_RANDOM +#endif -/* XXX this is a quick hack, should be fixed */ +#if !defined(HAVE_RANDOM) && defined(HAVE_RAND) +#define srandom srand +#define random rand +#endif + +#ifdef HAVE_RANDOM void des_not_rand_data(unsigned char *data, int size) @@ -129,6 +144,8 @@ des_not_rand_data(unsigned char *data, int size) #endif +#ifndef WIN32 + #ifndef HAVE_SETITIMER void pacemaker(struct timeval *tv) { @@ -216,6 +233,13 @@ des_rand_data(unsigned char *data, int size) #endif sigaction(SIGALRM, &osa, 0); } +#else +void +des_rand_data(unsigned char *p, int s) +{ + return des_not_rand_data (p, s); +} +#endif void des_generate_random_block(des_cblock *block) @@ -223,7 +247,6 @@ des_generate_random_block(des_cblock *block) des_rand_data((unsigned char *)block, sizeof(*block)); } -#if 0 /* * Generate a "random" DES key. */ @@ -255,7 +278,6 @@ des_mem_rand8(unsigned char *data) { return 1; } -#endif /* * In case the generator does not get initialized use this as fallback. diff --git a/lib/des/speed.c b/lib/des/speed.c index 1e5774c80..258fab2a8 100644 --- a/lib/des/speed.c +++ b/lib/des/speed.c @@ -52,7 +52,7 @@ #include #endif -#ifndef MSDOS +#if !defined(MSDOS) && !defined(WIN32) #define TIMES #endif @@ -178,6 +178,7 @@ int s; #endif } +/* int main(argc,argv) int argc; char **argv; @@ -313,3 +314,4 @@ char **argv; return(0); #endif } +*/