From 0dd0b4ca77a0dbdaf3970f033a085bd440302b55 Mon Sep 17 00:00:00 2001 From: "Adel I. Mirzazhanov" Date: Thu, 7 Aug 2003 22:40:39 +0700 Subject: [PATCH] APG v2.3.0b --- CHANGES | 7 + Makefile | 125 ++++++++------ README | 28 +++- THANKS | 1 + TODO | 3 - apg.c | 81 +++++++-- apgbfm.c | 2 +- bloom.h | 2 +- convert.c | 3 +- doc/man/apg.1 | 81 ++++----- doc/man/apgd.8 | 74 +++++---- doc/man/wapg.txt | 388 ++++++++++++++++++++++---------------------- doc/man/wapgbfm.txt | 234 +++++++++++++------------- pronpass.c | 2 +- randpass.c | 2 +- restrict.c | 32 ++++ restrict.h | 8 + rnd.c | 11 +- 18 files changed, 626 insertions(+), 458 deletions(-) diff --git a/CHANGES b/CHANGES index 89776be..ed7d185 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +apg-2.3.0b + Added support for cracklib + Improved Makefile structure + +apg-2.2.1 + Changed manpages of apg and apgd. + apg-2.2.0 Added polish translation for APG PHP frontend. Added option -p (see apg(1) apgd(8)). diff --git a/Makefile b/Makefile index c8dab03..3555f76 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,62 @@ +################################################################## +# Directories +# Install dirs +INSTALL_PREFIX = /usr/local + +# Full default path is /usr/local/bin +APG_BIN_DIR = /bin + +# Full default path is /usr/local/man/man1 +APG_MAN_DIR = /man/man1 + +# Full default path is /usr/local/sbin +APGD_BIN_DIR = /sbin + +# Full default path is /usr/local/man/man8 +APGD_MAN_DIR = /man/man8 + +# You should not edit 2 lines below +APGBFM_CLIBS = -lm +APG_CLIBS = -lm + +################################################################## +# Support for crypted passwords +# If you do not want to use crypted passwords output then you must +# comment the folowing 2 line. +# +# NOTE#1: You should comment the line 'APG_CLIBS += -lcrypt' for QNX +# RTP 6.1.0, OpenBSD 2.8 and for WIN32. +# +# NOTE#2: If ld (linker) could not find `crypt' library try to +# replace line +# 'APG_CLIBS += -lcrypt' +# with line +# 'APG_CLIBS += -lcrypto' +# This works on MacOS X +# +STANDALONE_OPTIONS += -DAPG_USE_CRYPT +APG_CLIBS += -lcrypt + +################################################################## +# Support for cracklib +# NOTE: Cracklib can be found at +# http://www.crypticide.org/users/alecm/ +# If you want to use cracklib for password quality check then you +# must uncomment the folowing 4 lines (you must not do this for WIN32) +# +#CRACKLIB_DICTPATH = "/usr/local/lib/pw_dict" +#STANDALONE_OPTIONS += -DAPG_USE_CRACKLIB '-DCRACKLIB_DICTPATH=${CRACKLIB_DICTPATH}' -I/usr/local/include -L/usr/local/lib +#CLISERV_OPTIONS += -DAPG_USE_CRACKLIB '-DCRACKLIB_DICTPATH=${CRACKLIB_DICTPATH}' -I/usr/local/include -L/usr/local/lib +#APG_CLIBS += -lcrack + +################################################################## +# Support for ANSI X9.17/SHA1 PRNG +# If you want to use SHA1 for random number genetation then you +# must uncomment the folowing 2 lines +# +#STANDALONE_OPTIONS += -DAPG_USE_SHA +#CLISERV_OPTIONS += -DAPG_USE_SHA + ################################################################## # You can modify CC variable if you have compiler other than GCC # But the code was designed and tested with GCC @@ -6,44 +65,7 @@ CC = gcc ################################################################## # Compilation flags # You should comment the line below for AIX+native cc -FLAGS = -Wall - -################################################################## -# Libraries -# -# You should comment the line below ('LIBS= -lcrypt')for QNX RTP -# 6.1.0, OpenBSD 2.8 and above, WIN32 (+MinGW) -LIBS = -lcrypt -LIBM = -lm -# Use lines below for cygwin -# LIBS = -# LIBM = - -################################################################## -# Support for crypted passwords -# -# DO NOT EDIT THE LINE BELOW !!! -CRYPTED_PASS = APG_DONOTUSE_CRYPT -# Coment this if you do not want to use crypted passwords output -# or trying to build programm for win32 -CRYPTED_PASS = APG_USE_CRYPT - -################################################################## -# Support for ANSI X9.17/SHA1 PRNG -# -# DO NOT EDIT THE LINE BELOW !!! -USE_SHA = APG_USE_SHA -# Coment this if you want to use PRNG X9.17 with SHA-1 -USE_SHA = APG_DONOTUSE_SHA - -################################################################## -# Directories -# Install dirs -INSTALL_PREFIX = /usr/local -APG_BIN_DIR = /bin -APG_MAN_DIR = /man/man1 -APGD_BIN_DIR = /sbin -APGD_MAN_DIR = /man/man8 +CFLAGS = -Wall #################################################################### # If you plan to install APG daemon you should look at lines below # @@ -59,21 +81,32 @@ APGD_MAN_DIR = /man/man8 # Linux # # Uncoment line below for LINUX -#CS_LIBS = -lnsl +#APG_CS_CLIBS += -lnsl #################################################################### # Solaris # # Uncoment line below for Solaris -#CS_LIBS = -lnsl -lsocket +#APG_CS_CLIBS += -lnsl -lsocket #################################################################### # QNX RTP 6.1.0 # # Uncoment line below for QNX RTP 6.1.0 -#CS_LIBS = -lsocket +#APG_CS_CLIBS += -lsocket + +#################################################################### +#################################################################### +# THE FOLOWING IS USED BY DEVELOPER AND YOU PROBABLY DO NOT NEED TO +# MODIFY THIS LINE +# STANDALONE_OPTIONS += -DAPG_DEBUG + +#################################################################### +# ======= YOU DO NOT NEED TO MODIFY ANYTHING BELOW THIS LINE ======= +#################################################################### + +APG_CS_CLIBS += ${APG_CLIBS} -# ====== YOU DO NOT NEED TO MODIFY ANYTHING BELOW THIS LINE ====== # Find group ID for user root FIND_GROUP = `grep '^root:' /etc/passwd | awk -F: '{ print $$4 }'` @@ -89,20 +122,20 @@ OBJECTS = rnd.o ./cast/cast.o pronpass.o randpass.o restrict.o apg.o errors.o standalone: apg apgbfm -all: cliserv standalone +all: standalone cliserv cliserv: apgd apgbfm cygwin: standalone apg: - ${CC} ${FLAGS} -D${CRYPTED_PASS} -D${USE_SHA} -o ${PROGNAME} ${SOURCES} ${LIBS} ${LIBM} + ${CC} ${CFLAGS} ${STANDALONE_OPTIONS} -o ${PROGNAME} ${SOURCES} ${APG_CLIBS} apgd: - ${CC} ${FLAGS} -DCLISERV -D${USE_SHA} -o ${CS_PROGNAME} ${SOURCES} ${CS_LIBS} ${LIBM} + ${CC} ${CFLAGS} -DCLISERV ${CLISERV_OPTIONS} -o ${CS_PROGNAME} ${SOURCES} ${APG_CS_CLIBS} apgbfm: - ${CC} ${FLAGS} -DAPGBFM -o ${BFM_PROGNAME} ${BFM_SOURCES} ${LIBM} + ${CC} ${FLAGS} -DAPGBFM -o ${BFM_PROGNAME} ${BFM_SOURCES} ${APGBFM_CLIBS} strip: strip ${PROGNAME} diff --git a/README b/README index 5e644c0..2564092 100644 --- a/README +++ b/README @@ -1,14 +1,30 @@ -APG v2.2.0 was tested and found working on: +APG v2.1.0 was tested and found working on: - i386 FreeBSD 5.0-RELEASE + i386 FreeBSD 4.6-RELEASE Intel Solaris 8 gcc-2.95.2 - QNX PRP 6.0 + SPARC Solaris 8 gcc-2.95.2 RedHat Linux 7.2 - Mandrake Linux 9.1 - Win 2000 Pro + +APG v1.2.13 was tested and found working on: + + i386 FreeBSD 4.0-RELEASE + NetBSD (reported by Tomasz Luchowski ) + OpenBSD (reported by Rick VanNorman ) + i386 Linux-Mandrake 6.0 + i386 Linux-Redhat 7.0 + i386 Linux-Mandrake 7.2 (reported by Andrew J. Caird ) + Intel Solaris 8 gcc-2.95.2 + SPARC Solaris 8 gcc-2.95.2 + Intel Windows 2000+CYGWIN v1.1.4 + HP-UX 10.20 HP ANSI C Compilier (reported by Alexander J Pierce ) + HP-UX 11.00 HP ANSI C Compilier (reported by Alexander J Pierce ) + HP-UX 11.00 gcc-2.95.2 (reported by Andrew J. Caird ) + IRIX 6.5.8 gcc-2.95.2 (reported by Andrew J. Caird ) + AIX 4.3.3+native cc (reported by Philip Le Riche ) + AIX 4.3.3+gcc (reported by Philip Le Riche ) NOTE: -This release (APG v2.2.0) is NOT compatible with TkAPG (Tcl/Tk frontend for APG) +This release (APG v2.1.0b1) is NOT yet compatible with TkAPG (Tcl/Tk frontend for APG) Any compatibility reports are welcome diff --git a/THANKS b/THANKS index 4d471fa..d350508 100644 --- a/THANKS +++ b/THANKS @@ -28,3 +28,4 @@ Bartosz Sobolewski - Worthy James Mancini Arno Wilhelm Michael Matthews +K.-M. Hansche diff --git a/TODO b/TODO index 72f31b2..996eb8b 100644 --- a/TODO +++ b/TODO @@ -5,9 +5,6 @@ Priority Hi: * Fix some code style or other errors if any. -* Make some kind of configuration file to avoid command - line parameter typing. - Priority Medium: * Include support for some other random number generation diff --git a/apg.c b/apg.c index 1e7ab0d..9a00168 100644 --- a/apg.c +++ b/apg.c @@ -39,9 +39,9 @@ #include #ifndef APG_USE_SHA -#define APG_VERSION "2.2.0 (PRNG: X9.17/CAST)" +#define APG_VERSION "2.3.0b (PRNG: X9.17/CAST)" #else /* APG_USE_SHA */ -#define APG_VERSION "2.2.0 (PRNG: X9.17/SHA-1)" +#define APG_VERSION "2.3.0b (PRNG: X9.17/SHA-1)" #endif /* APG_USE_SHA */ #ifdef __NetBSD__ @@ -87,6 +87,24 @@ #include "getopt.h" #include "convert.h" +#if !defined(CLISERV) +#if !defined(APG_USE_CRYPT) && !defined(APG_USE_CRACKLIB) +#define APG_PROGRAMM_OPTIONS "M:E:a:r:b:p:sdc:n:m:x:htvlq" +#elif defined(APG_USE_CRYPT) && !defined(APG_USE_CRACKLIB) +#define APG_PROGRAMM_OPTIONS "M:E:a:r:b:p:sdc:n:m:x:htvylq" +#elif !defined(APG_USE_CRYPT) && defined(APG_USE_CRACKLIB) +#define APG_PROGRAMM_OPTIONS "M:E:a:r:b:p:sdc:n:m:x:htvklq" +#elif defined(APG_USE_CRYPT) && defined(APG_USE_CRACKLIB) +#define APG_PROGRAMM_OPTIONS "M:E:a:r:b:p:sdc:n:m:x:htvyklq" +#endif /* CRYPT,CRACKLIB */ +#else /* CLISERV */ +#if defined(APG_USE_CRACKLIB) +#define APG_PROGRAMM_OPTIONS "M:E:a:r:b:p:n:m:x:vkt" +#else /* CRACKLIB */ +#define APG_PROGRAMM_OPTIONS "M:E:a:r:b:p:n:m:x:vt" +#endif /* CRACKLIB */ +#endif /* CLUSERV */ + struct pass_m { unsigned int pass; /* password generation mode */ unsigned int filter; /* password generation mode */ @@ -139,6 +157,9 @@ main (int argc, char *argv[]) UINT32 user_defined_seed = 0L; /* user defined random seed */ int user_defined_seed_present = FALSE; /* user defined random seed flag */ char *str_mode; /* string mode pointer */ +#ifdef APG_USE_CRACKLIB + unsigned int cracklib_restrict_present = FALSE; +#endif /* APG_USE_CRACKLIB*/ #ifndef CLISERV char *com_line_seq; char *spell_pass_string; @@ -148,6 +169,7 @@ main (int argc, char *argv[]) char *crypt_string; unsigned int show_crypt_text = FALSE; /* display crypt(3)'d text flag */ #endif /* APG_USE_CRYPT */ + #endif /* CLISERV */ #ifdef CLISERV #if defined(sgi) || defined(__APPLE__) || defined(__QNX__) /* Thanks to Andrew J. Caird */ @@ -175,18 +197,14 @@ main (int argc, char *argv[]) syslog (LOG_INFO, "password generation request from %s.%d\n", peer_ip, htons(cliaddr->sin_port)); #endif /* CLISERV */ +#if defined(APG_DEBUG) + fprintf (stdout,"APG_PROGRAMM_OPTIONS--> %s\n\n", APG_PROGRAMM_OPTIONS); + fflush (stdout); +#endif /* ** Analize options */ -#ifndef CLISERV -#ifdef APG_USE_CRYPT - while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:sdc:n:m:x:htvylq")) != -1) -#else /* APG_USE_CRYPT */ - while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:sdc:n:m:x:htvlq")) != -1) -#endif /* APG_USE_CRYPT */ -#else /* CLISERV */ - while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:n:m:x:vt")) != -1) -#endif /* CLISERV */ + while ((option = apg_getopt (argc, argv, APG_PROGRAMM_OPTIONS)) != -1) { switch (option) { @@ -225,6 +243,14 @@ main (int argc, char *argv[]) min_substr_len = atoi (apg_optarg); paranoid_bloom_restrict_present = TRUE; break; +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) +#if defined(APG_USE_CRACKLIB) + case 'k': /* cracklib password check */ + restrictions_present = TRUE; + cracklib_restrict_present = TRUE; + break; +#endif /* CRACKLIB */ +#endif /* WIN32 */ #ifndef CLISERV case 'l': spell_present = TRUE; @@ -353,10 +379,18 @@ main (int argc, char *argv[]) restrict_res = paranoid_bloom_check_pass(pass_string, restrictions_file, min_substr_len); } } +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) +#if defined(APG_USE_CRACKLIB) + /* Cracklib check */ + if (restrict_res == 0) + if(cracklib_restrict_present == TRUE) + restrict_res = cracklib_check_pass (pass_string, CRACKLIB_DICTPATH); +#endif /* APG_USE_CRACKLIB */ +#endif /* WIN32 */ /* Dictionary check */ - if (restrict_res == 0) - if (plain_restrictions_present == TRUE) - restrict_res = check_pass(pass_string, plain_restrictions_file); + if (restrict_res == 0) + if (plain_restrictions_present == TRUE) + restrict_res = check_pass(pass_string, plain_restrictions_file); switch (restrict_res) @@ -464,10 +498,18 @@ main (int argc, char *argv[]) restrict_res = paranoid_bloom_check_pass(pass_string, restrictions_file, min_substr_len); } } +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) +#if defined(APG_USE_CRACKLIB) + /* Cracklib check */ + if (restrict_res == 0) + if(cracklib_restrict_present == TRUE) + restrict_res = cracklib_check_pass (pass_string, CRACKLIB_DICTPATH); +#endif /* APG_USE_CRACKLIB */ +#endif /* WIN32 */ /* Dictionary check */ - if (restrict_res == 0) - if (plain_restrictions_present == TRUE) - restrict_res = check_pass(pass_string, plain_restrictions_file); + if (restrict_res == 0) + if (plain_restrictions_present == TRUE) + restrict_res = check_pass(pass_string, plain_restrictions_file); switch (restrict_res) @@ -627,6 +669,11 @@ print_help (void) printf ("-b filter_file apply bloom filter check against filter_file\n"); printf (" (filter_file should be created with apgbfm(1) utility)\n"); printf ("-p substr_len paranoid modifier for bloom filter check\n"); +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) +#ifdef APG_USE_CRACKLIB + printf ("-k apply cracklib ckeck\n"); +#endif /* APG_USE_CRYPT */ +#endif /* WIN32 */ printf ("-a algorithm choose algorithm\n"); printf (" 1 - random password generation according to\n"); printf (" password modes\n"); diff --git a/apgbfm.c b/apgbfm.c index 89b0a62..1993fe8 100644 --- a/apgbfm.c +++ b/apgbfm.c @@ -35,7 +35,7 @@ #include "getopt.h" -#define VERSION "2.2.0" +#define VERSION "2.3.0b" #define FOUND "FOUND" diff --git a/bloom.h b/bloom.h index 1480645..0eaaaab 100644 --- a/bloom.h +++ b/bloom.h @@ -40,7 +40,7 @@ #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include -#endif +#endif /* WIN32 */ #include #include "sha/sha.h" diff --git a/convert.c b/convert.c index 9b4ef85..d780987 100644 --- a/convert.c +++ b/convert.c @@ -31,7 +31,8 @@ #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include -#endif +#endif /* WIN32 */ + #ifndef APGBFM # include "errs.h" # include "randpass.h" diff --git a/doc/man/apg.1 b/doc/man/apg.1 index 55a8470..154b928 100644 --- a/doc/man/apg.1 +++ b/doc/man/apg.1 @@ -2,7 +2,7 @@ .\" Licensed under BSD-like License. .\" Created by Adel I. Mirzazhanov .\" -.TH APG 1 "2003 Jun 19" "Automated Password Generator" "User Manual" +.TH APG 1 "2003 Aug 04" "Automated Password Generator" "User Manual" .SH NAME apg \- generates several random passwords @@ -12,7 +12,8 @@ apg [\fB-a algorithm\fP] [\fB-M mode\fP] [\fB-E char_string\fP] [\fB-n num_of_pass\fP] [\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP] [\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP] [\fB-p min_substr_len\fP] -[\fB-s\fP] [\fB-c cl_seed\fP] [\fB-d\fP] [\fB-y\fP] [\fB-l\fP] [\fB-t\fP] [\fB-q\fP] [\fB-h\fP] [\fB-v\fP] +[\fB-s\fP] [\fB-c cl_seed\fP] [\fB-d\fP] [\fB-y\fP] [\fB-l\fP] [\fB-t\fP] +[\fB-k\fP] [\fB-q\fP] [\fB-h\fP] [\fB-v\fP] .PP .SH DESCRIPTION .B apg @@ -73,13 +74,40 @@ name of Bloom filter file. In that dictionary you may place words common words, etc. You even can use one of the dictionaries that come with .I dictionary password crackers. Bloom filter file should be created with \fBapgbfm\fP(1) utility included -in apg distribution. These checks are case sensitive. For example, if you want -to reject word 'root', you should insert in \fIdictfile\fP words: root, Root, -RoOt, ... , ROOT. It is not the easiest way to check password quality, but -it is the most powerful way. In future releases I plan to implement some other +in apg distribution. In future releases I plan to implement some other techniques to check passwords (like pattern check) just to make life easier. .sp .SH "OPTIONS" +.SS "Password generation modes options" +.TP +.B -a algorithm +use +.B algorithm +for password generation. +.RS +.B 0 +- (default) pronounceable password generation +.br +.B 1 +- random character password generation +.RE +.TP +.B -n num_of_pass +generate +.B num_of_pass +number of passwords. Default is 6. +.TP +.B -m min_pass_len +generate password with minimum length +.B min_pass_len. +If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. +Default minimum password length is 8. +.TP +.B -x max_pass_len +generate password with maximum length +.B max_pass_len. +If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. +Default maximum password length is 10. .TP .B -M mode Use symbolsets specified with \fBmode\fP for password generation. @@ -130,18 +158,6 @@ Usage of L, M, N, C will slow down password generation process. \fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP .RE .TP -.B -a algorithm -use -.B algorithm -for password generation. -.RS -.B 0 -- (default) pronounceable password generation -.br -.B 1 -- random character password generation -.RE -.TP .B -E char_string exclude characters in \fBchar_string\fP from password generation process (in pronounceable password generation mode you can not exclude small letters). To include special symbols that @@ -151,7 +167,7 @@ the backslashed versions. .PP .B Examples: .PP -Command \fBapg -a 1 -M n -n 3 -m 8 -e 23456789\fP will generate a set of passwords that +Command \fBapg -a 1 -M n -n 3 -m 8 -E 23456789\fP will generate a set of passwords that will look like this .br \fB10100110\fP @@ -161,7 +177,7 @@ will look like this \fB11011101\fP .br .PP -Command \fBapg -a 1 -M nc -n 3 -m 26 -e GHIJKLMNOPQRSTUVWXYZ\fP will generate a set of passwords +Command \fBapg -a 1 -M nc -n 3 -m 26 -E GHIJKLMNOPQRSTUVWXYZ\fP will generate a set of passwords that will look like this .br \fB16A1653CD4DE5E7BD9584A3476\fP @@ -171,6 +187,11 @@ that will look like this \fB8C8DF37CD792D36D056BBD5002\fP .br .RE +.SS "Password quality control options" +.TP +.B -k +check every generated password using \fBcracklib\fP. To use this ability you must +enable cracklib support during programm building. .TP .B -r \fIdictfile\fP check generated passwords for their appearance in @@ -188,6 +209,7 @@ be found in the \fIfilter_file\fP then generated password would be rejected and apg(1) will generate another one. \fBmin_substr_len\fP specifies minimum substring length to check. This option is active only if \fB-b\fP option is defined. +.SS "Pseudo random number generator options" .TP .B -s ask user for random sequence for password generation @@ -197,28 +219,13 @@ use .B cl_seed as a random seed for password generation. I use it when i have to generate passwords in a shell script. +.SS "Password output options" +.br .TP .B -d do NOT use any delimiters between generated passwords. I use it when i have to generate passwords in a shell script. .TP -.B -n num_of_pass -generate -.B num_of_pass -number of passwords. Default is 6. -.TP -.B -m min_pass_len -generate password with minimum length -.B min_pass_len. -If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. -Default minimum password length is 8. -.TP -.B -x max_pass_len -generate password with maximum length -.B max_pass_len. -If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. -Default maximum password length is 10. -.TP .B -y print generated passwords and crypted passwords (see man \fBcrypt\fP(3)) .TP diff --git a/doc/man/apgd.8 b/doc/man/apgd.8 index bfaa284..229c7f5 100644 --- a/doc/man/apgd.8 +++ b/doc/man/apgd.8 @@ -2,7 +2,7 @@ .\" Licensed under BSD-like License. .\" Created by Adel I. Mirzazhanov .\" -.TH APGD 8 "2003 Jun 19" "Automated Password Generator" "User Manual" +.TH APGD 8 "2003 Aug 4" "Automated Password Generator" "User Manual" .SH NAME apgd \- server that generates several random passwords @@ -11,7 +11,7 @@ apgd .B apgd [\fB-a algorithm\fP] [\fB-M mode\fP] [\fB-E char_string\fP] [\fB-n num_of_pass\fP] [\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP] -[\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP] [\fB-p min_substr_len\fP] +[\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP] [\fB-p min_substr_len\fP] [\fB-k\fP] [\fB-t\fP] [\fB-l\fP] .PP .SH DESCRIPTION @@ -88,10 +88,7 @@ name of Bloom filter file. In that dictionary you may place words common words, etc. You even can use one of the dictionaries that come with .I dictionary password crackers. Bloom filter file should be created with \fBapgbfm\fP(1) utility included -in apg distribution. These checks are case sensitive. For example, if you -want to reject word 'root', you should insert in \fIdictfile\fP words: root, -Root, RoOt, ... , ROOT. It is not the easiest way to check password quality, -but it is the most powerful way. In future releases I plan to implement some +in apg distribution. In future releases I plan to implement some other techniques to check passwords just to make life easier. .PP .B apgd @@ -117,6 +114,36 @@ for internal debug information See the \fBsyslogd\fP(8) and \fBsyslog.conf\fP(5) man pages for information on how to configure your syslog daemon. .sp .SH "OPTIONS" +.SS "Password generation modes options" +.TP +.B -a algorithm +use +.B algorithm +for password generation. +.RS +.B 0 +- (default) pronounceable password generation +.br +.B 1 +- random character password generation +.RE +.TP +.B -n num_of_pass +generate +.B num_of_pass +number of passwords. Default is 6. +.TP +.B -m min_pass_len +generate password with minimum length +.B min_pass_len. +If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. +Default minimum password length is 8. +.TP +.B -x max_pass_len +generate password with maximum length +.B max_pass_len +If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. +Default maximum password length is 10. .TP .B -M mode Use symbolsets specified with \fBmode\fP for password generation. @@ -167,18 +194,6 @@ Usage of L, M, N, C will slow down password generation process. \fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP .RE .TP -.B -a algorithm -use -.B algorithm -for password generation. -.RS -.B 0 -- (default) pronounceable password generation -.br -.B 1 -- random character password generation -.RE -.TP .B -E char_string exclude characters in \fBchar_string\fP from password generation process (in pronounceable password generation mode you can not exclude small letters). To include special symbols @@ -208,6 +223,11 @@ that will look like this \fB8C8DF37CD792D36D056BBD5002\fP .br .RE +.SS "Password quality control options" +.TP +.B -k +check every generated password using \fBcracklib\fP. To use this ability you must +enable cracklib support during programm building. .TP .B -r \fIdictfile\fP check generated passwords for their appearance in @@ -225,23 +245,7 @@ be found in the \fIfilter_file\fP then generated password would be rejected and apg(1) will generate another one. \fBmin_substr_len\fP is specifies minimum substring length to check. This option is active only if \fB-b\fP option is defined. -.TP -.B -n num_of_pass -generate -.B num_of_pass -number of passwords. Default is 6. -.TP -.B -m min_pass_len -generate password with minimum length -.B min_pass_len. -If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. -Default minimum password length is 8. -.TP -.B -x max_pass_len -generate password with maximum length -.B max_pass_len -If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. -Default maximum password length is 10. +.SS "Password output options" .TP .B -l spell genetated passwords. Useful when you want to read generated password by telephone. diff --git a/doc/man/wapg.txt b/doc/man/wapg.txt index 0015e1d..6e5521d 100644 --- a/doc/man/wapg.txt +++ b/doc/man/wapg.txt @@ -1,192 +1,196 @@ -WAPG(1) User Manual WAPG(1) - - - -NAME - WAPG - generates several random passwords - - -SYNOPSIS - WAPG [-a algorithm] [-M mode] [-E char_string] [-n num_of_pass] [-m - min_pass_len] [-x max_pass_len] [-r dictfile] [-b filter_file] [-p - min_substr_len] [-c cl_seed] [-d] [-l] [-t] [-q] [-h] [-v] - - -DESCRIPTION - WAPG generates several random passwords. It uses several password gener- - ation algorithms (currently two) and a built-in pseudo random number - generator. - - Default algorithm is pronounceable password generation algorithm - designed by Morrie Gasser and described in A Random Word Generator For - Pronounceable Passwords National Technical Information Service (NTIS) - AD-A-017676. The original paper is very old and had never been put - online, so I have to use NIST implementation described in FIPS-181. - - Another algorithm is simple random character generation algorithm, but - it uses four user-defined symbol sets to produce random password. It - means that user can choose type of symbols that should appear in pass- - word. Symbol sets are: numeric symbol set (0,...,9) , capital letters - symbol set (A,...,Z) , small letters symbol set (a,...,z) and special - symbols symbol set (#,@,!,...). - - Built-in pseudo random number generator is an implementation of algo- - rithm described in Appendix C of ANSI X9.17 or RFC1750 with exception - that it uses CAST or SHA-1 instead of Triple DES. It uses local time - with precision of microseconds (see gettimeofday(2)) and /dev/random - (if available) to produce initial random seed. - - WAPG also have the ability to check generated password quality using - dictionary. You can use this ability if you specify command-line - options -r dictfile or -b filtername where dictfile is the dictionary - file name and filtername is the name of Bloom filter file. In that dic- - tionary you may place words (one per line) that should not appear as - generated passwords. For example: user names, common words, etc. You - even can use one of the dictionaries that come with dictionary password - crackers. Bloom filter file should be created with WAPGbfm(1) utility - included in WAPG distribution. These checks are case sensitive. For - example, if you want to reject word 'root', you should insert in dict- - file words: root, Root, RoOt, ... , ROOT. It is not the easiest way to - check password quality, but it is the most powerful way. In future - releases I plan to implement some other techniques to check passwords - (like pattern check) just to make life easier. - - -OPTIONS - -M mode - Use symbolsets specified with mode for password generation. - mode is a text string consisting of characters S, s, N, n, C, c, - L, l. Where: - - S generator must use special symbol set for every generated - password. - - s generator should use special symbol set for password gen- - eration. - - N generator must use numeral symbol set for every generated - password. - - n generator should use numeral symbol set for password gen- - eration. - - C generator must use capital symbol set for every generated - password. - - c generator should use capital symbol set for password gen- - eration. - - L generator must use small letters symbol set for every - generated password (always present if pronounceable pass- - word generation algorithm is used). - - l generator should use small letters symbol set for pass- - word generation. - - R,r not supported any more. Use -E char_string option - instead. - mode can not be more than 4 characters in length. - - Note: - Usage of L, M, N, C will slow down password generation process. - - Examples: - -M sncl or -M SNCL or -M Cn - - -a algorithm - use algorithm for password generation. - 0 - (default) pronounceable password generation - 1 - random character password generation - - -E char_string - exclude characters in char_string from password generation pro- - cess (in pronounceable password generation mode you can not - exclude small letters). To include special symbols that can be - recognized by shell (apostrophe, quotes, dollar sign, etc.) in - char_string use the backslashed versions. - - Examples: - - Command WAPG -a 1 -M n -n 3 -m 8 -e 23456789 will generate a set - of passwords that will look like this - 10100110 - 01111000 - 11011101 - - Command WAPG -a 1 -M nc -n 3 -m 26 -e GHIJKLMNOPQRSTUVWXYZ will - generate a set of passwords that will look like this - 16A1653CD4DE5E7BD9584A3476 - C8F78E06944AFD57FB9CB882BC - 8C8DF37CD792D36D056BBD5002 - - -r dictfile - check generated passwords for their appearance in dictfile - - -b filter_file - check generated passwords for their appearance in filter_file. - filter_file should be created with WAPGBFM utility. - - -p min_substr_len - this option tells WAPG to check every substring of the gener- - ated password for appearance in filter_file. If any of such sub- - strings would be found in the filter_file then generated - password would be rejected and WAPG will generate another one. - min_substr_len specifies minimum substring length to check. - This option is active only if -b option is defined. - - -c cl_seed - use cl_seed as a random seed for password generation. I use it - when i have to generate passwords in a shell script. - - -d do NOT use any delimiters between generated passwords. I use it - when i have to generate passwords in a shell script. - - -n num_of_pass - generate num_of_pass number of passwords. Default is 6. - - -m min_pass_len - generate password with minimum length min_pass_len. If - min_pass_len > max_pass_len then max_pass_len = min_pass_len. - Default minimum password length is 8. - - -x max_pass_len - generate password with maximum length max_pass_len. If - min_pass_len > max_pass_len then max_pass_len = min_pass_len. - Default maximum password length is 10. - - -q quiet mode (do not print warnings) - - -l spell genetated passwords. Useful when you want to read gener- - ated password by telephone. - WARNING: Think twice before read your password by phone. - - -t print pronunciation for generated pronounceable password - - -h print help information and exit - - -v print version information and exit - -DEFAULT OPTIONS - WAPG -a 0 -M sncl -n 6 -x 10 -m 8 (new style) - -EXIT CODE - On successful completion of its task, WAPG will complete with exit code - 0. An exit code of -1 indicates an error occurred. Textual errors are - written to the standard error stream. - -FILES - None. - -BUGS - None. If you've found one, please send bug description to the author. - -SEE ALSO - WAPGBFM.TXT - -AUTHOR - Adel I. Mirzazhanov, - Project home page: http://www.adel.nursat.kz/WAPG/ - - - -Automated Password Generator 2003 Jun 19 WAPG(1) \ No newline at end of file +WAPG User Manual WAPG + + + +NAME + apg - generates several random passwords + + +SYNOPSIS + apg [-a algorithm] [-M mode] [-E char_string] [-n num_of_pass] [-m + min_pass_len] [-x max_pass_len] [-r dictfile] [-b filter_file] [-p + min_substr_len] [-c cl_seed] [-d] [-l] [-t] [-q] [-h] [-v] + + +DESCRIPTION + apg generates several random passwords. It uses several password gener- + ation algorithms (currently two) and a built-in pseudo random number + generator. + + Default algorithm is pronounceable password generation algorithm + designed by Morrie Gasser and described in A Random Word Generator For + Pronounceable Passwords National Technical Information Service (NTIS) + AD-A-017676. The original paper is very old and had never been put + online, so I have to use NIST implementation described in FIPS-181. + + Another algorithm is simple random character generation algorithm, but + it uses four user-defined symbol sets to produce random password. It + means that user can choose type of symbols that should appear in pass- + word. Symbol sets are: numeric symbol set (0,...,9) , capital letters + symbol set (A,...,Z) , small letters symbol set (a,...,z) and special + symbols symbol set (#,@,!,...). + + Built-in pseudo random number generator is an implementation of algo- + rithm described in Appendix C of ANSI X9.17 or RFC1750 with exception + that it uses CAST or SHA-1 instead of Triple DES. It uses local time + with precision of microseconds (see gettimeofday(2)) and /dev/random + (if available) to produce initial random seed. + + apg also have the ability to check generated password quality using + dictionary. You can use this ability if you specify command-line + options -r dictfile or -b filtername where dictfile is the dictionary + file name and filtername is the name of Bloom filter file. In that dic- + tionary you may place words (one per line) that should not appear as + generated passwords. For example: user names, common words, etc. You + even can use one of the dictionaries that come with dictionary password + crackers. Bloom filter file should be created with apgbfm(1) utility + included in apg distribution. In future releases I plan to implement + some other techniques to check passwords (like pattern check) just to + make life easier. + + +OPTIONS + Password generation modes options + -a algorithm + use algorithm for password generation. + 0 - (default) pronounceable password generation + 1 - random character password generation + + -n num_of_pass + generate num_of_pass number of passwords. Default is 6. + + -m min_pass_len + generate password with minimum length min_pass_len. If + min_pass_len > max_pass_len then max_pass_len = min_pass_len. + Default minimum password length is 8. + + -x max_pass_len + generate password with maximum length max_pass_len. If + min_pass_len > max_pass_len then max_pass_len = min_pass_len. + Default maximum password length is 10. + + -M mode + Use symbolsets specified with mode for password generation. + mode is a text string consisting of characters S, s, N, n, C, c, + L, l. Where: + + S generator must use special symbol set for every generated + password. + + s generator should use special symbol set for password gen- + eration. + + N generator must use numeral symbol set for every generated + password. + + n generator should use numeral symbol set for password gen- + eration. + + C generator must use capital symbol set for every generated + password. + + c generator should use capital symbol set for password gen- + eration. + + L generator must use small letters symbol set for every + generated password (always present if pronounceable pass- + word generation algorithm is used). + + l generator should use small letters symbol set for pass- + word generation. + + R,r not supported any more. Use -E char_string option + instead. + mode can not be more than 4 characters in length. + + Note: + Usage of L, M, N, C will slow down password generation process. + + Examples: + -M sncl or -M SNCL or -M Cn + + -E char_string + exclude characters in char_string from password generation pro- + cess (in pronounceable password generation mode you can not + exclude small letters). To include special symbols that can be + recognized by shell (apostrophe, quotes, dollar sign, etc.) in + char_string use the backslashed versions. + + Examples: + + Command apg -a 1 -M n -n 3 -m 8 -E 23456789 will generate a set + of passwords that will look like this + 10100110 + 01111000 + 11011101 + + Command apg -a 1 -M nc -n 3 -m 26 -E GHIJKLMNOPQRSTUVWXYZ will + generate a set of passwords that will look like this + 16A1653CD4DE5E7BD9584A3476 + C8F78E06944AFD57FB9CB882BC + 8C8DF37CD792D36D056BBD5002 + + Password quality control options + -r dictfile + check generated passwords for their appearance in dictfile + + -b filter_file + check generated passwords for their appearance in filter_file. + filter_file should be created with apgbfm(1) utility. + + -p min_substr_len + this option tells apg(1) to check every substring of the gener- + ated password for appearance in filter_file. If any of such sub- + strings would be found in the filter_file then generated pass- + word would be rejected and apg(1) will generate another one. + min_substr_len specifies minimum substring length to check. + This option is active only if -b option is defined. + + Pseudo random number generator options + -c cl_seed + use cl_seed as a random seed for password generation. I use it + when i have to generate passwords in a shell script. + + Password output options + -d do NOT use any delimiters between generated passwords. I use it + when i have to generate passwords in a shell script. + + -q quiet mode (do not print warnings) + + -l spell genetated passwords. Useful when you want to read gener- + ated password by telephone. + WARNING: Think twice before read your password by phone. + + -t print pronunciation for generated pronounceable password + + -h print help information and exit + + -v print version information and exit + +DEFAULT OPTIONS + apg -a 0 -M sncl -n 6 -x 10 -m 8 (new style) + + If you want to generate really secure passwords, you should use option + -s. + +EXIT CODE + On successful completion of its task, apg will complete with exit code + 0. An exit code of -1 indicates an error occurred. Textual errors are + written to the standard error stream. + +FILES + None. + +BUGS + None. If you've found one, please send bug description to the author. + +SEE ALSO + wapgbfm.txt + +AUTHOR + Adel I. Mirzazhanov, + Project home page: http://www.adel.nursat.kz/apg/ + + + +Automated Password Generator 2003 Aug 04 WAPG diff --git a/doc/man/wapgbfm.txt b/doc/man/wapgbfm.txt index 18c19c8..aa0701b 100644 --- a/doc/man/wapgbfm.txt +++ b/doc/man/wapgbfm.txt @@ -1,116 +1,118 @@ -WAPGBFM User Manual WAPGBFM - - - -NAME - WAPGBFM - APG Bloom filter management program - - -SYNOPSIS - WAPGBFM -f filter -n numofwords [-q] [-s] - WAPGBFM -f filter -d dictfile [-q] [-s] - WAPGBFM -f filter -a word [-q] - WAPGBFM -f filter -A dictfile [-q] - WAPGBFM -f filter -c word [-q] - WAPGBFM -f filter -C dictfile [-q] - WAPGBFM -i filter - WAPGBFM [-v] [-h] - - -DESCRIPTION - WAPGBFM is used to manage Bloom filter that is used to restrict password - generation in WAPG pasword generation software. Usage of the Bloom fil- - ter allows to speed up password check for large dictionaries and has - some other benefits. - - The idea to use Bloom filter for that purpose is came from the descrip- - tion of the OPUS project OPUS: Preventing Weak Password Choices Purdue - Technical Report CSD-TR 92-028 writen by Eugene H. Spafford. - - You can obtain this article from: - http://www.cerias.purdue.edu/homes/spaf/tech-reps/9128.ps - It has very nice description of Bloom filter and it's advantages for - password checking systems. - - In simple words, WAPGBFM generates n hash values for every word and sets - corresponding bits in filter file to 1. To check the word WAPGBFM gener- - ates the same hash functions for that word and if all n corresponding - bits in filter file are set to 1 then it suppose that word exists in - dicionary. WAPGBFM uses SHA-1 as a hash function. - - WAPGBFM can be used as standalone utility, not only with apg, or apgd. - - - WARNING !!! - Filter file format can be changed in the future. I'll try to - make file formats compatible but i can not guaranty this. - - WARNING !!! - WAPGBFM may slow down your computer during filter creation. - -OPTIONS - -f filter - use filter as the name for Bloom filter filename. - - -i filter - print information about filter. - - -n numofwords - create new empty filter for numofwords number of words. Useful - when you want to fill filter dynamicaly. - - -d dictfile - create new filter from dictfile. It may take a lot of time to - generate filter from a big dictionary. In that dictionary you - may place words (one per line) that should not appear as gener- - ated passwords. For example: user names common words, etc. You - even can use one of the dictionaries that come with dictionary - password crackers. This check is case sensitive. For example, - if you want to reject word 'root', you should insert in dictfile - words: root, Root, RoOt, ... , ROOT. To indicate that program - is working WAPGBFM prints dot for every 100 words added in dic- - tionary. - - -a word - add word to the filter. - - -A dictfile - add all words from dictfile to the filter. To indicate that pro- - gram is working WAPGBFM prints dot for every 100 words added in - dictionary. - - -c word - check word for appearance in the filter. - - -C dictfile - check every word from dictfile for appearance in the filter. - - -q quiet mode. - - -s create new filter in case-insensitive mode. - - -v print version information. - - -h print help information. - -EXIT CODE - On successful completion of its task, WAPGBFM will complete with exit - code 0. An exit code of -1 indicates an error occurred. Textual - errors are written to the standard error stream. - -FILES - None. - -BUGS - None. If you've found one, please send bug description to the author. - -SEE ALSO - WAPG.TXT - -AUTHOR - Adel I. Mirzazhanov, - Project home page: http://www.adel.nursat.kz/apg/ - - - -Automated Password Generator 2003 Jun 19 WAPGBFM +APGBFM(1) User Manual APGBFM(1) + + + +NAME + apgbfm - APG Bloom filter management program + + +SYNOPSIS + apgbfm -f filter -n numofwords [-q] [-s] + apgbfm -f filter -d dictfile [-q] [-s] + apgbfm -f filter -a word [-q] + apgbfm -f filter -A dictfile [-q] + apgbfm -f filter -c word [-q] + apgbfm -f filter -C dictfile [-q] + apgbfm -i filter + apgbfm [-v] [-h] + + +DESCRIPTION + apgbfm is used to manage Bloom filter that is used to restrict password + generation in APG pasword generation software. Usage of the Bloom fil- + ter allows to speed up password check for large dictionaries and has + some other benefits. + + The idea to use Bloom filter for that purpose is came from the descrip- + tion of the OPUS project OPUS: Preventing Weak Password Choices Purdue + Technical Report CSD-TR 92-028 writen by Eugene H. Spafford. + + You can obtain this article from: + http://www.cerias.purdue.edu/homes/spaf/tech-reps/9128.ps + It has very nice description of Bloom filter and it's advantages for + password checking systems. + + In simple words, apgbfm generates n hash values for every word and sets + corresponding bits in filter file to 1. To check the word apgbfm gener- + ates the same hash functions for that word and if all n corresponding + bits in filter file are set to 1 then it suppose that word exists in + dicionary. apgbfm uses SHA-1 as a hash function. + + apgbfm can be used as standalone utility, not only with apg, or apgd. + + + WARNING !!! + Filter file format can be changed in the future. I'll try to + make file formats compatible but i can not guaranty this. + + WARNING !!! + apgbfm may slow down your computer during filter creation. + +OPTIONS + -f filter + use filter as the name for Bloom filter filename. + + -i filter + print information about filter. + + -n numofwords + create new empty filter for numofwords number of words. Useful + when you want to fill filter dynamicaly. + + -d dictfile + create new filter from dictfile. It may take a lot of time to + generate filter from a big dictionary. In that dictionary you + may place words (one per line) that should not appear as gener- + ated passwords. For example: user names common words, etc. You + even can use one of the dictionaries that come with dictionary + password crackers. This check is case sensitive. For example, + if you want to reject word 'root', you should insert in dictfile + words: root, Root, RoOt, ... , ROOT. To indicate that program + is working apgbfm prints dot for every 100 words added in dic- + tionary. + + -a word + add word to the filter. + + -A dictfile + add all words from dictfile to the filter. To indicate that pro- + gram is working apgbfm prints dot for every 100 words added in + dictionary. + + -c word + check word for appearance in the filter. + + -C dictfile + check every word from dictfile for appearance in the filter. + + -q quiet mode. + + -s create new filter in case-insensitive mode. + + -v print version information. + + -h print help information. + +EXIT CODE + On successful completion of its task, apgbfm will complete with exit + code 0. An exit code of -1 indicates an error occurred. Textual + errors are written to the standard error stream. + +FILES + None. + +BUGS + None. If you've found one, please send bug description to the author. + + This man page is Alpha too. + +SEE ALSO + apgd(8), apg(1) + +AUTHOR + Adel I. Mirzazhanov, + Project home page: http://www.adel.nursat.kz/apg/ + + + +Automated Password Generator 2003 Jun 19 APGBFM(1) diff --git a/pronpass.c b/pronpass.c index ca78293..328a997 100644 --- a/pronpass.c +++ b/pronpass.c @@ -39,7 +39,7 @@ #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include -#endif +#endif /* WIN32 */ #include #include #include "pronpass.h" diff --git a/randpass.c b/randpass.c index b804365..80f9346 100644 --- a/randpass.c +++ b/randpass.c @@ -36,7 +36,7 @@ #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include -#endif +#endif /* WIN32 */ #include #include "randpass.h" diff --git a/restrict.c b/restrict.c index 2f17560..aa5047f 100644 --- a/restrict.c +++ b/restrict.c @@ -184,6 +184,38 @@ paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len) return(0); } + +#if defined(APG_USE_CRACKLIB) +/* +** cracklib_check_pass() - check password against cracklib. +** INPUT: +** char * - password to check. +** char * - cracklib dict. +** OUTPUT: +** int +** -1 - error +** 1 - password does not pass this check +** 0 - password does pass this check +** NOTES: +** none. +*/ +int +cracklib_check_pass(char *pw, char *dictpath) +{ + char * msg; + msg = FascistCheck(pw,dictpath); + if (msg == NULL) return (0); + else + { +#ifdef APG_DEBUG + fprintf(stdout,"cracklib_check_pass: password --> %s rejected (%s)\n", pw, msg); + fflush(stdout); +#endif + return (1); + } +} +#endif + /* ** filter_check_pass() - routine that checks password against filter string ** diff --git a/restrict.h b/restrict.h index c54ebf3..9dfa68f 100644 --- a/restrict.h +++ b/restrict.h @@ -33,13 +33,21 @@ #ifndef APG_RESTRICT_H #define APG_RESTRICT_H 1 +#if defined(APG_USE_CRACKLIB) +#include +#endif + #include "bloom.h" #include "randpass.h" + #define MAX_DICT_STRING_SIZE 255 int check_pass(char * pass, char *dict); int bloom_check_pass (char *word, char *filter); int paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len); int filter_check_pass(const char * word, unsigned int cond); int set_exclude_list(const char * char_string); +#if defined(APG_USE_CRACKLIB) +int cracklib_check_pass(char *pw, char *dictpath); +#endif #endif /* APG_RESTRICT_H */ diff --git a/rnd.c b/rnd.c index 81e9eec..cbbaf49 100644 --- a/rnd.c +++ b/rnd.c @@ -31,7 +31,7 @@ #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include -#endif +#endif /* WIN32 */ #include #include #include @@ -130,7 +130,11 @@ u8 ro_key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, UINT32 x917sha1_rnd (void) { +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) struct timeval local_time; +#else + clock_t local_time[2]; /* clock ticks for win32 */ +#endif UINT32 I[2] = {0L,0L}; UINT32 I_plus_s[2] = {0L,0L}; UINT32 Xi[2] = {0L,0L}; @@ -139,7 +143,12 @@ x917sha1_rnd (void) BYTE hash [SHA_DIGESTSIZE]; apg_SHA_INFO shaInfo; +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) (void) gettimeofday (&local_time, 0); +#else + local_time[0] = clock(); + local_time[1] = clock(); +#endif apg_shaInit ( &shaInfo ); apg_shaUpdate ( &shaInfo, (BYTE *)&local_time, 8); apg_shaFinal ( &shaInfo, hash );