Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df3f864b46 | ||
|
|
900ff5ea18 |
76
CHANGES
76
CHANGES
@@ -1,3 +1,77 @@
|
||||
apg-2.2.0
|
||||
Added polish translation for APG PHP frontend.
|
||||
Added option -p (see apg(1) apgd(8)).
|
||||
Added option -t (see apg(1) apgd(8)).
|
||||
Added option -l (see apg(1)).
|
||||
Changed format of the bloom-filter file. Added
|
||||
converter utility to convert old format to the
|
||||
new one (bfconvert).
|
||||
Added option -i (see apgbfm(1)).
|
||||
Fixed some bugs.
|
||||
Some compatibility changes.
|
||||
Changed default apg options.
|
||||
|
||||
apg-2.1.0
|
||||
Some code cleanup.
|
||||
|
||||
apg-2.1.0b1
|
||||
Option [-E char_string] now works for pronounceable
|
||||
password generation too (see apg(1), apgd(8)).
|
||||
|
||||
apg-2.1.0b0
|
||||
Added new option [-e char_string] that allow to exclude some
|
||||
characters from password generation process.
|
||||
(works only for random password generation yet)
|
||||
|
||||
apg-2.1.0a0
|
||||
Added support for /dev/arandom for OpenBSD
|
||||
|
||||
apg-2.1.0a0
|
||||
Fixed some typing errors in the man pages
|
||||
System getopt() replaced with own apg_getopt().
|
||||
All calls of bcopy() and bzero() replaced with memcpy() and memset().
|
||||
Changed documentation.
|
||||
PRNG algorithm changed to use PID as an element of initial seed.
|
||||
Redesigned PHP frontend. Added support for German language.
|
||||
Implemented password quality ckeck based on filter. Now you can enforce
|
||||
APG to generate passwords that must contain numbers, special characters etc.
|
||||
Removed support for old style password generation mode definition.
|
||||
|
||||
apg-2.0.0final
|
||||
Changed PHP frontend to work with PHP safe-mode.
|
||||
Version numbers of apg, apgd, apgbfm, apgonline changed to 2.0.0final.
|
||||
|
||||
apg-2.0.0b1
|
||||
Fixed error that has forced user to set world-write privileges on
|
||||
Bloom-filter file. (Thanks to Mike Robbins <mike.robbins@sweetolive.net>)
|
||||
Fixed PHP frontend to clean-up generated HTML code.
|
||||
(Thanks to Mike Robbins <mike.robbins@sweetolive.net>)
|
||||
|
||||
apg-2.0.0b0
|
||||
Some code style fixes.
|
||||
Support for "special" symbol-set usage for password generation
|
||||
in pronounceable mode (S mode).
|
||||
Support for "resticted special" symbol-set usage for password generation
|
||||
in pronounceable mode (R mode).
|
||||
New style of hyphenated password output for pronounceable
|
||||
password generation mode.
|
||||
|
||||
apg-2.0.0a3
|
||||
Better error handling in apgbfm.
|
||||
Added -q option for apgbfm and apg (quiet mode).
|
||||
Added PHP frontend for APG.
|
||||
|
||||
apg-2.0.0a2
|
||||
Added support for SHA1 algorithm used for random numbers and hash
|
||||
generation.
|
||||
Hash function used in apgbfm changed to SHA1.
|
||||
Added info to APG_TIPS file.
|
||||
|
||||
apg-2.0.0a1 (not published)
|
||||
Finaly fixed some warnings during compilation process.
|
||||
Added support for OpenBSD.
|
||||
Added info to APG_TIPS file.
|
||||
|
||||
apg-2.0.0a0
|
||||
Added new algorithm (-b option) to check generated passwords
|
||||
quality (Bloom filter).
|
||||
@@ -70,7 +144,7 @@ apg-1.0.4
|
||||
Added option -c (see apg(1)).Changed apg.c, apg.1 manpage.
|
||||
|
||||
apg-1.0.3
|
||||
Fixed somecode style errors. Changed INSTALL, apgd.8 manpage.
|
||||
Fixed some code style errors. Changed INSTALL, apgd.8 manpage.
|
||||
|
||||
apg-1.0.2
|
||||
Improved event logging of apgd. Changed INSTALL.
|
||||
|
||||
2
COPYING
2
COPYING
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 1999, 2000, 2001
|
||||
Copyright (c) 1999, 2000, 2001, 2002
|
||||
Adel I. Mirzazhanov. All rights reserved
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
4
INSTALL
4
INSTALL
@@ -7,8 +7,8 @@ use them together.
|
||||
The simplest way to install this package is:
|
||||
1. untar the distribution and cd to the top:
|
||||
|
||||
% gzip -d -c apg-1.X.XX.tar.gz | tar xf -
|
||||
% cd apg-1.X.XX
|
||||
% gzip -d -c apg-2.X.XX.tar.gz | tar xf -
|
||||
% cd apg-2.X.XX
|
||||
|
||||
If you are reading this file, you probably have already done this!
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@ Generaly there are 2 types of installation:
|
||||
(2) client-server
|
||||
but only standalone installation implemented for CYGWIN yet.
|
||||
|
||||
APGD(server) works too, but it has some bugs and i could
|
||||
not recommend to use it.
|
||||
|
||||
The instruction below IS FOR STANDALONE INSTALLATION ONLY
|
||||
|
||||
The simplest way to install this package is:
|
||||
1. untar the distribution and cd to the top:
|
||||
|
||||
% gzip -d -c apg-1.X.XX.tar.gz | tar xf -
|
||||
% cd apg-1.X.XX
|
||||
% gzip -d -c apg-2.X.XX.tar.gz | tar xf -
|
||||
% cd apg-2.X.XX
|
||||
|
||||
If you are reading this file, you probably have already done this!
|
||||
|
||||
|
||||
64
Makefile
64
Makefile
@@ -1,23 +1,43 @@
|
||||
##################################################################
|
||||
# You can modify CC variable if you have compiler other than GCC
|
||||
# But the code was designed and tested with GCC
|
||||
CC = gcc
|
||||
|
||||
# compilation flags
|
||||
##################################################################
|
||||
# Compilation flags
|
||||
# You should comment the line below for AIX+native cc
|
||||
FLAGS = -Wall
|
||||
|
||||
# libraries
|
||||
##################################################################
|
||||
# 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
|
||||
@@ -25,48 +45,64 @@ APG_MAN_DIR = /man/man1
|
||||
APGD_BIN_DIR = /sbin
|
||||
APGD_MAN_DIR = /man/man8
|
||||
|
||||
# Find group ID for user root
|
||||
FIND_GROUP = `grep '^root:' /etc/passwd | awk -F: '{ print $$4 }'`
|
||||
|
||||
####################################################################
|
||||
# If you plan to install APG daemon you should look at lines below #
|
||||
####################################################################
|
||||
|
||||
####################################################################
|
||||
# FreeBSD
|
||||
#
|
||||
# Uncoment NOTHING for FreeBSD
|
||||
#
|
||||
|
||||
####################################################################
|
||||
# Linux
|
||||
#
|
||||
# Uncoment line below for LINUX
|
||||
#CS_LIBS = -lnsl
|
||||
|
||||
####################################################################
|
||||
# Solaris
|
||||
#
|
||||
# Uncoment line below for Solaris
|
||||
#CS_LIBS = -lnsl -lsocket
|
||||
|
||||
####################################################################
|
||||
# QNX RTP 6.1.0
|
||||
#
|
||||
# Uncoment line below for QNX RTP 6.1.0
|
||||
#CS_LIBS = -lsocket
|
||||
|
||||
# ====== 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 }'`
|
||||
|
||||
PROGNAME = apg
|
||||
CS_PROGNAME = apgd
|
||||
BFM_PROGNAME = apgbfm
|
||||
BFM_SOURCES = apgbfm.c bloom.c md5/md5.c errors.c
|
||||
SOURCES = bloom.c md5/md5.c rnd.c ./cast/cast.c pronpass.c randpass.c restrict.c errors.c apg.c
|
||||
HEADERS = owntypes.h pronpass.h randpass.h restrict.h errs.h rnd.h ./cast/cast.h ./cast/cast_sboxes.h
|
||||
BFM_SOURCES = apgbfm.c bloom.c sha/sha.c errors.c getopt.c convert.c
|
||||
SOURCES = bloom.c ./sha/sha.c ./cast/cast.c rnd.c pronpass.c \
|
||||
randpass.c restrict.c errors.c apg.c getopt.c convert.c
|
||||
HEADERS = owntypes.h pronpass.h randpass.h restrict.h errs.h rnd.h \
|
||||
./cast/cast.h ./cast/cast_sboxes.h getopt.h convert.h
|
||||
OBJECTS = rnd.o ./cast/cast.o pronpass.o randpass.o restrict.o apg.o errors.o
|
||||
|
||||
standalone: apg apgbfm
|
||||
|
||||
all: cliserv standalone
|
||||
|
||||
cliserv: apgd apgbfm
|
||||
|
||||
standalone: apg apgbfm
|
||||
|
||||
cygwin: standalone
|
||||
|
||||
apg:
|
||||
${CC} ${FLAGS} ${LIBS} ${LIBM} -D${CRYPTED_PASS} -o ${PROGNAME} ${SOURCES}
|
||||
${CC} ${FLAGS} -D${CRYPTED_PASS} -D${USE_SHA} -o ${PROGNAME} ${SOURCES} ${LIBS} ${LIBM}
|
||||
|
||||
apgd:
|
||||
${CC} ${FLAGS} ${CS_LIBS} ${LIBM} -DCLISERV -o ${CS_PROGNAME} ${SOURCES}
|
||||
${CC} ${FLAGS} -DCLISERV -D${USE_SHA} -o ${CS_PROGNAME} ${SOURCES} ${CS_LIBS} ${LIBM}
|
||||
|
||||
apgbfm:
|
||||
${CC} ${FLAGS} ${LIBM} -o ${BFM_PROGNAME} ${BFM_SOURCES}
|
||||
${CC} ${FLAGS} -DAPGBFM -o ${BFM_PROGNAME} ${BFM_SOURCES} ${LIBM}
|
||||
|
||||
strip:
|
||||
strip ${PROGNAME}
|
||||
@@ -108,4 +144,4 @@ fi
|
||||
fi
|
||||
|
||||
clean:
|
||||
rm -f ${CS_PROGNAME} ${PROGNAME} ${BFM_PROGNAME} ${OBJECTS} core*
|
||||
rm -f ${CS_PROGNAME} ${PROGNAME} ${BFM_PROGNAME} ${OBJECTS} *core*
|
||||
|
||||
28
README
28
README
@@ -1,26 +1,14 @@
|
||||
APG v2.0.0a0 was tested and found working on:
|
||||
APG v2.2.0 was tested and found working on:
|
||||
|
||||
i386 FreeBSD 4.0-RELEASE
|
||||
i386 Linux-Mandrake 6.0
|
||||
i386 FreeBSD 5.0-RELEASE
|
||||
Intel Solaris 8 gcc-2.95.2
|
||||
Intel Windows 2000+CYGWIN v1.1.4
|
||||
QNX PRP 6.0
|
||||
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 <zuntum@eik.pl>)
|
||||
i386 Linux-Mandrake 6.0
|
||||
i386 Linux-Redhat 7.0
|
||||
i386 Linux-Mandrake 7.2 (reported by Andrew J. Caird <acaird@advance-inc.com>)
|
||||
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 <apierce@boi.hp.com>)
|
||||
HP-UX 11.00 HP ANSI C Compilier (reported by Alexander J Pierce <apierce@boi.hp.com>)
|
||||
HP-UX 11.00 gcc-2.95.2 (reported by Andrew J. Caird <acaird@advance-inc.com>)
|
||||
IRIX 6.5.8 gcc-2.95.2 (reported by Andrew J. Caird <acaird@advance-inc.com>)
|
||||
AIX 4.3.3+native cc (reported by Philip Le Riche <pleriche@uk03.bull.co.uk>)
|
||||
AIX 4.3.3+gcc (reported by Philip Le Riche <pleriche@uk03.bull.co.uk>)
|
||||
NOTE:
|
||||
This release (APG v2.2.0) is NOT compatible with TkAPG (Tcl/Tk frontend for APG)
|
||||
|
||||
Any compatibility reports are welcome
|
||||
|
||||
|
||||
18
THANKS
18
THANKS
@@ -10,3 +10,21 @@ Alexander J Pierce <apierce@boi.hp.com>
|
||||
Philip Le Riche <pleriche@uk03.bull.co.uk>
|
||||
Tomasz Luchowski <zuntum@eik.pl>
|
||||
Barton Hodges <barton@gcmcomputers.com>
|
||||
Rick VanNorman <rick@neverslow.com>
|
||||
Tomaz Zupan <tomaz.zupan@orpo.si>
|
||||
Marc Haber <Marc.Haber@plannet.de>
|
||||
Tom Schutter <tom@platte.com>
|
||||
Matt Mullins <matt_mullins@ared.uscourts.gov>
|
||||
Mike Robbins <mike.robbins@sweetolive.net>
|
||||
Bernhard Wesely <mail@weselyb.net>
|
||||
Allen Wells <Allen.Wells@state.mn.us>
|
||||
Jose Nazario <jose@crimelabs.net>
|
||||
Sebastian Stark <seb@todesplanet.de>
|
||||
Joseph P. Crotty <jcrotty18@attbi.com>
|
||||
Schlies, Peter <PSchlies@syntellect.com>
|
||||
Eugene Podkopaev <eugene@emetex.ru>
|
||||
Bill Plesko <bplesko@mcguirebearing.com>
|
||||
Bartosz Sobolewski - Worthy <worthy@data.pl>
|
||||
James Mancini <jmancini@netreo.net>
|
||||
Arno Wilhelm <a.wilhelm@phion.com>
|
||||
Michael Matthews <mjmatt@qsun.mt.att.com>
|
||||
|
||||
3
TODO
3
TODO
@@ -15,6 +15,3 @@ Priority Medium:
|
||||
|
||||
* Make some interfase for plug-in language modules
|
||||
for pronounceable password generation.
|
||||
|
||||
* Make some interface ( language ) to describe
|
||||
restriction rules for passwords.
|
||||
|
||||
395
apg.c
395
apg.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -32,17 +32,30 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define APG_VERSION "2.0.0a0"
|
||||
#ifndef APG_USE_SHA
|
||||
#define APG_VERSION "2.2.0 (PRNG: X9.17/CAST)"
|
||||
#else /* APG_USE_SHA */
|
||||
#define APG_VERSION "2.2.0 (PRNG: X9.17/SHA-1)"
|
||||
#endif /* APG_USE_SHA */
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define MAX_MODE_LENGTH 5
|
||||
#if defined(__sun) || defined(sun) || defined(linux) || defined(__linux) || defined(__linux__)
|
||||
#include <crypt.h>
|
||||
#endif
|
||||
|
||||
#define MAX_MODE_LENGTH 4
|
||||
#define DEFAULT_MIN_PASS_LEN 8
|
||||
#define DEFAULT_MAX_PASS_LEN 10
|
||||
#define DEFAULT_NUM_OF_PASS 6
|
||||
|
||||
#ifndef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE
|
||||
@@ -53,16 +66,15 @@
|
||||
#endif
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include <getopt.h>
|
||||
#undef APG_USE_CRYPT
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#ifdef CLISERV
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <syslog.h>
|
||||
# define MAXSOCKADDDR 128
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <syslog.h>
|
||||
#define MAXSOCKADDDR 128
|
||||
#endif /* CLISERV */
|
||||
|
||||
#include "owntypes.h"
|
||||
@@ -72,18 +84,27 @@
|
||||
#include "bloom.h"
|
||||
#include "rnd.h"
|
||||
#include "errs.h"
|
||||
#include "getopt.h"
|
||||
#include "convert.h"
|
||||
|
||||
struct pass_m {
|
||||
unsigned int pass; /* password generation mode */
|
||||
unsigned int filter; /* password generation mode */
|
||||
};
|
||||
#ifndef CLISERV
|
||||
UINT32 get_user_seq (void);
|
||||
UINT32 com_line_user_seq (char * seq);
|
||||
char *crypt_passstring (const char *p); /*!!*/
|
||||
char *crypt_passstring (const char *p);
|
||||
void print_help (void);
|
||||
#endif /* CLISERV */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
void checkopt(char *opt);
|
||||
unsigned int construct_mode(char *str_mode);
|
||||
int construct_mode(char *str_mode, struct pass_m * mde);
|
||||
|
||||
/*
|
||||
** main()
|
||||
*/
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -99,18 +120,29 @@ main (int argc, char *argv[])
|
||||
|
||||
int algorithm = 0; /* algorithm for generation */
|
||||
int restrictions_present = FALSE; /* restrictions flag */
|
||||
int plain_restrictions_present = FALSE; /* dictionary restrictions_flag */
|
||||
int bloom_restrict_present = FALSE; /* bloom filter restrictions flag */
|
||||
int paranoid_bloom_restrict_present = FALSE; /* paranoid bloom filter restrictions flag */
|
||||
int filter_restrict_present = FALSE; /* filter restrictions flag */
|
||||
int exclude_list_present = FALSE; /* exclude list present */
|
||||
int quiet_present = FALSE; /* quiet mode flag */
|
||||
int hyph_req_present = FALSE; /* Request to print hyphenated password */
|
||||
char *restrictions_file; /* dictionary file name */
|
||||
unsigned int pass_mode = 0; /* password generation mode */
|
||||
char *plain_restrictions_file; /* dictionary file name */
|
||||
struct pass_m mode;
|
||||
unsigned int pass_mode_present = FALSE; /* password generation mode flag */
|
||||
USHORT min_pass_length = 6; /* min password length */
|
||||
USHORT max_pass_length = 8; /* max password length */
|
||||
int number_of_pass = 6; /* number of passwords to generate */
|
||||
USHORT min_pass_length = DEFAULT_MIN_PASS_LEN; /* min password length */
|
||||
USHORT max_pass_length = DEFAULT_MAX_PASS_LEN; /* max password length */
|
||||
USHORT min_substr_len = 0; /* min substring length to check if
|
||||
** paranoid check is used */
|
||||
int number_of_pass = DEFAULT_NUM_OF_PASS; /* number of passwords to generate */
|
||||
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 */
|
||||
#ifndef CLISERV
|
||||
char *com_line_seq;
|
||||
char *spell_pass_string;
|
||||
int spell_present = FALSE; /* spell password mode flag */
|
||||
unsigned int delimiter_flag_present = FALSE;
|
||||
#ifdef APG_USE_CRYPT
|
||||
char *crypt_string;
|
||||
@@ -118,7 +150,7 @@ main (int argc, char *argv[])
|
||||
#endif /* APG_USE_CRYPT */
|
||||
#endif /* CLISERV */
|
||||
#ifdef CLISERV
|
||||
#ifdef sgi /* Thanks to Andrew J. Caird */
|
||||
#if defined(sgi) || defined(__APPLE__) || defined(__QNX__) /* Thanks to Andrew J. Caird */
|
||||
typedef unsigned int socklen_t;
|
||||
#endif
|
||||
socklen_t len;
|
||||
@@ -148,86 +180,92 @@ main (int argc, char *argv[])
|
||||
*/
|
||||
#ifndef CLISERV
|
||||
#ifdef APG_USE_CRYPT
|
||||
while ((option = getopt (argc, argv, "SNCLRM:a:r:b:sdc:n:m:x:hvy")) != -1)
|
||||
while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:sdc:n:m:x:htvylq")) != -1)
|
||||
#else /* APG_USE_CRYPT */
|
||||
while ((option = getopt (argc, argv, "SNCLRM:a:r:b:sdc:n:m:x:hv")) != -1)
|
||||
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 = getopt (argc, argv, "SNCLRM:a:r:b:n:m:x:v")) != -1)
|
||||
while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:n:m:x:vt")) != -1)
|
||||
#endif /* CLISERV */
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case 'S': /* special symbols required */
|
||||
pass_mode = pass_mode | S_SS;
|
||||
pass_mode_present = TRUE;
|
||||
break;
|
||||
case 'R': /* special symbols required */
|
||||
pass_mode = pass_mode | S_SS;
|
||||
pass_mode = pass_mode | S_RS;
|
||||
pass_mode_present = TRUE;
|
||||
break;
|
||||
case 'N': /* numbers required */
|
||||
pass_mode = pass_mode | S_NB;
|
||||
pass_mode_present = TRUE;
|
||||
break;
|
||||
case 'C': /* capital letters required */
|
||||
pass_mode = pass_mode | S_CL;
|
||||
pass_mode_present = TRUE;
|
||||
break;
|
||||
case 'L': /* small letters required */
|
||||
pass_mode = pass_mode | S_SL;
|
||||
pass_mode_present = TRUE;
|
||||
break;
|
||||
case 'M':
|
||||
str_mode = optarg;
|
||||
if( (pass_mode = construct_mode(str_mode)) == 0xFFFF)
|
||||
case 'M': /* mode parameter */
|
||||
str_mode = apg_optarg;
|
||||
if( (construct_mode(str_mode,&mode)) == -1)
|
||||
err_app_fatal("construct_mode","wrong parameter");
|
||||
pass_mode_present = TRUE;
|
||||
if(mode.filter != 0)
|
||||
{
|
||||
filter_restrict_present = TRUE;
|
||||
restrictions_present = TRUE;
|
||||
}
|
||||
break;
|
||||
case 'E': /* exclude char */
|
||||
if(set_exclude_list(apg_optarg)==-1)
|
||||
err_app_fatal("set_exclude_list","string is too long (max. 93 characters)");
|
||||
exclude_list_present = TRUE;
|
||||
break;
|
||||
case 'a': /* algorithm specification */
|
||||
checkopt(optarg);
|
||||
algorithm = atoi (optarg);
|
||||
checkopt(apg_optarg);
|
||||
algorithm = atoi (apg_optarg);
|
||||
break;
|
||||
case 'r': /* restrictions */
|
||||
restrictions_present = TRUE;
|
||||
restrictions_file = optarg;
|
||||
plain_restrictions_present = TRUE;
|
||||
plain_restrictions_file = apg_optarg;
|
||||
break;
|
||||
case 'b': /* bloom restrictions */
|
||||
restrictions_present = TRUE;
|
||||
bloom_restrict_present = TRUE;
|
||||
restrictions_file = optarg;
|
||||
restrictions_file = apg_optarg;
|
||||
break;
|
||||
case 'p': /* paranoid bloom restrictions */
|
||||
checkopt(apg_optarg);
|
||||
min_substr_len = atoi (apg_optarg);
|
||||
paranoid_bloom_restrict_present = TRUE;
|
||||
break;
|
||||
#ifndef CLISERV
|
||||
case 'l':
|
||||
spell_present = TRUE;
|
||||
break;
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
case 's': /* user random seed required */
|
||||
user_defined_seed = get_user_seq ();
|
||||
user_defined_seed_present = TRUE;
|
||||
break;
|
||||
#endif /* WIN32 */
|
||||
case 'c': /* user random seed given in command line */
|
||||
com_line_seq = optarg;
|
||||
com_line_seq = apg_optarg;
|
||||
user_defined_seed = com_line_user_seq (com_line_seq);
|
||||
user_defined_seed_present = TRUE;
|
||||
break;
|
||||
case 'd': /* No delinmiters option */
|
||||
case 'd': /* no delimiters option */
|
||||
delimiter_flag_present = TRUE;
|
||||
break;
|
||||
case 'q': /* quiet mode */
|
||||
quiet_present = TRUE;
|
||||
break;
|
||||
#ifdef APG_USE_CRYPT
|
||||
case 'y': /* display crypt(3)'d text next to passwords */ /*!!*/
|
||||
case 'y': /* display crypt(3)'d text next to passwords */
|
||||
show_crypt_text = TRUE;
|
||||
break;
|
||||
#endif /* APG_USE_CRYPT */
|
||||
#endif /* CLISERV */
|
||||
case 'n': /* number of password specification */
|
||||
checkopt(optarg);
|
||||
number_of_pass = atoi (optarg);
|
||||
checkopt(apg_optarg);
|
||||
number_of_pass = atoi (apg_optarg);
|
||||
break;
|
||||
case 'm': /* min password length */
|
||||
checkopt(optarg);
|
||||
min_pass_length = (USHORT) atoi (optarg);
|
||||
checkopt(apg_optarg);
|
||||
min_pass_length = (USHORT) atoi (apg_optarg);
|
||||
break;
|
||||
case 'x': /* max password length */
|
||||
checkopt(optarg);
|
||||
max_pass_length = (USHORT) atoi (optarg);
|
||||
checkopt(apg_optarg);
|
||||
max_pass_length = (USHORT) atoi (apg_optarg);
|
||||
break;
|
||||
case 't': /* request to print hyphenated password */
|
||||
hyph_req_present = TRUE;
|
||||
break;
|
||||
#ifndef CLISERV
|
||||
case 'h': /* print help */
|
||||
@@ -237,7 +275,7 @@ main (int argc, char *argv[])
|
||||
case 'v': /* print version */
|
||||
printf ("APG (Automated Password Generator)");
|
||||
printf ("\nversion %s", APG_VERSION);
|
||||
printf ("\nCopyright (c) 1999, 2000, 2001 Adel I. Mirzazhanov\n");
|
||||
printf ("\nCopyright (c) 1999, 2000, 2001, 2002, 2003 Adel I. Mirzazhanov\n");
|
||||
return (0);
|
||||
default: /* print help end exit */
|
||||
#ifndef CLISERV
|
||||
@@ -247,22 +285,25 @@ main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (pass_mode_present != TRUE)
|
||||
pass_mode = S_SS | S_NB | S_CL | S_SL;
|
||||
mode.pass = S_SS | S_NB | S_CL | S_SL;
|
||||
if (exclude_list_present == TRUE)
|
||||
mode.pass = mode.pass | S_RS;
|
||||
if( (tme = time(NULL)) == ( (time_t)-1))
|
||||
err_sys("time");
|
||||
if (user_defined_seed_present != TRUE)
|
||||
x917cast_setseed ( (UINT32)tme);
|
||||
x917_setseed ( (UINT32)tme, quiet_present);
|
||||
else
|
||||
x917cast_setseed (user_defined_seed ^ (UINT32)tme);
|
||||
x917_setseed (user_defined_seed ^ (UINT32)tme, quiet_present);
|
||||
if (min_pass_length > max_pass_length)
|
||||
max_pass_length = min_pass_length;
|
||||
/* main code section */
|
||||
|
||||
/*
|
||||
** reserv space for password and hyphenated password and report of errors
|
||||
** 18 because the maximum length of element for hyphenated password is 17
|
||||
*/
|
||||
if ( (pass_string = (char *)calloc (1, (size_t)(max_pass_length + 1)))==NULL ||
|
||||
(hyph_pass_string = (char *)calloc (1, (size_t)(max_pass_length*2)))==NULL)
|
||||
(hyph_pass_string = (char *)calloc (1, (size_t)(max_pass_length*18)))==NULL)
|
||||
err_sys_fatal("calloc");
|
||||
#ifndef CLISERV
|
||||
#ifdef APG_USE_CRYPT
|
||||
@@ -272,7 +313,7 @@ main (int argc, char *argv[])
|
||||
#endif /* APG_USE_CRYPT */
|
||||
#endif /* CLISERV */
|
||||
#ifdef CLISERV
|
||||
if ( (out_pass = (char *)calloc(1, (size_t)(max_pass_length*3 + 4))) == NULL)
|
||||
if ( (out_pass = (char *)calloc(1, (size_t)(max_pass_length*19 + 4))) == NULL)
|
||||
err_sys_fatal("calloc");
|
||||
#endif /* CLISERV */
|
||||
/*
|
||||
@@ -284,38 +325,65 @@ main (int argc, char *argv[])
|
||||
if (algorithm == 0)
|
||||
{
|
||||
if (gen_pron_pass(pass_string, hyph_pass_string,
|
||||
min_pass_length, max_pass_length, pass_mode) == -1)
|
||||
min_pass_length, max_pass_length, mode.pass) == -1)
|
||||
err_app_fatal("apg","wrong password length parameter");
|
||||
#ifndef CLISERV
|
||||
#ifdef APG_USE_CRYPT
|
||||
if (show_crypt_text == TRUE)
|
||||
bcopy ((void *)crypt_passstring (pass_string),
|
||||
(void *)crypt_string, 255);
|
||||
(void) memcpy ((void *)crypt_string,
|
||||
(void *)crypt_passstring (pass_string), 255);
|
||||
#endif /* APG_USE_CRYPT */
|
||||
#endif /* CLISERV */
|
||||
/***************************************
|
||||
** ALGORITHM = 0 RESTRICTIONS = PRESENT
|
||||
****************************************/
|
||||
if (restrictions_present == TRUE)
|
||||
{
|
||||
/* Filter check */
|
||||
if (filter_restrict_present == TRUE)
|
||||
restrict_res = filter_check_pass(pass_string, mode.filter);
|
||||
/* Bloom-filter check */
|
||||
if (restrict_res == 0)
|
||||
{
|
||||
if (bloom_restrict_present == TRUE)
|
||||
{
|
||||
if(paranoid_bloom_restrict_present != TRUE)
|
||||
restrict_res = bloom_check_pass(pass_string, restrictions_file);
|
||||
else
|
||||
restrict_res = check_pass(pass_string, restrictions_file);
|
||||
restrict_res = paranoid_bloom_check_pass(pass_string, restrictions_file, min_substr_len);
|
||||
}
|
||||
}
|
||||
/* Dictionary check */
|
||||
if (restrict_res == 0)
|
||||
if (plain_restrictions_present == TRUE)
|
||||
restrict_res = check_pass(pass_string, plain_restrictions_file);
|
||||
|
||||
|
||||
switch (restrict_res)
|
||||
{
|
||||
case 0:
|
||||
#ifndef CLISERV
|
||||
fprintf (stdout, "%s", pass_string);
|
||||
if (hyph_req_present == TRUE)
|
||||
fprintf (stdout, " (%s)", hyph_pass_string);
|
||||
#ifdef APG_USE_CRYPT
|
||||
if (show_crypt_text == TRUE)
|
||||
fprintf (stdout, "%s (%s) %s", pass_string, hyph_pass_string,
|
||||
crypt_string);
|
||||
else
|
||||
fprintf (stdout, " %s", crypt_string);
|
||||
#endif /* APG_USE_CRYPT */
|
||||
fprintf (stdout, "%s (%s)", pass_string, hyph_pass_string);
|
||||
if (spell_present == TRUE)
|
||||
{
|
||||
spell_pass_string = spell_word(pass_string, spell_pass_string);
|
||||
fprintf (stdout, (" %s"), spell_pass_string);
|
||||
free((void*)spell_pass_string);
|
||||
}
|
||||
if ( delimiter_flag_present == FALSE )
|
||||
fprintf (stdout, "\n");
|
||||
fflush (stdout);
|
||||
#else /* CLISERV */
|
||||
snprintf(out_pass, max_pass_length*3 + 4,
|
||||
"%s (%s)", pass_string, hyph_pass_string);
|
||||
if (hyph_req_present == TRUE)
|
||||
snprintf(out_pass, max_pass_length*19 + 4, "%s (%s)", pass_string, hyph_pass_string);
|
||||
else
|
||||
snprintf(out_pass, max_pass_length*19 + 4, "%s", pass_string);
|
||||
write (0, (void*) out_pass, strlen(out_pass));
|
||||
write (0, (void*)&delim[0],2);
|
||||
#endif /* CLISERV */
|
||||
@@ -329,46 +397,79 @@ main (int argc, char *argv[])
|
||||
break;
|
||||
} /* switch */
|
||||
}
|
||||
else /* if (restrictions_present == 0) */
|
||||
/******************************************
|
||||
** ALGORITHM = 0 RESTRICTIONS = NOT_PRESENT
|
||||
*******************************************/
|
||||
else
|
||||
{
|
||||
#ifndef CLISERV
|
||||
fprintf (stdout, "%s", pass_string);
|
||||
if (hyph_req_present == TRUE)
|
||||
fprintf (stdout, " (%s)", hyph_pass_string);
|
||||
#ifdef APG_USE_CRYPT
|
||||
if (show_crypt_text == TRUE)
|
||||
fprintf (stdout, "%s (%s) %s", pass_string, hyph_pass_string,
|
||||
crypt_string);
|
||||
else
|
||||
fprintf (stdout, " %s", crypt_string);
|
||||
#endif /* APG_USE_CRYPT */
|
||||
fprintf (stdout, "%s (%s)", pass_string, hyph_pass_string);
|
||||
if (spell_present == TRUE)
|
||||
{
|
||||
spell_pass_string = spell_word(pass_string, spell_pass_string);
|
||||
fprintf (stdout, (" %s"), spell_pass_string);
|
||||
free((void*)spell_pass_string);
|
||||
}
|
||||
if ( delimiter_flag_present == FALSE )
|
||||
fprintf (stdout, "\n");
|
||||
fflush (stdout);
|
||||
#else /* CLISERV */
|
||||
snprintf(out_pass, max_pass_length*3 + 4,
|
||||
"%s (%s)", pass_string, hyph_pass_string);
|
||||
if (hyph_req_present == TRUE)
|
||||
snprintf(out_pass, max_pass_length*19 + 4, "%s (%s)", pass_string, hyph_pass_string);
|
||||
else
|
||||
snprintf(out_pass, max_pass_length*19 + 4, "%s", pass_string);
|
||||
write (0, (void*) out_pass, strlen(out_pass));
|
||||
write (0, (void*)&delim[0],2);
|
||||
#endif /* CLISERV */
|
||||
i++;
|
||||
}
|
||||
} /* end of if (algorithm == 0) */
|
||||
}
|
||||
/***************************************
|
||||
** ALGORITHM = 1
|
||||
****************************************/
|
||||
else if (algorithm == 1)
|
||||
{
|
||||
if (gen_rand_pass(pass_string, min_pass_length,
|
||||
max_pass_length, pass_mode) == -1)
|
||||
max_pass_length, mode.pass) == -1)
|
||||
err_app_fatal("apg","wrong password length parameter");
|
||||
#ifndef CLISERV
|
||||
#ifdef APG_USE_CRYPT
|
||||
if (show_crypt_text == TRUE)
|
||||
bcopy ((void *)crypt_passstring(pass_string),
|
||||
(void *)crypt_string, 255);
|
||||
(void)memcpy ((void *)crypt_string,
|
||||
(void *)crypt_passstring(pass_string), 255);
|
||||
#endif /* APG_USE_CRYPT */
|
||||
#endif /* CLISERV */
|
||||
/***************************************
|
||||
** ALGORITHM = 1 RESTRICTIONS = PRESENT
|
||||
****************************************/
|
||||
if ( (restrictions_present == TRUE))
|
||||
{
|
||||
/* Filter check */
|
||||
if (filter_restrict_present == TRUE)
|
||||
restrict_res = filter_check_pass(pass_string, mode.filter);
|
||||
/* Bloom-filter check */
|
||||
if (restrict_res == 0)
|
||||
{
|
||||
if (bloom_restrict_present == TRUE)
|
||||
{
|
||||
if(paranoid_bloom_restrict_present != TRUE)
|
||||
restrict_res = bloom_check_pass(pass_string, restrictions_file);
|
||||
else
|
||||
restrict_res = check_pass(pass_string, restrictions_file);
|
||||
restrict_res = paranoid_bloom_check_pass(pass_string, restrictions_file, min_substr_len);
|
||||
}
|
||||
}
|
||||
/* Dictionary check */
|
||||
if (restrict_res == 0)
|
||||
if (plain_restrictions_present == TRUE)
|
||||
restrict_res = check_pass(pass_string, plain_restrictions_file);
|
||||
|
||||
|
||||
switch (restrict_res)
|
||||
{
|
||||
case 0:
|
||||
@@ -379,6 +480,12 @@ main (int argc, char *argv[])
|
||||
else
|
||||
#endif /* APG_USE_CRYPT */
|
||||
fprintf (stdout, "%s", pass_string);
|
||||
if (spell_present == TRUE)
|
||||
{
|
||||
spell_pass_string = spell_word(pass_string, spell_pass_string);
|
||||
fprintf (stdout, (" %s"), spell_pass_string);
|
||||
free((void*)spell_pass_string);
|
||||
}
|
||||
if ( delimiter_flag_present == FALSE )
|
||||
fprintf (stdout, "\n");
|
||||
fflush (stdout);
|
||||
@@ -396,7 +503,10 @@ main (int argc, char *argv[])
|
||||
break;
|
||||
} /* switch */
|
||||
}
|
||||
else /* if (restrictions_present == 0) */
|
||||
/***************************************
|
||||
** ALGORITHM = 1 RESTRICTIONS = PRESENT
|
||||
****************************************/
|
||||
else
|
||||
{
|
||||
#ifndef CLISERV
|
||||
#ifdef APG_USE_CRYPT
|
||||
@@ -405,6 +515,12 @@ main (int argc, char *argv[])
|
||||
else
|
||||
#endif /* APG_USE_CRYPT */
|
||||
fprintf (stdout, "%s", pass_string);
|
||||
if (spell_present == TRUE)
|
||||
{
|
||||
spell_pass_string = spell_word(pass_string, spell_pass_string);
|
||||
fprintf (stdout, (" %s"), spell_pass_string);
|
||||
free((void*)spell_pass_string);
|
||||
}
|
||||
if ( delimiter_flag_present == FALSE )
|
||||
fprintf (stdout, "\n");
|
||||
fflush (stdout);
|
||||
@@ -438,9 +554,16 @@ main (int argc, char *argv[])
|
||||
} /* end of main */
|
||||
|
||||
#ifndef CLISERV
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
/*
|
||||
** Routine that gets user random sequense and generates
|
||||
** sutable random seed according to it
|
||||
** get_user_seq() - Routine that gets user random sequense
|
||||
** and generates sutable random seed according to it.
|
||||
** INPUT:
|
||||
** void
|
||||
** OUTPUT:
|
||||
** UINT32 - random seed
|
||||
** NOTES:
|
||||
** none
|
||||
*/
|
||||
UINT32
|
||||
get_user_seq (void)
|
||||
@@ -451,16 +574,22 @@ get_user_seq (void)
|
||||
printf ("\nPlease enter some random data (only first %d are significant)\n", sizeof(prom));
|
||||
seq = (char *)getpass("(eg. your old password):>");
|
||||
if (strlen(seq) < sizeof(prom))
|
||||
bcopy((void *)seq, (void *)&prom[0], (int)strlen(seq));
|
||||
(void)memcpy((void *)&prom[0], (void *)seq, (int)strlen(seq));
|
||||
else
|
||||
bcopy((void *)seq, (void *)&prom[0], sizeof(prom));
|
||||
(void)memcpy((void *)&prom[0], (void *)seq, sizeof(prom));
|
||||
sdres = prom[0]^prom[1];
|
||||
return (sdres);
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
/*
|
||||
** Routine that gets user random sequense from command line and generates
|
||||
** sutable random seed according to it
|
||||
** com_line_user_seq() - Routine that gets user random sequense
|
||||
** from command line and generates sutable random seed according to it
|
||||
** INPUT:
|
||||
** char * - command line seed
|
||||
** OUTPUT:
|
||||
** UINT32 - random seed
|
||||
** NOTES:
|
||||
** none
|
||||
*/
|
||||
UINT32
|
||||
com_line_user_seq (char * seq)
|
||||
@@ -468,26 +597,36 @@ com_line_user_seq (char * seq)
|
||||
UINT32 prom[2] = { 0L, 0L };
|
||||
UINT32 sdres = 0L;
|
||||
if (strlen(seq) < sizeof (prom))
|
||||
bcopy((void *)seq, (void *)&prom[0], (int)strlen(seq));
|
||||
(void)memcpy((void *)&prom[0], (void *)seq, (int)strlen(seq));
|
||||
else
|
||||
bcopy((void *)seq, (void *)&prom[0], sizeof(prom));
|
||||
(void)memcpy((void *)&prom[0], (void *)seq, sizeof(prom));
|
||||
sdres = prom[0]^prom[1];
|
||||
return (sdres);
|
||||
}
|
||||
|
||||
/*
|
||||
** print_help() - print help :)))
|
||||
** INPUT:
|
||||
** none.
|
||||
** OUTPUT:
|
||||
** help info to the stdout.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
print_help (void)
|
||||
{
|
||||
printf ("\napg Automated Password Generator\n");
|
||||
printf (" Copyright (c) Adel I. Mirzazhanov\n");
|
||||
printf ("\napg [-a algorithm] [-r file] [-S] [-C] [-L] [-R]\n");
|
||||
printf (" [-N] [-M mode] [-n num_of_pass] [-m min_pass_len]\n");
|
||||
printf (" [-x max_pass_len] [-c cl_seed] [-d] [-s] [-h] [-y]\n");
|
||||
printf ("\n-S -N -C -L -R password modes\n");
|
||||
printf ("-M mode new style pasword modes\n");
|
||||
printf ("\napg [-a algorithm] [-r file] \n");
|
||||
printf (" [-M mode] [-E char_string] [-n num_of_pass] [-m min_pass_len]\n");
|
||||
printf (" [-x max_pass_len] [-c cl_seed] [-d] [-s] [-h] [-y] [-q]\n");
|
||||
printf ("\n-M mode new style password modes\n");
|
||||
printf ("-E char_string exclude characters from password generation process\n");
|
||||
printf ("-r file apply dictionary check against file\n");
|
||||
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");
|
||||
printf ("-a algorithm choose algorithm\n");
|
||||
printf (" 1 - random password generation according to\n");
|
||||
printf (" password modes\n");
|
||||
@@ -495,18 +634,32 @@ print_help (void)
|
||||
printf ("-n num_of_pass generate num_of_pass passwords\n");
|
||||
printf ("-m min_pass_len minimum password length\n");
|
||||
printf ("-x max_pass_len maximum password length\n");
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
printf ("-s ask user for a random seed for password\n");
|
||||
printf (" generation\n");
|
||||
#endif /* WIN32 */
|
||||
printf ("-c cl_seed use cl_seed as a random seed for password\n");
|
||||
printf ("-d do NOT use any delimiters between generated passwords\n");
|
||||
printf ("-l spell generated password\n");
|
||||
printf ("-t print pronunciation for generated pronounceable password\n");
|
||||
#ifdef APG_USE_CRYPT
|
||||
printf ("-y print crypted passwords\n");
|
||||
#endif /* APG_USE_CRYPT */
|
||||
printf ("-q quiet mode (do not print warnings)\n");
|
||||
printf ("-h print this help screen\n");
|
||||
printf ("-v print version information\n");
|
||||
}
|
||||
|
||||
#ifdef APG_USE_CRYPT
|
||||
/*
|
||||
** crypt_passstring() - produce crypted password.
|
||||
** INPUT:
|
||||
** const char * - password string
|
||||
** OUTPUT:
|
||||
** char * - crypted password
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
char * crypt_passstring (const char *p)
|
||||
{
|
||||
char salt[10];
|
||||
@@ -516,6 +669,15 @@ char * crypt_passstring (const char *p)
|
||||
#endif /* APG_USE_CRYPT */
|
||||
#endif /* CLISERV */
|
||||
|
||||
/*
|
||||
** checkopt() - check options.
|
||||
** INPUT:
|
||||
** char * - options string.
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** option should contain only numeral symbols.
|
||||
*/
|
||||
void
|
||||
checkopt(char *opt)
|
||||
{
|
||||
@@ -528,9 +690,22 @@ checkopt(char *opt)
|
||||
err_app_fatal ("checkopt", "wrong option format");
|
||||
}
|
||||
|
||||
unsigned int construct_mode(char *s_mode)
|
||||
/*
|
||||
** construct_mode() - construct mode for password
|
||||
** generation from string.
|
||||
** INPUT:
|
||||
** char * - string mode.
|
||||
** OUTPUT:
|
||||
** int - return code.
|
||||
** 0 - OK
|
||||
** -1 - ERROR
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int construct_mode(char *s_mode, struct pass_m * mde)
|
||||
{
|
||||
unsigned int mode = 0;
|
||||
unsigned int filter = 0;
|
||||
int ch = 0;
|
||||
int i = 0;
|
||||
int str_length = 0;
|
||||
@@ -538,7 +713,7 @@ unsigned int construct_mode(char *s_mode)
|
||||
str_length = strlen(s_mode);
|
||||
|
||||
if (str_length > MAX_MODE_LENGTH)
|
||||
return(0xFFFF);
|
||||
return(-1);
|
||||
for (i=0; i < str_length; i++)
|
||||
{
|
||||
ch = (int)*s_mode;
|
||||
@@ -546,19 +721,19 @@ unsigned int construct_mode(char *s_mode)
|
||||
{
|
||||
case 'S':
|
||||
mode = mode | S_SS;
|
||||
filter = filter | S_SS;
|
||||
break;
|
||||
case 'N':
|
||||
mode = mode | S_NB;
|
||||
filter = filter | S_NB;
|
||||
break;
|
||||
case 'C':
|
||||
mode = mode | S_CL;
|
||||
filter = filter | S_CL;
|
||||
break;
|
||||
case 'L':
|
||||
mode = mode | S_SL;
|
||||
break;
|
||||
case 'R':
|
||||
mode = mode | S_SS;
|
||||
mode = mode | S_RS;
|
||||
filter = filter | S_SL;
|
||||
break;
|
||||
case 's':
|
||||
mode = mode | S_SS;
|
||||
@@ -572,16 +747,14 @@ unsigned int construct_mode(char *s_mode)
|
||||
case 'l':
|
||||
mode = mode | S_SL;
|
||||
break;
|
||||
case 'r':
|
||||
mode = mode | S_SS;
|
||||
mode = mode | S_RS;
|
||||
break;
|
||||
default:
|
||||
mode = mode | 0xFFFF;
|
||||
return(-1);
|
||||
break;
|
||||
}
|
||||
s_mode++;
|
||||
}
|
||||
return (mode);
|
||||
mde->pass = mode;
|
||||
mde->filter = filter;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
198
apgbfm.c
198
apgbfm.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 2001
|
||||
** Copyright (c) 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -32,16 +32,23 @@
|
||||
#include <unistd.h>
|
||||
#include "bloom.h"
|
||||
#include "errs.h"
|
||||
#include "getopt.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include <getopt.h>
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#define VERSION "1.0.0a0"
|
||||
#define VERSION "2.2.0"
|
||||
|
||||
|
||||
#define FOUND "FOUND"
|
||||
#define NOT_FOUND "NOT FOUND"
|
||||
/*
|
||||
#define FOUND "YES"
|
||||
#define NOT_FOUND "NO"
|
||||
*/
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
void print_help(void);
|
||||
void checkopt(char *opt);
|
||||
void print_filter_info(char * filter);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
@@ -55,11 +62,13 @@ main (int argc, char *argv[])
|
||||
FILE *f_filter; /* filter file descriptor */
|
||||
|
||||
char *word; /* word to add or check */
|
||||
char *tmp; /* just tmp char pointer */
|
||||
h_val wc = 0L; /* amount of words to build dictionaty */
|
||||
h_val filter_size =0L; /* filter size in bits */
|
||||
int dummy_test = 0; /* variable to make dummy test for */
|
||||
/* options correctness */
|
||||
h_val i = 0L; /* cointer */
|
||||
h_val i = 0L; /* counter */
|
||||
f_mode flt_mode = 0x00; /* filter mode */
|
||||
|
||||
/* flags */
|
||||
flag add_word_flag = FALSE; /* -a */
|
||||
@@ -69,6 +78,8 @@ main (int argc, char *argv[])
|
||||
flag new_flag = FALSE; /* -n */
|
||||
flag new_from_dict_flag = FALSE; /* -d */
|
||||
flag filter_flag = FALSE; /* -f */
|
||||
flag silent_flag = FALSE; /* -q */
|
||||
flag case_insensitive_flag = FALSE; /* -q */
|
||||
/* end of flags section */
|
||||
|
||||
/* Analize options */
|
||||
@@ -78,43 +89,43 @@ main (int argc, char *argv[])
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
while ((option = getopt (argc, argv, "a:A:c:C:n:d:f:hv")) != -1)
|
||||
while ((option = apg_getopt (argc, argv, "a:A:c:C:n:d:f:i:hvqs")) != -1)
|
||||
{
|
||||
switch(option)
|
||||
{
|
||||
case 'a':
|
||||
word = optarg;
|
||||
word = apg_optarg;
|
||||
add_word_flag = TRUE;
|
||||
dummy_test = dummy_test + 2;
|
||||
break;
|
||||
case 'A':
|
||||
dictfile = optarg;
|
||||
dictfile = apg_optarg;
|
||||
add_file_flag = TRUE;
|
||||
dummy_test = dummy_test + 2;
|
||||
break;
|
||||
case 'c':
|
||||
word = optarg;
|
||||
word = apg_optarg;
|
||||
check_word_flag = TRUE;
|
||||
dummy_test = dummy_test + 2;
|
||||
break;
|
||||
case 'C':
|
||||
dictfile = optarg;
|
||||
dictfile = apg_optarg;
|
||||
check_file_flag = TRUE;
|
||||
dummy_test = dummy_test + 2;
|
||||
break;
|
||||
case 'n':
|
||||
checkopt(optarg);
|
||||
wc = atoi(optarg);
|
||||
checkopt(apg_optarg);
|
||||
wc = atoi(apg_optarg);
|
||||
new_flag = TRUE;
|
||||
dummy_test = dummy_test + 2;
|
||||
break;
|
||||
case 'd':
|
||||
dictfile = optarg;
|
||||
dictfile = apg_optarg;
|
||||
new_from_dict_flag = TRUE;
|
||||
dummy_test = dummy_test + 2;
|
||||
break;
|
||||
case 'f':
|
||||
filter = optarg;
|
||||
filter = apg_optarg;
|
||||
filter_flag = TRUE;
|
||||
dummy_test = dummy_test + 1;
|
||||
break;
|
||||
@@ -124,8 +135,18 @@ main (int argc, char *argv[])
|
||||
case 'v':
|
||||
printf ("APG Bloom filter management programm");
|
||||
printf ("\nversion %s", VERSION);
|
||||
printf ("\nCopyright (c) 2001 Adel I. Mirzazhanov\n");
|
||||
printf ("\nCopyright (c) 2001, 2002, 2003 Adel I. Mirzazhanov\n");
|
||||
return (0);
|
||||
case 'i':
|
||||
print_filter_info(apg_optarg);
|
||||
return (0);
|
||||
case 'q':
|
||||
silent_flag = TRUE;
|
||||
break;
|
||||
case 's':
|
||||
flt_mode = flt_mode | BF_CASE_INSENSITIVE;
|
||||
case_insensitive_flag = TRUE;
|
||||
break;
|
||||
default:
|
||||
print_help();
|
||||
exit(-1);
|
||||
@@ -135,98 +156,119 @@ main (int argc, char *argv[])
|
||||
if (dummy_test != 3) err_app_fatal ("apg", "too many options");
|
||||
/* Main part */
|
||||
/* At this point we can be sure that all options a correct */
|
||||
if (add_word_flag == TRUE)
|
||||
if (add_word_flag == TRUE) /* -a word */
|
||||
{
|
||||
if ( (f_filter = open_filter(filter)) == NULL)
|
||||
if ( (f_filter = open_filter(filter, "r+")) == NULL)
|
||||
err_sys_fatal("open_filter");
|
||||
filter_size = get_filtersize(f_filter);
|
||||
if ( insert_word (word, f_filter, filter_size) == -1)
|
||||
flt_mode = get_filtermode(f_filter);
|
||||
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||
if ( insert_word (word, f_filter, filter_size, flt_mode) == -1)
|
||||
err_sys_fatal("insert_word");
|
||||
if (silent_flag != TRUE)
|
||||
printf ("Word %s added\n",word);
|
||||
return (0);
|
||||
}
|
||||
if (add_file_flag == TRUE)
|
||||
if (add_file_flag == TRUE) /* -A dictfile */
|
||||
{
|
||||
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
||||
err_sys_fatal("fopen");
|
||||
if( (f_filter = open_filter(filter)) == NULL)
|
||||
if( (f_filter = open_filter(filter,"r+")) == NULL)
|
||||
err_sys_fatal("open_filter");
|
||||
filter_size = get_filtersize(f_filter);
|
||||
flt_mode = get_filtermode(f_filter);
|
||||
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||
while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL))
|
||||
{
|
||||
word = (char *)strtok (word," \t\n\0");
|
||||
if ( insert_word (word, f_filter, filter_size) == -1)
|
||||
tmp = (char *)strtok (word," \t\n\0");
|
||||
if( tmp != NULL)
|
||||
word = tmp;
|
||||
else continue;
|
||||
if ( insert_word (word, f_filter, filter_size, flt_mode) == -1)
|
||||
err_sys_fatal("insert_word");
|
||||
i++;
|
||||
if (silent_flag != TRUE)
|
||||
{
|
||||
if ( i % 100 == 0)
|
||||
{
|
||||
fprintf (stdout,".");
|
||||
fflush (stdout);
|
||||
}
|
||||
bzero((void *)word, MAX_DICT_STRLEN);
|
||||
}
|
||||
printf ("\n");
|
||||
(void)memset((void *)word, 0, MAX_DICT_STRLEN);
|
||||
}
|
||||
if (silent_flag != TRUE) printf ("\n");
|
||||
free ( (void *)word);
|
||||
fclose (f_dictfile);
|
||||
fclose (f_filter);
|
||||
close_filter (f_filter);
|
||||
return (0);
|
||||
}
|
||||
if (check_word_flag == TRUE)
|
||||
if (check_word_flag == TRUE) /* -c word */
|
||||
{
|
||||
if ( (f_filter = open_filter(filter)) == NULL)
|
||||
if ( (f_filter = open_filter(filter, "r")) == NULL)
|
||||
err_sys_fatal("open_filter");
|
||||
filter_size = get_filtersize(f_filter);
|
||||
switch(check_word (word, f_filter, filter_size))
|
||||
flt_mode = get_filtermode(f_filter);
|
||||
|
||||
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||
switch(check_word (word, f_filter, filter_size, flt_mode))
|
||||
{
|
||||
case -1:
|
||||
err_sys_fatal("check_word");
|
||||
break;
|
||||
case 1:
|
||||
printf ("%s: FOUND \n",word);
|
||||
printf ("%s: %s \n",word, FOUND);
|
||||
break;
|
||||
case 0:
|
||||
printf ("%s: NOT FOUND\n",word);
|
||||
printf ("%s: %s\n",word, NOT_FOUND);
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
if (check_file_flag == TRUE)
|
||||
if (check_file_flag == TRUE) /* -C dictfile */
|
||||
{
|
||||
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
||||
err_sys_fatal("fopen");
|
||||
wc = count_words (f_dictfile);
|
||||
if( (f_filter = open_filter(filter)) == NULL)
|
||||
if (wc == 0) err_sys_fatal("count_words");
|
||||
if( (f_filter = open_filter(filter, "r")) == NULL)
|
||||
err_sys_fatal("open_filter");
|
||||
filter_size = get_filtersize(f_filter);
|
||||
flt_mode = get_filtermode(f_filter);
|
||||
|
||||
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||
while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL))
|
||||
{
|
||||
word = (char *)strtok (word," \t\n\0");
|
||||
switch(check_word (word, f_filter, filter_size))
|
||||
tmp = (char *)strtok (word," \t\n\0");
|
||||
if( tmp != NULL)
|
||||
word = tmp;
|
||||
else continue;
|
||||
switch(check_word (word, f_filter, filter_size, flt_mode))
|
||||
{
|
||||
case -1:
|
||||
err_sys_fatal("check_word");
|
||||
break;
|
||||
case 1:
|
||||
printf ("%s: FOUND \n",word);
|
||||
printf ("%s: %s\n",word, FOUND);
|
||||
break;
|
||||
case 0:
|
||||
printf ("%s: NOT FOUND\n",word);
|
||||
printf ("%s: %s\n",word, NOT_FOUND);
|
||||
break;
|
||||
}
|
||||
bzero((void *)word, MAX_DICT_STRLEN);
|
||||
(void)memset((void *)word, 0, MAX_DICT_STRLEN);
|
||||
}
|
||||
free ( (void *)word);
|
||||
fclose (f_dictfile);
|
||||
fclose (f_filter);
|
||||
close_filter (f_filter);
|
||||
return (0);
|
||||
}
|
||||
if (new_flag == TRUE) /* -n nwords */
|
||||
{
|
||||
if ((f_filter = create_filter(filter, wc)) == NULL)
|
||||
if ((f_filter = create_filter(filter, wc, flt_mode)) == NULL)
|
||||
err_sys_fatal("create_filter");
|
||||
fclose(f_filter);
|
||||
close_filter(f_filter);
|
||||
return (0);
|
||||
}
|
||||
if (new_from_dict_flag == TRUE) /* -d dictfile */
|
||||
@@ -234,37 +276,57 @@ main (int argc, char *argv[])
|
||||
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
||||
err_sys_fatal("fopen");
|
||||
if (silent_flag != TRUE)
|
||||
{
|
||||
fprintf (stdout,"Counting words in dictionary. Please wait...\n");
|
||||
fflush (stdout);
|
||||
}
|
||||
wc = count_words (f_dictfile);
|
||||
if( (f_filter = create_filter(filter, wc)) == NULL)
|
||||
if (wc == 0) err_sys_fatal("count_words");
|
||||
if( (f_filter = create_filter(filter, wc, flt_mode)) == NULL)
|
||||
err_sys_fatal("create_filter");
|
||||
filter_size = get_filtersize(f_filter);
|
||||
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||
while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL))
|
||||
{
|
||||
word = (char *)strtok (word," \t\n\0");
|
||||
if ( insert_word (word, f_filter, filter_size) == -1)
|
||||
tmp = (char *)strtok (word," \t\n\0");
|
||||
if( tmp != NULL)
|
||||
{
|
||||
word = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( insert_word (word, f_filter, filter_size, flt_mode) == -1)
|
||||
err_sys_fatal("insert_word");
|
||||
i++;
|
||||
if (silent_flag != TRUE)
|
||||
{
|
||||
if ( i % 100 == 0)
|
||||
{
|
||||
fprintf (stdout, ".");
|
||||
fflush (stdout);
|
||||
}
|
||||
bzero((void *)word, MAX_DICT_STRLEN);
|
||||
}
|
||||
printf ("\n");
|
||||
(void)memset((void *)word, 0, MAX_DICT_STRLEN);
|
||||
}
|
||||
if (silent_flag != TRUE) printf ("\n");
|
||||
free ( (void *)word);
|
||||
fclose (f_dictfile);
|
||||
fclose (f_filter);
|
||||
close_filter (f_filter);
|
||||
return (0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
** print_help - prints short help info
|
||||
** INPUT: NOTHING
|
||||
** RETURN: NOTHING
|
||||
** print_help() - prints short help info
|
||||
** INPUT:
|
||||
** none.
|
||||
** OUTPUT:
|
||||
** prints help info to the stdout.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
print_help(void)
|
||||
@@ -272,7 +334,8 @@ print_help(void)
|
||||
printf ("\napgbfm APG Bloom filter management\n");
|
||||
printf (" Copyright (c) 2001 Adel I. Mirzazhanov\n");
|
||||
printf ("\napgbfm -f filter < [-a word] | [-A dictfile] | [-n numofwords] |\n");
|
||||
printf (" [-c word] | [-C dictfile] | [-d dictfile] >\n");
|
||||
printf (" [-c word] | [-C dictfile] | [-d dictfile] > [-s]\n");
|
||||
printf ("apgbfm -i filter\n");
|
||||
printf ("apgbfm [-v] [-h]\n\n");
|
||||
printf ("-a word add word to filter\n");
|
||||
printf ("-A dictfile add words from dictfile to filter\n");
|
||||
@@ -281,10 +344,22 @@ print_help(void)
|
||||
printf ("-n numofwords create new empty filter\n");
|
||||
printf ("-d dictfile create new filter and add all words from dictfile\n");
|
||||
printf ("-f filtername use filtername as the name for filter\n");
|
||||
printf ("-q quiet mode (do not print dots for -A and -d)\n");
|
||||
printf ("-s create case insentive filter\n");
|
||||
printf ("-i filter print filter information\n");
|
||||
printf ("-v print version information\n");
|
||||
printf ("-h print help (this screen)\n");
|
||||
}
|
||||
|
||||
/*
|
||||
** checkopt() - check options
|
||||
** INPUT:
|
||||
** char * - option string.
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** checks only is the option string numeral.
|
||||
*/
|
||||
void
|
||||
checkopt(char *opt)
|
||||
{
|
||||
@@ -296,3 +371,24 @@ checkopt(char *opt)
|
||||
opt[i] != '8' && opt[i] != '9')
|
||||
err_app_fatal ("checkopt", "wrong option format");
|
||||
}
|
||||
|
||||
/*
|
||||
** print_filter_info(char * filter) - print filter information
|
||||
** INPUT:
|
||||
** char * - filter file name.
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
print_filter_info(char * filter)
|
||||
{
|
||||
FILE * f_filter;
|
||||
|
||||
if ( (f_filter = open_filter(filter, "r")) == NULL)
|
||||
err_sys_fatal("open_filter");
|
||||
if (( print_flt_info(f_filter)) == -1)
|
||||
err_sys_fatal("print_flt_info");
|
||||
close_filter(f_filter);
|
||||
}
|
||||
|
||||
29
bfconvert/Makefile
Normal file
29
bfconvert/Makefile
Normal file
@@ -0,0 +1,29 @@
|
||||
##################################################################
|
||||
# You can modify CC variable if you have compiler other than GCC
|
||||
# But the code was designed and tested with GCC
|
||||
CC = gcc
|
||||
|
||||
##################################################################
|
||||
# Compilation flags
|
||||
# You should comment the line below for AIX+native cc
|
||||
FLAGS = -Wall
|
||||
|
||||
ECHO = echo
|
||||
PROGNAME = bfconvert
|
||||
SOURCES = bfconvert.c
|
||||
|
||||
all:
|
||||
${CC} ${FLAGS} -o ${PROGNAME} ${SOURCES}
|
||||
|
||||
strip:
|
||||
strip ${PROGNAME}
|
||||
|
||||
install:
|
||||
@${ECHO} "**********************************************"
|
||||
@${ECHO} "* This program shold be used to convert your *"
|
||||
@${ECHO} "* filters once. So if you want to install *"
|
||||
@${ECHO} "* this program you have to do it manualy :-) *"
|
||||
@${ECHO} "**********************************************"
|
||||
|
||||
clean:
|
||||
rm -f ${PROGNAME} *.o *core
|
||||
24
bfconvert/README
Normal file
24
bfconvert/README
Normal file
@@ -0,0 +1,24 @@
|
||||
NAME
|
||||
bfconvert
|
||||
|
||||
DESCRIPTION
|
||||
Convert APG Bloom-filter version 1.0.1 to
|
||||
version 1.1.0
|
||||
|
||||
BUILD
|
||||
Just type `make' and hit [Enter] at the
|
||||
command prompt.
|
||||
|
||||
USAGE
|
||||
bfconvert old_bf_file_name new_bf_file_name
|
||||
|
||||
RETURN
|
||||
0 - success
|
||||
-1 - something wrong
|
||||
|
||||
NOTE
|
||||
Converted filter will be case sensitive.
|
||||
|
||||
Conversion to the case insensitive filter
|
||||
is impossible because of the bloom-filter
|
||||
nature.
|
||||
168
bfconvert/bfconvert.c
Normal file
168
bfconvert/bfconvert.c
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
** Copyright (c) 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1.Redistributions of source code must retain the above
|
||||
** copyright notice, this list of conditions and the following
|
||||
** disclaimer.
|
||||
** 2.Redistributions in binary form must reproduce the above
|
||||
** copyright notice, this list of conditions and the following
|
||||
** disclaimer in the documentation and/or other materials
|
||||
** provided with the distribution.
|
||||
** 3.The name of the author may not be used to endorse or
|
||||
** promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
***************************************************************
|
||||
** NAME : BFCONVERT **
|
||||
** DESCRIPTION : convert APG Bloom-filter version 1.0.1 to **
|
||||
** version 1.1.0 **
|
||||
** USAGE : bfconvert old_bf_file_name new_bf_file_name **
|
||||
** RETURN : 0 - success **
|
||||
** -1 - something wrong **
|
||||
***************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define OLD_APGBF_HEADER_LEN 12
|
||||
#define OLD_APGBF_HEADER_ID "APGBF101"
|
||||
|
||||
#define NEW_APGBF_HEADER_LEN 13
|
||||
#define NEW_APGBF_HEADER_ID "APGBF"
|
||||
#define NEW_APGBF_HEADER_VER "110"
|
||||
#define NEW_APGBF_HEADER_MODE 0x00
|
||||
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
typedef unsigned char f_mode;
|
||||
|
||||
struct new_apg_bf_hdr {
|
||||
char id[5]; /* filter ID */
|
||||
char version[3]; /* filter version */
|
||||
unsigned long int fs; /* filter size */
|
||||
f_mode mode; /* filter flags */
|
||||
};
|
||||
|
||||
struct old_apg_bf_hdr {
|
||||
char id[8]; /* ID */
|
||||
unsigned long int fs; /* filter size */
|
||||
};
|
||||
struct new_apg_bf_hdr new_bf_hdr;
|
||||
struct old_apg_bf_hdr old_bf_hdr;
|
||||
|
||||
char old_etalon_bf_id[] = OLD_APGBF_HEADER_ID;
|
||||
|
||||
char new_etalon_bf_id[] = NEW_APGBF_HEADER_ID;
|
||||
char new_etalon_bf_ver[] = NEW_APGBF_HEADER_VER;
|
||||
|
||||
FILE *old_f; /* old filter file descriptor */
|
||||
FILE *new_f; /* new filter file descriptor */
|
||||
|
||||
unsigned char tmp_buf; /* Temporary buffer */
|
||||
|
||||
/* Checking arguments */
|
||||
if (argc != 3)
|
||||
{
|
||||
printf ("Usage: bfconvert old_bf_file_name new_bf_file_name\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Opening input and output files */
|
||||
if ((old_f = fopen (argv[1], "r")) == NULL)
|
||||
{
|
||||
perror("open the old bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
if ((new_f = fopen (argv[2], "w")) == NULL)
|
||||
{
|
||||
perror("open the new bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
if (fread ( (void *)&old_bf_hdr, OLD_APGBF_HEADER_LEN, 1, old_f) != 1)
|
||||
if (ferror (old_f) != 0)
|
||||
{
|
||||
perror("read from the old bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Checking input file */
|
||||
if ((old_bf_hdr.id[0] != old_etalon_bf_id[0]) || (old_bf_hdr.id[1] != old_etalon_bf_id[1]) ||
|
||||
(old_bf_hdr.id[2] != old_etalon_bf_id[2]) || (old_bf_hdr.id[3] != old_etalon_bf_id[3]) ||
|
||||
(old_bf_hdr.id[4] != old_etalon_bf_id[4]) || (old_bf_hdr.id[5] != old_etalon_bf_id[5]) ||
|
||||
(old_bf_hdr.id[6] != old_etalon_bf_id[6]) || (old_bf_hdr.id[7] != old_etalon_bf_id[7]) )
|
||||
{
|
||||
fprintf(stderr,"Input file is not APG bloom filter file v1.0.1\n");
|
||||
fflush (stderr);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Constructing output BF file header */
|
||||
new_bf_hdr.id[0] = new_etalon_bf_id[0];
|
||||
new_bf_hdr.id[1] = new_etalon_bf_id[1];
|
||||
new_bf_hdr.id[2] = new_etalon_bf_id[2];
|
||||
new_bf_hdr.id[3] = new_etalon_bf_id[3];
|
||||
new_bf_hdr.id[4] = new_etalon_bf_id[4];
|
||||
new_bf_hdr.version[0] = new_etalon_bf_ver[0];
|
||||
new_bf_hdr.version[1] = new_etalon_bf_ver[1];
|
||||
new_bf_hdr.version[2] = new_etalon_bf_ver[2];
|
||||
new_bf_hdr.fs = old_bf_hdr.fs;
|
||||
new_bf_hdr.mode = NEW_APGBF_HEADER_MODE;
|
||||
|
||||
/* Writing new filter header to output file */
|
||||
if (fwrite ( (void *)&new_bf_hdr, NEW_APGBF_HEADER_LEN, 1, new_f) != 1)
|
||||
{
|
||||
perror("write to the new bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
/* Reading filter content from the old BF file and writing it to the new BF file */
|
||||
while (fread ( (void *)&tmp_buf, 1, 1, old_f) == 1)
|
||||
{
|
||||
if(fwrite( (void *)&tmp_buf, 1, 1, new_f) != 1)
|
||||
{
|
||||
perror("write to the new bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
if (ferror (old_f) != 0)
|
||||
{
|
||||
perror("read from the old bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
/* Close input and output files */
|
||||
if (fclose(old_f) == EOF)
|
||||
{
|
||||
perror("close old bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
if (fclose(new_f) == EOF)
|
||||
{
|
||||
perror("close new bloom-filter file");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
printf("\nInput file has been successfuly converted\n");
|
||||
return(0);
|
||||
}
|
||||
265
bloom.c
265
bloom.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 2001
|
||||
** Copyright (c) 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,42 +37,107 @@
|
||||
** create_filter - create initial(empty) filter file
|
||||
** open_filter - open APG Bloom filter file
|
||||
** get_filtersize - get APG Bloom filter size
|
||||
** get_filtermode - get APG Bloom filter mode
|
||||
** count_words - count words in plain dictionary file
|
||||
***************************************************************************
|
||||
** hash2bit - generates 4 values (should be 4 values of independent
|
||||
** print_flt_info - print filter info
|
||||
**=============================================================
|
||||
** hash2bit - generates 5 values (should be 5 values of independent
|
||||
** hash functions) from input string.
|
||||
** getbit - get the bit value from file.
|
||||
** putbit - put the bit in the file.
|
||||
*/
|
||||
|
||||
#include "bloom.h"
|
||||
#include "convert.h"
|
||||
|
||||
#define FSIZE_BIT(word_count) ((unsigned long int)(5.0/(1.0-pow( 0.84151068, 1.0/((double)word_count)))))
|
||||
#define FSIZE_BYTE(word_count) ((((unsigned long int)(5.0/(1.0-pow( 0.84151068, 1.0/((double)word_count)))))/8)+1)
|
||||
|
||||
h_val * hash2bit(char * word, h_val *b);
|
||||
int getbit(FILE * f, h_val bitnum);
|
||||
int putbit(FILE * f, h_val bitnum);
|
||||
|
||||
#ifdef APGBFM
|
||||
/*
|
||||
** print_flt_info - print filter information
|
||||
** INPUT:
|
||||
** FILE * filter - filter file descriptor
|
||||
** OUTPUT:
|
||||
** int
|
||||
** 0 - everything OK
|
||||
** -1 - something wrong
|
||||
*/
|
||||
int
|
||||
print_flt_info(FILE * filter)
|
||||
{
|
||||
struct apg_bf_hdr bf_hdr;
|
||||
int i = 0;
|
||||
|
||||
if (fseek (filter, 0, SEEK_SET) == -1)
|
||||
return(-1);
|
||||
if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, filter) != 1)
|
||||
if (ferror (filter) != 0)
|
||||
return(-1);
|
||||
printf ("**************************************\n");
|
||||
printf ("** APGBFM: Bloom-filter information **\n");
|
||||
printf ("**************************************\n");
|
||||
printf ("Filter ID : ");
|
||||
for (i=0; i < sizeof(bf_hdr.id); i++)
|
||||
printf ("%c", bf_hdr.id[i]);
|
||||
printf ("\n");
|
||||
printf ("Filter Version: ");
|
||||
printf ("%c.", bf_hdr.version[0]);
|
||||
printf ("%c.", bf_hdr.version[1]);
|
||||
printf ("%c", bf_hdr.version[2]);
|
||||
printf ("\n");
|
||||
printf ("Filter size : %lu bits\n", (unsigned long int)bf_hdr.fs);
|
||||
printf ("Filter mode : ");
|
||||
if (bf_hdr.mode == 0x00) printf ("PLAIN\n");
|
||||
if (bf_hdr.mode == 0x01) printf ("CASE_INSENSITIVE\n");
|
||||
printf ("**************************************\n");
|
||||
if (fseek (filter, 0, SEEK_SET) == -1)
|
||||
return(-1);
|
||||
return(0);
|
||||
}
|
||||
#endif /* APGBFM */
|
||||
|
||||
/*
|
||||
** insert_word - insert word in the filter file
|
||||
** INPUT:
|
||||
** char *word - word to incert in the filter
|
||||
** FILE *file - filter file descriptor
|
||||
** h_val filter_size - filter size in bits
|
||||
** RETURN:
|
||||
** f_mode mode - filter mode
|
||||
** OUTPUT:
|
||||
** int
|
||||
** 0 - everything OK
|
||||
** -1 - something wrong
|
||||
*/
|
||||
int
|
||||
insert_word(char *word, FILE *file, h_val filter_size)
|
||||
insert_word(char *word, FILE *file, h_val filter_size, f_mode mode)
|
||||
{
|
||||
h_val h[4];
|
||||
int i = 0;
|
||||
h_val h[H_NUM];
|
||||
int i = 0;
|
||||
|
||||
hash2bit (word, &h[0]);
|
||||
for(i = 0; i < 4; i++)
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> insert_word: word to insert: %s\n", word);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
|
||||
if ((mode & BF_CASE_INSENSITIVE) > 0)
|
||||
{
|
||||
decapitalize(word);
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> insert_word: decapitalized word: %s\n", word);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
}
|
||||
|
||||
hash2bit (word, &h[0]);
|
||||
for(i = 0; i < H_NUM; i++)
|
||||
if (putbit (file, h[i] % filter_size)== -1)
|
||||
return (-1);
|
||||
return(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -81,20 +146,42 @@ return(0);
|
||||
** char *word - word to check
|
||||
** FILE *file - filter file descriptor
|
||||
** h_val filter_size - filter size in bits
|
||||
** RETURN:
|
||||
** f_mode - filter mode
|
||||
** OUTPUT:
|
||||
** int
|
||||
** 0 - word is not in dictionary
|
||||
** 1 - word is in dictionary
|
||||
** -1 - something wrong
|
||||
*/
|
||||
int
|
||||
check_word(char *word, FILE *file, h_val filter_size)
|
||||
check_word(char *word, FILE *file, h_val filter_size, f_mode mode)
|
||||
{
|
||||
h_val h[4];
|
||||
h_val h[H_NUM];
|
||||
int i = 0;
|
||||
char * tmp_word;
|
||||
|
||||
hash2bit (word, &h[0]);
|
||||
for(i = 0; i < 4; i++)
|
||||
if ((tmp_word = (char *) calloc(1,MAX_DICT_STRLEN)) == NULL)
|
||||
return(-1);
|
||||
(void)memcpy ((void *) tmp_word, (void *) word, strlen(word));
|
||||
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> check_word: word to check: %s\n", word);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
if ((mode & BF_CASE_INSENSITIVE) > 0)
|
||||
{
|
||||
decapitalize(tmp_word);
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> check_word: decapitalized word: %s\n", tmp_word);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
}
|
||||
|
||||
hash2bit (tmp_word, &h[0]);
|
||||
|
||||
free ((void *)tmp_word);
|
||||
|
||||
for(i = 0; i < H_NUM; i++)
|
||||
{
|
||||
switch(getbit(file, h[i] % filter_size))
|
||||
{
|
||||
@@ -116,24 +203,32 @@ check_word(char *word, FILE *file, h_val filter_size)
|
||||
** open filter file and check is this the real bloom filter file
|
||||
** INPUT:
|
||||
** char * f_name - filter filename
|
||||
** RETURN:
|
||||
** const char *mode - "r" or "r+"
|
||||
** OUTPUT:
|
||||
** FILE * - file pointer
|
||||
** NULL - something wrong.
|
||||
*/
|
||||
FILE *
|
||||
open_filter(char * f_name)
|
||||
open_filter(char * f_name, const char *mode)
|
||||
{
|
||||
FILE *f;
|
||||
char etalon_bf_id[] = APGBF_ID;
|
||||
char etalon_bf_ver[] = APGBF_VERSION;
|
||||
struct apg_bf_hdr bf_hdr;
|
||||
if ((f = fopen (f_name, "r+")) == NULL)
|
||||
|
||||
if ((f = fopen (f_name, mode)) == NULL)
|
||||
return(NULL);
|
||||
if(fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) < APGBFHDRSIZE)
|
||||
if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1)
|
||||
if (ferror (f) != 0)
|
||||
return(NULL);
|
||||
if( (bf_hdr.id[0] != 'A') || (bf_hdr.id[1] != 'P') ||
|
||||
(bf_hdr.id[2] != 'G') || (bf_hdr.id[3] != 'B') ||
|
||||
(bf_hdr.id[4] != 'F') || (bf_hdr.id[5] != '1') ||
|
||||
(bf_hdr.id[6] != '0') || (bf_hdr.id[7] != '0') ) return (NULL);
|
||||
if ((bf_hdr.id[0] != etalon_bf_id[0]) || (bf_hdr.id[1] != etalon_bf_id[1]) ||
|
||||
(bf_hdr.id[2] != etalon_bf_id[2]) || (bf_hdr.id[3] != etalon_bf_id[3]) ||
|
||||
(bf_hdr.id[4] != etalon_bf_id[4]) )
|
||||
return (NULL);
|
||||
if ((bf_hdr.version[0] != etalon_bf_ver[0]) ||
|
||||
(bf_hdr.version[1] != etalon_bf_ver[1]) ||
|
||||
(bf_hdr.version[2] != etalon_bf_ver[2]) )
|
||||
return (NULL);
|
||||
else
|
||||
{
|
||||
if (fseek (f, 0, SEEK_SET) == -1)
|
||||
@@ -142,70 +237,117 @@ open_filter(char * f_name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** close_filter - close APG Bloom filter file
|
||||
** close filter file
|
||||
** INPUT:
|
||||
** FILE * f_dsk - filter file pointer
|
||||
** OUTPUT:
|
||||
** int - same as fclose() return value
|
||||
*/
|
||||
int
|
||||
close_filter(FILE *f_dsk)
|
||||
{
|
||||
return(fclose(f_dsk));
|
||||
}
|
||||
|
||||
/*
|
||||
** get_filtersize - get APG Bloom filter size
|
||||
** INPUT:
|
||||
** FILE *f - filter file descriptor
|
||||
** RETURN:
|
||||
** OUTPUT:
|
||||
** h_val - size of APG Bloom filter.
|
||||
** 0 - something wrong
|
||||
*/
|
||||
h_val
|
||||
get_filtersize(FILE * f)
|
||||
{
|
||||
struct apg_bf_hdr bf_hdr;
|
||||
fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f);
|
||||
fseek (f, 0, SEEK_SET);
|
||||
if (fseek (f, 0, SEEK_SET) == -1)
|
||||
return(0);
|
||||
if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1)
|
||||
if (ferror (f) != 0)
|
||||
return(0);
|
||||
if (fseek (f, 0, SEEK_SET) == -1)
|
||||
return(0);
|
||||
return( (h_val)bf_hdr.fs);
|
||||
}
|
||||
|
||||
/*
|
||||
** get_filtermode - get APG Bloom filter mode
|
||||
** INPUT:
|
||||
** FILE *f - filter file descriptor
|
||||
** OUTPUT:
|
||||
** f_mode - APG Bloom filter mode.
|
||||
** 0 - something wrong
|
||||
*/
|
||||
f_mode
|
||||
get_filtermode(FILE *f)
|
||||
{
|
||||
struct apg_bf_hdr bf_hdr;
|
||||
if (fseek (f, 0, SEEK_SET) == -1)
|
||||
return(0);
|
||||
if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1)
|
||||
if (ferror (f) != 0)
|
||||
return(0);
|
||||
if (fseek (f, 0, SEEK_SET) == -1)
|
||||
return(0);
|
||||
return( (f_mode)bf_hdr.mode);
|
||||
}
|
||||
|
||||
/*
|
||||
** create_filter - create initial(empty) filter file
|
||||
** 4 - number of hash functions
|
||||
** 5 - number of hash functions
|
||||
** 0.0001 (0.01%) - probability of false positives
|
||||
** INPUT:
|
||||
** char * f_name - filter filename
|
||||
** unsigned long int n_words - number of words in filter
|
||||
** RETURN:
|
||||
** OUTPUT:
|
||||
** FILE * - filter file descriptor
|
||||
** NULL - something wrong
|
||||
***********************************************************
|
||||
** NOTES:
|
||||
** n - number of words in the filter
|
||||
** N - size of filter(?)
|
||||
**
|
||||
** a=(1-(4/N))^n
|
||||
** 0.0001=(1-a)^4 ==> 1-a=0.1 ==> a=0.9 ==>
|
||||
** 0.9=(1-(4/N))^n ==> 0.9^(1/n)=1-(4/N) ==>
|
||||
** 0.0001=(1-a)^5 ==> 1-a=0.15849... ==> a=0.84151068 ==>
|
||||
** 0.84151068=(1-(5/N))^n ==> 0.84151068^(1/n)=1-(5/N) ==>
|
||||
**
|
||||
** N=4/(1-[0.9^(1/n)])
|
||||
** N=5/(1-[0.84151068^(1/n)])
|
||||
**
|
||||
** 4
|
||||
** N = ----------
|
||||
** 5
|
||||
** N = -----------------
|
||||
** 1/n
|
||||
** 1 - 0.9
|
||||
** 1 - 0.84151068
|
||||
*/
|
||||
FILE *
|
||||
create_filter(char * f_name, unsigned long int n_words)
|
||||
create_filter(char * f_name, unsigned long int n_words, f_mode mode)
|
||||
{
|
||||
FILE *f;
|
||||
char zero = 0x00;
|
||||
long int i = 0L;
|
||||
char etalon_bf_id[] = APGBF_ID;
|
||||
char etalon_bf_ver[] = APGBF_VERSION;
|
||||
struct apg_bf_hdr bf_hdr;
|
||||
|
||||
bf_hdr.id[0] = 'A';
|
||||
bf_hdr.id[1] = 'P';
|
||||
bf_hdr.id[2] = 'G';
|
||||
bf_hdr.id[3] = 'B';
|
||||
bf_hdr.id[4] = 'F';
|
||||
bf_hdr.id[5] = '1';
|
||||
bf_hdr.id[6] = '0';
|
||||
bf_hdr.id[7] = '0';
|
||||
bf_hdr.id[0] = etalon_bf_id[0];
|
||||
bf_hdr.id[1] = etalon_bf_id[1];
|
||||
bf_hdr.id[2] = etalon_bf_id[2];
|
||||
bf_hdr.id[3] = etalon_bf_id[3];
|
||||
bf_hdr.id[4] = etalon_bf_id[4];
|
||||
|
||||
bf_hdr.version[0] = etalon_bf_ver[0];
|
||||
bf_hdr.version[1] = etalon_bf_ver[1];
|
||||
bf_hdr.version[2] = etalon_bf_ver[2];
|
||||
|
||||
bf_hdr.fs = FSIZE_BIT(n_words);
|
||||
|
||||
bf_hdr.mode = mode;
|
||||
|
||||
if ((f = fopen (f_name, "w+")) == NULL)
|
||||
return(NULL);
|
||||
|
||||
if (fwrite ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) < APGBFHDRSIZE)
|
||||
if (fwrite ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1)
|
||||
if (ferror (f) != 0)
|
||||
return(NULL);
|
||||
|
||||
@@ -223,18 +365,25 @@ create_filter(char * f_name, unsigned long int n_words)
|
||||
** count_words - count words in plain dictionary file
|
||||
** INPUT:
|
||||
** FILE *dict_file -plain dicionary file descriptor
|
||||
** RETURN:
|
||||
** OUTPUT:
|
||||
** h_val - amount of words in dictionary file
|
||||
** 0 - something wrong
|
||||
*/
|
||||
h_val
|
||||
count_words(FILE *dict_file)
|
||||
{
|
||||
h_val i = 0L; /* word counter */
|
||||
char *string; /* temp string holder */
|
||||
string = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||
char *tmp; /* just tmp char pointer and nothing more it has no memory assigned */
|
||||
if ((string = (char *) calloc(1,MAX_DICT_STRLEN)) == NULL)
|
||||
return(0);
|
||||
while ((fgets(string, MAX_DICT_STRLEN, dict_file) != NULL))
|
||||
i++;
|
||||
fseek (dict_file, 0, SEEK_SET);
|
||||
{
|
||||
tmp = (char *)strtok (string," \t\n\0");
|
||||
if (tmp != NULL) i++;
|
||||
}
|
||||
if (fseek (dict_file, 0, SEEK_SET) == -1)
|
||||
return (0);
|
||||
free ((void *) string);
|
||||
return (i);
|
||||
}
|
||||
@@ -245,19 +394,19 @@ count_words(FILE *dict_file)
|
||||
** INPUT:
|
||||
** char *word - word to hash
|
||||
** h_val *b - pointer to bitnumber array
|
||||
** RETURN
|
||||
** OUTPUT:
|
||||
** h_val * - pointer to bitnumber array
|
||||
*/
|
||||
h_val *
|
||||
hash2bit(char * word, h_val *b)
|
||||
{
|
||||
struct apg_MD5Context context;
|
||||
unsigned char cs[16];
|
||||
apg_SHA_INFO context;
|
||||
BYTE cs[SHA_DIGESTSIZE];
|
||||
|
||||
apg_MD5Init (&context);
|
||||
apg_MD5Update (&context, word, strlen(word));
|
||||
apg_MD5Final (cs, &context);
|
||||
return ( (h_val *)memcpy( (void *)b, (void *)&cs[0], 16));
|
||||
apg_shaInit (&context);
|
||||
apg_shaUpdate (&context, (BYTE *)word, strlen(word));
|
||||
apg_shaFinal (&context, cs);
|
||||
return ( (h_val *)memcpy( (void *)b, (void *)&cs[0], SHA_DIGESTSIZE));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -265,7 +414,7 @@ hash2bit(char * word, h_val *b)
|
||||
** INPUT:
|
||||
** FILE *f - file descriptor
|
||||
** h_val bitnum - bit number
|
||||
** RETURN:
|
||||
** OUTPUT:
|
||||
** int
|
||||
** 0,1 - bit value
|
||||
** -1 - something wrong
|
||||
@@ -297,7 +446,7 @@ getbit(FILE * f, h_val bitnum)
|
||||
** INPUT:
|
||||
** FILE *f - file descriptor
|
||||
** h_val bitnum - bit number
|
||||
** RETURN:
|
||||
** OUTPUT:
|
||||
** int
|
||||
** 0 - everything OK
|
||||
** -1 - something wrong
|
||||
|
||||
51
bloom.h
51
bloom.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 2001
|
||||
** Copyright (c) 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,43 +38,54 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
/* Add prototype support. */
|
||||
#ifndef PROTO
|
||||
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
|
||||
#define PROTO(ARGS) ARGS
|
||||
#else
|
||||
#define PROTO(ARGS) ()
|
||||
#endif
|
||||
#endif
|
||||
#include "sha/sha.h"
|
||||
|
||||
#include "md5/md5.h"
|
||||
#define APGBF_ID "APGBF"
|
||||
#define APGBF_VERSION "110" /* Version 1.1.0 */
|
||||
|
||||
#define FSIZE_BIT(word_count) ((unsigned long int)(4.0/(1.0-pow( 0.9,1.0/((double)word_count)))))
|
||||
#define FSIZE_BYTE(word_count) ((((unsigned long int)(4.0/(1.0-pow( 0.9,1.0/((double)word_count)))))/8)+1)
|
||||
/* Bloom filter modes flags */
|
||||
#define BF_CASE_INSENSITIVE 0x01
|
||||
#define BF_RESERVED1 0x02
|
||||
#define BF_RESERVED2 0x04
|
||||
#define BF_RESERVED3 0x08
|
||||
#define BF_RESERVED4 0x10
|
||||
#define BF_RESERVED5 0x20
|
||||
#define BF_RESERVED6 0x40
|
||||
#define BF_RESERVED7 0x80
|
||||
|
||||
#define APGBFHDRSIZE 12
|
||||
#define APGBFHDRSIZE 13
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define MAX_DICT_STRLEN 255
|
||||
#define H_NUM 5
|
||||
|
||||
typedef unsigned long int h_val; /* should be 32-bit */
|
||||
typedef unsigned short int flag;
|
||||
typedef unsigned char f_mode;
|
||||
|
||||
struct apg_bf_hdr {
|
||||
char id[8];
|
||||
unsigned long int fs;
|
||||
char id[5]; /* filter ID */
|
||||
char version[3]; /* filter version */
|
||||
unsigned long int fs; /* filter size */
|
||||
f_mode mode; /* filter flags */
|
||||
};
|
||||
|
||||
extern int insert_word(char *word, FILE *file, h_val filter_size);
|
||||
extern int check_word(char *word, FILE *file, h_val filter_size);
|
||||
extern FILE * create_filter(char * f_name, unsigned long int n_words);
|
||||
extern FILE * open_filter(char * f_name);
|
||||
extern int insert_word(char *word, FILE *file, h_val filter_size, f_mode mode);
|
||||
extern int check_word(char *word, FILE *file, h_val filter_size, f_mode mode);
|
||||
extern FILE * create_filter(char * f_name, unsigned long int n_words, f_mode mode);
|
||||
extern FILE * open_filter(char * f_name, const char *mode);
|
||||
extern int close_filter(FILE *f_dsk);
|
||||
extern h_val get_filtersize(FILE *f);
|
||||
extern f_mode get_filtermode(FILE *f);
|
||||
extern h_val count_words(FILE *dict_file);
|
||||
|
||||
#ifdef APGBFM
|
||||
extern int print_flt_info(FILE * filter);
|
||||
#endif /* APGBFM */
|
||||
#endif /* APG_BLOOM_H */
|
||||
407
convert.c
Normal file
407
convert.c
Normal file
@@ -0,0 +1,407 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1.Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2.Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3.The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#ifndef APGBFM
|
||||
# include "errs.h"
|
||||
# include "randpass.h"
|
||||
#endif
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
/*
|
||||
** GLOBALS
|
||||
*/
|
||||
|
||||
/* small letters */
|
||||
char let[26] =
|
||||
{
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'w', 'z'
|
||||
};
|
||||
/* capital letters */
|
||||
char clet[26] =
|
||||
{
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
||||
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'W', 'Z'
|
||||
};
|
||||
|
||||
/*
|
||||
** FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
** decapitalize() - This routine replaces all capital letters
|
||||
** to small letters in the word:
|
||||
** INPUT:
|
||||
** char * - word.
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
decapitalize (char *word)
|
||||
{
|
||||
int i = 0; /* counter */
|
||||
int j = 0; /* counter */
|
||||
int str_len = strlen(word);
|
||||
for(j = 0; j < str_len; j++)
|
||||
for(i=0; i < 26; i++)
|
||||
if(word[j] == clet[i])
|
||||
word[j] = let[i];
|
||||
}
|
||||
|
||||
#ifndef APGBFM
|
||||
/*
|
||||
** capitalize() - This routine designed to modify sullable like this:
|
||||
** adel ----> Adel
|
||||
** dot ----> Dot
|
||||
** etc.
|
||||
** INPUT:
|
||||
** char * - syllable.
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
capitalize (char *syllable)
|
||||
{
|
||||
char tmp = 0x00;
|
||||
int i = 0;
|
||||
if ( randint(2) == TRUE)
|
||||
{
|
||||
(void)memcpy((void *)&tmp, (void *)syllable, sizeof(tmp));
|
||||
for(i=0; i < 26; i++)
|
||||
if ( let[i] == tmp )
|
||||
if (is_restricted_symbol(clet[i]) != TRUE)
|
||||
(void)memcpy ((void *)syllable, (void *)&clet[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** numerize() - This routine designed to modify single-letter
|
||||
** syllable like this:
|
||||
** a ----> 1 or 2 or 3 etc.
|
||||
** u ----> 1 or 2 or 3 etc.
|
||||
** etc.
|
||||
** INPUT:
|
||||
** char * - single-letter syllable
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
numerize (char *syllable)
|
||||
{
|
||||
char *tmp;
|
||||
if ( (tmp = (char *)calloc(1, 4)) == NULL)
|
||||
err_sys_fatal("calloc");
|
||||
if ( strlen (syllable) == 1 )
|
||||
{
|
||||
(void) gen_rand_symbol(tmp, S_NB);
|
||||
(void)memcpy ((void *)syllable, (void *)tmp, 1);
|
||||
}
|
||||
free ((void *)tmp);
|
||||
}
|
||||
/*
|
||||
** specialize() - This routine designed to modify single-letter syllable
|
||||
** like this:
|
||||
** a ----> # or $ or % etc.
|
||||
** u ----> # or $ or % etc.
|
||||
** etc.
|
||||
** INPUT:
|
||||
** char * - single-letter syllable.
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
specialize (char *syllable)
|
||||
{
|
||||
char *tmp;
|
||||
if ( (tmp = (char *)calloc(1, 4)) == NULL)
|
||||
err_sys_fatal("calloc");
|
||||
if ( strlen (syllable) == 1 )
|
||||
{
|
||||
(void) gen_rand_symbol(tmp, S_SS);
|
||||
(void)memcpy ((void *)syllable, (void *)tmp, 1);
|
||||
}
|
||||
free ((void *)tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
** symb2name - convert symbol to it's name
|
||||
** INPUT:
|
||||
** char * - one symbol syllable
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
symb2name(char * syllable, char * h_syllable)
|
||||
{
|
||||
struct ssymb_names
|
||||
{
|
||||
char symbol;
|
||||
char *name;
|
||||
};
|
||||
static struct ssymb_names ssn[42] =
|
||||
{
|
||||
{'1',"ONE"},
|
||||
{'2',"TWO"},
|
||||
{'3',"THREE"},
|
||||
{'4',"FOUR"},
|
||||
{'5',"FIVE"},
|
||||
{'6',"SIX"},
|
||||
{'7',"SEVEN"},
|
||||
{'8',"EIGHT"},
|
||||
{'9',"NINE"},
|
||||
{'0',"ZERO"},
|
||||
{33, "EXCLAMATION_POINT"},
|
||||
{34, "QUOTATION_MARK"},
|
||||
{35, "CROSSHATCH"},
|
||||
{36, "DOLLAR_SIGN"},
|
||||
{37, "PERCENT_SIGN"},
|
||||
{38, "AMPERSAND"},
|
||||
{39, "APOSTROPHE"},
|
||||
{40, "LEFT_PARENTHESIS"},
|
||||
{41, "RIGHT_PARENTHESIS"},
|
||||
{42, "ASTERISK"},
|
||||
{43, "PLUS_SIGN"},
|
||||
{44, "COMMA"},
|
||||
{45, "HYPHEN"},
|
||||
{46, "PERIOD"},
|
||||
{47, "SLASH"},
|
||||
{58, "COLON"},
|
||||
{59, "SEMICOLON"},
|
||||
{60, "LESS_THAN"},
|
||||
{61, "EQUAL_SIGN"},
|
||||
{62, "GREATER_THAN"},
|
||||
{63, "QUESTION_MARK"},
|
||||
{64, "AT_SIGN"},
|
||||
{91, "LEFT_BRACKET"},
|
||||
{92, "BACKSLASH"},
|
||||
{93, "RIGHT_BRACKET"},
|
||||
{94, "CIRCUMFLEX"},
|
||||
{95, "UNDERSCORE"},
|
||||
{96, "GRAVE"},
|
||||
{123, "LEFT_BRACE"},
|
||||
{124, "VERTICAL_BAR"},
|
||||
{125, "RIGHT_BRACE"},
|
||||
{126, "TILDE"}
|
||||
};
|
||||
int i = 0;
|
||||
int flag = FALSE;
|
||||
|
||||
if (strlen(syllable) == 1)
|
||||
{
|
||||
for (i = 0; i < 42; i++)
|
||||
{
|
||||
if(*syllable == ssn[i].symbol)
|
||||
{
|
||||
(void)memcpy((void*)h_syllable, (void*)ssn[i].name, strlen(ssn[i].name));
|
||||
flag = TRUE;
|
||||
}
|
||||
}
|
||||
if (flag != TRUE)
|
||||
(void)memcpy((void*)h_syllable, (void*)syllable, strlen(syllable));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** spell_word - spell the word
|
||||
** INPUT:
|
||||
** char * - pointer to the word
|
||||
** char * - pointer to the spelled word
|
||||
** OUTPUT:
|
||||
** char * - pointer to the spelled word
|
||||
** NULL - something is wrong
|
||||
** NOTES:
|
||||
** You should free() memory pointed by spelled_word after each use of spell_word
|
||||
*/
|
||||
char *
|
||||
spell_word(char * word, char * spelled_word)
|
||||
{
|
||||
struct char_spell
|
||||
{
|
||||
char symbol;
|
||||
char *name;
|
||||
};
|
||||
static struct char_spell cs[94] =
|
||||
{
|
||||
{'1',"ONE" },
|
||||
{'2',"TWO" },
|
||||
{'3',"THREE" },
|
||||
{'4',"FOUR" },
|
||||
{'5',"FIVE" },
|
||||
{'6',"SIX" },
|
||||
{'7',"SEVEN" },
|
||||
{'8',"EIGHT" },
|
||||
{'9',"NINE" },
|
||||
{'0',"ZERO" },
|
||||
{'A', "Alfa" },
|
||||
{'B', "Bravo" },
|
||||
{'C', "Charlie" },
|
||||
{'D', "Delta" },
|
||||
{'E', "Echo" },
|
||||
{'F', "Foxtrot" },
|
||||
{'G', "Golf" },
|
||||
{'H', "Hotel" },
|
||||
{'I', "India" },
|
||||
{'J', "Juliett" },
|
||||
{'K', "Kilo" },
|
||||
{'L', "Lima" },
|
||||
{'M', "Mike" },
|
||||
{'N', "November" },
|
||||
{'O', "Oscar" },
|
||||
{'P', "Papa" },
|
||||
{'Q', "Quebec" },
|
||||
{'R', "Romeo" },
|
||||
{'S', "Sierra" },
|
||||
{'T', "Tango" },
|
||||
{'U', "Uniform" },
|
||||
{'V', "Victor" },
|
||||
{'W', "Whiskey" },
|
||||
{'X', "X_ray" },
|
||||
{'Y', "Yankee" },
|
||||
{'Z', "Zulu" },
|
||||
{'a', "alfa" },
|
||||
{'b', "bravo" },
|
||||
{'c', "charlie" },
|
||||
{'d', "delta" },
|
||||
{'e', "echo" },
|
||||
{'f', "foxtrot" },
|
||||
{'g', "golf" },
|
||||
{'h', "hotel" },
|
||||
{'i', "india" },
|
||||
{'j', "juliett" },
|
||||
{'k', "kilo" },
|
||||
{'l', "lima" },
|
||||
{'m', "mike" },
|
||||
{'n', "november" },
|
||||
{'o', "oscar" },
|
||||
{'p', "papa" },
|
||||
{'q', "quebec" },
|
||||
{'r', "romeo" },
|
||||
{'s', "sierra" },
|
||||
{'t', "tango" },
|
||||
{'u', "uniform" },
|
||||
{'v', "victor" },
|
||||
{'w', "whiskey" },
|
||||
{'x', "x_ray" },
|
||||
{'y', "yankee" },
|
||||
{'z', "zulu" },
|
||||
{33, "EXCLAMATION_POINT"},
|
||||
{34, "QUOTATION_MARK" },
|
||||
{35, "CROSSHATCH" },
|
||||
{36, "DOLLAR_SIGN" },
|
||||
{37, "PERCENT_SIGN" },
|
||||
{38, "AMPERSAND" },
|
||||
{39, "APOSTROPHE" },
|
||||
{40, "LEFT_PARENTHESIS" },
|
||||
{41, "RIGHT_PARENTHESIS"},
|
||||
{42, "ASTERISK" },
|
||||
{43, "PLUS_SIGN" },
|
||||
{44, "COMMA" },
|
||||
{45, "HYPHEN" },
|
||||
{46, "PERIOD" },
|
||||
{47, "SLASH" },
|
||||
{58, "COLON" },
|
||||
{59, "SEMICOLON" },
|
||||
{60, "LESS_THAN" },
|
||||
{61, "EQUAL_SIGN" },
|
||||
{62, "GREATER_THAN" },
|
||||
{63, "QUESTION_MARK" },
|
||||
{64, "AT_SIGN" },
|
||||
{91, "LEFT_BRACKET" },
|
||||
{92, "BACKSLASH" },
|
||||
{93, "RIGHT_BRACKET" },
|
||||
{94, "CIRCUMFLEX" },
|
||||
{95, "UNDERSCORE" },
|
||||
{96, "GRAVE" },
|
||||
{123, "LEFT_BRACE" },
|
||||
{124, "VERTICAL_BAR" },
|
||||
{125, "RIGHT_BRACE" },
|
||||
{126, "TILDE" }
|
||||
};
|
||||
int s_length = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int word_len = strlen(word);
|
||||
char * tmp_ptr;
|
||||
char hyphen = '-';
|
||||
char zero = 0x00;
|
||||
|
||||
/* Count the length of the spelled word */
|
||||
for (i=0; i <= word_len; i++)
|
||||
for (j=0; j < 94; j++)
|
||||
if (word[i] == cs[j].symbol)
|
||||
{
|
||||
s_length = s_length + strlen(cs[j].name) + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Allocate memory for spelled word */
|
||||
if ( (spelled_word = (char *)calloc(1, (size_t)s_length)) == NULL)
|
||||
return(NULL);
|
||||
|
||||
/* Construct spelled word */
|
||||
tmp_ptr = spelled_word;
|
||||
|
||||
for (i=0; i < word_len; i++)
|
||||
for (j=0; j < 94; j++)
|
||||
if (word[i] == cs[j].symbol)
|
||||
{
|
||||
(void) memcpy((void *)tmp_ptr, (void *)cs[j].name, strlen(cs[j].name));
|
||||
tmp_ptr = tmp_ptr + strlen(cs[j].name);
|
||||
/* Place the hyphen after each symbol */
|
||||
(void) memcpy((void *)(tmp_ptr), (void *)&hyphen, 1);
|
||||
tmp_ptr = tmp_ptr + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Remove hyphen at the end of the word */
|
||||
tmp_ptr = tmp_ptr - 1;
|
||||
(void) memcpy((void *)(tmp_ptr), (void *)&zero, 1);
|
||||
|
||||
return (spelled_word);
|
||||
}
|
||||
|
||||
#endif /* APGBFM */
|
||||
43
convert.h
Normal file
43
convert.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1.Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2.Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3.The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef APG_CONVERT_H
|
||||
#define APG_CONVERT_H 1
|
||||
|
||||
void decapitalize (char *word);
|
||||
|
||||
#ifndef APGBFM
|
||||
void capitalize (char *syllable);
|
||||
void numerize (char *syllable);
|
||||
void specialize (char *syllable);
|
||||
void symb2name(char * syllable, char * h_syllable);
|
||||
char* spell_word(char * word, char * spelled_word);
|
||||
#endif /* APGBFM */
|
||||
|
||||
#endif /* APG_CONVERT_H */
|
||||
73
doc/APG_TIPS
73
doc/APG_TIPS
@@ -44,3 +44,76 @@ genpw () {
|
||||
|
||||
until genpw; do : ; done
|
||||
----------[cut here]
|
||||
|
||||
Note:
|
||||
Since apg-2.1.0b0 you can use [-e char_string] option
|
||||
to do the same thing.
|
||||
|
||||
#######################################################
|
||||
# 2. APG and xinetd
|
||||
# by Tomaz Zupan <tomaz.zupan@orpo.si>
|
||||
#######################################################
|
||||
|
||||
I use xinetd instead of inetd as per your documentation,
|
||||
so I hope you (or anyone using apgd) might find usefull
|
||||
this xinetd.conf entry. Arguments are tailored according
|
||||
to my needs, but that shouldn't be a problem for anyone
|
||||
that read man pages ...
|
||||
|
||||
--------> [cut here]
|
||||
# default: on
|
||||
# description: APGD is a deamon that returns randomly generated password
|
||||
service pwdgen
|
||||
{
|
||||
port = 129
|
||||
socket_type = stream
|
||||
wait = no
|
||||
only_from = localhost
|
||||
user = pismonosa
|
||||
server = /usr/local/sbin/apgd
|
||||
server_args = -M ln -n 1 -m 6 -x 8 -a 1
|
||||
instances = 1
|
||||
log_on_failure += USERID
|
||||
disable = no
|
||||
}
|
||||
--------> [cut here]
|
||||
|
||||
######################################################
|
||||
# 3. APG and PHP script
|
||||
# from http://www.forth.com/rick/
|
||||
######################################################
|
||||
|
||||
After building and installing APG, you must make it
|
||||
easily available. The simplest is as a web-page
|
||||
reference. The simplest way to do this is by a php
|
||||
script located in the root of the web server's data
|
||||
tree:
|
||||
|
||||
--------> [cut here]
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<?
|
||||
$foo = `/usr/local/bin/apg -n 20`;
|
||||
echo $foo
|
||||
?>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
--------> [cut here]
|
||||
|
||||
######################################################
|
||||
# 4. APG v2.1.0b0 and [R,r] letters in mode string
|
||||
# by Adel I. Mirzazhanov <a-del@iname.com>
|
||||
######################################################
|
||||
Since version 2.1.0b0 You can not use symbols R,r to ask
|
||||
APG not to generate symbols (' ` | \ ? $ ") when You
|
||||
plan to use special symbol set for password generation.
|
||||
|
||||
But You stil can get the same resault with new option
|
||||
[-e char_string] (see apg(1)). Just run APG like this:
|
||||
|
||||
apg -a1 -M s -e \'\`\|\?\$\"\\
|
||||
|
||||
This method will work for random password generation
|
||||
only.
|
||||
|
||||
161
doc/man/apg.1
161
doc/man/apg.1
@@ -2,17 +2,17 @@
|
||||
.\" Licensed under BSD-like License.
|
||||
.\" Created by Adel I. Mirzazhanov
|
||||
.\"
|
||||
.TH APG 1 "2001 Mar 18" "Automated Password Generator" "User Manual"
|
||||
.TH APG 1 "2003 Jun 19" "Automated Password Generator" "User Manual"
|
||||
.SH NAME
|
||||
apg
|
||||
\- generates several random passwords
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B apg
|
||||
[\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP]
|
||||
[\fB-a algorithm\fP] [\fB-C\fP] [\fB-L\fP] [\fB-S\fP] [\fB-N\fP] [\fB-R\fP]
|
||||
[\fB-M mode\fP] [\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP] [\fB-n num_of_pass\fP]
|
||||
[\fB-s\fP] [\fB-c cl_seed\fP] [\fB-d\fP] [\fB-y\fP] [\fB-h\fP] [\fB-v\fP]
|
||||
[\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]
|
||||
.PP
|
||||
.SH DESCRIPTION
|
||||
.B apg
|
||||
@@ -51,6 +51,8 @@ or
|
||||
.B RFC1750
|
||||
with exception that it uses
|
||||
.I CAST
|
||||
or
|
||||
.I SHA-1
|
||||
instead of
|
||||
.I Triple DES.
|
||||
It uses local time with precision of microseconds (see
|
||||
@@ -59,16 +61,21 @@ initial random seed.
|
||||
.PP
|
||||
.B apg
|
||||
also have the ability to check generated password quality using
|
||||
dictionary. You can use this ability if you specify command-line option
|
||||
dictionary. You can use this ability if you specify command-line options
|
||||
.B -r
|
||||
.I dictfile
|
||||
where \fIdictfile\fP is dictionary file name. In that dictionary you may place words
|
||||
or
|
||||
.B -b
|
||||
.I filtername
|
||||
where \fIdictfile\fP is the dictionary file name and \fIfiltername\fP is the
|
||||
name of Bloom filter file. In that dictionary 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
|
||||
.I dictionary password crackers.
|
||||
This check is 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
|
||||
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
|
||||
techniques to check passwords (like pattern check) just to make life easier.
|
||||
.sp
|
||||
@@ -76,64 +83,53 @@ techniques to check passwords (like pattern check) just to make life easier.
|
||||
.TP
|
||||
.B -M mode
|
||||
Use symbolsets specified with \fBmode\fP for password generation.
|
||||
\fBmode\fP is a text string consisting of characters \fBS[s]\fP, \fBN[n]\fP,
|
||||
\fBC[c]\fP, \fBL[l]\fP,\fBR[r]\fP. Where:
|
||||
\fBmode\fP is a text string consisting of characters \fBS\fP, \fBs\fP, \fBN\fP, \fBn\fP,
|
||||
\fBC\fP, \fBc\fP, \fBL\fP, \fBl\fP. Where:
|
||||
.RS
|
||||
.TP
|
||||
.B S[s]
|
||||
use special symbol set (for random character password generation algorithm only).
|
||||
.B S
|
||||
generator \fBmust\fP use special symbol set for every generated password.
|
||||
.TP
|
||||
.B N[n]
|
||||
use numeral symbol set.
|
||||
.B s
|
||||
generator \fBshould\fP use special symbol set for password generation.
|
||||
.TP
|
||||
.B C[c]
|
||||
use capital symbol set.
|
||||
.B N
|
||||
generator \fBmust\fP use numeral symbol set for every generated password.
|
||||
.TP
|
||||
.B L[l]
|
||||
use small letters symbol set (always present if pronounceable password
|
||||
.B n
|
||||
generator \fBshould\fP use numeral symbol set for password generation.
|
||||
.TP
|
||||
.B C
|
||||
generator \fBmust\fP use capital symbol set for every generated password.
|
||||
.TP
|
||||
.B c
|
||||
generator \fBshould\fP use capital symbol set for password generation.
|
||||
.TP
|
||||
.B L
|
||||
generator \fBmust\fP use small letters symbol set for every generated password
|
||||
(always present if pronounceable password
|
||||
generation algorithm is used).
|
||||
.TP
|
||||
.B R[r]
|
||||
the same as \fBS[s]\fP but it does not generate symbols \fB`\fP, \fB'\fP,
|
||||
\fB"\fP, \fB|\fP, \fB$\fP, \fBbackslash\fP, \fB?\fP. Useful for password generation in
|
||||
a shell script. (For random character password generation algorithm only).
|
||||
.B l
|
||||
generator \fBshould\fP use small letters symbol set for password generation.
|
||||
.TP
|
||||
.B R,r
|
||||
not supported any more. Use \fB-E char_string\fP option instead.
|
||||
.RE
|
||||
.RS
|
||||
.br
|
||||
\fBmode\fP can not be more then 5 characters in
|
||||
\fBmode\fP can not be more than 4 characters in
|
||||
length.
|
||||
.PP
|
||||
.B Note:
|
||||
.br
|
||||
Usage of L, M, N, C will slow down password generation process.
|
||||
.PP
|
||||
.B Examples:
|
||||
.br
|
||||
\fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP
|
||||
.PP
|
||||
\fB-M mode\fP is the new style password generation mode definition, but the old style
|
||||
options(-C, -N, -S, -L, -R) are also supported.
|
||||
.RE
|
||||
.TP
|
||||
.B -S
|
||||
use special symbol set. For random character password generation algorithm only.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -R
|
||||
the same as \fB-S\fP but it does not generate symbols \fB`\fP, \fB'\fP,
|
||||
\fB"\fP, \fB|\fP, \fB$\fP, \fBbackslash\fP, \fB?\fP. Useful for password generation in
|
||||
a shell script. For random character password generation algorithm only.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -N
|
||||
use numeral symbol set.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -C
|
||||
use capital symbol set.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -L
|
||||
use small letters symbol set. Always present if pronounceable password
|
||||
generation algorithm is used.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -a algorithm
|
||||
use
|
||||
.B algorithm
|
||||
@@ -146,6 +142,36 @@ for password generation.
|
||||
- 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
|
||||
can be recognized by shell (apostrophe, quotes, dollar sign, etc.) in \fBchar_string\fP use
|
||||
the backslashed versions.
|
||||
.RS
|
||||
.PP
|
||||
.B Examples:
|
||||
.PP
|
||||
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
|
||||
.br
|
||||
\fB01111000\fP
|
||||
.br
|
||||
\fB11011101\fP
|
||||
.br
|
||||
.PP
|
||||
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
|
||||
.br
|
||||
\fBC8F78E06944AFD57FB9CB882BC\fP
|
||||
.br
|
||||
\fB8C8DF37CD792D36D056BBD5002\fP
|
||||
.br
|
||||
.RE
|
||||
.TP
|
||||
.B -r \fIdictfile\fP
|
||||
check generated passwords for their appearance in
|
||||
.I dictfile
|
||||
@@ -155,6 +181,14 @@ check generated passwords for their appearance in
|
||||
\fIfilter_file\fP. \fIfilter_file\fP should be created with \fBapgbfm\fP(1)
|
||||
utility.
|
||||
.TP
|
||||
.B -p min_substr_len
|
||||
this option tells \fBapg\fP(1) to check every substring of the generated
|
||||
password for appearance in \fIfilter_file\fP. If any of such substrings would
|
||||
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.
|
||||
.TP
|
||||
.B -s
|
||||
ask user for random sequence for password generation
|
||||
.TP
|
||||
@@ -177,29 +211,40 @@ number of passwords. Default is 6.
|
||||
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 6.
|
||||
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 8.
|
||||
Default maximum password length is 10.
|
||||
.TP
|
||||
.B -y
|
||||
print generated passwords and crypted passwords (see man \fBcrypt\fP(3))
|
||||
.TP
|
||||
.B -q
|
||||
quiet mode (do not print warnings)
|
||||
.TP
|
||||
.B -l
|
||||
spell genetated passwords. Useful when you want to read generated password by telephone.
|
||||
.RS
|
||||
.B WARNING:
|
||||
Think twice before read your password by phone.
|
||||
.RE
|
||||
.TP
|
||||
.B -t
|
||||
print pronunciation for generated pronounceable password
|
||||
.TP
|
||||
.B -h
|
||||
print help information and exit
|
||||
.TP
|
||||
.B -v
|
||||
print version information and exit
|
||||
.SH "DEFAULT OPTIONS"
|
||||
\fBapg -a 0 -N -C -L -n 6 -x 8 -m 6\fP (old style)
|
||||
.br
|
||||
\fBapg -a 0 -M NCL -n 6 -x 8 -m 6\fP (new style)
|
||||
\fBapg -a 0 -M sncl -n 6 -x 10 -m 8\fP (new style)
|
||||
.PP
|
||||
If you want to generate realy secure passwords,
|
||||
you should use option \fB-s\fP. To simlify
|
||||
If you want to generate really secure passwords,
|
||||
you should use option \fB-s\fP. To simplify
|
||||
.B apg
|
||||
usage, you can write a small shell script. For example:
|
||||
.br
|
||||
|
||||
@@ -2,29 +2,32 @@
|
||||
.\" Licensed under BSD-like License.
|
||||
.\" Created by Adel I. Mirzazhanov
|
||||
.\"
|
||||
.TH APGBFM 1 "2001 Mar 18" "Automated Password Generator" "User Manual"
|
||||
.TH APGBFM 1 "2003 Jun 19" "Automated Password Generator" "User Manual"
|
||||
.SH NAME
|
||||
apg
|
||||
apgbfm
|
||||
\- APG Bloom filter management program
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B apgbfm
|
||||
\fB-f\fP \fIfilter\fP \fB-n\fP \fBnumofwords\fP
|
||||
\fB-f\fP \fIfilter\fP \fB-n\fP \fBnumofwords\fP [\fB-q\fP] [\fB-s\fP]
|
||||
.br
|
||||
.B apgbfm
|
||||
\fB-f\fP \fIfilter\fP \fB-d\fP \fIdictfile\fP
|
||||
\fB-f\fP \fIfilter\fP \fB-d\fP \fIdictfile\fP [\fB-q\fP] [\fB-s\fP]
|
||||
.br
|
||||
.B apgbfm
|
||||
\fB-f\fP \fIfilter\fP \fB-a\fP \fBword\fP
|
||||
\fB-f\fP \fIfilter\fP \fB-a\fP \fBword\fP [\fB-q\fP]
|
||||
.br
|
||||
.B apgbfm
|
||||
\fB-f\fP \fIfilter\fP \fB-A\fP \fIdictfile\fP
|
||||
\fB-f\fP \fIfilter\fP \fB-A\fP \fIdictfile\fP [\fB-q\fP]
|
||||
.br
|
||||
.B apgbfm
|
||||
\fB-f\fP \fIfilter\fP \fB-c\fP \fBword\fP
|
||||
\fB-f\fP \fIfilter\fP \fB-c\fP \fBword\fP [\fB-q\fP]
|
||||
.br
|
||||
.B apgbfm
|
||||
\fB-f\fP \fIfilter\fP \fB-C\fP \fIdictfile\fP
|
||||
\fB-f\fP \fIfilter\fP \fB-C\fP \fIdictfile\fP [\fB-q\fP]
|
||||
.br
|
||||
.B apgbfm
|
||||
\fB-i\fP \fIfilter\fP
|
||||
.br
|
||||
.B apgbfm
|
||||
[\fB-v\fP] [\fB-h\fP]
|
||||
@@ -50,14 +53,14 @@ In simple words, \fBapgbfm\fP generates \fIn\fP hash values for every word and
|
||||
sets corresponding bits in filter file to 1. To check the word \fBapgbfm\fP
|
||||
generates the same hash functions for that word and if all \fIn\fP corresponding
|
||||
bits in filter file are set to 1 then it suppose that word exists in dicionary.
|
||||
\fBapgbfm\fP uses \fBmd5\fP as a hash function.
|
||||
\fBapgbfm\fP uses \fBSHA-1\fP as a hash function.
|
||||
.PP
|
||||
\fBapgbfm\fP can be used as standalone utility, not only with \fBapg\fP, or
|
||||
\fBapgd\fP.
|
||||
.PP
|
||||
.TP
|
||||
.B WARNING !!!
|
||||
This is the first release of \fBapgbfm\fP and filter file format can be changed
|
||||
Filter file format can be changed
|
||||
in the future. I'll try to make file formats compatible but i can not guaranty this.
|
||||
.TP
|
||||
.B WARNING !!!
|
||||
@@ -67,20 +70,30 @@ in the future. I'll try to make file formats compatible but i can not guaranty t
|
||||
.B -f \fIfilter\fP
|
||||
use \fIfilter\fP as the name for Bloom filter filename.
|
||||
.TP
|
||||
.B -i \fIfilter\fP
|
||||
print information about \fIfilter\fP.
|
||||
.TP
|
||||
.B -n numofwords
|
||||
create new empty filter for \fBnumofwords\fP number of words. Useful when you
|
||||
want to fill filter dynamicaly.
|
||||
.TP
|
||||
.B -d \fIdictfile\fP
|
||||
create new filter from \fIdictfile\fP. It may take a lot of time to
|
||||
generate filter from a big dictionary. To indicate that program is working
|
||||
\fBapgbfm\fP prints dot for every 100 words added in dictionary.
|
||||
generate filter from a big dictionary. In that dictionary 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 \fIdictionary password crackers\fP.
|
||||
This check is case sensitive. For example, if you want to reject word 'root',
|
||||
you should insert in \fIdictfile\fP words: root, Root, RoOt, ... , ROOT.
|
||||
To indicate that program is working \fBapgbfm\fP prints dot for every 100
|
||||
words added in dictionary.
|
||||
.TP
|
||||
.B -a word
|
||||
add \fBword\fP to the filter.
|
||||
.TP
|
||||
.B -A \fIdictfile\fP
|
||||
add all words from \fIdictfile\fP to the filter.
|
||||
add all words from \fIdictfile\fP to the filter. To indicate that program is working
|
||||
\fBapgbfm\fP prints dot for every 100 words added in dictionary.
|
||||
.TP
|
||||
.B -c word
|
||||
check \fBword\fP for appearance in the filter.
|
||||
@@ -88,6 +101,12 @@ check \fBword\fP for appearance in the filter.
|
||||
.B -C \fIdictfile\fP
|
||||
check every word from \fIdictfile\fP for appearance in the filter.
|
||||
.TP
|
||||
.B -q
|
||||
quiet mode.
|
||||
.TP
|
||||
.B -s
|
||||
create new filter in case-insensitive mode.
|
||||
.TP
|
||||
.B -v
|
||||
print version information.
|
||||
.TP
|
||||
|
||||
155
doc/man/apgd.8
155
doc/man/apgd.8
@@ -2,16 +2,17 @@
|
||||
.\" Licensed under BSD-like License.
|
||||
.\" Created by Adel I. Mirzazhanov
|
||||
.\"
|
||||
.TH APGD 8 "2001 Mar 18" "Automated Password Generator" "User Manual"
|
||||
.TH APGD 8 "2003 Jun 19" "Automated Password Generator" "User Manual"
|
||||
.SH NAME
|
||||
apgd
|
||||
\- server that generates several random passwords
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B apgd
|
||||
[\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP]
|
||||
[\fB-a algorithm\fP] [\fB-C\fP] [\fB-L\fP] [\fB-S\fP] [\fB-N\fP]
|
||||
[\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP] [\fB-n num_of_pass\fP]
|
||||
[\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-t\fP] [\fB-l\fP]
|
||||
.PP
|
||||
.SH DESCRIPTION
|
||||
.B apgd
|
||||
@@ -65,6 +66,8 @@ or
|
||||
.B RFC1750
|
||||
with exception that it uses
|
||||
.I CAST
|
||||
or
|
||||
.I SHA-1
|
||||
instead of
|
||||
.I Triple DES.
|
||||
It uses local time with precision of microseconds (see
|
||||
@@ -76,15 +79,20 @@ also have the ability to check generated password quality using
|
||||
dictionary. You can use this ability if you specify command-line option
|
||||
.B -r
|
||||
.I dictfile
|
||||
where \fIdictfile\fP is dictionary file name. In that dictionary you may place words
|
||||
or
|
||||
.B -b
|
||||
.I filtername
|
||||
where \fIdictfile\fP is dictionary file name and \fIfiltername\fP is the
|
||||
name of Bloom filter file. In that dictionary 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
|
||||
.I dictionary password crackers.
|
||||
This check is 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
|
||||
techniques to check passwords just to make life easier.
|
||||
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 techniques to check passwords just to make life easier.
|
||||
.PP
|
||||
.B apgd
|
||||
has the ability log user password generation activity and internal debug information. It does this
|
||||
@@ -112,64 +120,53 @@ See the \fBsyslogd\fP(8) and \fBsyslog.conf\fP(5) man pages for information on h
|
||||
.TP
|
||||
.B -M mode
|
||||
Use symbolsets specified with \fBmode\fP for password generation.
|
||||
\fBmode\fP is a text string consisting of characters \fBS[s]\fP, \fBN[n]\fP,
|
||||
\fBC[c]\fP, \fBL[l]\fP,\fBR[r]\fP. Where:
|
||||
\fBmode\fP is a text string consisting of characters \fBS\fP, \fBs\fP, \fBN\fP, \fBn\fP,
|
||||
\fBC\fP, \fBc\fP, \fBL\fP, \fBl\fP. Where:
|
||||
.RS
|
||||
.TP
|
||||
.B S[s]
|
||||
use special symbol set (for random character password generation algorithm only).
|
||||
.B S
|
||||
generator \fBmust\fP use special symbol set for every generated password.
|
||||
.TP
|
||||
.B N[n]
|
||||
use numeral symbol set.
|
||||
.B s
|
||||
generator \fBshould\fP use special symbol set for password generation.
|
||||
.TP
|
||||
.B C[c]
|
||||
use capital symbol set.
|
||||
.B N
|
||||
generator \fBmust\fP use numeral symbol set for every generated password.
|
||||
.TP
|
||||
.B L[l]
|
||||
use small letters symbol set (always present if pronounceable password
|
||||
.B n
|
||||
generator \fBshould\fP use numeral symbol set for password generation.
|
||||
.TP
|
||||
.B C
|
||||
generator \fBmust\fP use capital symbol set for every generated password.
|
||||
.TP
|
||||
.B c
|
||||
generator \fBshould\fP use capital symbol set for password generation.
|
||||
.TP
|
||||
.B L
|
||||
generator \fBmust\fP use small letters symbol set for every generated password
|
||||
(always present if pronounceable password
|
||||
generation algorithm is used).
|
||||
.TP
|
||||
.B R[r]
|
||||
the same as \fBS[s]\fP but it does not generate symbols \fB`\fP, \fB'\fP,
|
||||
\fB"\fP, \fB|\fP, \fB$\fP, \fBbackslash\fP, \fB?\fP. Useful for password generation in
|
||||
a shell script. (For random character password generation algorithm only).
|
||||
.B l
|
||||
generator \fBshould\fP use small letters symbol set for password generation.
|
||||
.TP
|
||||
.B R,r
|
||||
not supported any more. Use \fB-E char_string\fP option instead.
|
||||
.RE
|
||||
.RS
|
||||
.br
|
||||
\fBmode\fP can not be more then 5 characters in
|
||||
\fBmode\fP can not be more than 4 characters in
|
||||
length.
|
||||
.PP
|
||||
.B Note:
|
||||
.br
|
||||
Usage of L, M, N, C will slow down password generation process.
|
||||
.PP
|
||||
.B Examples:
|
||||
.br
|
||||
\fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP
|
||||
.PP
|
||||
\fB-M mode\fP is the new style password generation mode definition, but the old style
|
||||
options(-C, -N, -S, -L, -R) are also supported.
|
||||
.RE
|
||||
.TP
|
||||
.B -S
|
||||
use special symbol set. For random character password generation algorithm only.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -R
|
||||
the same as \fB-S\fP but it does not generate symbols \fB`\fP, \fB'\fP,
|
||||
\fB"\fP, \fB|\fP, \fB$\fP, \fBbackslash\fP, \fB?\fP. Useful for password generation in
|
||||
a shell script. For random character password generation algorithm only.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -N
|
||||
use numeral symbol set.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -C
|
||||
use capital symbol set.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -L
|
||||
use small letters symbol set. Always present if pronounceable password
|
||||
generation algorithm is used.
|
||||
(old style - use \fB-M mode\fP instead).
|
||||
.TP
|
||||
.B -a algorithm
|
||||
use
|
||||
.B algorithm
|
||||
@@ -182,6 +179,36 @@ for password generation.
|
||||
- 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 can be recognized by shell (apostrophe, quotes, dollar sign, etc.) in \fBchar_string\fP
|
||||
use the backslashed versions.
|
||||
.RS
|
||||
.PP
|
||||
.B Examples:
|
||||
.PP
|
||||
Command \fBapgd -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
|
||||
.br
|
||||
\fB01111000\fP
|
||||
.br
|
||||
\fB11011101\fP
|
||||
.br
|
||||
.PP
|
||||
Command \fBapgd -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
|
||||
.br
|
||||
\fBC8F78E06944AFD57FB9CB882BC\fP
|
||||
.br
|
||||
\fB8C8DF37CD792D36D056BBD5002\fP
|
||||
.br
|
||||
.RE
|
||||
.TP
|
||||
.B -r \fIdictfile\fP
|
||||
check generated passwords for their appearance in
|
||||
.B dictfile
|
||||
@@ -191,6 +218,14 @@ check generated passwords for their appearance in
|
||||
\fIfilter_file\fP. \fIfilter_file\fP should be created with \fBapgbfm\fP(1)
|
||||
utility.
|
||||
.TP
|
||||
.B -p min_substr_len
|
||||
this option tells \fBapg\fP(1) to check every substring of the generated
|
||||
password for appearance in \fIfilter_file\fP. If any of such substrings would
|
||||
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
|
||||
@@ -200,17 +235,25 @@ number of passwords. Default is 6.
|
||||
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 6.
|
||||
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 8.
|
||||
Default maximum password length is 10.
|
||||
.TP
|
||||
.B -l
|
||||
spell genetated passwords. Useful when you want to read generated password by telephone.
|
||||
.RS
|
||||
.B WARNING:
|
||||
Think twice before read your password by phone.
|
||||
.RE
|
||||
.TP
|
||||
.B -t
|
||||
print pronunciation for generated pronounceable password
|
||||
.SH "DEFAULT OPTIONS"
|
||||
\fBapgd -a 0 -N -C -L -n 6 -m 6 -x 8\fP (old style)
|
||||
.br
|
||||
\fBapgd -a 0 -M NCL -n 6 -x 8 -m 6\fP (new style)
|
||||
\fBapgd -a 0 -M sncl -n 6 -x 10 -m 8\fP (new style)
|
||||
.SH "EXIT CODE"
|
||||
On successful completion of its task,
|
||||
.B apgd
|
||||
|
||||
192
doc/man/wapg.txt
Normal file
192
doc/man/wapg.txt
Normal file
@@ -0,0 +1,192 @@
|
||||
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, <a-del@iname.com>
|
||||
Project home page: http://www.adel.nursat.kz/WAPG/
|
||||
|
||||
|
||||
|
||||
Automated Password Generator 2003 Jun 19 WAPG(1)
|
||||
116
doc/man/wapgbfm.txt
Normal file
116
doc/man/wapgbfm.txt
Normal file
@@ -0,0 +1,116 @@
|
||||
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, <a-del@iname.com>
|
||||
Project home page: http://www.adel.nursat.kz/apg/
|
||||
|
||||
|
||||
|
||||
Automated Password Generator 2003 Jun 19 WAPGBFM
|
||||
235
doc/pronun.txt
Normal file
235
doc/pronun.txt
Normal file
@@ -0,0 +1,235 @@
|
||||
pronunciation guide for unix
|
||||
29 Apr 97
|
||||
|
||||
|
||||
|
||||
|
||||
How do I pronounce "vi" , or "!", or "/*", or ...?
|
||||
You can start a very long and pointless discussion by wondering
|
||||
about this topic on the net. Some people say "vye", some say
|
||||
"vee-eye" (the vi manual suggests this) and some Roman numerologists
|
||||
say "six". How you pronounce "vi" has nothing to do with whether
|
||||
or not you are a true Unix wizard.
|
||||
|
||||
Similarly, you'll find that some people pronounce "char" as "care",
|
||||
and that there are lots of ways to say "#" or "/*" or "!" or
|
||||
"tty" or "/etc". No one pronunciation is correct - enjoy the regional
|
||||
dialects and accents.
|
||||
|
||||
Since this topic keeps coming up on the net, here is a comprehensive
|
||||
pronunciation list that has made the rounds.
|
||||
|
||||
The Pronunciation Guide
|
||||
-----------------------
|
||||
version 2.5
|
||||
|
||||
Names derived from UNIX are marked with *, names derived from C are marked
|
||||
with +, names derived from (Net)Hack are marked with & and names deserving
|
||||
further explanation are marked with a #. The explanations will be given at
|
||||
the very end.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- SINGLE CHARACTERS --
|
||||
|
||||
SPACE, blank, ghost&
|
||||
|
||||
! EXCLAMATION POINT, exclamation (mark), (ex)clam, excl, wow, hey, boing,
|
||||
bang#, shout, yell, shriek, pling, factorial, ball-bat, smash, cuss,
|
||||
store#, potion&, not*+, dammit*#
|
||||
|
||||
" QUOTATION MARK, (double) quote, dirk, literal mark, rabbit ears,
|
||||
double ping, double glitch, amulet&, web&, inverted commas
|
||||
|
||||
# CROSSHATCH, pound, pound sign, number, number sign, sharp, octothorpe#,
|
||||
hash, (garden) fence, crunch, mesh, hex, flash, grid, pig-pen,
|
||||
tictactoe, scratch (mark), (garden) gate, hak, oof, rake, sink&,
|
||||
corridor&, unequal#, punch mark
|
||||
|
||||
$ DOLLAR SIGN, dollar, cash, currency symbol, buck, string#, escape#,
|
||||
ding, big-money, gold&, Sonne#
|
||||
|
||||
% PERCENT SIGN, percent, mod+, shift-5, double-oh-seven, grapes, food&
|
||||
|
||||
& AMPERSAND, and, amper, address+, shift-7, andpersand, snowman,
|
||||
bitand+, donald duck#, daemon&, background*, pretzel
|
||||
|
||||
' APOSTROPHE, (single) quote, tick, prime, irk, pop, spark, glitch,
|
||||
lurker above&
|
||||
|
||||
* ASTERISK, star, splat, spider, aster, times, wildcard*, gear, dingle,
|
||||
(Nathan) Hale#, bug, gem&, twinkle, funny button#, pine cone, glob*
|
||||
|
||||
() PARENTHESES, parens, round brackets, bananas, ears, bowlegs
|
||||
( LEFT PARENTHESIS, (open) paren, so, wane, parenthesee, open, sad,
|
||||
tool&
|
||||
) RIGHT PARENTHESIS, already, wax, unparenthesee, close (paren), happy,
|
||||
thesis, weapon&
|
||||
|
||||
+ PLUS SIGN, plus, add, cross, and, intersection, door&, spellbook&
|
||||
|
||||
, COMMA, tail, trapper&
|
||||
|
||||
- HYPHEN, minus (sign), dash, dak, option, flag, negative (sign), worm,
|
||||
bithorpe#
|
||||
|
||||
. PERIOD, dot, decimal (point), (radix) point, spot, full stop,
|
||||
put#, floor&
|
||||
|
||||
/ SLASH, stroke, virgule, solidus, slant, diagonal, over, slat, slak,
|
||||
across#, compress#, reduce#, replicate#, spare, divided-by, wand&,
|
||||
forward slash, shilling#
|
||||
|
||||
: COLON, two-spot, double dot, dots, chameleon&
|
||||
|
||||
; SEMICOLON, semi, hybrid, giant eel&, go-on#
|
||||
|
||||
<> ANGLE BRACKETS, angles, funnels, brokets, pointy brackets, widgets
|
||||
< LESS THAN, less, read from*, from*, in*, comesfrom*, crunch,
|
||||
sucks, left chevron#, open pointy (brack[et]), bra#, upstairs&, west,
|
||||
(left|open) widget
|
||||
> GREATER THAN, more, write to*, into/toward*, out*, gazinta*, zap,
|
||||
blows, right chevron#, closing pointy (brack[et]), ket#, downstairs&,
|
||||
east, (right|close) widget
|
||||
|
||||
= EQUAL SIGN, equal(s), gets, becomes, quadrathorpe#, half-mesh, ring&
|
||||
|
||||
? QUESTION MARK, question, query, whatmark, what, wildchar*, huh, ques,
|
||||
kwes, quiz, quark, hook, scroll&, interrogation point
|
||||
|
||||
@ AT SIGN, at, each, vortex, whirl, whirlpool, cyclone, snail, ape (tail),
|
||||
cat, snable-a#, trunk-a#, rose, cabbage, Mercantile symbol, strudel#,
|
||||
fetch#, shopkeeper&, human&, commercial-at, monkey (tail)
|
||||
|
||||
[] BRACKETS, square brackets, U-turns, edged parentheses
|
||||
[ LEFT BRACKET, bracket, bra, (left) square (brack[et]), opensquare,
|
||||
armor&
|
||||
] RIGHT BRACKET, unbracket, ket, right square (brack[et]), unsquare, close,
|
||||
mimic&
|
||||
|
||||
\ BACKSLASH, reversed virgule, bash, (back)slant, backwhack, backslat,
|
||||
escape*, backslak, bak, scan#, expand#, opulent throne&, slosh, slope,
|
||||
blash
|
||||
|
||||
^ CIRCUMFLEX, caret, carrot, (top)hat, cap, uphat, party hat, housetop,
|
||||
up arrow, control, boink, chevron, hiccup, power, to-the(-power), fang,
|
||||
sharkfin, and#, xor+, wok, trap&, pointer#, pipe*, upper-than#
|
||||
|
||||
_ UNDERSCORE, underline, underbar, under, score, backarrow, flatworm, blank,
|
||||
chain&, gets#, dash#, sneak
|
||||
|
||||
` GRAVE, (grave/acute) accent, backquote, left/open quote, backprime,
|
||||
unapostrophe, backspark, birk, blugle, backtick, push, backglitch,
|
||||
backping, execute#, boulder&, rock&, blip
|
||||
|
||||
{} BRACES, curly braces, squiggly braces, curly brackets, squiggle brackets,
|
||||
Tuborgs#, ponds, curly chevrons#, squirrly braces, hitchcocks#,
|
||||
chippendale brackets#
|
||||
{ LEFT BRACE, brace, curly, leftit, embrace, openbrace, begin+,
|
||||
fountain&
|
||||
} RIGHT BRACE, unbrace, uncurly, rytit, bracelet, close, end+, a pool&
|
||||
|
||||
| VERTICAL BAR, pipe*, pipe to*, vertical line, broken line#, bar, or+,
|
||||
bitor+, vert, v-bar, spike, to*, gazinta*, thru*, pipesinta*, tube,
|
||||
mark, whack, gutter, wall&
|
||||
|
||||
~ TILDE, twiddle, tilda, tildee, wave, squiggle, swung dash, approx,
|
||||
wiggle, enyay#, home*, worm, not+
|
||||
|
||||
|
||||
-- MULTIPLE CHARACTER STRINGS --
|
||||
|
||||
!? interrobang (one overlapped character)
|
||||
*/ asterslash+, times-div#
|
||||
/* slashterix+, slashaster
|
||||
:= becomes#
|
||||
<- gets
|
||||
<< left-shift+, double smaller
|
||||
<> unequal#
|
||||
>> appends*, cat-astrophe, right-shift+, double greater
|
||||
-> arrow+, pointer to+, hiccup+
|
||||
#! sh'bang, wallop
|
||||
\!* bash-bang-splat
|
||||
() nil#
|
||||
&& and+, and-and+, amper-amper, succeeds-then*
|
||||
|| or+, or-or+, fails-then*
|
||||
|
||||
|
||||
-- NOTES --
|
||||
|
||||
! bang comes from old card punch phenom where punching ! code made a
|
||||
loud noise; however, this pronunciation is used in the (non-
|
||||
computerized) publishing and typesetting industry in the U.S.
|
||||
too, so ...
|
||||
Alternatively it could have come from comic books, where the
|
||||
words each character utters are shown in a "balloon" near that
|
||||
character's head. When one character shoots another, it is
|
||||
common to see a balloon pointing at the barrel of the gun to
|
||||
denote that the gun had been fired, not merely aimed.
|
||||
That balloon contained the word "!" -- hence, "!" == "Bang!"
|
||||
! store from FORTH
|
||||
! dammit as in "quit, dammit!" while exiting vi and hoping one hasn't
|
||||
clobbered a file too badly
|
||||
# octothorpe from Bell System (orig. octalthorpe)
|
||||
# unequal e.g. Modula-2
|
||||
$ string from BASIC
|
||||
$ escape from TOPS-10
|
||||
$ Sonne In the "socialist" countries they used and are using all kinds
|
||||
of IBM clones (hardware + sw). It was a common practice just
|
||||
to rename everything (IBM 360 --> ESER 1040 etc.).
|
||||
Of course the "dollar" sign had to be renamed - it became the
|
||||
"international currency symbol" which looks like a circle with
|
||||
4 rays spreading from it:
|
||||
____
|
||||
\/ \/
|
||||
/ \
|
||||
\ /
|
||||
/\____/\
|
||||
|
||||
Because it looks like a (small) shining sun, in the German
|
||||
Democratic Republic it was usually called "Sonne" (sun).
|
||||
& donald duck from the Danish "Anders And", which means "Donald Duck"
|
||||
* splat from DEC "spider" glyph
|
||||
* Nathan Hale "I have but one asterisk for my country."
|
||||
* funny button at Pacific Bell, * was referred to by employees as the "funny
|
||||
button", which did not please management at all when it became
|
||||
part of the corporate logo of Pacific Telesis, the holding
|
||||
company ...
|
||||
*/ times-div from FORTH
|
||||
= quadrathorpe half an octothorpe
|
||||
- bithorpe half a quadrathorpe (So what's a monothorpe?)
|
||||
. put Victor Borge's Phonetic Punctuation which dates back to the
|
||||
middle 1950's
|
||||
/ across APL
|
||||
/ compress APL
|
||||
/ reduce APL
|
||||
/ replicate APL
|
||||
/ shilling from the British currency symbol
|
||||
:= becomes e.g. Pascal
|
||||
; go-on Algol68
|
||||
< left chevron from the military: worn vertically on the sleeve to signify
|
||||
rating
|
||||
< bra from quantum mechanics
|
||||
<> unequal e.g. Pascal
|
||||
> right chevron see "< left chevron"
|
||||
> ket from quantum mechanics
|
||||
@ snable-a from Danish; may translate as "trunk-a"
|
||||
@ trunk-a "trunk" = "elephant nose"
|
||||
@ strudel as in Austrian apple cake
|
||||
@ fetch from FORTH
|
||||
\ scan APL
|
||||
\ expand APL
|
||||
^ and from formal logic
|
||||
^ pointer from PASCAL
|
||||
^ upper-than cf. > and <
|
||||
_ gets some alternative representation of underscore resembles a
|
||||
backarrow
|
||||
_ dash as distinct from '-' == minus
|
||||
` execute from shell command substitution
|
||||
{} Tuborgs from advertizing for well-known Danish beverage
|
||||
{} curly chevr. see "< left chevron"
|
||||
{} hitchcocks from the old Alfred Hitchcock show, with the stylized profile
|
||||
of the man
|
||||
{} chipp. br. after Chippendale chairs
|
||||
| broken line EBCDIC has two vertical bars, one solid and one broken.
|
||||
~ enyay from the Spanish n-tilde
|
||||
() nil LISP
|
||||
39
errors.c
39
errors.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "errs.h"
|
||||
|
||||
#ifdef CLISERV
|
||||
@@ -37,7 +38,14 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
** routine that handles non-fatal system errors like calloc, open, etc.
|
||||
** err_sys() - routine that handles non-fatal system errors
|
||||
** like calloc, open, etc.
|
||||
** INPUT:
|
||||
** const char * - error name.
|
||||
** OUTPUT:
|
||||
** prints error to stderr.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
err_sys(const char *string)
|
||||
@@ -51,7 +59,14 @@ err_sys(const char *string)
|
||||
}
|
||||
|
||||
/*
|
||||
** routine that handles fatal system errors like calloc, open, etc.
|
||||
** err_sus_fatal() - routine that handles fatal system errors
|
||||
** like calloc, open, etc.
|
||||
** INPUT:
|
||||
** const char * - error name.
|
||||
** OUTPUT:
|
||||
** prints error to stderr and then exit.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
err_sys_fatal(const char *string)
|
||||
@@ -68,7 +83,14 @@ err_sys_fatal(const char *string)
|
||||
}
|
||||
|
||||
/*
|
||||
** routine that handles non-fatal application errors.
|
||||
** err_app() - routine that handles non-fatal application errors.
|
||||
** INPUT:
|
||||
** const char * - error name.
|
||||
** const char * - error description.
|
||||
** OUTPUT:
|
||||
** prints error to stderr.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
err_app(const char *string, const char * err)
|
||||
@@ -83,7 +105,14 @@ err_app(const char *string, const char * err)
|
||||
}
|
||||
|
||||
/*
|
||||
** routine that handles fatal application errors.
|
||||
** err_app_fatal() - routine that handles fatal application errors.
|
||||
** INPUT:
|
||||
** const char * - error name.
|
||||
** const char * - error description.
|
||||
** OUTPUT:
|
||||
** prints error to stderr and then exit.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
err_app_fatal(const char *string, const char *err)
|
||||
|
||||
8
errs.h
8
errs.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -27,8 +27,8 @@
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ERRS_H
|
||||
#define ERRS_H 1
|
||||
#ifndef APG_ERRS_H
|
||||
#define APG_ERRS_H 1
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
@@ -37,4 +37,4 @@ extern void err_sys_fatal(const char *string);
|
||||
extern void err_app(const char *string, const char *err);
|
||||
extern void err_app_fatal(const char *string, const char *err);
|
||||
|
||||
#endif /* ERRS_H */
|
||||
#endif /* APG_ERRS_H */
|
||||
|
||||
94
getopt.c
Normal file
94
getopt.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Modified by Adel I. Mirzazhanov 2002, 2003
|
||||
* getopt - get option letter from argv
|
||||
*
|
||||
* This is a version of the public domain getopt() implementation by
|
||||
* Henry Spencer, changed for 4.3BSD compatibility (in addition to System V).
|
||||
* It allows rescanning of an option list by setting optind to 0 before
|
||||
* calling, which is why we use it even if the system has its own (in fact,
|
||||
* this one has a unique name so as not to conflict with the system's).
|
||||
* Thanks to Dennis Ferguson for the appropriate modifications.
|
||||
*
|
||||
* This file is in the Public Domain.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "getopt.h"
|
||||
|
||||
static int badopt(const char *mess,int ch);
|
||||
|
||||
|
||||
char *apg_optarg; /* Global argument pointer. */
|
||||
int apg_optind = 0; /* Global argv index. */
|
||||
int apg_opterr = 1; /* for compatibility, should error be printed? */
|
||||
int apg_optopt; /* for compatibility, option character checked */
|
||||
|
||||
static char *scan = NULL; /* Private scan pointer. */
|
||||
static const char *prog = "apg";
|
||||
|
||||
/*
|
||||
* Print message about a bad option.
|
||||
*/
|
||||
static int
|
||||
badopt(const char *mess,int ch)
|
||||
{
|
||||
if (apg_opterr) {
|
||||
fprintf(stderr,"%s%s%c\n", prog, mess, ch);
|
||||
fflush(stderr);
|
||||
}
|
||||
return ('?');
|
||||
}
|
||||
|
||||
int
|
||||
apg_getopt(int argc,char *argv[],const char *optstring)
|
||||
{
|
||||
register char c;
|
||||
register const char *place;
|
||||
|
||||
prog = argv[0];
|
||||
apg_optarg = NULL;
|
||||
|
||||
if (apg_optind == 0) {
|
||||
scan = NULL;
|
||||
apg_optind++;
|
||||
}
|
||||
|
||||
if (scan == NULL || *scan == '\0') {
|
||||
if (apg_optind >= argc
|
||||
|| argv[apg_optind][0] != '-'
|
||||
|| argv[apg_optind][1] == '\0') {
|
||||
return (EOF);
|
||||
}
|
||||
if (argv[apg_optind][1] == '-'
|
||||
&& argv[apg_optind][2] == '\0') {
|
||||
apg_optind++;
|
||||
return (EOF);
|
||||
}
|
||||
|
||||
scan = argv[apg_optind++]+1;
|
||||
}
|
||||
|
||||
c = *scan++;
|
||||
apg_optopt = c & 0377;
|
||||
for (place = optstring; place != NULL && *place != '\0'; ++place)
|
||||
if (*place == c)
|
||||
break;
|
||||
|
||||
if (place == NULL || *place == '\0' || c == ':' || c == '?') {
|
||||
return (badopt(": unknown option -", c));
|
||||
}
|
||||
|
||||
place++;
|
||||
if (*place == ':') {
|
||||
if (*scan != '\0') {
|
||||
apg_optarg = scan;
|
||||
scan = NULL;
|
||||
} else if (apg_optind >= argc) {
|
||||
return (badopt(": option requires an argument -", c));
|
||||
} else {
|
||||
apg_optarg = argv[apg_optind++];
|
||||
}
|
||||
}
|
||||
|
||||
return (c & 0377);
|
||||
}
|
||||
38
getopt.h
Normal file
38
getopt.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
** Copyright (c) 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1.Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2.Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3.The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef APG_GETOPT_H
|
||||
#define APG_GETOPT_H 1
|
||||
|
||||
extern char * apg_optarg; /* global argument pointer */
|
||||
extern int apg_optind; /* global argv index */
|
||||
|
||||
extern int apg_getopt(int argc,char *argv[],const char *optstring);
|
||||
|
||||
#endif /* APG_GETOPT_H */
|
||||
332
md5/md5.c
332
md5/md5.c
@@ -1,332 +0,0 @@
|
||||
/*
|
||||
** This code implements the MD5 message-digest algorithm.
|
||||
** The algorithm is due to Ron Rivest. This code was
|
||||
** written by Colin Plumb in 1993, no copyright is claimed.
|
||||
** This code is in the public domain; do with it what you wish.
|
||||
**
|
||||
** Equivalent code is available from RSA Data Security, Inc.
|
||||
** This code has been tested against that, and is equivalent,
|
||||
** except that you don't need to include two pages of legalese
|
||||
** with every copy.
|
||||
**
|
||||
** To compute the message digest of a chunk of bytes, declare an
|
||||
** MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
** needed on buffers full of bytes, and then call MD5Final, which
|
||||
** will fill a supplied 16-byte array with the digest.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This code was modified in 1997 by Jim Kingdon of Cyclic Software to
|
||||
** not require an integer type which is exactly 32 bits. This work
|
||||
** draws on the changes for the same purpose by Tatu Ylonen
|
||||
** <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use
|
||||
** that code, there is no copyright issue. I hereby disclaim
|
||||
** copyright in any changes I have made; this code remains in the
|
||||
** public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
** Note regarding apg_* namespace: this avoids potential conflicts
|
||||
** with libraries such as some versions of Kerberos. No particular
|
||||
** need to worry about whether the system supplies an MD5 library, as
|
||||
** this file is only about 3k of object code.
|
||||
*/
|
||||
|
||||
#include <string.h> /* for memcpy() and memset() */
|
||||
|
||||
/* Add prototype support. */
|
||||
#ifndef PROTO
|
||||
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
|
||||
#define PROTO(ARGS) ARGS
|
||||
#else
|
||||
#define PROTO(ARGS) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "md5.h"
|
||||
|
||||
/* Little-endian byte-swapping routines. Note that these do not
|
||||
depend on the size of datatypes such as apg_uint32, nor do they require
|
||||
us to detect the endianness of the machine we are running on. It
|
||||
is possible they should be macros for speed, but I would be
|
||||
surprised if they were a performance bottleneck for MD5. */
|
||||
|
||||
static apg_uint32
|
||||
getu32 (addr)
|
||||
const unsigned char *addr;
|
||||
{
|
||||
return (((((unsigned long)addr[3] << 8) | addr[2]) << 8)
|
||||
| addr[1]) << 8 | addr[0];
|
||||
}
|
||||
|
||||
static void
|
||||
putu32 (data, addr)
|
||||
apg_uint32 data;
|
||||
unsigned char *addr;
|
||||
{
|
||||
addr[0] = (unsigned char)data;
|
||||
addr[1] = (unsigned char)(data >> 8);
|
||||
addr[2] = (unsigned char)(data >> 16);
|
||||
addr[3] = (unsigned char)(data >> 24);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
void
|
||||
apg_MD5Init (ctx)
|
||||
struct apg_MD5Context *ctx;
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
void
|
||||
apg_MD5Update (ctx, buf, len)
|
||||
struct apg_MD5Context *ctx;
|
||||
unsigned char const *buf;
|
||||
unsigned len;
|
||||
{
|
||||
apg_uint32 t;
|
||||
|
||||
/* Update bitcount */
|
||||
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = (t + ((apg_uint32)len << 3)) & 0xffffffff) < t)
|
||||
ctx->bits[1]++; /* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if ( t ) {
|
||||
unsigned char *p = ctx->in + t;
|
||||
|
||||
t = 64-t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
apg_MD5Transform (ctx->buf, ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
apg_MD5Transform (ctx->buf, ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void
|
||||
apg_MD5Final (digest, ctx)
|
||||
unsigned char digest[16];
|
||||
struct apg_MD5Context *ctx;
|
||||
{
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8) {
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset(p, 0, count);
|
||||
apg_MD5Transform (ctx->buf, ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
/* Pad block to 56 bytes */
|
||||
memset(p, 0, count-8);
|
||||
}
|
||||
|
||||
/* Append length in bits and transform */
|
||||
putu32(ctx->bits[0], ctx->in + 56);
|
||||
putu32(ctx->bits[1], ctx->in + 60);
|
||||
|
||||
apg_MD5Transform (ctx->buf, ctx->in);
|
||||
putu32(ctx->buf[0], digest);
|
||||
putu32(ctx->buf[1], digest + 4);
|
||||
putu32(ctx->buf[2], digest + 8);
|
||||
putu32(ctx->buf[3], digest + 12);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||
( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
void
|
||||
apg_MD5Transform (buf, inraw)
|
||||
apg_uint32 buf[4];
|
||||
const unsigned char inraw[64];
|
||||
{
|
||||
register apg_uint32 a, b, c, d;
|
||||
apg_uint32 in[16];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
in[i] = getu32 (inraw + 4 * i);
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
/* Simple test program. Can use it to manually run the tests from
|
||||
RFC1321 for example. */
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct apg_MD5Context context;
|
||||
unsigned char checksum[16];
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf (stderr, "usage: %s string-to-hash\n", argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
for (j = 1; j < argc; ++j)
|
||||
{
|
||||
printf ("MD5 (\"%s\") = ", argv[j]);
|
||||
apg_MD5Init (&context);
|
||||
apg_MD5Update (&context, argv[j], strlen (argv[j]));
|
||||
apg_MD5Final (checksum, &context);
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
printf ("%02x", (unsigned int) checksum[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST */
|
||||
41
md5/md5.h
41
md5/md5.h
@@ -1,41 +0,0 @@
|
||||
/* See md5.c for explanation and copyright information. */
|
||||
|
||||
/*
|
||||
* $FreeBSD: src/contrib/cvs/lib/md5.h,v 1.2 1999/12/11 15:10:02 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef MD5_H
|
||||
#define MD5_H
|
||||
/*
|
||||
#ifdef __FreeBSD__
|
||||
#define apg_MD5Context MD5Context
|
||||
#define apg_MD5Init MD5Init
|
||||
#define apg_MD5Update MD5Update
|
||||
#define apg_MD5Final MD5Final
|
||||
#define apg_MD5Transform MD5Transform
|
||||
#include <sys/md5.h>
|
||||
#else
|
||||
*/
|
||||
/* Unlike previous versions of this code, uint32 need not be exactly
|
||||
32 bits, merely 32 bits or more. Choosing a data type which is 32
|
||||
bits instead of 64 is not important; speed is considerably more
|
||||
important. ANSI guarantees that "unsigned long" will be big enough,
|
||||
and always using it seems to have few disadvantages. */
|
||||
typedef unsigned long apg_uint32;
|
||||
|
||||
struct apg_MD5Context {
|
||||
apg_uint32 buf[4];
|
||||
apg_uint32 bits[2];
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
void apg_MD5Init PROTO ((struct apg_MD5Context *context));
|
||||
void apg_MD5Update PROTO ((struct apg_MD5Context *context,
|
||||
unsigned char const *buf, unsigned len));
|
||||
void apg_MD5Final PROTO ((unsigned char digest[16],
|
||||
struct apg_MD5Context *context));
|
||||
void apg_MD5Transform PROTO ((apg_uint32 buf[4], const unsigned char in[64]));
|
||||
|
||||
/*#endif*/
|
||||
|
||||
#endif /* !MD5_H */
|
||||
11
owntypes.h
11
owntypes.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -27,10 +27,9 @@
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef OWN_TYPES_H
|
||||
#define OWN_TYPES_H 1
|
||||
#ifndef APG_OWN_TYPES_H
|
||||
#define APG_OWN_TYPES_H 1
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef short int SHORT;
|
||||
@@ -40,4 +39,6 @@ typedef unsigned long int UINT32;
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#endif /* OWN_TYPES_H */
|
||||
#define APG_MAX_PASSWORD_LENGTH 255
|
||||
|
||||
#endif /* APG_OWN_TYPES_H */
|
||||
|
||||
39
php/apgonline/README
Normal file
39
php/apgonline/README
Normal file
@@ -0,0 +1,39 @@
|
||||
APG Online is the PHP frontend for Automated Password Generator
|
||||
|
||||
It is tested with apg-2.1.0, apache-2.0.40 and php-4.2.3
|
||||
|
||||
INSTALL
|
||||
1. Install Apache with PHP support (see Apache and PHP documentation).
|
||||
|
||||
2. Copy index.php to SOME_DIRECTORY inside Apache's document root
|
||||
|
||||
Example:
|
||||
mkdir /usr/local/apache/htdocs/apgonline
|
||||
cp index.php /usr/local/apache/htdocs/apgonline
|
||||
|
||||
3. Copy dictionary file to the SOME_DIRECTORY/lang directory.
|
||||
|
||||
Example:
|
||||
cp lang/english.php /usr/local/apache/htdocs/apgonline/lang
|
||||
|
||||
4. Copy theme file to the SOME_DIRECTORY/themes directory.
|
||||
|
||||
Example:
|
||||
cp themes/default.php /usr/local/apache/htdocs/apgonline/themes
|
||||
|
||||
4. Edit "Config data" section of index.php
|
||||
|
||||
5. Open URL http://your.server.name/apgonline/index.php with Your
|
||||
favorite browser.
|
||||
|
||||
NOTES
|
||||
a) APG Online uses cookie to save Your settings, so You should enable
|
||||
cookie support in Your browser settings.
|
||||
|
||||
b) I'm not a designer, so themes included in APG distribution is just to
|
||||
demonstrate a new feature. You can suggest your own theme to include in the
|
||||
APG distribution.
|
||||
|
||||
c) Password quality checks are not supported in PHP frontend because,
|
||||
if implemented, it can slow down your web server. But you can add
|
||||
support for them at your own risk.
|
||||
634
php/apgonline/index.php
Normal file
634
php/apgonline/index.php
Normal file
@@ -0,0 +1,634 @@
|
||||
<?
|
||||
################################################################
|
||||
# APGOnline v2.1.0
|
||||
################################################################
|
||||
# Config data
|
||||
################################################################
|
||||
|
||||
$apg_title = "Automated Password Generator Online" ;
|
||||
|
||||
$generator = "/usr/local/bin/apg -q" ; # APG location
|
||||
#
|
||||
# Default options
|
||||
#
|
||||
$default_sl = "y"; # Use small letters symbol set. Define "n" if not.
|
||||
$default_cl = "y"; # Use capital letters symbol set. Define "n" if not.
|
||||
$default_nb = "y"; # Use numeral symbol set. Define "n" if not.
|
||||
$default_ss = "y"; # Use special symbol set. Define "n" if not.
|
||||
$default_algo = "2"; # 1-random. 2-pronounceable.
|
||||
$default_numofpass = "6"; # default number of passwords to generate. Up to 255.
|
||||
$default_minpasslength = "6"; # default minimum password length. Up to 255.
|
||||
$default_maxpasslength = "8"; # default maximum password length. Up to 255.
|
||||
$default_clseed = ""; # default command line seed.
|
||||
|
||||
$print_command_line = "false" ; # true|false define it to something else to
|
||||
# disable command line printing
|
||||
####################################################
|
||||
# Theme settings
|
||||
#
|
||||
include ('themes/default.php');
|
||||
|
||||
####################################################
|
||||
# Language settings
|
||||
include ('lang/english.php');
|
||||
|
||||
################################################################
|
||||
# End of Config data
|
||||
################################################################
|
||||
######################################################
|
||||
# Print formatted text
|
||||
#
|
||||
function print_text($font,$size,$color,$text)
|
||||
{
|
||||
print "<font ";
|
||||
if ($font != "default") print "face=\"$font\" ";
|
||||
if ($size != "0") print "size=\"$size\" ";
|
||||
print "color=\"$color\">";
|
||||
print "$text</font>";
|
||||
}
|
||||
#################
|
||||
# Cookie analyzer
|
||||
# d is delimiter
|
||||
#
|
||||
if (isset($apg_online_cky) && (!$_POST['save_settings'])) {
|
||||
$tok = strtok ($apg_online_cky,"d");
|
||||
$i = 0;
|
||||
while ($tok) {
|
||||
if (($tok == "2") && ($i == "0")) $default_algo = "2";
|
||||
if (($tok == "1") && ($i == "0")) $default_algo = "1";
|
||||
if (($tok == "l") && ($i == "1")) $default_sl = "y";
|
||||
else if (($tok != "l") && ($i == "1")) $default_sl = "n";
|
||||
if (($tok == "c") && ($i == "2")) $default_cl = "y";
|
||||
else if (($tok != "c") && ($i == "2")) $default_cl = "n";
|
||||
if (($tok == "n") && ($i == "3")) $default_nb = "y";
|
||||
else if (($tok != "n") && ($i == "3")) $default_nb = "n";
|
||||
if (($tok == "s") && ($i == "4")) $default_ss = "y";
|
||||
else if (($tok != "n") && ($i == "4")) $default_ss = "n";
|
||||
if ((is_numeric($tok)) && ($i == "5")) $default_numofpass = $tok;
|
||||
if ((is_numeric($tok)) && ($i == "6")) $default_minpasslength = $tok;
|
||||
if ((is_numeric($tok)) && ($i == "7")) $default_maxpasslength = $tok;
|
||||
$i = $i + 1;
|
||||
$tok = strtok ("d");
|
||||
}
|
||||
$i = 0;
|
||||
}
|
||||
|
||||
|
||||
###########
|
||||
# Algorithm
|
||||
#
|
||||
if (!$_POST['algo']) $algo = $default_algo;
|
||||
else $algo = $_POST['algo'];
|
||||
switch ($algo)
|
||||
{
|
||||
case "1":
|
||||
$generator = $generator . " -a 1";
|
||||
$cookie_text = $cookie_text . "1d";
|
||||
break;
|
||||
case "2":
|
||||
$generator = $generator . " -a 0";
|
||||
$cookie_text = $cookie_text . "2d";
|
||||
break;
|
||||
case "":
|
||||
$algo = $default_algo;
|
||||
$cookie_text = $cookie_text . $algo . "d";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
############
|
||||
# Symbolsets
|
||||
#
|
||||
$genmode = " -M ";
|
||||
if (!$_POST['sl']) $sl = $default_sl;
|
||||
else $sl = $_POST['sl'];
|
||||
switch($sl)
|
||||
{
|
||||
case "y":
|
||||
$genmode = $genmode . "l";
|
||||
$cookie_text = $cookie_text . "ld";
|
||||
break;
|
||||
case "n":
|
||||
$cookie_text = $cookie_text . "ed";
|
||||
break;
|
||||
case "":
|
||||
$sl = $default_sl;
|
||||
$cookie_text = $cookie_text . $sl . "d";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!$_POST['cl']) $cl = $default_cl;
|
||||
else $cl = $_POST['cl'];
|
||||
switch($cl)
|
||||
{
|
||||
case "y":
|
||||
$genmode = $genmode . "c";
|
||||
$cookie_text = $cookie_text . "cd";
|
||||
break;
|
||||
case "n":
|
||||
$cookie_text = $cookie_text . "ed";
|
||||
break;
|
||||
case "":
|
||||
$cl = $default_cl;
|
||||
$cookie_text = $cookie_text . $cl . "d";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!$_POST['nb']) $nb = $default_nb;
|
||||
else $nb = $_POST['nb'];
|
||||
switch($nb)
|
||||
{
|
||||
case "y":
|
||||
$genmode = $genmode . "n";
|
||||
$cookie_text = $cookie_text . "nd";
|
||||
break;
|
||||
case "n":
|
||||
$cookie_text = $cookie_text . "ed";
|
||||
break;
|
||||
case "":
|
||||
$nb = $default_nb;
|
||||
$cookie_text = $cookie_text . $nb . "d";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!$_POST['ss']) $ss = $default_ss;
|
||||
else $ss = $_POST['ss'];
|
||||
switch($ss)
|
||||
{
|
||||
case "y":
|
||||
$genmode = $genmode . "s";
|
||||
$cookie_text = $cookie_text . "sd";
|
||||
break;
|
||||
case "n":
|
||||
$cookie_text = $cookie_text . "ed";
|
||||
break;
|
||||
case "":
|
||||
$ss = $default_ss;
|
||||
$cookie_text = $cookie_text . $ss . "d";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ($genmode != " -M ")
|
||||
$generator = $generator . $genmode;
|
||||
|
||||
###############################
|
||||
# Number of passwords parameter
|
||||
#
|
||||
if (!$_POST['numofpass']) {
|
||||
$numofpass = $default_numofpass;
|
||||
$generator= $generator . " -n " . $numofpass;
|
||||
$cookie_text = $cookie_text . $numofpass . "d";
|
||||
}
|
||||
else if (is_numeric($_POST['numofpass'])) {
|
||||
$numofpass = $_POST['numofpass'];
|
||||
if ($numofpass >= "255") {
|
||||
$numofpass = "255";
|
||||
$generator= $generator . " -n " . $numofpass;
|
||||
$cookie_text = $cookie_text . $numofpass . "d";
|
||||
}
|
||||
else {
|
||||
$generator= $generator . " -n " . $numofpass;
|
||||
$cookie_text = $cookie_text . $numofpass . "d";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$numofpass = $default_numofpass;
|
||||
$generator= $generator . " -n " . $numofpass;
|
||||
$cookie_text = $cookie_text . $numofpass . "d";
|
||||
}
|
||||
|
||||
###################################
|
||||
# Minimum password length parameter
|
||||
#
|
||||
if (!$_POST['minpasslength']) {
|
||||
$minpasslength = $default_minpasslength;
|
||||
$generator= $generator . " -m " . $minpasslength;
|
||||
$cookie_text = $cookie_text . $minpasslength . "d";
|
||||
}
|
||||
else if (is_numeric($_POST['minpasslength'])) {
|
||||
$minpasslength = $_POST['minpasslength'];
|
||||
if ($minpasslength >= "255") {
|
||||
$minpasslength = "255";
|
||||
$generator= $generator . " -m " . $minpasslength;
|
||||
$cookie_text = $cookie_text . $minpasslength . "d";
|
||||
}
|
||||
else {
|
||||
$generator= $generator . " -m " . $minpasslength;
|
||||
$cookie_text = $cookie_text . $minpasslength . "d";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$minpasslength = $default_minpasslength;
|
||||
$generator= $generator . " -m " . $minpasslength;
|
||||
$cookie_text = $cookie_text . $minpasslength . "d";
|
||||
}
|
||||
|
||||
###################################
|
||||
# Maximum password length parameter
|
||||
#
|
||||
if (!$_POST['maxpasslength']) {
|
||||
$maxpasslength = $default_maxpasslength;
|
||||
$generator= $generator . " -x " . $maxpasslength;
|
||||
$cookie_text = $cookie_text . $maxpasslength . "d";
|
||||
}
|
||||
else if (is_numeric($_POST['maxpasslength'])) {
|
||||
$maxpasslength = $_POST['maxpasslength'];
|
||||
if ($maxpasslength >= "255") {
|
||||
$maxpasslength = "255";
|
||||
$generator= $generator . " -x " . $maxpasslength;
|
||||
$cookie_text = $cookie_text . $maxpasslength . "d";
|
||||
}
|
||||
else {
|
||||
$generator= $generator . " -x " . $maxpasslength;
|
||||
$cookie_text = $cookie_text . $maxpasslength . "d";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$maxpasslength = $default_maxpasslength;
|
||||
$generator= $generator . " -x " . $maxpasslength;
|
||||
$cookie_text = $cookie_text . $maxpasslength . "d";
|
||||
}
|
||||
|
||||
#############
|
||||
# Random seed
|
||||
#
|
||||
if (!$_POST['clseed']) {
|
||||
$clseed = $default_clseed;
|
||||
}
|
||||
else {
|
||||
$clseed = $_POST['clseed'];
|
||||
#
|
||||
# base64_encode() is used for security reasons
|
||||
#
|
||||
$generator = $generator . " -c " . base64_encode($clseed);
|
||||
}
|
||||
|
||||
###############
|
||||
# Save settings
|
||||
#
|
||||
if ($_POST['save_settings'] == "s") {
|
||||
setcookie("apg_online_cky");
|
||||
setcookie("apg_online_cky", "$cookie_text");
|
||||
}
|
||||
else if ($_POST['save_settings'] == "r") setcookie("apg_online_cky");
|
||||
|
||||
###############################################################
|
||||
print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
|
||||
print "<html>\n";
|
||||
print "<head>\n";
|
||||
print " <meta name=\"author\" content=\"Adel I. Mirzazhanov\">\n";
|
||||
print " <title>APGOnline</title>\n";
|
||||
print "</head>\n";
|
||||
print "<body text=\"$page_text\" bgcolor=\"$page_bgcolor\" link=\"$page_link\" alink=\"$page_alink\" vlink=\"$page_vlink\">\n";
|
||||
unset ($passwords, $outpasswords);
|
||||
exec ($generator, $passwords);
|
||||
$max_ii = count($passwords);
|
||||
for ($ii = 0; $ii < $max_ii; $ii++)
|
||||
{
|
||||
$outpasswords[$ii] = htmlspecialchars($passwords[$ii] , ENT_QUOTES);
|
||||
}
|
||||
unset ($passwords);
|
||||
$ii = 0;
|
||||
print "<center>\n";
|
||||
print "<form method=\"post\" action=\"$PHP_SELF\" name=\"main\">\n";
|
||||
print "<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\" width=\"$interface_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td align=\"center\" colspan=\"2\" bgcolor=\"$interface_header_color\">\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th>";
|
||||
print_text($p_header_font_face,"0",$p_header_font_color,$apg_title);
|
||||
print "</th>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td valign=\"top\" align=\"left\">\n";
|
||||
print " <!-- ###ALGORITHM PANNEL BEGIN -->\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$p_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th align=\"left\" bgcolor=\"$p_header_bgcolor\">";
|
||||
print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_algorithm);
|
||||
print "</th>\n";
|
||||
print " <tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_pronounceable);
|
||||
print"</td>\n";
|
||||
print " <td><input type=\"radio\" name=\"algo\" value=\"2\"";
|
||||
if ($algo == "2") print " checked"; print"></td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_random);
|
||||
print "</td>\n";
|
||||
print " <td><input type=\"radio\" name=\"algo\" value=\"1\"";
|
||||
if ($algo == "1") print " checked"; print"></td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " <!-- ###ALGORITHM PANNEL END -->\n";
|
||||
print " </td>\n";
|
||||
print " <td valign=\"top\" align=\"right\">\n";
|
||||
print " <!-- ###SYMBOLSETS PANNEL BEGIN -->\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$p_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th align=\"left\" bgcolor=\"$p_header_bgcolor\">\n";
|
||||
print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_symbol_sets);
|
||||
print "</th>\n";
|
||||
print " <tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_small_lerrers);
|
||||
print "</td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes);
|
||||
print" </td>\n";
|
||||
print " <td><input type=\"radio\" name=\"sl\" value=\"y\"";
|
||||
if ($sl=="y") print " checked"; print "></td>\n";
|
||||
print " <td><input type=\"radio\" name=\"sl\" value=\"n\"";
|
||||
if ($sl=="n") print " checked"; print "></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no);
|
||||
print" </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_cap_letters);
|
||||
print "</td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes);
|
||||
print" </td>\n";
|
||||
print " <td><input type=\"radio\" name=\"cl\" value=\"y\"";
|
||||
if ($cl=="y") print " checked"; print "></td>\n";
|
||||
print " <td><input type=\"radio\" name=\"cl\" value=\"n\"";
|
||||
if ($cl=="n") print " checked"; print "></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no);
|
||||
print" </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_numbers);
|
||||
print "</td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes);
|
||||
print" </td>\n";
|
||||
print " <td><input type=\"radio\" name=\"nb\" value=\"y\"";
|
||||
if ($nb=="y") print " checked"; print "></td>\n";
|
||||
print " <td><input type=\"radio\" name=\"nb\" value=\"n\"";
|
||||
if ($nb=="n") print " checked"; print "></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no);
|
||||
print" </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_spec_symbols);
|
||||
print "</td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes);
|
||||
print" </td>\n";
|
||||
print " <td><input type=\"radio\" name=\"ss\" value=\"y\"";
|
||||
if ($ss=="y") print " checked"; print "></td>\n";
|
||||
print " <td><input type=\"radio\" name=\"ss\" value=\"n\"";
|
||||
if ($ss=="n") print " checked"; print "></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no);
|
||||
print" </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " <!-- ###SYMBOLSETS PANNEL END -->\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td valign=\"bottom\" align=\"left\">\n";
|
||||
print " <!-- ###AMOUNT AND SIZE PANNEL BEGIN -->\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$p_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th align=\"left\" bgcolor=\"$p_header_bgcolor\">";
|
||||
print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_amount_length);
|
||||
print "</th>\n";
|
||||
print " <tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_num_of_pass);
|
||||
print "</td>\n";
|
||||
print " <td><input type=\"text\" value=\"$numofpass\" name=\"numofpass\" size=\"3\" maxlength=\"3\"></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_up_to);
|
||||
print "</td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_min_pass_len);
|
||||
print "</td>\n";
|
||||
print " <td><input type=\"text\" value=\"$minpasslength\" name=\"minpasslength\" size=\"3\" maxlength=\"3\"></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_up_to);
|
||||
print "</td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_max_pass_len);
|
||||
print "</td>\n";
|
||||
print " <td><input type=\"text\" value=\"$maxpasslength\" name=\"maxpasslength\" size=\"3\" maxlength=\"3\"></td>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_up_to);
|
||||
print "</td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " <!-- ###AMOUNT AND SIZE PANNEL END -->\n";
|
||||
print " </td>\n";
|
||||
print " <td valign=\"bottom\" align=\"right\">\n";
|
||||
print " <!-- ###CL_SEED PANNEL BEGIN -->\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$p_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th align=\"left\" bgcolor=\"$p_header_bgcolor\">";
|
||||
print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_user_random_seed);
|
||||
print "</th>\n";
|
||||
print " <tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_seed);
|
||||
print "</td>\n";
|
||||
print " <td align=\"right\"><input type=\"text\" name=\"clseed\" value=\"$clseed\" size=\"8\" maxlength=\"8\"></td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " <!-- ###CL_SEED PANNEL END -->\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td valign=\"top\" align=\"left\">\n";
|
||||
print " <!-- ###CLEAR_SETTINGS PANNEL BEGIN -->\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$p_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_remove_saved);
|
||||
print "</td>\n";
|
||||
print " <td><input type=\"radio\" name=\"save_settings\" value=\"r\"></td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " <!-- ###CLEAR_SETTINGS PANNEL END -->\n";
|
||||
print " </td>\n";
|
||||
print " <td valign=\"top\" align=\"right\">\n";
|
||||
print " <!-- ###SAVE_SETTINGS PANNEL BEGIN -->\n";
|
||||
print " <table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$p_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_save_settings);
|
||||
print "</td>\n";
|
||||
print " <td><input type=\"radio\" name=\"save_settings\" value=\"s\"</td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " <!-- ###SAVE_SETTINGS PANNEL END -->\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td align=\"center\" colspan=\"2\"><input type=\"submit\" value=\"$submit_button_text\"></td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print "</form>\n";
|
||||
print "<!-- ###GENERATED PASSWORDS PANNEL BEGIN -->\n";
|
||||
print "<table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$interface_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th align=\"left\" bgcolor=\"$p_header_bgcolor\">";
|
||||
print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_generated_pass);
|
||||
print "</th>\n";
|
||||
print " <tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
$max_i = count ($outpasswords);
|
||||
for ($i = 0; $i < $max_i; $i++)
|
||||
{
|
||||
print " <tr>\n";
|
||||
if ($i % 2 == 0)
|
||||
print " <td><tt>$outpasswords[$i]</tt></td>\n";
|
||||
else
|
||||
print " <td bgcolor=\"$pass_hilight_color\"><tt>$outpasswords[$i]</tt></td>\n";
|
||||
print " </tr>\n";
|
||||
}
|
||||
$i = 0;
|
||||
unset($outpasswords);
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print "</table>\n";
|
||||
print "<br>\n";
|
||||
print "<!-- ###GENERATED PASSWORDS PANNEL END -->\n";
|
||||
if ($print_command_line == "true")
|
||||
{
|
||||
print "<!-- ###COMMAND LINE PANNEL BEGIN -->\n";
|
||||
print "<table cellpadding=\"$p_border_width\" cellspacing=\"0\" border=\"$p_3d_border_width\" bgcolor=\"$p_border_color\" width=\"$interface_width\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_header_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <th align=\"left\" bgcolor=\"$p_header_bgcolor\">";
|
||||
print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_command_line);
|
||||
print "</th>\n";
|
||||
print " <tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td>\n";
|
||||
print " <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$p_body_bgcolor\" width=\"100%\">\n";
|
||||
print " <tr>\n";
|
||||
print " <td>";
|
||||
print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$generator);
|
||||
print "</td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </td>\n";
|
||||
print " </tr>\n";
|
||||
print "</table>\n";
|
||||
print " <!-- ###COMMAND LINE PANNEL END -->\n";
|
||||
}
|
||||
print "</center>\n";
|
||||
####################################
|
||||
# Copyright dada
|
||||
#
|
||||
print "<font size=\"-3\" color=\"$copyright_color\">Copyright (c) 2001 Adel I. Mirzazhanov<br>\n";
|
||||
print "<a href=\"http://www.adel.nursat.kz/apg\">APG Homepage</a></font>\n";
|
||||
print "</body>\n";
|
||||
print "</html>\n";
|
||||
?>
|
||||
25
php/apgonline/lang/english.php
Normal file
25
php/apgonline/lang/english.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?
|
||||
$submit_button_text = "Generate";
|
||||
$message_algorithm = "Algorithm";
|
||||
$message_amount_length = "Amount and Length";
|
||||
$message_symbol_sets = "Symbol sets";
|
||||
$message_user_random_seed = "User's Random Seed";
|
||||
$message_save_settings = "Save settings in the cookie";
|
||||
$message_remove_saved = "Remove saved settings";
|
||||
$message_command_line = "Command line";
|
||||
$message_generated_pass = "Generated passwords";
|
||||
$message_yes = "Yes";
|
||||
$message_no = "No";
|
||||
$submessage_pronounceable = "Pronounceable:";
|
||||
$submessage_random = "Random:";
|
||||
$submessage_num_of_pass = "Number of passwords to generate:";
|
||||
$submessage_min_pass_len = "Min. password length:";
|
||||
$submessage_max_pass_len = "Max. password length:";
|
||||
$submessage_small_lerrers = "Small letters:";
|
||||
$submessage_cap_letters = "Capital letters:";
|
||||
$submessage_numbers = "Numbers";
|
||||
$submessage_spec_symbols = "Special symbols:";
|
||||
$submessage_seed = "Seed:";
|
||||
$submessage_up_to = "up to 255";
|
||||
header ("Pragma: no-cache");
|
||||
?>
|
||||
26
php/apgonline/lang/german.php
Normal file
26
php/apgonline/lang/german.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?
|
||||
// Translated by Bernhard Wesely (mail@weselyb.net)
|
||||
$submit_button_text = "Generieren";
|
||||
$message_algorithm = "Algorithmus";
|
||||
$message_amount_length = "Anzahl und Stellen";
|
||||
$message_symbol_sets = "Zeichensatz";
|
||||
$message_user_random_seed = "Eigener Random Seed";
|
||||
$message_save_settings = "Einstellungen in einem cookie speichern";
|
||||
$message_remove_saved = "Gespeicherte Einstellungen löschen";
|
||||
$message_command_line = "Shell-Befehl";
|
||||
$message_generated_pass = "Generierte Passwörter";
|
||||
$message_yes = "Ja";
|
||||
$message_no = "Nein";
|
||||
$submessage_pronounceable = "Aussprechbar:";
|
||||
$submessage_random = "Zufällig:";
|
||||
$submessage_num_of_pass = "Anzahl der zu generierenden Passwörter:";
|
||||
$submessage_min_pass_len = "Min. Passwort Länge:";
|
||||
$submessage_max_pass_len = "Max. Passwort Länge:";
|
||||
$submessage_small_lerrers = "Kleinbuchstaben:";
|
||||
$submessage_cap_letters = "Grossbuchstaben:";
|
||||
$submessage_numbers = "Nummern";
|
||||
$submessage_spec_symbols = "Symbole:";
|
||||
$submessage_seed = "Seed:";
|
||||
$submessage_up_to = "bis zu 255";
|
||||
header ("Pragma: no-cache");
|
||||
?>
|
||||
26
php/apgonline/lang/polish.php
Normal file
26
php/apgonline/lang/polish.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?
|
||||
$submit_button_text = "Wygeneruj";
|
||||
$message_algorithm = "Algorytm";
|
||||
$message_amount_length = "Ilo<EFBFBD><EFBFBD> i d<>ugo<67><6F>";
|
||||
$message_symbol_sets = "Zestawy znak<61>w";
|
||||
$message_user_random_seed = "Ziarno u<>ytkownika";
|
||||
$message_save_settings = "Zapisz ustawienia w \"cookie\"";
|
||||
$message_remove_saved = "Usu<EFBFBD> zapisane ustawienia";
|
||||
$message_command_line = "Linia polecenia";
|
||||
$message_generated_pass = "Wygenerowane has<61>a";
|
||||
$message_yes = "Tak";
|
||||
$message_no = "Nie";
|
||||
$submessage_pronounceable = "Wymawialne:";
|
||||
$submessage_random = "Losowe:";
|
||||
$submessage_num_of_pass = "Ilo<EFBFBD><EFBFBD> hase<73> do wygenerowania:";
|
||||
$submessage_min_pass_len = "Minimalna d<>ugo<67><6F> has<61>a:";
|
||||
$submessage_max_pass_len = "Maksymalna d<>ugo<67><6F> has<61>a:";
|
||||
$submessage_small_lerrers = "Ma<EFBFBD>e litery:";
|
||||
$submessage_cap_letters = "Du<EFBFBD>e litery:";
|
||||
$submessage_numbers = "Liczby";
|
||||
$submessage_spec_symbols = "Znaki specjalne:";
|
||||
$submessage_seed = "Ziarno:";
|
||||
$submessage_up_to = "do 255";
|
||||
header( "Content-type: text/html; charset=iso-8859-2" );
|
||||
header ("Pragma: no-cache");
|
||||
?>
|
||||
26
php/apgonline/lang/rus-1251.php
Normal file
26
php/apgonline/lang/rus-1251.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?
|
||||
$submit_button_text = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_algorithm = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_amount_length = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_symbol_sets = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_user_random_seed = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_save_settings = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> cookie";
|
||||
$message_remove_saved = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_command_line = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_generated_pass = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_yes = "<EFBFBD><EFBFBD>";
|
||||
$message_no = "<EFBFBD><EFBFBD><EFBFBD>";
|
||||
$submessage_pronounceable = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_random = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_num_of_pass = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_min_pass_len = "<EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_max_pass_len = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_small_lerrers = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_cap_letters = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_numbers = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_spec_symbols = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_seed = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_up_to = "<EFBFBD><EFBFBD> 255";
|
||||
header( "Content-type: text/html; charset=windows-1251" );
|
||||
header ("Pragma: no-cache");
|
||||
?>
|
||||
26
php/apgonline/lang/rus-koi8r.php
Normal file
26
php/apgonline/lang/rus-koi8r.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?
|
||||
$submit_button_text = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_algorithm = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_amount_length = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_symbol_sets = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_user_random_seed = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_save_settings = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> cookie";
|
||||
$message_remove_saved = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_command_line = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_generated_pass = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
$message_yes = "<EFBFBD><EFBFBD>";
|
||||
$message_no = "<EFBFBD><EFBFBD><EFBFBD>";
|
||||
$submessage_pronounceable = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_random = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_num_of_pass = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_min_pass_len = "<EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_max_pass_len = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_small_lerrers = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_cap_letters = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_numbers = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_spec_symbols = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_seed = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:";
|
||||
$submessage_up_to = "<EFBFBD><EFBFBD> 255";
|
||||
header( "Content-type: text/html; charset=koi8-r" );
|
||||
header ("Pragma: no-cache");
|
||||
?>
|
||||
35
php/apgonline/themes/black-green.php
Normal file
35
php/apgonline/themes/black-green.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?
|
||||
###################################
|
||||
# Standard HTML Page colors
|
||||
#
|
||||
$page_bgcolor = "#000000" ;
|
||||
$page_text = "#ffffff" ;
|
||||
$page_link = "#33ff33" ;
|
||||
$page_vlink = "#33ff33" ;
|
||||
$page_alink = "#ff0000" ;
|
||||
|
||||
###################################
|
||||
# Interface settings
|
||||
$interface_width = "760";
|
||||
$copyright_color = "#333333";
|
||||
|
||||
###################################
|
||||
# Pannel properis
|
||||
#
|
||||
$p_width = "370";
|
||||
$p_border_width = "1";
|
||||
$p_3d_border_width = "0";
|
||||
$p_border_color = "#009900";
|
||||
|
||||
$p_header_bgcolor = "#006600";
|
||||
$p_header_font_color = "#ffffff";
|
||||
$p_header_font_size = "0";
|
||||
$p_header_font_face = "Helvetica,Arial,sans-serif";
|
||||
|
||||
$p_body_bgcolor = "#000000";
|
||||
$p_body_font_color = "#ffffff";
|
||||
$p_body_font_size = "0";
|
||||
$p_body_font_face = "Helvetica,Arial,sans-serif";
|
||||
|
||||
$pass_hilight_color = "#666666";
|
||||
?>
|
||||
35
php/apgonline/themes/black-orange.php
Normal file
35
php/apgonline/themes/black-orange.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?
|
||||
###################################
|
||||
# Standard HTML Page colors
|
||||
#
|
||||
$page_bgcolor = "#000000" ;
|
||||
$page_text = "#ffffff" ;
|
||||
$page_link = "#33ff33" ;
|
||||
$page_vlink = "#33ff33" ;
|
||||
$page_alink = "#ff0000" ;
|
||||
|
||||
###################################
|
||||
# Interface settings
|
||||
$interface_width = "760";
|
||||
$copyright_color = "#333333";
|
||||
|
||||
###################################
|
||||
# Pannel properis
|
||||
#
|
||||
$p_width = "370";
|
||||
$p_border_width = "1";
|
||||
$p_3d_border_width = "0";
|
||||
$p_border_color = "#cc6600";
|
||||
|
||||
$p_header_bgcolor = "#990000";
|
||||
$p_header_font_color = "#ffffff";
|
||||
$p_header_font_size = "0";
|
||||
$p_header_font_face = "Helvetica,Arial,sans-serif";
|
||||
|
||||
$p_body_bgcolor = "#000000";
|
||||
$p_body_font_color = "#ffffff";
|
||||
$p_body_font_size = "0";
|
||||
$p_body_font_face = "Helvetica,Arial,sans-serif";
|
||||
|
||||
$pass_hilight_color = "#666666";
|
||||
?>
|
||||
35
php/apgonline/themes/default.php
Normal file
35
php/apgonline/themes/default.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?
|
||||
###################################
|
||||
# Standard HTML Page colors
|
||||
#
|
||||
$page_bgcolor = "#ffffff" ;
|
||||
$page_text = "#000000" ;
|
||||
$page_link = "#0000ff" ;
|
||||
$page_vlink = "#000080" ;
|
||||
$page_alink = "#ff0000" ;
|
||||
|
||||
###################################
|
||||
# Interface settings
|
||||
$interface_width = "760";
|
||||
$copyright_color = "#eeeeee";
|
||||
|
||||
###################################
|
||||
# Pannel properis
|
||||
#
|
||||
$p_width = "370";
|
||||
$p_border_width = "1";
|
||||
$p_3d_border_width = "0";
|
||||
$p_border_color = "#6633ff";
|
||||
|
||||
$p_header_bgcolor = "#6633ff";
|
||||
$p_header_font_color = "#ffffff";
|
||||
$p_header_font_size = "0";
|
||||
$p_header_font_face = "Helvetica,Arial,sans-serif";
|
||||
|
||||
$p_body_bgcolor = "#ffffff";
|
||||
$p_body_font_color = "#000000";
|
||||
$p_body_font_size = "-1";
|
||||
$p_body_font_face = "Helvetica,Arial,sans-serif";
|
||||
|
||||
$pass_hilight_color = "#eeeeee";
|
||||
?>
|
||||
255
pronpass.c
255
pronpass.c
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,11 +37,14 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include "pronpass.h"
|
||||
#include "randpass.h"
|
||||
#include "convert.h"
|
||||
#include "errs.h"
|
||||
|
||||
struct unit
|
||||
@@ -89,7 +92,7 @@ static struct unit rules[] =
|
||||
|
||||
static int digram[][RULE_SIZE] =
|
||||
{
|
||||
/* aa */ ILLEGAL_PAIR,
|
||||
{/* aa */ ILLEGAL_PAIR,
|
||||
/* ab */ ANY_COMBINATION,
|
||||
/* ac */ ANY_COMBINATION,
|
||||
/* ad */ ANY_COMBINATION,
|
||||
@@ -122,8 +125,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* ath */ ANY_COMBINATION,
|
||||
/* awh */ ILLEGAL_PAIR,
|
||||
/* aqu */ BREAK | NOT_END,
|
||||
/* ack */ ANY_COMBINATION,
|
||||
/* ba */ ANY_COMBINATION,
|
||||
/* ack */ ANY_COMBINATION},
|
||||
{/* ba */ ANY_COMBINATION,
|
||||
/* bb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* bc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* bd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -156,8 +159,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* bth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* bwh */ ILLEGAL_PAIR,
|
||||
/* bqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* bck */ ILLEGAL_PAIR,
|
||||
/* ca */ ANY_COMBINATION,
|
||||
/* bck */ ILLEGAL_PAIR },
|
||||
{/* ca */ ANY_COMBINATION,
|
||||
/* cb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* cc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* cd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -190,8 +193,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* cth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* cwh */ ILLEGAL_PAIR,
|
||||
/* cqu */ NOT_BEGIN | SUFFIX | NOT_END,
|
||||
/* cck */ ILLEGAL_PAIR,
|
||||
/* da */ ANY_COMBINATION,
|
||||
/* cck */ ILLEGAL_PAIR},
|
||||
{/* da */ ANY_COMBINATION,
|
||||
/* db */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* dc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* dd */ NOT_BEGIN,
|
||||
@@ -224,8 +227,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* dth */ NOT_BEGIN | PREFIX,
|
||||
/* dwh */ ILLEGAL_PAIR,
|
||||
/* dqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* dck */ ILLEGAL_PAIR,
|
||||
/* ea */ ANY_COMBINATION,
|
||||
/* dck */ ILLEGAL_PAIR },
|
||||
{/* ea */ ANY_COMBINATION,
|
||||
/* eb */ ANY_COMBINATION,
|
||||
/* ec */ ANY_COMBINATION,
|
||||
/* ed */ ANY_COMBINATION,
|
||||
@@ -258,8 +261,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* eth */ ANY_COMBINATION,
|
||||
/* ewh */ ILLEGAL_PAIR,
|
||||
/* equ */ BREAK | NOT_END,
|
||||
/* eck */ ANY_COMBINATION,
|
||||
/* fa */ ANY_COMBINATION,
|
||||
/* eck */ ANY_COMBINATION },
|
||||
{/* fa */ ANY_COMBINATION,
|
||||
/* fb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* fc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* fd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -292,8 +295,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* fth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* fwh */ ILLEGAL_PAIR,
|
||||
/* fqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* fck */ ILLEGAL_PAIR,
|
||||
/* ga */ ANY_COMBINATION,
|
||||
/* fck */ ILLEGAL_PAIR },
|
||||
{/* ga */ ANY_COMBINATION,
|
||||
/* gb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* gc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* gd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -326,8 +329,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* gth */ NOT_BEGIN,
|
||||
/* gwh */ ILLEGAL_PAIR,
|
||||
/* gqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* gck */ ILLEGAL_PAIR,
|
||||
/* ha */ ANY_COMBINATION,
|
||||
/* gck */ ILLEGAL_PAIR },
|
||||
{/* ha */ ANY_COMBINATION,
|
||||
/* hb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* hc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* hd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -360,8 +363,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* hth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* hwh */ ILLEGAL_PAIR,
|
||||
/* hqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* hck */ ILLEGAL_PAIR,
|
||||
/* ia */ ANY_COMBINATION,
|
||||
/* hck */ ILLEGAL_PAIR },
|
||||
{/* ia */ ANY_COMBINATION,
|
||||
/* ib */ ANY_COMBINATION,
|
||||
/* ic */ ANY_COMBINATION,
|
||||
/* id */ ANY_COMBINATION,
|
||||
@@ -394,8 +397,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* ith */ ANY_COMBINATION,
|
||||
/* iwh */ ILLEGAL_PAIR,
|
||||
/* iqu */ BREAK | NOT_END,
|
||||
/* ick */ ANY_COMBINATION,
|
||||
/* ja */ ANY_COMBINATION,
|
||||
/* ick */ ANY_COMBINATION },
|
||||
{/* ja */ ANY_COMBINATION,
|
||||
/* jb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* jc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* jd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -428,8 +431,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* jth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* jwh */ ILLEGAL_PAIR,
|
||||
/* jqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* jck */ ILLEGAL_PAIR,
|
||||
/* ka */ ANY_COMBINATION,
|
||||
/* jck */ ILLEGAL_PAIR },
|
||||
{/* ka */ ANY_COMBINATION,
|
||||
/* kb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* kc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* kd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -462,8 +465,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* kth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* kwh */ ILLEGAL_PAIR,
|
||||
/* kqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* kck */ ILLEGAL_PAIR,
|
||||
/* la */ ANY_COMBINATION,
|
||||
/* kck */ ILLEGAL_PAIR },
|
||||
{/* la */ ANY_COMBINATION,
|
||||
/* lb */ NOT_BEGIN | PREFIX,
|
||||
/* lc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ld */ NOT_BEGIN | PREFIX,
|
||||
@@ -496,8 +499,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* lth */ NOT_BEGIN | PREFIX,
|
||||
/* lwh */ ILLEGAL_PAIR,
|
||||
/* lqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* lck */ ILLEGAL_PAIR,
|
||||
/* ma */ ANY_COMBINATION,
|
||||
/* lck */ ILLEGAL_PAIR },
|
||||
{/* ma */ ANY_COMBINATION,
|
||||
/* mb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* mc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* md */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -530,8 +533,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* mth */ NOT_BEGIN,
|
||||
/* mwh */ ILLEGAL_PAIR,
|
||||
/* mqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* mck */ ILLEGAL_PAIR,
|
||||
/* na */ ANY_COMBINATION,
|
||||
/* mck */ ILLEGAL_PAIR },
|
||||
{/* na */ ANY_COMBINATION,
|
||||
/* nb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* nc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* nd */ NOT_BEGIN,
|
||||
@@ -564,8 +567,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* nth */ NOT_BEGIN,
|
||||
/* nwh */ ILLEGAL_PAIR,
|
||||
/* nqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* nck */ NOT_BEGIN | PREFIX,
|
||||
/* oa */ ANY_COMBINATION,
|
||||
/* nck */ NOT_BEGIN | PREFIX },
|
||||
{/* oa */ ANY_COMBINATION,
|
||||
/* ob */ ANY_COMBINATION,
|
||||
/* oc */ ANY_COMBINATION,
|
||||
/* od */ ANY_COMBINATION,
|
||||
@@ -598,8 +601,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* oth */ ANY_COMBINATION,
|
||||
/* owh */ ILLEGAL_PAIR,
|
||||
/* oqu */ BREAK | NOT_END,
|
||||
/* ock */ ANY_COMBINATION,
|
||||
/* pa */ ANY_COMBINATION,
|
||||
/* ock */ ANY_COMBINATION },
|
||||
{/* pa */ ANY_COMBINATION,
|
||||
/* pb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* pc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* pd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -632,8 +635,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* pth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* pwh */ ILLEGAL_PAIR,
|
||||
/* pqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* pck */ ILLEGAL_PAIR,
|
||||
/* ra */ ANY_COMBINATION,
|
||||
/* pck */ ILLEGAL_PAIR },
|
||||
{/* ra */ ANY_COMBINATION,
|
||||
/* rb */ NOT_BEGIN | PREFIX,
|
||||
/* rc */ NOT_BEGIN | PREFIX,
|
||||
/* rd */ NOT_BEGIN | PREFIX,
|
||||
@@ -666,8 +669,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* rth */ NOT_BEGIN | PREFIX,
|
||||
/* rwh */ ILLEGAL_PAIR,
|
||||
/* rqu */ NOT_BEGIN | PREFIX | NOT_END,
|
||||
/* rck */ NOT_BEGIN | PREFIX,
|
||||
/* sa */ ANY_COMBINATION,
|
||||
/* rck */ NOT_BEGIN | PREFIX },
|
||||
{/* sa */ ANY_COMBINATION,
|
||||
/* sb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* sc */ NOT_END,
|
||||
/* sd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -700,8 +703,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* sth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* swh */ ILLEGAL_PAIR,
|
||||
/* squ */ SUFFIX | NOT_END,
|
||||
/* sck */ NOT_BEGIN,
|
||||
/* ta */ ANY_COMBINATION,
|
||||
/* sck */ NOT_BEGIN },
|
||||
{/* ta */ ANY_COMBINATION,
|
||||
/* tb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* tc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* td */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -734,8 +737,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* tth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* twh */ ILLEGAL_PAIR,
|
||||
/* tqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* tck */ ILLEGAL_PAIR,
|
||||
/* ua */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* tck */ ILLEGAL_PAIR },
|
||||
{/* ua */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ub */ ANY_COMBINATION,
|
||||
/* uc */ ANY_COMBINATION,
|
||||
/* ud */ ANY_COMBINATION,
|
||||
@@ -768,8 +771,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* uth */ ANY_COMBINATION,
|
||||
/* uwh */ ILLEGAL_PAIR,
|
||||
/* uqu */ BREAK | NOT_END,
|
||||
/* uck */ ANY_COMBINATION,
|
||||
/* va */ ANY_COMBINATION,
|
||||
/* uck */ ANY_COMBINATION },
|
||||
{/* va */ ANY_COMBINATION,
|
||||
/* vb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* vc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* vd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -802,8 +805,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* vth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* vwh */ ILLEGAL_PAIR,
|
||||
/* vqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* vck */ ILLEGAL_PAIR,
|
||||
/* wa */ ANY_COMBINATION,
|
||||
/* vck */ ILLEGAL_PAIR },
|
||||
{/* wa */ ANY_COMBINATION,
|
||||
/* wb */ NOT_BEGIN | PREFIX,
|
||||
/* wc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* wd */ NOT_BEGIN | PREFIX | END,
|
||||
@@ -836,8 +839,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* wth */ NOT_BEGIN,
|
||||
/* wwh */ ILLEGAL_PAIR,
|
||||
/* wqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* wck */ NOT_BEGIN,
|
||||
/* xa */ NOT_BEGIN,
|
||||
/* wck */ NOT_BEGIN },
|
||||
{/* xa */ NOT_BEGIN,
|
||||
/* xb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* xc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* xd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -870,8 +873,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* xth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* xwh */ ILLEGAL_PAIR,
|
||||
/* xqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* xck */ ILLEGAL_PAIR,
|
||||
/* ya */ ANY_COMBINATION,
|
||||
/* xck */ ILLEGAL_PAIR },
|
||||
{/* ya */ ANY_COMBINATION,
|
||||
/* yb */ NOT_BEGIN,
|
||||
/* yc */ NOT_BEGIN | NOT_END,
|
||||
/* yd */ NOT_BEGIN,
|
||||
@@ -904,8 +907,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* yth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ywh */ ILLEGAL_PAIR,
|
||||
/* yqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* yck */ ILLEGAL_PAIR,
|
||||
/* za */ ANY_COMBINATION,
|
||||
/* yck */ ILLEGAL_PAIR },
|
||||
{/* za */ ANY_COMBINATION,
|
||||
/* zb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* zc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* zd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -938,8 +941,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* zth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* zwh */ ILLEGAL_PAIR,
|
||||
/* zqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* zck */ ILLEGAL_PAIR,
|
||||
/* cha */ ANY_COMBINATION,
|
||||
/* zck */ ILLEGAL_PAIR },
|
||||
{/* cha */ ANY_COMBINATION,
|
||||
/* chb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* chc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* chd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -972,8 +975,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* chth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* chwh */ ILLEGAL_PAIR,
|
||||
/* chqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* chck */ ILLEGAL_PAIR,
|
||||
/* gha */ ANY_COMBINATION,
|
||||
/* chck */ ILLEGAL_PAIR },
|
||||
{/* gha */ ANY_COMBINATION,
|
||||
/* ghb */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||
/* ghc */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||
/* ghd */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||
@@ -1006,8 +1009,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* ghth */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||
/* ghwh */ ILLEGAL_PAIR,
|
||||
/* ghqu */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||
/* ghck */ ILLEGAL_PAIR,
|
||||
/* pha */ ANY_COMBINATION,
|
||||
/* ghck */ ILLEGAL_PAIR },
|
||||
{/* pha */ ANY_COMBINATION,
|
||||
/* phb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* phc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* phd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -1040,8 +1043,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* phth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* phwh */ ILLEGAL_PAIR,
|
||||
/* phqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* phck */ ILLEGAL_PAIR,
|
||||
/* rha */ BEGIN | NOT_END,
|
||||
/* phck */ ILLEGAL_PAIR },
|
||||
{/* rha */ BEGIN | NOT_END,
|
||||
/* rhb */ ILLEGAL_PAIR,
|
||||
/* rhc */ ILLEGAL_PAIR,
|
||||
/* rhd */ ILLEGAL_PAIR,
|
||||
@@ -1074,8 +1077,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* rhth */ ILLEGAL_PAIR,
|
||||
/* rhwh */ ILLEGAL_PAIR,
|
||||
/* rhqu */ ILLEGAL_PAIR,
|
||||
/* rhck */ ILLEGAL_PAIR,
|
||||
/* sha */ ANY_COMBINATION,
|
||||
/* rhck */ ILLEGAL_PAIR },
|
||||
{/* sha */ ANY_COMBINATION,
|
||||
/* shb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* shc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* shd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -1108,8 +1111,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* shth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* shwh */ ILLEGAL_PAIR,
|
||||
/* shqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* shck */ ILLEGAL_PAIR,
|
||||
/* tha */ ANY_COMBINATION,
|
||||
/* shck */ ILLEGAL_PAIR },
|
||||
{/* tha */ ANY_COMBINATION,
|
||||
/* thb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* thc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* thd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -1142,8 +1145,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* thth */ ILLEGAL_PAIR,
|
||||
/* thwh */ ILLEGAL_PAIR,
|
||||
/* thqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* thck */ ILLEGAL_PAIR,
|
||||
/* wha */ BEGIN | NOT_END,
|
||||
/* thck */ ILLEGAL_PAIR },
|
||||
{/* wha */ BEGIN | NOT_END,
|
||||
/* whb */ ILLEGAL_PAIR,
|
||||
/* whc */ ILLEGAL_PAIR,
|
||||
/* whd */ ILLEGAL_PAIR,
|
||||
@@ -1176,8 +1179,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* whth */ ILLEGAL_PAIR,
|
||||
/* whwh */ ILLEGAL_PAIR,
|
||||
/* whqu */ ILLEGAL_PAIR,
|
||||
/* whck */ ILLEGAL_PAIR,
|
||||
/* qua */ ANY_COMBINATION,
|
||||
/* whck */ ILLEGAL_PAIR },
|
||||
{/* qua */ ANY_COMBINATION,
|
||||
/* qub */ ILLEGAL_PAIR,
|
||||
/* quc */ ILLEGAL_PAIR,
|
||||
/* qud */ ILLEGAL_PAIR,
|
||||
@@ -1210,8 +1213,8 @@ static int digram[][RULE_SIZE] =
|
||||
/* quth */ ILLEGAL_PAIR,
|
||||
/* quwh */ ILLEGAL_PAIR,
|
||||
/* ququ */ ILLEGAL_PAIR,
|
||||
/* quck */ ILLEGAL_PAIR,
|
||||
/* cka */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* quck */ ILLEGAL_PAIR },
|
||||
{/* cka */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ckb */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ckc */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ckd */ NOT_BEGIN | BREAK | NOT_END,
|
||||
@@ -1244,7 +1247,7 @@ static int digram[][RULE_SIZE] =
|
||||
/* ckth */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ckwh */ ILLEGAL_PAIR,
|
||||
/* ckqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||
/* ckck */ ILLEGAL_PAIR
|
||||
/* ckck */ ILLEGAL_PAIR}
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1273,7 +1276,8 @@ gen_pron_pass (char *word, char *hyphenated_word, USHORT minlen,
|
||||
* Check for minlen>maxlen. This is an error.
|
||||
* and a length of 0.
|
||||
*/
|
||||
if (minlen > maxlen || minlen > 255 || maxlen > 255)
|
||||
if (minlen > maxlen || minlen > APG_MAX_PASSWORD_LENGTH ||
|
||||
maxlen > APG_MAX_PASSWORD_LENGTH)
|
||||
return (-1);
|
||||
/*
|
||||
* Check for zero length words. This is technically not an error,
|
||||
@@ -1309,6 +1313,7 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
||||
USHORT word_length;
|
||||
USHORT syllable_length;
|
||||
char *new_syllable;
|
||||
char *syllable_for_hyph;
|
||||
USHORT *syllable_units;
|
||||
USHORT word_size;
|
||||
USHORT word_place;
|
||||
@@ -1316,6 +1321,7 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
||||
USHORT syllable_size;
|
||||
UINT tries;
|
||||
int ch_flag = FALSE;
|
||||
int dsd = 0;
|
||||
|
||||
/*
|
||||
* Keep count of retries.
|
||||
@@ -1345,7 +1351,8 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
||||
*/
|
||||
if ( (word_units = (USHORT *) calloc (sizeof (USHORT), pwlen+1))==NULL ||
|
||||
(syllable_units = (USHORT *) calloc (sizeof (USHORT), pwlen+1))==NULL ||
|
||||
(new_syllable = (char *) calloc (sizeof (USHORT), pwlen+1)) ==NULL)
|
||||
(new_syllable = (char *) calloc (sizeof (USHORT), pwlen+1)) ==NULL ||
|
||||
(syllable_for_hyph = (char *) calloc (sizeof(char), 20))==NULL)
|
||||
return(-1);
|
||||
|
||||
/*
|
||||
@@ -1387,18 +1394,33 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
||||
** Modify syllable for numeric or capital symbols required
|
||||
** Should be done after word quality check.
|
||||
*/
|
||||
if ( ((pass_mode & S_NB) > 0) && (syllable_length == 1))
|
||||
dsd = randint(2);
|
||||
if ( ((pass_mode & S_NB) > 0) && (syllable_length == 1) && dsd == 0)
|
||||
{
|
||||
numerize(new_syllable);
|
||||
ch_flag = TRUE;
|
||||
}
|
||||
if ( ((pass_mode & S_SS) > 0) && (syllable_length == 1) && (dsd == 1))
|
||||
{
|
||||
specialize(new_syllable);
|
||||
ch_flag = TRUE;
|
||||
}
|
||||
if ( ( (pass_mode & S_CL) > 0) && (ch_flag != TRUE))
|
||||
capitalize(new_syllable);
|
||||
ch_flag = FALSE;
|
||||
/**/
|
||||
(void) strcpy (word, new_syllable);
|
||||
if (syllable_length == 1)
|
||||
{
|
||||
symb2name(new_syllable, syllable_for_hyph);
|
||||
(void) strcpy (hyphenated_word, syllable_for_hyph);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) strcpy (hyphenated_word, new_syllable);
|
||||
bzero ( (void *)new_syllable, (size_t)(pwlen * sizeof(USHORT)+1));
|
||||
}
|
||||
(void)memset ( (void *)new_syllable, 0, (size_t)(pwlen * sizeof(USHORT)+1));
|
||||
(void)memset ( (void *)syllable_for_hyph, 0, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1406,19 +1428,34 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
||||
** Modify syllable for numeric or capital symbols required
|
||||
** Should be done after word quality check.
|
||||
*/
|
||||
if ( ((pass_mode & S_NB) > 0) && (syllable_length == 1))
|
||||
dsd = randint(2);
|
||||
if ( ((pass_mode & S_NB) > 0) && (syllable_length == 1) && (dsd == 0))
|
||||
{
|
||||
numerize(new_syllable);
|
||||
ch_flag = TRUE;
|
||||
}
|
||||
if ( ( (pass_mode & S_SS) > 0) && (syllable_length == 1) && (dsd == 1))
|
||||
{
|
||||
specialize(new_syllable);
|
||||
ch_flag = TRUE;
|
||||
}
|
||||
if ( ( (pass_mode & S_CL) > 0) && (ch_flag != TRUE))
|
||||
capitalize(new_syllable);
|
||||
ch_flag = FALSE;
|
||||
/**/
|
||||
(void) strcat (word, new_syllable);
|
||||
(void) strcat (hyphenated_word, "-");
|
||||
if (syllable_length == 1)
|
||||
{
|
||||
symb2name(new_syllable, syllable_for_hyph);
|
||||
(void) strcat (hyphenated_word, syllable_for_hyph);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) strcat (hyphenated_word, new_syllable);
|
||||
bzero ( (void *)new_syllable, (size_t)(pwlen * sizeof(USHORT)+1));
|
||||
}
|
||||
(void)memset ( (void *)new_syllable, 0, (size_t)(pwlen * sizeof(USHORT)+1));
|
||||
(void)memset ( (void *)syllable_for_hyph, 0, 20);
|
||||
}
|
||||
word_length += syllable_length;
|
||||
}
|
||||
@@ -1448,6 +1485,7 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
||||
free ((char *) new_syllable);
|
||||
free ((char *) syllable_units);
|
||||
free ((char *) word_units);
|
||||
free ((char *) syllable_for_hyph);
|
||||
|
||||
return ((int) word_length);
|
||||
}
|
||||
@@ -2228,11 +2266,19 @@ random_unit (USHORT type)
|
||||
|
||||
|
||||
/*
|
||||
* This routine should return a uniformly distributed Random number between
|
||||
* minlen and maxlen inclusive. The Electronic Code Book form of CAST is
|
||||
* used to produce the Random number. The inputs to CAST are the old pass-
|
||||
* word and a pseudoRandom key generated according to the procedure out-
|
||||
* lined in Appendix C of ANSI X9.17.
|
||||
** get_random() -
|
||||
** This routine should return a uniformly distributed Random number between
|
||||
** minlen and maxlen inclusive. The Electronic Code Book form of CAST is
|
||||
** used to produce the Random number. The inputs to CAST are the old pass-
|
||||
** word and a pseudoRandom key generated according to the procedure out-
|
||||
** lined in Appendix C of ANSI X9.17.
|
||||
** INPUT:
|
||||
** USHORT - minimum
|
||||
** USHORT - maximum
|
||||
** OUTPUT:
|
||||
** USHORT - random number
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
|
||||
USHORT
|
||||
@@ -2242,52 +2288,3 @@ get_random (USHORT minlen, USHORT maxlen)
|
||||
ret = minlen + (USHORT) randint ((int) (maxlen - minlen + 1));
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
** This routine designed to modify sullable like this:
|
||||
** adel ----> Adel
|
||||
** dot ----> Dot
|
||||
** etc.
|
||||
*/
|
||||
void capitalize (char *syllable)
|
||||
{
|
||||
char let[26] =
|
||||
{
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'w', 'z'
|
||||
};
|
||||
char clet[26] =
|
||||
{
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
||||
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'W', 'Z'
|
||||
};
|
||||
char tmp = 0x00;
|
||||
int i = 0;
|
||||
if ( randint(2) == TRUE)
|
||||
{
|
||||
bcopy ((void *)syllable, (void *)&tmp, sizeof(tmp));
|
||||
for(i=0; i < 26; i++)
|
||||
if ( let[i] == tmp ) bcopy ((void *)&clet[i], (void *)syllable, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** This routine designed to modify single-letter syllable like this:
|
||||
** a ----> 1 or 2 or 3 etc.
|
||||
** u ----> 1 or 2 or 3 etc.
|
||||
** etc.
|
||||
*/
|
||||
void numerize (char *syllable)
|
||||
{
|
||||
char *tmp;
|
||||
if ( (tmp = (char *)calloc(1, 4)) == NULL)
|
||||
err_sys_fatal("calloc");
|
||||
if ( (randint(2) == TRUE) && (strlen (syllable) == 1) )
|
||||
{
|
||||
sprintf(tmp, "%d", randint(10));
|
||||
bcopy ((void *)tmp, (void *)syllable, 1);
|
||||
}
|
||||
free ((void *)tmp);
|
||||
}
|
||||
|
||||
18
pronpass.h
18
pronpass.h
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,16 +34,16 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PRONPASS_H
|
||||
#define PRONPASS_H 1
|
||||
#ifndef APG_PRONPASS_H
|
||||
#define APG_PRONPASS_H 1
|
||||
|
||||
#ifndef OWN_TYPES_H
|
||||
#ifndef APG_OWN_TYPES_H
|
||||
#include "owntypes.h"
|
||||
#endif /* OWN_TYPES_H */
|
||||
#endif /* APG_OWN_TYPES_H */
|
||||
|
||||
#ifndef RND_H
|
||||
#ifndef APG_RND_H
|
||||
#include "rnd.h"
|
||||
#endif /* RND_H */
|
||||
#endif /* APG_RND_H */
|
||||
|
||||
#define RULE_SIZE (sizeof(rules)/sizeof(struct unit))
|
||||
#define ALLOWED(flag) (digram[units_in_syllable[current_unit -1]][unit] & (flag))
|
||||
@@ -80,7 +80,5 @@ int gen_word (char *word, char *hyphenated_word, USHORT pwlen,
|
||||
unsigned int pass_mode);
|
||||
char *gen_syllable(char *syllable, USHORT pwlen, USHORT *units_in_syllable,
|
||||
USHORT *syllable_length);
|
||||
void capitalize (char *syllable);
|
||||
void numerize (char *syllable);
|
||||
|
||||
#endif /* PRONPASS_H */
|
||||
#endif /* APG_PRONPASS_H */
|
||||
|
||||
109
randpass.c
109
randpass.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,37 +34,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include "randpass.h"
|
||||
|
||||
#include "owntypes.h"
|
||||
struct sym
|
||||
{
|
||||
char ch;
|
||||
USHORT type;
|
||||
};
|
||||
static struct sym smbl[94] =
|
||||
{
|
||||
{'a', S_SL}, {'b', S_SL}, {'c', S_SL}, {'d', S_SL}, {'e', S_SL}, {'f', S_SL},
|
||||
{'g', S_SL}, {'h', S_SL}, {'i', S_SL}, {'j', S_SL}, {'k', S_SL}, {'l', S_SL},
|
||||
{'m', S_SL}, {'n', S_SL}, {'o', S_SL}, {'p', S_SL}, {'q', S_SL}, {'r', S_SL},
|
||||
{'s', S_SL}, {'t', S_SL}, {'u', S_SL}, {'v', S_SL}, {'w', S_SL}, {'x', S_SL},
|
||||
{'y', S_SL}, {'z', S_SL}, {'A', S_CL}, {'B', S_CL}, {'C', S_CL}, {'D', S_CL},
|
||||
{'E', S_CL}, {'F', S_CL}, {'G', S_CL}, {'H', S_CL}, {'I', S_CL}, {'I', S_CL},
|
||||
{'K', S_CL}, {'K', S_CL}, {'M', S_CL}, {'N', S_CL}, {'O', S_CL}, {'P', S_CL},
|
||||
{'Q', S_CL}, {'R', S_CL}, {'S', S_CL}, {'T', S_CL}, {'U', S_CL}, {'V', S_CL},
|
||||
{'W', S_CL}, {'X', S_CL}, {'Y', S_CL}, {'Z', S_CL}, {'1', S_NB}, {'2', S_NB},
|
||||
{'3', S_NB}, {'4', S_NB}, {'5', S_NB}, {'6', S_NB}, {'7', S_NB}, {'8', S_NB},
|
||||
{'9', S_NB}, {'0', S_NB}, {33 , S_SS}, {34 , S_SS|S_RS}, {35 , S_SS}, {36 , S_SS|S_RS},
|
||||
{37 , S_SS}, {38 , S_SS}, {39 , S_SS|S_RS}, {40 , S_SS}, {41 , S_SS}, {42 , S_SS},
|
||||
{43 , S_SS}, {44 , S_SS}, {45 , S_SS}, {46 , S_SS}, {47 , S_SS}, {58 , S_SS},
|
||||
{59 , S_SS}, {60 , S_SS}, {61 , S_SS}, {62 , S_SS}, {63 , S_SS|S_RS}, {64 , S_SS},
|
||||
{91 , S_SS}, {92 , S_SS|S_RS}, {93 , S_SS}, {94 , S_SS}, {95 , S_SS}, {96 , S_SS|S_RS},
|
||||
{123, S_SS}, {124, S_SS|S_RS}, {125, S_SS}, {126, S_SS}
|
||||
};
|
||||
#include "smbl.h"
|
||||
|
||||
/*
|
||||
** gen_rand_pass - generates random password of specified type
|
||||
** INPUT:
|
||||
** char * - password string.
|
||||
** int - minimum password length.
|
||||
** int - maximum password length.
|
||||
** unsigned int - password generation mode.
|
||||
** OUTPUT:
|
||||
** int - password length or -1 on error.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int
|
||||
gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode)
|
||||
@@ -77,7 +66,8 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
|
||||
int max_weight = 0;
|
||||
int max_weight_element_number = 0;
|
||||
|
||||
if (minl > 256 || maxl > 256 || minl < 1 || maxl < 1 || minl > maxl)
|
||||
if (minl > APG_MAX_PASSWORD_LENGTH || maxl > APG_MAX_PASSWORD_LENGTH ||
|
||||
minl < 1 || maxl < 1 || minl > maxl)
|
||||
return (-1);
|
||||
for (i = 0; i <= 93; i++) random_weight[i] = 0;
|
||||
length = minl + randint(maxl-minl+1);
|
||||
@@ -87,8 +77,8 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
|
||||
{
|
||||
/* Asign random weight in weight array if mode is present*/
|
||||
for (j = 0; j <= 93 ; j++)
|
||||
/*!!!*/ if ( ((pass_mode & smbl[j].type) > 0) &&
|
||||
!((pass_mode & smbl[j].type) == 0x12))
|
||||
if ( ( (pass_mode & smbl[j].type) > 0) &&
|
||||
!( (S_RS & smbl[j].type) > 0))
|
||||
random_weight[j] = 1 + randint(20000);
|
||||
j = 0;
|
||||
/* Find an element with maximum weight */
|
||||
@@ -108,3 +98,66 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
|
||||
*str_pointer = 0;
|
||||
return (length);
|
||||
}
|
||||
|
||||
/*
|
||||
** gen_rand_symbol - generates random password of specified type
|
||||
** INPUT:
|
||||
** char * - symbol.
|
||||
** unsigned int - symbol type.
|
||||
** OUTPUT:
|
||||
** int - password length or -1 on error.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int
|
||||
gen_rand_symbol (char *symbol, unsigned int mode)
|
||||
{
|
||||
int j = 0;
|
||||
char *str_pointer;
|
||||
int random_weight[94];
|
||||
int max_weight = 0;
|
||||
int max_weight_element_number = 0;
|
||||
|
||||
for (j = 0; j <= 93; j++) random_weight[j] = 0;
|
||||
str_pointer = symbol;
|
||||
j = 0;
|
||||
/* Asign random weight in weight array if mode is present*/
|
||||
for (j = 0; j <= 93 ; j++)
|
||||
if ( ( (mode & smbl[j].type) > 0) &&
|
||||
!( (S_RS & smbl[j].type) > 0))
|
||||
random_weight[j] = 1 + randint(20000);
|
||||
j = 0;
|
||||
/* Find an element with maximum weight */
|
||||
for (j = 0; j <= 93; j++)
|
||||
if (random_weight[j] > max_weight)
|
||||
{
|
||||
max_weight = random_weight[j];
|
||||
max_weight_element_number = j;
|
||||
}
|
||||
/* Get password symbol */
|
||||
*str_pointer = smbl[max_weight_element_number].ch;
|
||||
max_weight = 0;
|
||||
max_weight_element_number = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
** is_restricted_symbol - detcts if symbol is restricted rigt now
|
||||
** INPUT:
|
||||
** char - symbol.
|
||||
** OUTPUT:
|
||||
** int - 0 - not restricted
|
||||
** 1 - restricted
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int
|
||||
is_restricted_symbol (char symbol)
|
||||
{
|
||||
int j = 0;
|
||||
for (j = 0; j <= 93 ; j++)
|
||||
if (symbol == smbl[j].ch)
|
||||
if ((S_RS & smbl[j].type) > 0)
|
||||
return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
23
randpass.h
23
randpass.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,20 +30,33 @@
|
||||
/*
|
||||
** randpass.h
|
||||
*/
|
||||
#ifndef RANDPASS_H
|
||||
#define RANDPASS_H 1
|
||||
#ifndef APG_RANDPASS_H
|
||||
#define APG_RANDPASS_H 1
|
||||
|
||||
#ifndef RND_H
|
||||
#ifndef APG_RND_H
|
||||
#include "rnd.h"
|
||||
#endif
|
||||
|
||||
#ifndef APG_OWN_TYPES_H
|
||||
#include "owntypes.h"
|
||||
#endif
|
||||
|
||||
#define S_NB 0x01 /* Numeric */
|
||||
#define S_SS 0x02 /* Special */
|
||||
#define S_CL 0x04 /* Capital */
|
||||
#define S_SL 0x08 /* Small */
|
||||
#define S_RS 0x10 /* Restricted Special*/
|
||||
#define S_RS 0x10 /* Restricted Symbol*/
|
||||
|
||||
struct sym
|
||||
{
|
||||
char ch;
|
||||
USHORT type;
|
||||
};
|
||||
|
||||
/* char gen_symbol(unsigned short int symbol_class); */
|
||||
extern int gen_rand_pass(char* password_string, int minl,
|
||||
int maxl, unsigned int pass_mode);
|
||||
extern int gen_rand_symbol (char *symbol, unsigned int mode);
|
||||
extern int is_restricted_symbol (char symbol);
|
||||
|
||||
#endif /* RANDPASS_H */
|
||||
|
||||
214
restrict.c
214
restrict.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,20 +34,33 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "restrict.h"
|
||||
|
||||
extern struct sym smbl[94];
|
||||
/*
|
||||
** Routine that checks if password exist in dictionary
|
||||
** RETURN -1 - error
|
||||
** check_pass() - routine that checks if password exist in dictionary
|
||||
** INPUT:
|
||||
** char * - password to check.
|
||||
** char * - dictionary filename.
|
||||
** OUTPUT:
|
||||
** int
|
||||
** -1 - error
|
||||
** 1 - password exist in dictionary
|
||||
** 0 - password does not exist in dictionary
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int
|
||||
check_pass(char *pass, char *dict)
|
||||
{
|
||||
FILE *dct;
|
||||
char *string;
|
||||
string = (char *) calloc(1,MAX_DICT_STRING_SIZE);
|
||||
char *tmp;
|
||||
if( (string = (char *) calloc(1,MAX_DICT_STRING_SIZE)) == NULL)
|
||||
return(-1);
|
||||
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> check_pass: ck pass: %s\n", pass);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
/*
|
||||
** Open dict file an report of error
|
||||
*/
|
||||
@@ -56,22 +69,205 @@ check_pass(char *pass, char *dict)
|
||||
|
||||
while ((fgets(string, MAX_DICT_STRING_SIZE, dct) != NULL))
|
||||
{
|
||||
string = strtok (string," \t\n\0");
|
||||
tmp = strtok (string," \t\n\0");
|
||||
if( tmp != NULL)
|
||||
string = tmp;
|
||||
else
|
||||
continue;
|
||||
if(strlen(string) != strlen(pass)) continue;
|
||||
else if (strncmp(string, pass, strlen(pass)) == 0) return (1);
|
||||
else if (strncmp(string, pass, strlen(pass)) == 0)
|
||||
{
|
||||
free ( (void *)string);
|
||||
fclose (dct);
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> check_pass: password found in dictionary: %s\n", pass);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
free ( (void *)string);
|
||||
fclose (dct);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
** bloom_check_pass() - routine that checks if password exist in dictionary
|
||||
** using Bloom filter.
|
||||
** INPUT:
|
||||
** char * - password to check.
|
||||
** char * - bloom-filter filename.
|
||||
** OUTPUT:
|
||||
** int
|
||||
** -1 - error
|
||||
** 1 - password exist in dictionary
|
||||
** 0 - password does not exist in dictionary
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int
|
||||
bloom_check_pass (char *word, char *filter)
|
||||
{
|
||||
int ret = 0;
|
||||
FILE *f_filter;
|
||||
h_val filter_size = 0L;
|
||||
if ( (f_filter = open_filter(filter)) == NULL)
|
||||
f_mode flt_mode = 0x00;
|
||||
if ( (f_filter = open_filter(filter,"r")) == NULL)
|
||||
return(-1);
|
||||
filter_size = get_filtersize(f_filter);
|
||||
return(check_word (word, f_filter, filter_size));
|
||||
flt_mode = get_filtermode(f_filter);
|
||||
ret = check_word (word, f_filter, filter_size, flt_mode);
|
||||
close_filter(f_filter);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
** paranoid_bloom_check_pass() - routine that checks if password or any
|
||||
** substring of the password exist in dictionary using Bloom filter.
|
||||
** INPUT:
|
||||
** char * - password to check.
|
||||
** char * - bloom-filter filename.
|
||||
** USHORT - minimum substring length
|
||||
** OUTPUT:
|
||||
** int
|
||||
** -1 - error
|
||||
** 1 - password exist in dictionary
|
||||
** 0 - password does not exist in dictionary
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int
|
||||
paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len)
|
||||
{
|
||||
char * substring;
|
||||
int len = strlen(password); /* string length */
|
||||
int c_substr_start_pos = 0; /* current start position */
|
||||
int substr_len = 0; /* substring length (LEN-I >= substr_len >= 2) */
|
||||
int k = 0; /* counter */
|
||||
int c = 0; /* counter */
|
||||
int ret = 0;
|
||||
if (s_len < 2) s_len = 2;
|
||||
if (s_len > len) return (bloom_check_pass(password, filter));
|
||||
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: ck pass: %s\n", password);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
|
||||
if ((substring = (char *)calloc(1, (size_t)len))==NULL)
|
||||
return (-1);
|
||||
|
||||
for (c_substr_start_pos = 0; c_substr_start_pos <= len-s_len; c_substr_start_pos++)
|
||||
for (substr_len = s_len; substr_len <= len-c_substr_start_pos; substr_len++)
|
||||
{
|
||||
c = 0;
|
||||
for (k = c_substr_start_pos; k <= c_substr_start_pos + substr_len-1; k++)
|
||||
{
|
||||
substring[c]=password[k];
|
||||
c++;
|
||||
}
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: ck substr: %s\n", substring);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
if((ret = bloom_check_pass(substring, filter)) == 1)
|
||||
{
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: substr found in filter: %s\n", substring);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
return(1);
|
||||
}
|
||||
else if (ret == -1) return(-1);
|
||||
(void)memset(substring,0,(size_t)len);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
** filter_check_pass() - routine that checks password against filter string
|
||||
**
|
||||
** INPUT:
|
||||
** char * - password to check.
|
||||
** char * - bloom-filter filename.
|
||||
** OUTPUT:
|
||||
** int
|
||||
** -1 - error
|
||||
** 1 - password do not pass the filter
|
||||
** 0 - password pass the filter
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
|
||||
int
|
||||
filter_check_pass(const char * word, unsigned int cond)
|
||||
{
|
||||
int i = 0;
|
||||
int sl_ret = 0;
|
||||
int cl_ret = 0;
|
||||
int nb_ret = 0;
|
||||
int ss_ret = 0;
|
||||
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> filter_check_pass: ck pass: %s\n", word);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
|
||||
if ((cond & S_SS) > 0)
|
||||
for (i=0; i < 94; i++)
|
||||
if ((smbl[i].type & S_SS) > 0)
|
||||
if ((strchr(word,smbl[i].ch)) != NULL)
|
||||
ss_ret = 1;
|
||||
i = 0;
|
||||
if ((cond & S_SL) > 0)
|
||||
for (i=0; i < 94; i++)
|
||||
if ((smbl[i].type & S_SL) > 0)
|
||||
if ((strchr(word,smbl[i].ch)) != NULL)
|
||||
sl_ret = 1;
|
||||
i = 0;
|
||||
if ((cond & S_CL) > 0)
|
||||
for (i=0; i < 94; i++)
|
||||
if ((smbl[i].type & S_CL) > 0)
|
||||
if ((strchr(word,smbl[i].ch)) != NULL)
|
||||
cl_ret = 1;
|
||||
i = 0;
|
||||
if ((cond & S_NB) > 0)
|
||||
for (i=0; i < 94; i++)
|
||||
if ((smbl[i].type & S_NB) > 0)
|
||||
if ((strchr(word,smbl[i].ch)) != NULL)
|
||||
nb_ret = 1;
|
||||
if (((cond & S_SS) > 0) &&(ss_ret != 1)) return (1);
|
||||
if (((cond & S_SL) > 0) &&(sl_ret != 1)) return (1);
|
||||
if (((cond & S_CL) > 0) &&(cl_ret != 1)) return (1);
|
||||
if (((cond & S_NB) > 0) &&(nb_ret != 1)) return (1);
|
||||
|
||||
#ifdef APG_DEBUG
|
||||
fprintf (stdout, "DEBUG> filter_check_pass: password %s pass the filter\n", word);
|
||||
fflush (stdout);
|
||||
#endif /* APG_DEBUG */
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
** set_exclude_list() - set up character list that should
|
||||
** be excluded from password generation process
|
||||
**
|
||||
** INPUT:
|
||||
** char * - string of characters.
|
||||
** OUTPUT:
|
||||
** int - return code
|
||||
** 0 - OK
|
||||
** -1 - char_string is too long (max 93)
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
int set_exclude_list(const char * char_string)
|
||||
{
|
||||
int i = 0;
|
||||
if (strlen(char_string) > 93)
|
||||
return(-1);
|
||||
for(i=0; i < 94; i++)
|
||||
if ((strchr(char_string, smbl[i].ch)) != NULL)
|
||||
smbl[i].type = smbl[i].type | S_RS;
|
||||
return(0);
|
||||
}
|
||||
|
||||
16
restrict.h
16
restrict.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,12 +30,16 @@
|
||||
/*
|
||||
** restrict.h
|
||||
*/
|
||||
#ifndef RESTRICT_H
|
||||
#define RESTRICT_H 1
|
||||
#ifndef APG_RESTRICT_H
|
||||
#define APG_RESTRICT_H 1
|
||||
|
||||
#include "bloom.h"
|
||||
#include "randpass.h"
|
||||
#define MAX_DICT_STRING_SIZE 255
|
||||
extern int check_pass(char * pass, char *dict);
|
||||
extern int bloom_check_pass (char *word, char *filter);
|
||||
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);
|
||||
|
||||
#endif /* RESTRICT_H */
|
||||
#endif /* APG_RESTRICT_H */
|
||||
|
||||
123
rnd.c
123
rnd.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -29,29 +29,61 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include "rnd.h"
|
||||
#include "./cast/cast.h"
|
||||
|
||||
#ifndef APG_USE_SHA
|
||||
# include "./cast/cast.h"
|
||||
#else /* APG_USE_SHA */
|
||||
# include "./sha/sha.h"
|
||||
#endif /* APG_USE_SHA */
|
||||
|
||||
UINT32 __rnd_seed[2]; /* Random Seed 2*32=64 */
|
||||
|
||||
/*
|
||||
** randint(int n) - Produces a Random number from 0 to n-1 .
|
||||
** randint(int n) - Produces a Random number from 0 to n-1.
|
||||
** INPUT:
|
||||
** int - limit
|
||||
** OUTPUT:
|
||||
** UINT - pandom number.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
UINT
|
||||
randint(int n)
|
||||
{
|
||||
#ifndef APG_USE_SHA
|
||||
return ( (UINT)( x917cast_rnd() % (UINT32)n ) );
|
||||
#else /* APG_USE_SHA */
|
||||
return ( (UINT)( x917sha1_rnd() % (UINT32)n ) );
|
||||
#endif /* APG_USE_SHA */
|
||||
}
|
||||
|
||||
#ifndef APG_USE_SHA
|
||||
/*
|
||||
** ANSI X9.17 pseudorandom generator that uses CAST algorithm instead of DES
|
||||
** m = 1
|
||||
** INPUT:
|
||||
** none.
|
||||
** OUTPUT:
|
||||
** UINT32 - random number.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
UINT32
|
||||
x917cast_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};
|
||||
@@ -68,7 +100,12 @@ u8 ro_key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
* ENCRYPTION KEY HEX : 0x000102030405060708090A0B0C0D0E0F (128-bit) *
|
||||
* YOU CAN CHANGE IT IF YOU WANT *
|
||||
**********************************************************************/
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
(void) gettimeofday (&local_time, 0);
|
||||
#else
|
||||
local_time[0] = clock();
|
||||
local_time[1] = clock();
|
||||
#endif
|
||||
cast_setkey(&ky, (u8*)&ro_key[0], 16);
|
||||
cast_encrypt (&ky, (u8 *)&local_time, (u8*)&I[0]); /* I=Ek(D), D-time */
|
||||
I_plus_s[0] = I[0] ^ __rnd_seed[0]; /* I0 (+) s0 */
|
||||
@@ -79,27 +116,82 @@ u8 ro_key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
cast_encrypt (&ky, (u8 *)&Xi_plus_I[0], (u8*)&__rnd_seed[0]); /* s=Ek( Xi (+) I ) */
|
||||
return (Xi[0]);
|
||||
}
|
||||
|
||||
#else /* APG_USE_SHA */
|
||||
/*
|
||||
** x917cast_setseed (UINT32 seed) - Initializes seed
|
||||
** UINT32 seed - seed value
|
||||
** ANSI X9.17 pseudorandom generator that uses SHA1 algorithm instead of DES
|
||||
** m=1
|
||||
** INPUT:
|
||||
** none.
|
||||
** OUTPUT:
|
||||
** UINT32 - random number.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
UINT32
|
||||
x917sha1_rnd (void)
|
||||
{
|
||||
struct timeval local_time;
|
||||
UINT32 I[2] = {0L,0L};
|
||||
UINT32 I_plus_s[2] = {0L,0L};
|
||||
UINT32 Xi[2] = {0L,0L};
|
||||
UINT32 Xi_plus_I[2] = {0L,0L};
|
||||
|
||||
BYTE hash [SHA_DIGESTSIZE];
|
||||
apg_SHA_INFO shaInfo;
|
||||
|
||||
(void) gettimeofday (&local_time, 0);
|
||||
apg_shaInit ( &shaInfo );
|
||||
apg_shaUpdate ( &shaInfo, (BYTE *)&local_time, 8);
|
||||
apg_shaFinal ( &shaInfo, hash );
|
||||
(void)memcpy ( (void *)&I[0], (void *)&hash[0], sizeof(I));
|
||||
I_plus_s[0] = I[0] ^ __rnd_seed[0]; /* I0 (+) s0 */
|
||||
I_plus_s[1] = I[1] ^ __rnd_seed[1]; /* I1 (+) s1 */
|
||||
|
||||
apg_shaInit(&shaInfo);
|
||||
apg_shaUpdate( &shaInfo, (BYTE *)&I_plus_s, 8);
|
||||
apg_shaFinal( &shaInfo, hash );
|
||||
(void)memcpy ( (void *)&Xi[0], (void *)&hash[0], sizeof(Xi)); /* Xi=Ek( I (+) s ) */
|
||||
|
||||
Xi_plus_I[0] = Xi[0] ^ I[0]; /* Xi0 (+) I0 */
|
||||
Xi_plus_I[1] = Xi[1] ^ I[1]; /* Xi1 (+) I1 */
|
||||
|
||||
apg_shaInit(&shaInfo);
|
||||
apg_shaUpdate( &shaInfo, (BYTE *)&Xi_plus_I, 8);
|
||||
apg_shaFinal(&shaInfo, hash);
|
||||
(void)memcpy ( (void *)&__rnd_seed[0], (void *)&hash[0],
|
||||
sizeof(__rnd_seed)); /* s=Ek( Xi (+) I ) */
|
||||
return (Xi[0]);
|
||||
}
|
||||
#endif /* APG_USE_SHA */
|
||||
/*
|
||||
** x917_setseed (UINT32 seed) - Initializes seed
|
||||
** INPUT:
|
||||
** UINT32 - seed value
|
||||
** int - quiet mode flag
|
||||
** OUTPUT:
|
||||
** none.
|
||||
** NOTES:
|
||||
** none.
|
||||
*/
|
||||
void
|
||||
x917cast_setseed (UINT32 seed)
|
||||
x917_setseed (UINT32 seed, int quiet)
|
||||
{
|
||||
FILE * dr;
|
||||
UINT32 drs[2];
|
||||
UINT32 pid = 0;
|
||||
|
||||
pid = (UINT32)getpid();
|
||||
|
||||
if ( (dr = fopen(APG_DEVRANDOM, "r")) != NULL)
|
||||
{
|
||||
(void) fread( (void *)&drs[0], 8, 1, dr);
|
||||
(void)fread( (void *)&drs[0], 8, 1, dr);
|
||||
__rnd_seed[0] = seed ^ drs[0];
|
||||
__rnd_seed[1] = seed ^ drs[1];
|
||||
(void) fclose(dr);
|
||||
}
|
||||
else if ( (dr = fopen(APG_DEVURANDOM, "r")) != NULL)
|
||||
{
|
||||
(void) fread( (void *)&drs[0], 8, 1, dr);
|
||||
(void)fread( (void *)&drs[0], 8, 1, dr);
|
||||
__rnd_seed[0] = seed ^ drs[0];
|
||||
__rnd_seed[1] = seed ^ drs[1];
|
||||
(void) fclose(dr);
|
||||
@@ -107,11 +199,16 @@ x917cast_setseed (UINT32 seed)
|
||||
else
|
||||
{
|
||||
#ifndef CLISERV
|
||||
fprintf(stderr,"CAN NOT USE /dev/random TO GENERATE RANDOM SEED\n");
|
||||
fprintf(stderr,"USEING LOCAL TIME FOR SEED GENERATION !!!\n");
|
||||
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
|
||||
if (quiet != TRUE)
|
||||
{
|
||||
fprintf(stderr,"CAN NOT USE RANDOM DEVICE TO GENERATE RANDOM SEED\n");
|
||||
fprintf(stderr,"USING LOCAL TIME AND PID FOR SEED GENERATION !!!\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* CLISERV */
|
||||
__rnd_seed[0] = seed;
|
||||
__rnd_seed[1] = seed;
|
||||
__rnd_seed[0] = seed ^ pid;
|
||||
__rnd_seed[1] = seed ^ pid;
|
||||
}
|
||||
}
|
||||
|
||||
20
rnd.h
20
rnd.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
@@ -27,21 +27,29 @@
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef RND_H
|
||||
#define RND_H 1
|
||||
#ifndef APG_RND_H
|
||||
#define APG_RND_H 1
|
||||
|
||||
#ifndef OWN_TYPES_H
|
||||
#ifndef APG_OWN_TYPES_H
|
||||
#include "owntypes.h"
|
||||
#endif /* OWN_TYPES_H */
|
||||
|
||||
extern UINT32 __rnd_seed[2];
|
||||
|
||||
#define RND_MX 0x7FFFFFFF
|
||||
#ifdef __OpenBSD__
|
||||
#define APG_DEVRANDOM "/dev/arandom"
|
||||
#else
|
||||
#define APG_DEVRANDOM "/dev/random"
|
||||
#endif /* __OpenBSD__ */
|
||||
#define APG_DEVURANDOM "/dev/urandom"
|
||||
|
||||
extern void x917cast_setseed (UINT32 seed);
|
||||
extern void x917_setseed (UINT32 seed, int quiet);
|
||||
extern UINT randint (int n);
|
||||
#ifndef APG_USE_SHA
|
||||
UINT32 x917cast_rnd (void);
|
||||
#else /* APG_USE_SHA */
|
||||
UINT32 x917sha1_rnd (void);
|
||||
#endif /* APG_USE_SHA*/
|
||||
|
||||
#endif /* RND_H */
|
||||
#endif /* APG_RND_H */
|
||||
|
||||
297
sha/sha.c
Normal file
297
sha/sha.c
Normal file
@@ -0,0 +1,297 @@
|
||||
/***************************************************************************/
|
||||
/* sha.c */
|
||||
/* */
|
||||
/* Public domain SHA-1 implementation. */
|
||||
/* */
|
||||
/* Taken from the SHA implementation by Peter C. Gutmann of 9/2/1992 */
|
||||
/* and modified by Carl Ellison to be SHA-1. */
|
||||
/***************************************************************************/
|
||||
|
||||
/*
|
||||
** Note regarding apg_* namespace: this avoids potential conflicts
|
||||
** with libraries.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "sha.h"
|
||||
|
||||
/* The SHA f()-functions */
|
||||
|
||||
#define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) /* Rounds 0-19 */
|
||||
#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
|
||||
#define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) /* Rounds 40-59 */
|
||||
#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
|
||||
|
||||
/* The SHA Mysterious Constants */
|
||||
|
||||
#define K1 0x5A827999L /* Rounds 0-19 */
|
||||
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
|
||||
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
|
||||
#define K4 0xCA62C1D6L /* Rounds 60-79 */
|
||||
|
||||
/* SHA initial values */
|
||||
|
||||
#define h0init 0x67452301L
|
||||
#define h1init 0xEFCDAB89L
|
||||
#define h2init 0x98BADCFEL
|
||||
#define h3init 0x10325476L
|
||||
#define h4init 0xC3D2E1F0L
|
||||
|
||||
/* 32-bit rotate - kludged with shifts */
|
||||
|
||||
typedef unsigned long UL ; /* to save space */
|
||||
|
||||
#define S(n,X) ( ( ((UL)X) << n ) | ( ((UL)X) >> ( 32 - n ) ) )
|
||||
|
||||
/* The initial expanding function */
|
||||
|
||||
#define expand(count) W[ count ] = S(1,(W[ count - 3 ] ^ W[ count - 8 ] ^ W[ count - 14 ] ^ W[ count - 16 ])) /* to make this SHA-1 */
|
||||
|
||||
/* The four SHA sub-rounds */
|
||||
|
||||
#define subRound1(count) \
|
||||
{ \
|
||||
temp = S( 5, A ) + f1( B, C, D ) + E + W[ count ] + K1; \
|
||||
E = D; \
|
||||
D = C; \
|
||||
C = S( 30, B ); \
|
||||
B = A; \
|
||||
A = temp; \
|
||||
}
|
||||
|
||||
#define subRound2(count) \
|
||||
{ \
|
||||
temp = S( 5, A ) + f2( B, C, D ) + E + W[ count ] + K2; \
|
||||
E = D; \
|
||||
D = C; \
|
||||
C = S( 30, B ); \
|
||||
B = A; \
|
||||
A = temp; \
|
||||
}
|
||||
|
||||
#define subRound3(count) \
|
||||
{ \
|
||||
temp = S( 5, A ) + f3( B, C, D ) + E + W[ count ] + K3; \
|
||||
E = D; \
|
||||
D = C; \
|
||||
C = S( 30, B ); \
|
||||
B = A; \
|
||||
A = temp; \
|
||||
}
|
||||
|
||||
#define subRound4(count) \
|
||||
{ \
|
||||
temp = S( 5, A ) + f4( B, C, D ) + E + W[ count ] + K4; \
|
||||
E = D; \
|
||||
D = C; \
|
||||
C = S( 30, B ); \
|
||||
B = A; \
|
||||
A = temp; \
|
||||
}
|
||||
|
||||
/* The two buffers of 5 32-bit words */
|
||||
|
||||
LONG h0, h1, h2, h3, h4;
|
||||
LONG A, B, C, D, E;
|
||||
|
||||
/***************************************************************************/
|
||||
/* apg_shaInit */
|
||||
/* */
|
||||
/* Initialize the SHA values */
|
||||
/***************************************************************************/
|
||||
|
||||
void apg_shaInit( apg_SHA_INFO *shaInfo )
|
||||
{
|
||||
/* Set the h-vars to their initial values */
|
||||
shaInfo->digest[ 0 ] = h0init;
|
||||
shaInfo->digest[ 1 ] = h1init;
|
||||
shaInfo->digest[ 2 ] = h2init;
|
||||
shaInfo->digest[ 3 ] = h3init;
|
||||
shaInfo->digest[ 4 ] = h4init;
|
||||
|
||||
/* Initialise bit count */
|
||||
shaInfo->countLo = shaInfo->countHi = 0L;
|
||||
shaInfo->slop = 0 ; /* no data saved yet in data[] */
|
||||
} /* apg_shaInit */
|
||||
|
||||
/***************************************************************************/
|
||||
/* shaTransform */
|
||||
/* */
|
||||
/* Perform the SHA transformation over one input block. */
|
||||
/***************************************************************************/
|
||||
|
||||
static void shaTransform( apg_SHA_INFO *shaInfo )
|
||||
{
|
||||
LONG W[ 80 ], temp;
|
||||
int i;
|
||||
|
||||
/* Step A. Copy the data buffer into the local work buffer */
|
||||
for( i = 0; i < 16; i++ )
|
||||
W[ i ] = shaInfo->data[ i ];
|
||||
|
||||
/* Step B. Expand the 16 words into 64 temporary data words */
|
||||
expand( 16 ); expand( 17 ); expand( 18 ); expand( 19 ); expand( 20 );
|
||||
expand( 21 ); expand( 22 ); expand( 23 ); expand( 24 ); expand( 25 );
|
||||
expand( 26 ); expand( 27 ); expand( 28 ); expand( 29 ); expand( 30 );
|
||||
expand( 31 ); expand( 32 ); expand( 33 ); expand( 34 ); expand( 35 );
|
||||
expand( 36 ); expand( 37 ); expand( 38 ); expand( 39 ); expand( 40 );
|
||||
expand( 41 ); expand( 42 ); expand( 43 ); expand( 44 ); expand( 45 );
|
||||
expand( 46 ); expand( 47 ); expand( 48 ); expand( 49 ); expand( 50 );
|
||||
expand( 51 ); expand( 52 ); expand( 53 ); expand( 54 ); expand( 55 );
|
||||
expand( 56 ); expand( 57 ); expand( 58 ); expand( 59 ); expand( 60 );
|
||||
expand( 61 ); expand( 62 ); expand( 63 ); expand( 64 ); expand( 65 );
|
||||
expand( 66 ); expand( 67 ); expand( 68 ); expand( 69 ); expand( 70 );
|
||||
expand( 71 ); expand( 72 ); expand( 73 ); expand( 74 ); expand( 75 );
|
||||
expand( 76 ); expand( 77 ); expand( 78 ); expand( 79 );
|
||||
|
||||
/* Step C. Set up first buffer */
|
||||
A = shaInfo->digest[ 0 ];
|
||||
B = shaInfo->digest[ 1 ];
|
||||
C = shaInfo->digest[ 2 ];
|
||||
D = shaInfo->digest[ 3 ];
|
||||
E = shaInfo->digest[ 4 ];
|
||||
|
||||
/* Step D. Serious mangling, divided into four sub-rounds */
|
||||
subRound1( 0 ); subRound1( 1 ); subRound1( 2 ); subRound1( 3 );
|
||||
subRound1( 4 ); subRound1( 5 ); subRound1( 6 ); subRound1( 7 );
|
||||
subRound1( 8 ); subRound1( 9 ); subRound1( 10 ); subRound1( 11 );
|
||||
subRound1( 12 ); subRound1( 13 ); subRound1( 14 ); subRound1( 15 );
|
||||
subRound1( 16 ); subRound1( 17 ); subRound1( 18 ); subRound1( 19 );
|
||||
subRound2( 20 ); subRound2( 21 ); subRound2( 22 ); subRound2( 23 );
|
||||
subRound2( 24 ); subRound2( 25 ); subRound2( 26 ); subRound2( 27 );
|
||||
subRound2( 28 ); subRound2( 29 ); subRound2( 30 ); subRound2( 31 );
|
||||
subRound2( 32 ); subRound2( 33 ); subRound2( 34 ); subRound2( 35 );
|
||||
subRound2( 36 ); subRound2( 37 ); subRound2( 38 ); subRound2( 39 );
|
||||
subRound3( 40 ); subRound3( 41 ); subRound3( 42 ); subRound3( 43 );
|
||||
subRound3( 44 ); subRound3( 45 ); subRound3( 46 ); subRound3( 47 );
|
||||
subRound3( 48 ); subRound3( 49 ); subRound3( 50 ); subRound3( 51 );
|
||||
subRound3( 52 ); subRound3( 53 ); subRound3( 54 ); subRound3( 55 );
|
||||
subRound3( 56 ); subRound3( 57 ); subRound3( 58 ); subRound3( 59 );
|
||||
subRound4( 60 ); subRound4( 61 ); subRound4( 62 ); subRound4( 63 );
|
||||
subRound4( 64 ); subRound4( 65 ); subRound4( 66 ); subRound4( 67 );
|
||||
subRound4( 68 ); subRound4( 69 ); subRound4( 70 ); subRound4( 71 );
|
||||
subRound4( 72 ); subRound4( 73 ); subRound4( 74 ); subRound4( 75 );
|
||||
subRound4( 76 ); subRound4( 77 ); subRound4( 78 ); subRound4( 79 );
|
||||
|
||||
/* Step E. Build message digest */
|
||||
shaInfo->digest[ 0 ] += A;
|
||||
shaInfo->digest[ 1 ] += B;
|
||||
shaInfo->digest[ 2 ] += C;
|
||||
shaInfo->digest[ 3 ] += D;
|
||||
shaInfo->digest[ 4 ] += E;
|
||||
} /* shaTransform */
|
||||
|
||||
#ifdef APG_LITTLE_ENDIAN
|
||||
|
||||
/***************************************************************************/
|
||||
/* byteReverse */
|
||||
/* */
|
||||
/* When run on a little-endian CPU we need to perform byte reversal on an */
|
||||
/* array of longwords. It is possible to make the code endianness- */
|
||||
/* independant by fiddling around with data at the byte level, but this */
|
||||
/* makes for very slow code, so we rely on the user to sort out endianness */
|
||||
/* at compile time. */
|
||||
/***************************************************************************/
|
||||
|
||||
static void byteReverse( LONG *buffer, int byteCount )
|
||||
{
|
||||
LONG value;
|
||||
int count;
|
||||
|
||||
byteCount /= sizeof( LONG );
|
||||
for( count = 0; count < byteCount; count++ )
|
||||
{
|
||||
value = ( buffer[ count ] << 16 ) | ( buffer[ count ] >> 16 );
|
||||
buffer[ count ] = ( ( value & 0xFF00FF00L ) >> 8 ) | ( ( value & 0x00FF00FFL ) << 8 );
|
||||
} /* for */
|
||||
} /* byteReverse */
|
||||
#endif /* APG_LITTLE_ENDIAN */
|
||||
|
||||
/***************************************************************************/
|
||||
/* apg_shaUpdate */
|
||||
/* */
|
||||
/* Update SHA for a block of data. */
|
||||
/* Use any data already in the SHA_INFO structure and leave any partial */
|
||||
/* data block there. */
|
||||
/***************************************************************************/
|
||||
|
||||
void apg_shaUpdate( apg_SHA_INFO *shaInfo, BYTE *buffer, int count )
|
||||
{
|
||||
BYTE *db ;
|
||||
|
||||
db = (BYTE *) &(shaInfo->data[0]) ;
|
||||
|
||||
/* Update bitcount */
|
||||
if( ( shaInfo->countLo + ( ( LONG ) count << 3 ) ) < shaInfo->countLo )
|
||||
shaInfo->countHi++; /* Carry from low to high bitCount */
|
||||
shaInfo->countLo += ( ( LONG ) count << 3 );
|
||||
shaInfo->countHi += ( ( LONG ) count >> 29 );
|
||||
|
||||
/* Process data in SHA_BLOCKSIZE chunks */
|
||||
while ( count-- > 0 )
|
||||
{
|
||||
db[ shaInfo->slop++ ] = *(buffer++) ;
|
||||
if (shaInfo->slop == SHA_BLOCKSIZE)
|
||||
{ /* transform this one block */
|
||||
#ifdef APG_LITTLE_ENDIAN
|
||||
byteReverse( shaInfo->data, SHA_BLOCKSIZE );
|
||||
#endif /* APG_LITTLE_ENDIAN */
|
||||
shaTransform( shaInfo );
|
||||
shaInfo->slop = 0 ; /* no slop left */
|
||||
} /* if */
|
||||
} /* while */
|
||||
} /* apg_shaUpdate */
|
||||
|
||||
/***************************************************************************/
|
||||
/* apg_shaFinal */
|
||||
/* */
|
||||
/* Handle the last piece of data -- if any is left over in the data */
|
||||
/* buffer -- and append padding and a bit count for the last block */
|
||||
/* to process. Having transformed that block, pull the digest out */
|
||||
/* as a byte array. */
|
||||
/***************************************************************************/
|
||||
|
||||
void apg_shaFinal( apg_SHA_INFO *shaInfo, BYTE hash[SHA_DIGESTSIZE] )
|
||||
{
|
||||
int count;
|
||||
LONG lowBitcount = shaInfo->countLo, highBitcount = shaInfo->countHi;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = ( int ) ( ( shaInfo->countLo >> 3 ) & 0x3F );
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
( ( BYTE * ) shaInfo->data )[ count++ ] = 0x80;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if( count > 56 )
|
||||
{
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset( ( BYTE * ) &shaInfo->data + count, 0, 64 - count );
|
||||
#ifdef APG_LITTLE_ENDIAN
|
||||
byteReverse( shaInfo->data, SHA_BLOCKSIZE );
|
||||
#endif /* APG_LITTLE_ENDIAN */
|
||||
shaTransform( shaInfo );
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset( &shaInfo->data, 0, 56 );
|
||||
}
|
||||
else
|
||||
/* Pad block to 56 bytes */
|
||||
memset( ( BYTE * ) &shaInfo->data + count, 0, 56 - count );
|
||||
#ifdef APG_LITTLE_ENDIAN
|
||||
byteReverse( shaInfo->data, SHA_BLOCKSIZE );
|
||||
#endif /* APG_LITTLE_ENDIAN */
|
||||
|
||||
/* Append length in bits and transform */
|
||||
shaInfo->data[ 14 ] = highBitcount;
|
||||
shaInfo->data[ 15 ] = lowBitcount;
|
||||
|
||||
shaTransform( shaInfo );
|
||||
#ifdef APG_LITTLE_ENDIAN
|
||||
byteReverse( shaInfo->data, SHA_DIGESTSIZE );
|
||||
#endif /* APG_LITTLE_ENDIAN */
|
||||
|
||||
for (count=0; count<SHA_DIGESTSIZE; count++)
|
||||
hash[count] = (BYTE) ((shaInfo->digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff ;
|
||||
} /* apg_shaFinal */
|
||||
39
sha/sha.h
Normal file
39
sha/sha.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/***************************************************************************/
|
||||
/* sha.h */
|
||||
/* */
|
||||
/* SHA-1 code header file. */
|
||||
/* Taken from the public domain implementation by Peter C. Gutmann */
|
||||
/* on 2 Sep 1992, modified by Carl Ellison to be SHA-1. */
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef _SHA_H_
|
||||
#define _SHA_H_
|
||||
|
||||
/* Define APG_LITTLE_ENDIAN if the machine is little-endian */
|
||||
|
||||
#define APG_LITTLE_ENDIAN
|
||||
|
||||
/* Useful defines/typedefs */
|
||||
|
||||
typedef unsigned char BYTE ;
|
||||
typedef unsigned long LONG ;
|
||||
|
||||
/* The SHA block size and message digest sizes, in bytes */
|
||||
|
||||
#define SHA_BLOCKSIZE 64
|
||||
#define SHA_DIGESTSIZE 20
|
||||
|
||||
/* The structure for storing SHA info */
|
||||
|
||||
typedef struct {
|
||||
LONG digest[ 5 ] ; /* Message digest */
|
||||
LONG countLo, countHi ; /* 64-bit bit count */
|
||||
LONG data[ 16 ] ; /* SHA data buffer */
|
||||
LONG slop ; /* # of bytes saved in data[] */
|
||||
} apg_SHA_INFO ;
|
||||
|
||||
void apg_shaInit( apg_SHA_INFO *shaInfo ) ;
|
||||
void apg_shaUpdate( apg_SHA_INFO *shaInfo, BYTE *buffer, int count ) ;
|
||||
void apg_shaFinal( apg_SHA_INFO *shaInfo, BYTE hash[SHA_DIGESTSIZE] ) ;
|
||||
|
||||
#endif /* _SHA_H_ */
|
||||
51
smbl.h
Normal file
51
smbl.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
** Copyright (c) 1999, 2000, 2001, 2002, 2003
|
||||
** Adel I. Mirzazhanov. All rights reserved
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1.Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2.Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3.The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef APG_SMBL_H
|
||||
#define APG_SMBL_H 1
|
||||
struct sym smbl[94] =
|
||||
{
|
||||
{'a', S_SL}, {'b', S_SL}, {'c', S_SL}, {'d', S_SL}, {'e', S_SL}, {'f', S_SL},
|
||||
{'g', S_SL}, {'h', S_SL}, {'i', S_SL}, {'j', S_SL}, {'k', S_SL}, {'l', S_SL},
|
||||
{'m', S_SL}, {'n', S_SL}, {'o', S_SL}, {'p', S_SL}, {'q', S_SL}, {'r', S_SL},
|
||||
{'s', S_SL}, {'t', S_SL}, {'u', S_SL}, {'v', S_SL}, {'w', S_SL}, {'x', S_SL},
|
||||
{'y', S_SL}, {'z', S_SL}, {'A', S_CL}, {'B', S_CL}, {'C', S_CL}, {'D', S_CL},
|
||||
{'E', S_CL}, {'F', S_CL}, {'G', S_CL}, {'H', S_CL}, {'I', S_CL}, {'J', S_CL},
|
||||
{'K', S_CL}, {'L', S_CL}, {'M', S_CL}, {'N', S_CL}, {'O', S_CL}, {'P', S_CL},
|
||||
{'Q', S_CL}, {'R', S_CL}, {'S', S_CL}, {'T', S_CL}, {'U', S_CL}, {'V', S_CL},
|
||||
{'W', S_CL}, {'X', S_CL}, {'Y', S_CL}, {'Z', S_CL}, {'1', S_NB}, {'2', S_NB},
|
||||
{'3', S_NB}, {'4', S_NB}, {'5', S_NB}, {'6', S_NB}, {'7', S_NB}, {'8', S_NB},
|
||||
{'9', S_NB}, {'0', S_NB}, {33 , S_SS}, {34 , S_SS}, {35 , S_SS}, {36 , S_SS},
|
||||
{37 , S_SS}, {38 , S_SS}, {39 , S_SS}, {40 , S_SS}, {41 , S_SS}, {42 , S_SS},
|
||||
{43 , S_SS}, {44 , S_SS}, {45 , S_SS}, {46 , S_SS}, {47 , S_SS}, {58 , S_SS},
|
||||
{59 , S_SS}, {60 , S_SS}, {61 , S_SS}, {62 , S_SS}, {63 , S_SS}, {64 , S_SS},
|
||||
{91 , S_SS}, {92 , S_SS}, {93 , S_SS}, {94 , S_SS}, {95 , S_SS}, {96 , S_SS},
|
||||
{123, S_SS}, {124, S_SS}, {125, S_SS}, {126, S_SS}
|
||||
};
|
||||
|
||||
#endif /* APG_SMBL_H */
|
||||
Reference in New Issue
Block a user