Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
900ff5ea18 |
63
CHANGES
63
CHANGES
@@ -1,3 +1,64 @@
|
|||||||
|
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
|
apg-2.0.0a0
|
||||||
Added new algorithm (-b option) to check generated passwords
|
Added new algorithm (-b option) to check generated passwords
|
||||||
quality (Bloom filter).
|
quality (Bloom filter).
|
||||||
@@ -70,7 +131,7 @@ apg-1.0.4
|
|||||||
Added option -c (see apg(1)).Changed apg.c, apg.1 manpage.
|
Added option -c (see apg(1)).Changed apg.c, apg.1 manpage.
|
||||||
|
|
||||||
apg-1.0.3
|
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
|
apg-1.0.2
|
||||||
Improved event logging of apgd. Changed INSTALL.
|
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
|
Adel I. Mirzazhanov. All rights reserved
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
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:
|
The simplest way to install this package is:
|
||||||
1. untar the distribution and cd to the top:
|
1. untar the distribution and cd to the top:
|
||||||
|
|
||||||
% gzip -d -c apg-1.X.XX.tar.gz | tar xf -
|
% gzip -d -c apg-2.X.XX.tar.gz | tar xf -
|
||||||
% cd apg-1.X.XX
|
% cd apg-2.X.XX
|
||||||
|
|
||||||
If you are reading this file, you probably have already done this!
|
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
|
(2) client-server
|
||||||
but only standalone installation implemented for CYGWIN yet.
|
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 instruction below IS FOR STANDALONE INSTALLATION ONLY
|
||||||
|
|
||||||
The simplest way to install this package is:
|
The simplest way to install this package is:
|
||||||
1. untar the distribution and cd to the top:
|
1. untar the distribution and cd to the top:
|
||||||
|
|
||||||
% gzip -d -c apg-1.X.XX.tar.gz | tar xf -
|
% gzip -d -c apg-2.X.XX.tar.gz | tar xf -
|
||||||
% cd apg-1.X.XX
|
% cd apg-2.X.XX
|
||||||
|
|
||||||
If you are reading this file, you probably have already done this!
|
If you are reading this file, you probably have already done this!
|
||||||
|
|
||||||
|
|||||||
50
Makefile
50
Makefile
@@ -1,23 +1,41 @@
|
|||||||
|
##################################################################
|
||||||
# You can modify CC variable if you have compiler other than GCC
|
# You can modify CC variable if you have compiler other than GCC
|
||||||
# But the code was designed and tested with GCC
|
# But the code was designed and tested with GCC
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
# compilation flags
|
##################################################################
|
||||||
|
# Compilation flags
|
||||||
# You should comment the line below for AIX+native cc
|
# You should comment the line below for AIX+native cc
|
||||||
FLAGS = -Wall
|
FLAGS = -Wall
|
||||||
|
|
||||||
# libraries
|
##################################################################
|
||||||
|
# Libraries
|
||||||
|
#
|
||||||
|
# You should comment the line below for OpenBSD 2.8 and above
|
||||||
LIBS = -lcrypt
|
LIBS = -lcrypt
|
||||||
LIBM = -lm
|
LIBM = -lm
|
||||||
# Use lines below for cygwin
|
# Use lines below for cygwin
|
||||||
# LIBS =
|
# LIBS =
|
||||||
# LIBM =
|
# LIBM =
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# Support for crypted passwords
|
||||||
|
#
|
||||||
# DO NOT EDIT THE LINE BELOW !!!
|
# DO NOT EDIT THE LINE BELOW !!!
|
||||||
CRYPTED_PASS = APG_DONOTUSE_CRYPT
|
CRYPTED_PASS = APG_DONOTUSE_CRYPT
|
||||||
# Coment this if you do not want to use crypted passwords output
|
# Coment this if you do not want to use crypted passwords output
|
||||||
CRYPTED_PASS = APG_USE_CRYPT
|
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 dirs
|
||||||
INSTALL_PREFIX = /usr/local
|
INSTALL_PREFIX = /usr/local
|
||||||
APG_BIN_DIR = /bin
|
APG_BIN_DIR = /bin
|
||||||
@@ -25,30 +43,40 @@ APG_MAN_DIR = /man/man1
|
|||||||
APGD_BIN_DIR = /sbin
|
APGD_BIN_DIR = /sbin
|
||||||
APGD_MAN_DIR = /man/man8
|
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 #
|
# If you plan to install APG daemon you should look at lines below #
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
# FreeBSD
|
||||||
|
#
|
||||||
# Uncoment NOTHING for FreeBSD
|
# Uncoment NOTHING for FreeBSD
|
||||||
#
|
#
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
# Linux
|
||||||
|
#
|
||||||
# Uncoment line below for LINUX
|
# Uncoment line below for LINUX
|
||||||
#CS_LIBS = -lnsl
|
#CS_LIBS = -lnsl
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
# Solaris
|
||||||
|
#
|
||||||
# Uncoment line below for Solaris
|
# Uncoment line below for Solaris
|
||||||
#CS_LIBS = -lnsl -lsocket
|
#CS_LIBS = -lnsl -lsocket
|
||||||
|
|
||||||
# ====== YOU DO NOT NEED TO MODIFY ANYTHING BELOW THIS LINE ======
|
# ====== 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
|
PROGNAME = apg
|
||||||
CS_PROGNAME = apgd
|
CS_PROGNAME = apgd
|
||||||
BFM_PROGNAME = apgbfm
|
BFM_PROGNAME = apgbfm
|
||||||
BFM_SOURCES = apgbfm.c bloom.c md5/md5.c errors.c
|
BFM_SOURCES = apgbfm.c bloom.c sha/sha.c errors.c getopt.c
|
||||||
SOURCES = bloom.c md5/md5.c rnd.c ./cast/cast.c pronpass.c randpass.c restrict.c errors.c apg.c
|
SOURCES = bloom.c ./sha/sha.c ./cast/cast.c rnd.c pronpass.c \
|
||||||
HEADERS = owntypes.h pronpass.h randpass.h restrict.h errs.h rnd.h ./cast/cast.h ./cast/cast_sboxes.h
|
randpass.c restrict.c errors.c apg.c getopt.c
|
||||||
|
HEADERS = owntypes.h pronpass.h randpass.h restrict.h errs.h rnd.h \
|
||||||
|
./cast/cast.h ./cast/cast_sboxes.h getopt.h
|
||||||
OBJECTS = rnd.o ./cast/cast.o pronpass.o randpass.o restrict.o apg.o errors.o
|
OBJECTS = rnd.o ./cast/cast.o pronpass.o randpass.o restrict.o apg.o errors.o
|
||||||
|
|
||||||
all: cliserv standalone
|
all: cliserv standalone
|
||||||
@@ -60,13 +88,13 @@ standalone: apg apgbfm
|
|||||||
cygwin: standalone
|
cygwin: standalone
|
||||||
|
|
||||||
apg:
|
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:
|
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:
|
apgbfm:
|
||||||
${CC} ${FLAGS} ${LIBM} -o ${BFM_PROGNAME} ${BFM_SOURCES}
|
${CC} ${FLAGS} -o ${BFM_PROGNAME} ${BFM_SOURCES} ${LIBM}
|
||||||
|
|
||||||
strip:
|
strip:
|
||||||
strip ${PROGNAME}
|
strip ${PROGNAME}
|
||||||
|
|||||||
12
README
12
README
@@ -1,14 +1,15 @@
|
|||||||
APG v2.0.0a0 was tested and found working on:
|
APG v2.1.0 was tested and found working on:
|
||||||
|
|
||||||
i386 FreeBSD 4.0-RELEASE
|
i386 FreeBSD 4.6-RELEASE
|
||||||
i386 Linux-Mandrake 6.0
|
|
||||||
Intel Solaris 8 gcc-2.95.2
|
Intel Solaris 8 gcc-2.95.2
|
||||||
Intel Windows 2000+CYGWIN v1.1.4
|
SPARC Solaris 8 gcc-2.95.2
|
||||||
|
RedHat Linux 7.2
|
||||||
|
|
||||||
APG v1.2.13 was tested and found working on:
|
APG v1.2.13 was tested and found working on:
|
||||||
|
|
||||||
i386 FreeBSD 4.0-RELEASE
|
i386 FreeBSD 4.0-RELEASE
|
||||||
NetBSD (reported by Tomasz Luchowski <zuntum@eik.pl>)
|
NetBSD (reported by Tomasz Luchowski <zuntum@eik.pl>)
|
||||||
|
OpenBSD (reported by Rick VanNorman <rick@neverslow.com>)
|
||||||
i386 Linux-Mandrake 6.0
|
i386 Linux-Mandrake 6.0
|
||||||
i386 Linux-Redhat 7.0
|
i386 Linux-Redhat 7.0
|
||||||
i386 Linux-Mandrake 7.2 (reported by Andrew J. Caird <acaird@advance-inc.com>)
|
i386 Linux-Mandrake 7.2 (reported by Andrew J. Caird <acaird@advance-inc.com>)
|
||||||
@@ -22,6 +23,9 @@ APG v1.2.13 was tested and found working on:
|
|||||||
AIX 4.3.3+native cc (reported by Philip Le Riche <pleriche@uk03.bull.co.uk>)
|
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>)
|
AIX 4.3.3+gcc (reported by Philip Le Riche <pleriche@uk03.bull.co.uk>)
|
||||||
|
|
||||||
|
NOTE:
|
||||||
|
This release (APG v2.1.0b1) is NOT yet compatible with TkAPG (Tcl/Tk frontend for APG)
|
||||||
|
|
||||||
Any compatibility reports are welcome
|
Any compatibility reports are welcome
|
||||||
|
|
||||||
* For installation instructions see INSTALL
|
* For installation instructions see INSTALL
|
||||||
|
|||||||
14
THANKS
14
THANKS
@@ -10,3 +10,17 @@ Alexander J Pierce <apierce@boi.hp.com>
|
|||||||
Philip Le Riche <pleriche@uk03.bull.co.uk>
|
Philip Le Riche <pleriche@uk03.bull.co.uk>
|
||||||
Tomasz Luchowski <zuntum@eik.pl>
|
Tomasz Luchowski <zuntum@eik.pl>
|
||||||
Barton Hodges <barton@gcmcomputers.com>
|
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>
|
||||||
|
|||||||
3
TODO
3
TODO
@@ -15,6 +15,3 @@ Priority Medium:
|
|||||||
|
|
||||||
* Make some interfase for plug-in language modules
|
* Make some interfase for plug-in language modules
|
||||||
for pronounceable password generation.
|
for pronounceable password generation.
|
||||||
|
|
||||||
* Make some interface ( language ) to describe
|
|
||||||
restriction rules for passwords.
|
|
||||||
|
|||||||
244
apg.c
244
apg.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -36,13 +36,17 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define APG_VERSION "2.0.0a0"
|
#ifndef APG_USE_SHA
|
||||||
|
# define APG_VERSION "2.1.0 (PRNG: X9.17/CAST)"
|
||||||
|
#else /* APG_USE_SHA */
|
||||||
|
# define APG_VERSION "2.1.0 (PRNG: X9.17/SHA-1)"
|
||||||
|
#endif /* APG_USE_SHA */
|
||||||
|
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_MODE_LENGTH 5
|
#define MAX_MODE_LENGTH 4
|
||||||
|
|
||||||
#ifndef _XOPEN_SOURCE
|
#ifndef _XOPEN_SOURCE
|
||||||
#define _XOPEN_SOURCE
|
#define _XOPEN_SOURCE
|
||||||
@@ -53,7 +57,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
#include <getopt.h>
|
|
||||||
#undef APG_USE_CRYPT
|
#undef APG_USE_CRYPT
|
||||||
#endif /* __CYGWIN__ */
|
#endif /* __CYGWIN__ */
|
||||||
|
|
||||||
@@ -72,18 +75,26 @@
|
|||||||
#include "bloom.h"
|
#include "bloom.h"
|
||||||
#include "rnd.h"
|
#include "rnd.h"
|
||||||
#include "errs.h"
|
#include "errs.h"
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
|
struct pass_m {
|
||||||
|
unsigned int pass; /* password generation mode */
|
||||||
|
unsigned int filter; /* password generation mode */
|
||||||
|
};
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
UINT32 get_user_seq (void);
|
UINT32 get_user_seq (void);
|
||||||
UINT32 com_line_user_seq (char * seq);
|
UINT32 com_line_user_seq (char * seq);
|
||||||
char *crypt_passstring (const char *p); /*!!*/
|
char *crypt_passstring (const char *p);
|
||||||
void print_help (void);
|
void print_help (void);
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
void checkopt(char *opt);
|
void checkopt(char *opt);
|
||||||
unsigned int construct_mode(char *str_mode);
|
int construct_mode(char *str_mode, struct pass_m * mde);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** main()
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -100,8 +111,11 @@ main (int argc, char *argv[])
|
|||||||
int algorithm = 0; /* algorithm for generation */
|
int algorithm = 0; /* algorithm for generation */
|
||||||
int restrictions_present = FALSE; /* restrictions flag */
|
int restrictions_present = FALSE; /* restrictions flag */
|
||||||
int bloom_restrict_present = FALSE; /* bloom filter restrictions flag */
|
int bloom_restrict_present = FALSE; /* 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 */
|
||||||
char *restrictions_file; /* dictionary file name */
|
char *restrictions_file; /* dictionary file name */
|
||||||
unsigned int pass_mode = 0; /* password generation mode */
|
struct pass_m mode;
|
||||||
unsigned int pass_mode_present = FALSE; /* password generation mode flag */
|
unsigned int pass_mode_present = FALSE; /* password generation mode flag */
|
||||||
USHORT min_pass_length = 6; /* min password length */
|
USHORT min_pass_length = 6; /* min password length */
|
||||||
USHORT max_pass_length = 8; /* max password length */
|
USHORT max_pass_length = 8; /* max password length */
|
||||||
@@ -148,55 +162,44 @@ main (int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
#ifdef APG_USE_CRYPT
|
#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:sdc:n:m:x:hvyq")) != -1)
|
||||||
#else /* APG_USE_CRYPT */
|
#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:sdc:n:m:x:hvq")) != -1)
|
||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
#else /* CLISERV */
|
#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:n:m:x:v")) != -1)
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
{
|
{
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
case 'S': /* special symbols required */
|
case 'M': /* mode parameter */
|
||||||
pass_mode = pass_mode | S_SS;
|
str_mode = apg_optarg;
|
||||||
pass_mode_present = TRUE;
|
if( (construct_mode(str_mode,&mode)) == -1)
|
||||||
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)
|
|
||||||
err_app_fatal("construct_mode","wrong parameter");
|
err_app_fatal("construct_mode","wrong parameter");
|
||||||
pass_mode_present = TRUE;
|
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;
|
break;
|
||||||
case 'a': /* algorithm specification */
|
case 'a': /* algorithm specification */
|
||||||
checkopt(optarg);
|
checkopt(apg_optarg);
|
||||||
algorithm = atoi (optarg);
|
algorithm = atoi (apg_optarg);
|
||||||
break;
|
break;
|
||||||
case 'r': /* restrictions */
|
case 'r': /* restrictions */
|
||||||
restrictions_present = TRUE;
|
restrictions_present = TRUE;
|
||||||
restrictions_file = optarg;
|
restrictions_file = apg_optarg;
|
||||||
break;
|
break;
|
||||||
case 'b': /* bloom restrictions */
|
case 'b': /* bloom restrictions */
|
||||||
restrictions_present = TRUE;
|
restrictions_present = TRUE;
|
||||||
bloom_restrict_present = TRUE;
|
bloom_restrict_present = TRUE;
|
||||||
restrictions_file = optarg;
|
restrictions_file = apg_optarg;
|
||||||
break;
|
break;
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
case 's': /* user random seed required */
|
case 's': /* user random seed required */
|
||||||
@@ -204,30 +207,33 @@ main (int argc, char *argv[])
|
|||||||
user_defined_seed_present = TRUE;
|
user_defined_seed_present = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'c': /* user random seed given in command line */
|
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 = com_line_user_seq (com_line_seq);
|
||||||
user_defined_seed_present = TRUE;
|
user_defined_seed_present = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'd': /* No delinmiters option */
|
case 'd': /* no delimiters option */
|
||||||
delimiter_flag_present = TRUE;
|
delimiter_flag_present = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'q': /* quiet mode */
|
||||||
|
quiet_present = TRUE;
|
||||||
|
break;
|
||||||
#ifdef APG_USE_CRYPT
|
#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;
|
show_crypt_text = TRUE;
|
||||||
break;
|
break;
|
||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
case 'n': /* number of password specification */
|
case 'n': /* number of password specification */
|
||||||
checkopt(optarg);
|
checkopt(apg_optarg);
|
||||||
number_of_pass = atoi (optarg);
|
number_of_pass = atoi (apg_optarg);
|
||||||
break;
|
break;
|
||||||
case 'm': /* min password length */
|
case 'm': /* min password length */
|
||||||
checkopt(optarg);
|
checkopt(apg_optarg);
|
||||||
min_pass_length = (USHORT) atoi (optarg);
|
min_pass_length = (USHORT) atoi (apg_optarg);
|
||||||
break;
|
break;
|
||||||
case 'x': /* max password length */
|
case 'x': /* max password length */
|
||||||
checkopt(optarg);
|
checkopt(apg_optarg);
|
||||||
max_pass_length = (USHORT) atoi (optarg);
|
max_pass_length = (USHORT) atoi (apg_optarg);
|
||||||
break;
|
break;
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
case 'h': /* print help */
|
case 'h': /* print help */
|
||||||
@@ -237,7 +243,7 @@ main (int argc, char *argv[])
|
|||||||
case 'v': /* print version */
|
case 'v': /* print version */
|
||||||
printf ("APG (Automated Password Generator)");
|
printf ("APG (Automated Password Generator)");
|
||||||
printf ("\nversion %s", APG_VERSION);
|
printf ("\nversion %s", APG_VERSION);
|
||||||
printf ("\nCopyright (c) 1999, 2000, 2001 Adel I. Mirzazhanov\n");
|
printf ("\nCopyright (c) 1999, 2000, 2001, 2002 Adel I. Mirzazhanov\n");
|
||||||
return (0);
|
return (0);
|
||||||
default: /* print help end exit */
|
default: /* print help end exit */
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
@@ -247,22 +253,25 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pass_mode_present != TRUE)
|
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))
|
if( (tme = time(NULL)) == ( (time_t)-1))
|
||||||
err_sys("time");
|
err_sys("time");
|
||||||
if (user_defined_seed_present != TRUE)
|
if (user_defined_seed_present != TRUE)
|
||||||
x917cast_setseed ( (UINT32)tme);
|
x917_setseed ( (UINT32)tme, quiet_present);
|
||||||
else
|
else
|
||||||
x917cast_setseed (user_defined_seed ^ (UINT32)tme);
|
x917_setseed (user_defined_seed ^ (UINT32)tme, quiet_present);
|
||||||
if (min_pass_length > max_pass_length)
|
if (min_pass_length > max_pass_length)
|
||||||
max_pass_length = min_pass_length;
|
max_pass_length = min_pass_length;
|
||||||
/* main code section */
|
/* main code section */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** reserv space for password and hyphenated password and report of errors
|
** 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 ||
|
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");
|
err_sys_fatal("calloc");
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
#ifdef APG_USE_CRYPT
|
#ifdef APG_USE_CRYPT
|
||||||
@@ -272,7 +281,7 @@ main (int argc, char *argv[])
|
|||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
#ifdef 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");
|
err_sys_fatal("calloc");
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
/*
|
/*
|
||||||
@@ -284,20 +293,22 @@ main (int argc, char *argv[])
|
|||||||
if (algorithm == 0)
|
if (algorithm == 0)
|
||||||
{
|
{
|
||||||
if (gen_pron_pass(pass_string, hyph_pass_string,
|
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");
|
err_app_fatal("apg","wrong password length parameter");
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
#ifdef APG_USE_CRYPT
|
#ifdef APG_USE_CRYPT
|
||||||
if (show_crypt_text == TRUE)
|
if (show_crypt_text == TRUE)
|
||||||
bcopy ((void *)crypt_passstring (pass_string),
|
(void) memcpy ((void *)crypt_string,
|
||||||
(void *)crypt_string, 255);
|
(void *)crypt_passstring (pass_string), 255);
|
||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
if (restrictions_present == TRUE)
|
if (restrictions_present == TRUE)
|
||||||
{
|
{
|
||||||
if (bloom_restrict_present == TRUE)
|
if (filter_restrict_present == TRUE)
|
||||||
|
restrict_res = filter_check_pass(pass_string, mode.filter);
|
||||||
|
else if (bloom_restrict_present == TRUE)
|
||||||
restrict_res = bloom_check_pass(pass_string, restrictions_file);
|
restrict_res = bloom_check_pass(pass_string, restrictions_file);
|
||||||
else
|
else
|
||||||
restrict_res = check_pass(pass_string, restrictions_file);
|
restrict_res = check_pass(pass_string, restrictions_file);
|
||||||
switch (restrict_res)
|
switch (restrict_res)
|
||||||
{
|
{
|
||||||
@@ -314,7 +325,7 @@ main (int argc, char *argv[])
|
|||||||
fprintf (stdout, "\n");
|
fprintf (stdout, "\n");
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
#else /* CLISERV */
|
#else /* CLISERV */
|
||||||
snprintf(out_pass, max_pass_length*3 + 4,
|
snprintf(out_pass, max_pass_length*19 + 4,
|
||||||
"%s (%s)", pass_string, hyph_pass_string);
|
"%s (%s)", pass_string, hyph_pass_string);
|
||||||
write (0, (void*) out_pass, strlen(out_pass));
|
write (0, (void*) out_pass, strlen(out_pass));
|
||||||
write (0, (void*)&delim[0],2);
|
write (0, (void*)&delim[0],2);
|
||||||
@@ -343,7 +354,7 @@ main (int argc, char *argv[])
|
|||||||
fprintf (stdout, "\n");
|
fprintf (stdout, "\n");
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
#else /* CLISERV */
|
#else /* CLISERV */
|
||||||
snprintf(out_pass, max_pass_length*3 + 4,
|
snprintf(out_pass, max_pass_length*19 + 4,
|
||||||
"%s (%s)", pass_string, hyph_pass_string);
|
"%s (%s)", pass_string, hyph_pass_string);
|
||||||
write (0, (void*) out_pass, strlen(out_pass));
|
write (0, (void*) out_pass, strlen(out_pass));
|
||||||
write (0, (void*)&delim[0],2);
|
write (0, (void*)&delim[0],2);
|
||||||
@@ -354,20 +365,22 @@ main (int argc, char *argv[])
|
|||||||
else if (algorithm == 1)
|
else if (algorithm == 1)
|
||||||
{
|
{
|
||||||
if (gen_rand_pass(pass_string, min_pass_length,
|
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");
|
err_app_fatal("apg","wrong password length parameter");
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
#ifdef APG_USE_CRYPT
|
#ifdef APG_USE_CRYPT
|
||||||
if (show_crypt_text == TRUE)
|
if (show_crypt_text == TRUE)
|
||||||
bcopy ((void *)crypt_passstring(pass_string),
|
(void)memcpy ((void *)crypt_string,
|
||||||
(void *)crypt_string, 255);
|
(void *)crypt_passstring(pass_string), 255);
|
||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
if ( (restrictions_present == TRUE))
|
if ( (restrictions_present == TRUE))
|
||||||
{
|
{
|
||||||
if (bloom_restrict_present == TRUE)
|
if (filter_restrict_present == TRUE)
|
||||||
|
restrict_res = filter_check_pass(pass_string, mode.filter);
|
||||||
|
else if (bloom_restrict_present == TRUE)
|
||||||
restrict_res = bloom_check_pass(pass_string, restrictions_file);
|
restrict_res = bloom_check_pass(pass_string, restrictions_file);
|
||||||
else
|
else
|
||||||
restrict_res = check_pass(pass_string, restrictions_file);
|
restrict_res = check_pass(pass_string, restrictions_file);
|
||||||
switch (restrict_res)
|
switch (restrict_res)
|
||||||
{
|
{
|
||||||
@@ -439,8 +452,14 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
/*
|
/*
|
||||||
** Routine that gets user random sequense and generates
|
** get_user_seq() - Routine that gets user random sequense
|
||||||
** sutable random seed according to it
|
** and generates sutable random seed according to it.
|
||||||
|
** INPUT:
|
||||||
|
** void
|
||||||
|
** OUTPUT:
|
||||||
|
** UINT32 - random seed
|
||||||
|
** NOTES:
|
||||||
|
** none
|
||||||
*/
|
*/
|
||||||
UINT32
|
UINT32
|
||||||
get_user_seq (void)
|
get_user_seq (void)
|
||||||
@@ -451,16 +470,22 @@ get_user_seq (void)
|
|||||||
printf ("\nPlease enter some random data (only first %d are significant)\n", sizeof(prom));
|
printf ("\nPlease enter some random data (only first %d are significant)\n", sizeof(prom));
|
||||||
seq = (char *)getpass("(eg. your old password):>");
|
seq = (char *)getpass("(eg. your old password):>");
|
||||||
if (strlen(seq) < sizeof(prom))
|
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
|
else
|
||||||
bcopy((void *)seq, (void *)&prom[0], sizeof(prom));
|
(void)memcpy((void *)&prom[0], (void *)seq, sizeof(prom));
|
||||||
sdres = prom[0]^prom[1];
|
sdres = prom[0]^prom[1];
|
||||||
return (sdres);
|
return (sdres);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Routine that gets user random sequense from command line and generates
|
** com_line_user_seq() - Routine that gets user random sequense
|
||||||
** sutable random seed according to it
|
** from command line and generates sutable random seed according to it
|
||||||
|
** INPUT:
|
||||||
|
** char * - command line seed
|
||||||
|
** OUTPUT:
|
||||||
|
** UINT32 - random seed
|
||||||
|
** NOTES:
|
||||||
|
** none
|
||||||
*/
|
*/
|
||||||
UINT32
|
UINT32
|
||||||
com_line_user_seq (char * seq)
|
com_line_user_seq (char * seq)
|
||||||
@@ -468,23 +493,32 @@ com_line_user_seq (char * seq)
|
|||||||
UINT32 prom[2] = { 0L, 0L };
|
UINT32 prom[2] = { 0L, 0L };
|
||||||
UINT32 sdres = 0L;
|
UINT32 sdres = 0L;
|
||||||
if (strlen(seq) < sizeof (prom))
|
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
|
else
|
||||||
bcopy((void *)seq, (void *)&prom[0], sizeof(prom));
|
(void)memcpy((void *)&prom[0], (void *)seq, sizeof(prom));
|
||||||
sdres = prom[0]^prom[1];
|
sdres = prom[0]^prom[1];
|
||||||
return (sdres);
|
return (sdres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** print_help() - print help :)))
|
||||||
|
** INPUT:
|
||||||
|
** none.
|
||||||
|
** OUTPUT:
|
||||||
|
** help info to the stdout.
|
||||||
|
** NOTES:
|
||||||
|
** none.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
print_help (void)
|
print_help (void)
|
||||||
{
|
{
|
||||||
printf ("\napg Automated Password Generator\n");
|
printf ("\napg Automated Password Generator\n");
|
||||||
printf (" Copyright (c) Adel I. Mirzazhanov\n");
|
printf (" Copyright (c) Adel I. Mirzazhanov\n");
|
||||||
printf ("\napg [-a algorithm] [-r file] [-S] [-C] [-L] [-R]\n");
|
printf ("\napg [-a algorithm] [-r file] \n");
|
||||||
printf (" [-N] [-M mode] [-n num_of_pass] [-m min_pass_len]\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]\n");
|
printf (" [-x max_pass_len] [-c cl_seed] [-d] [-s] [-h] [-y] [-q]\n");
|
||||||
printf ("\n-S -N -C -L -R password modes\n");
|
printf ("\n-M mode new style password modes\n");
|
||||||
printf ("-M mode new style pasword modes\n");
|
printf ("-E char_string exclude characters from password generation process\n");
|
||||||
printf ("-r file apply dictionary check against file\n");
|
printf ("-r file apply dictionary check against file\n");
|
||||||
printf ("-b filter_file apply bloom filter check against filter_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 (" (filter_file should be created with apgbfm(1) utility)\n");
|
||||||
@@ -502,11 +536,21 @@ print_help (void)
|
|||||||
#ifdef APG_USE_CRYPT
|
#ifdef APG_USE_CRYPT
|
||||||
printf ("-y print crypted passwords\n");
|
printf ("-y print crypted passwords\n");
|
||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
|
printf ("-q quiet mode (do not print warnings)\n");
|
||||||
printf ("-h print this help screen\n");
|
printf ("-h print this help screen\n");
|
||||||
printf ("-v print version information\n");
|
printf ("-v print version information\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef APG_USE_CRYPT
|
#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 * crypt_passstring (const char *p)
|
||||||
{
|
{
|
||||||
char salt[10];
|
char salt[10];
|
||||||
@@ -516,6 +560,15 @@ char * crypt_passstring (const char *p)
|
|||||||
#endif /* APG_USE_CRYPT */
|
#endif /* APG_USE_CRYPT */
|
||||||
#endif /* CLISERV */
|
#endif /* CLISERV */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** checkopt() - check options.
|
||||||
|
** INPUT:
|
||||||
|
** char * - options string.
|
||||||
|
** OUTPUT:
|
||||||
|
** none.
|
||||||
|
** NOTES:
|
||||||
|
** option should contain only numeral symbols.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
checkopt(char *opt)
|
checkopt(char *opt)
|
||||||
{
|
{
|
||||||
@@ -528,9 +581,22 @@ checkopt(char *opt)
|
|||||||
err_app_fatal ("checkopt", "wrong option format");
|
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 mode = 0;
|
||||||
|
unsigned int filter = 0;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int str_length = 0;
|
int str_length = 0;
|
||||||
@@ -538,7 +604,7 @@ unsigned int construct_mode(char *s_mode)
|
|||||||
str_length = strlen(s_mode);
|
str_length = strlen(s_mode);
|
||||||
|
|
||||||
if (str_length > MAX_MODE_LENGTH)
|
if (str_length > MAX_MODE_LENGTH)
|
||||||
return(0xFFFF);
|
return(-1);
|
||||||
for (i=0; i < str_length; i++)
|
for (i=0; i < str_length; i++)
|
||||||
{
|
{
|
||||||
ch = (int)*s_mode;
|
ch = (int)*s_mode;
|
||||||
@@ -546,19 +612,19 @@ unsigned int construct_mode(char *s_mode)
|
|||||||
{
|
{
|
||||||
case 'S':
|
case 'S':
|
||||||
mode = mode | S_SS;
|
mode = mode | S_SS;
|
||||||
|
filter = filter | S_SS;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
mode = mode | S_NB;
|
mode = mode | S_NB;
|
||||||
|
filter = filter | S_NB;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
mode = mode | S_CL;
|
mode = mode | S_CL;
|
||||||
|
filter = filter | S_CL;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
mode = mode | S_SL;
|
mode = mode | S_SL;
|
||||||
break;
|
filter = filter | S_SL;
|
||||||
case 'R':
|
|
||||||
mode = mode | S_SS;
|
|
||||||
mode = mode | S_RS;
|
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
mode = mode | S_SS;
|
mode = mode | S_SS;
|
||||||
@@ -572,16 +638,14 @@ unsigned int construct_mode(char *s_mode)
|
|||||||
case 'l':
|
case 'l':
|
||||||
mode = mode | S_SL;
|
mode = mode | S_SL;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
|
||||||
mode = mode | S_SS;
|
|
||||||
mode = mode | S_RS;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
mode = mode | 0xFFFF;
|
return(-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s_mode++;
|
s_mode++;
|
||||||
}
|
}
|
||||||
return (mode);
|
mde->pass = mode;
|
||||||
|
mde->filter = filter;
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
170
apgbfm.c
170
apgbfm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 2001
|
** Copyright (c) 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -32,12 +32,18 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "bloom.h"
|
#include "bloom.h"
|
||||||
#include "errs.h"
|
#include "errs.h"
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif /* __CYGWIN__ */
|
|
||||||
|
|
||||||
#define VERSION "1.0.0a0"
|
#define VERSION "2.1.0"
|
||||||
|
|
||||||
|
|
||||||
|
#define FOUND "FOUND"
|
||||||
|
#define NOT_FOUND "NOT FOUND"
|
||||||
|
/*
|
||||||
|
#define FOUND "YES"
|
||||||
|
#define NOT_FOUND "NO"
|
||||||
|
*/
|
||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
void print_help(void);
|
void print_help(void);
|
||||||
@@ -55,6 +61,7 @@ main (int argc, char *argv[])
|
|||||||
FILE *f_filter; /* filter file descriptor */
|
FILE *f_filter; /* filter file descriptor */
|
||||||
|
|
||||||
char *word; /* word to add or check */
|
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 wc = 0L; /* amount of words to build dictionaty */
|
||||||
h_val filter_size =0L; /* filter size in bits */
|
h_val filter_size =0L; /* filter size in bits */
|
||||||
int dummy_test = 0; /* variable to make dummy test for */
|
int dummy_test = 0; /* variable to make dummy test for */
|
||||||
@@ -69,6 +76,7 @@ main (int argc, char *argv[])
|
|||||||
flag new_flag = FALSE; /* -n */
|
flag new_flag = FALSE; /* -n */
|
||||||
flag new_from_dict_flag = FALSE; /* -d */
|
flag new_from_dict_flag = FALSE; /* -d */
|
||||||
flag filter_flag = FALSE; /* -f */
|
flag filter_flag = FALSE; /* -f */
|
||||||
|
flag silent_flag = FALSE; /* -s */
|
||||||
/* end of flags section */
|
/* end of flags section */
|
||||||
|
|
||||||
/* Analize options */
|
/* Analize options */
|
||||||
@@ -78,43 +86,43 @@ main (int argc, char *argv[])
|
|||||||
exit(-1);
|
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:hvq")) != -1)
|
||||||
{
|
{
|
||||||
switch(option)
|
switch(option)
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
word = optarg;
|
word = apg_optarg;
|
||||||
add_word_flag = TRUE;
|
add_word_flag = TRUE;
|
||||||
dummy_test = dummy_test + 2;
|
dummy_test = dummy_test + 2;
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
dictfile = optarg;
|
dictfile = apg_optarg;
|
||||||
add_file_flag = TRUE;
|
add_file_flag = TRUE;
|
||||||
dummy_test = dummy_test + 2;
|
dummy_test = dummy_test + 2;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
word = optarg;
|
word = apg_optarg;
|
||||||
check_word_flag = TRUE;
|
check_word_flag = TRUE;
|
||||||
dummy_test = dummy_test + 2;
|
dummy_test = dummy_test + 2;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
dictfile = optarg;
|
dictfile = apg_optarg;
|
||||||
check_file_flag = TRUE;
|
check_file_flag = TRUE;
|
||||||
dummy_test = dummy_test + 2;
|
dummy_test = dummy_test + 2;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
checkopt(optarg);
|
checkopt(apg_optarg);
|
||||||
wc = atoi(optarg);
|
wc = atoi(apg_optarg);
|
||||||
new_flag = TRUE;
|
new_flag = TRUE;
|
||||||
dummy_test = dummy_test + 2;
|
dummy_test = dummy_test + 2;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
dictfile = optarg;
|
dictfile = apg_optarg;
|
||||||
new_from_dict_flag = TRUE;
|
new_from_dict_flag = TRUE;
|
||||||
dummy_test = dummy_test + 2;
|
dummy_test = dummy_test + 2;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
filter = optarg;
|
filter = apg_optarg;
|
||||||
filter_flag = TRUE;
|
filter_flag = TRUE;
|
||||||
dummy_test = dummy_test + 1;
|
dummy_test = dummy_test + 1;
|
||||||
break;
|
break;
|
||||||
@@ -124,8 +132,11 @@ main (int argc, char *argv[])
|
|||||||
case 'v':
|
case 'v':
|
||||||
printf ("APG Bloom filter management programm");
|
printf ("APG Bloom filter management programm");
|
||||||
printf ("\nversion %s", VERSION);
|
printf ("\nversion %s", VERSION);
|
||||||
printf ("\nCopyright (c) 2001 Adel I. Mirzazhanov\n");
|
printf ("\nCopyright (c) 2001, 2002 Adel I. Mirzazhanov\n");
|
||||||
return (0);
|
return (0);
|
||||||
|
case 'q':
|
||||||
|
silent_flag = TRUE;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print_help();
|
print_help();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@@ -135,98 +146,123 @@ main (int argc, char *argv[])
|
|||||||
if (dummy_test != 3) err_app_fatal ("apg", "too many options");
|
if (dummy_test != 3) err_app_fatal ("apg", "too many options");
|
||||||
/* Main part */
|
/* Main part */
|
||||||
/* At this point we can be sure that all options a correct */
|
/* 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");
|
err_sys_fatal("open_filter");
|
||||||
filter_size = get_filtersize(f_filter);
|
filter_size = get_filtersize(f_filter);
|
||||||
|
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||||
if ( insert_word (word, f_filter, filter_size) == -1)
|
if ( insert_word (word, f_filter, filter_size) == -1)
|
||||||
err_sys_fatal("insert_word");
|
err_sys_fatal("insert_word");
|
||||||
printf ("Word %s added\n",word);
|
if (silent_flag != TRUE)
|
||||||
|
printf ("Word %s added\n",word);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (add_file_flag == TRUE)
|
if (add_file_flag == TRUE) /* -A dictfile */
|
||||||
{
|
{
|
||||||
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||||
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
||||||
err_sys_fatal("fopen");
|
err_sys_fatal("fopen");
|
||||||
if( (f_filter = open_filter(filter)) == NULL)
|
if( (f_filter = open_filter(filter,"r+")) == NULL)
|
||||||
err_sys_fatal("open_filter");
|
err_sys_fatal("open_filter");
|
||||||
filter_size = get_filtersize(f_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))
|
while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL))
|
||||||
{
|
{
|
||||||
word = (char *)strtok (word," \t\n\0");
|
tmp = (char *)strtok (word," \t\n\0");
|
||||||
|
if( tmp != NULL)
|
||||||
|
{
|
||||||
|
word = tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( insert_word (word, f_filter, filter_size) == -1)
|
if ( insert_word (word, f_filter, filter_size) == -1)
|
||||||
err_sys_fatal("insert_word");
|
err_sys_fatal("insert_word");
|
||||||
i++;
|
i++;
|
||||||
if ( i % 100 == 0)
|
if (silent_flag != TRUE)
|
||||||
{
|
{
|
||||||
fprintf (stdout,".");
|
if ( i % 100 == 0)
|
||||||
fflush (stdout);
|
{
|
||||||
|
fprintf (stdout,".");
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bzero((void *)word, MAX_DICT_STRLEN);
|
(void)memset((void *)word, 0, MAX_DICT_STRLEN);
|
||||||
}
|
}
|
||||||
printf ("\n");
|
if (silent_flag != TRUE) printf ("\n");
|
||||||
free ( (void *)word);
|
free ( (void *)word);
|
||||||
fclose (f_dictfile);
|
fclose (f_dictfile);
|
||||||
fclose (f_filter);
|
close_filter (f_filter);
|
||||||
return (0);
|
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");
|
err_sys_fatal("open_filter");
|
||||||
filter_size = get_filtersize(f_filter);
|
filter_size = get_filtersize(f_filter);
|
||||||
|
if (filter_size == 0) err_sys_fatal("get_filtersize");
|
||||||
switch(check_word (word, f_filter, filter_size))
|
switch(check_word (word, f_filter, filter_size))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
err_sys_fatal("check_word");
|
err_sys_fatal("check_word");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
printf ("%s: FOUND \n",word);
|
printf ("%s: %s \n",word, FOUND);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
printf ("%s: NOT FOUND\n",word);
|
printf ("%s: %s\n",word, NOT_FOUND);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (check_file_flag == TRUE)
|
if (check_file_flag == TRUE) /* -C dictfile */
|
||||||
{
|
{
|
||||||
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||||
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
||||||
err_sys_fatal("fopen");
|
err_sys_fatal("fopen");
|
||||||
wc = count_words (f_dictfile);
|
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");
|
err_sys_fatal("open_filter");
|
||||||
filter_size = get_filtersize(f_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))
|
while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL))
|
||||||
{
|
{
|
||||||
word = (char *)strtok (word," \t\n\0");
|
tmp = (char *)strtok (word," \t\n\0");
|
||||||
|
if( tmp != NULL)
|
||||||
|
{
|
||||||
|
word = tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch(check_word (word, f_filter, filter_size))
|
switch(check_word (word, f_filter, filter_size))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
err_sys_fatal("check_word");
|
err_sys_fatal("check_word");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
printf ("%s: FOUND \n",word);
|
printf ("%s: %s\n",word, FOUND);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
printf ("%s: NOT FOUND\n",word);
|
printf ("%s: %s\n",word, NOT_FOUND);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bzero((void *)word, MAX_DICT_STRLEN);
|
(void)memset((void *)word, 0, MAX_DICT_STRLEN);
|
||||||
}
|
}
|
||||||
free ( (void *)word);
|
free ( (void *)word);
|
||||||
fclose (f_dictfile);
|
fclose (f_dictfile);
|
||||||
fclose (f_filter);
|
close_filter (f_filter);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (new_flag == TRUE) /* -n nwords */
|
if (new_flag == TRUE) /* -n nwords */
|
||||||
{
|
{
|
||||||
if ((f_filter = create_filter(filter, wc)) == NULL)
|
if ((f_filter = create_filter(filter, wc)) == NULL)
|
||||||
err_sys_fatal("create_filter");
|
err_sys_fatal("create_filter");
|
||||||
fclose(f_filter);
|
close_filter(f_filter);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (new_from_dict_flag == TRUE) /* -d dictfile */
|
if (new_from_dict_flag == TRUE) /* -d dictfile */
|
||||||
@@ -234,37 +270,57 @@ main (int argc, char *argv[])
|
|||||||
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
word = (char *) calloc(1,MAX_DICT_STRLEN);
|
||||||
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
if ( (f_dictfile = fopen(dictfile,"r")) == NULL)
|
||||||
err_sys_fatal("fopen");
|
err_sys_fatal("fopen");
|
||||||
fprintf (stdout,"Counting words in dictionary. Please wait...\n");
|
if (silent_flag != TRUE)
|
||||||
fflush (stdout);
|
{
|
||||||
|
fprintf (stdout,"Counting words in dictionary. Please wait...\n");
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
wc = count_words (f_dictfile);
|
wc = count_words (f_dictfile);
|
||||||
|
if (wc == 0) err_sys_fatal("count_words");
|
||||||
if( (f_filter = create_filter(filter, wc)) == NULL)
|
if( (f_filter = create_filter(filter, wc)) == NULL)
|
||||||
err_sys_fatal("create_filter");
|
err_sys_fatal("create_filter");
|
||||||
filter_size = get_filtersize(f_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))
|
while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL))
|
||||||
{
|
{
|
||||||
word = (char *)strtok (word," \t\n\0");
|
tmp = (char *)strtok (word," \t\n\0");
|
||||||
|
if( tmp != NULL)
|
||||||
|
{
|
||||||
|
word = tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( insert_word (word, f_filter, filter_size) == -1)
|
if ( insert_word (word, f_filter, filter_size) == -1)
|
||||||
err_sys_fatal("insert_word");
|
err_sys_fatal("insert_word");
|
||||||
i++;
|
i++;
|
||||||
if ( i % 100 == 0)
|
if (silent_flag != TRUE)
|
||||||
{
|
{
|
||||||
fprintf (stdout, ".");
|
if ( i % 100 == 0)
|
||||||
fflush (stdout);
|
{
|
||||||
|
fprintf (stdout, ".");
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bzero((void *)word, MAX_DICT_STRLEN);
|
(void)memset((void *)word, 0, MAX_DICT_STRLEN);
|
||||||
}
|
}
|
||||||
printf ("\n");
|
if (silent_flag != TRUE) printf ("\n");
|
||||||
free ( (void *)word);
|
free ( (void *)word);
|
||||||
fclose (f_dictfile);
|
fclose (f_dictfile);
|
||||||
fclose (f_filter);
|
close_filter (f_filter);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
** print_help - prints short help info
|
** print_help() - prints short help info
|
||||||
** INPUT: NOTHING
|
** INPUT:
|
||||||
** RETURN: NOTHING
|
** none.
|
||||||
|
** OUTPUT:
|
||||||
|
** prints help info to the stdout.
|
||||||
|
** NOTES:
|
||||||
|
** none.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
print_help(void)
|
print_help(void)
|
||||||
@@ -272,7 +328,7 @@ print_help(void)
|
|||||||
printf ("\napgbfm APG Bloom filter management\n");
|
printf ("\napgbfm APG Bloom filter management\n");
|
||||||
printf (" Copyright (c) 2001 Adel I. Mirzazhanov\n");
|
printf (" Copyright (c) 2001 Adel I. Mirzazhanov\n");
|
||||||
printf ("\napgbfm -f filter < [-a word] | [-A dictfile] | [-n numofwords] |\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 [-v] [-h]\n\n");
|
printf ("apgbfm [-v] [-h]\n\n");
|
||||||
printf ("-a word add word to filter\n");
|
printf ("-a word add word to filter\n");
|
||||||
printf ("-A dictfile add words from dictfile to filter\n");
|
printf ("-A dictfile add words from dictfile to filter\n");
|
||||||
@@ -281,10 +337,20 @@ print_help(void)
|
|||||||
printf ("-n numofwords create new empty filter\n");
|
printf ("-n numofwords create new empty filter\n");
|
||||||
printf ("-d dictfile create new filter and add all words from dictfile\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 ("-f filtername use filtername as the name for filter\n");
|
||||||
|
printf ("-q quiet mode (do not print dots for -A and -d)\n");
|
||||||
printf ("-v print version information\n");
|
printf ("-v print version information\n");
|
||||||
printf ("-h print help (this screen)\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
|
void
|
||||||
checkopt(char *opt)
|
checkopt(char *opt)
|
||||||
{
|
{
|
||||||
|
|||||||
129
bloom.c
129
bloom.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 2001
|
** Copyright (c) 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -38,8 +38,8 @@
|
|||||||
** open_filter - open APG Bloom filter file
|
** open_filter - open APG Bloom filter file
|
||||||
** get_filtersize - get APG Bloom filter size
|
** get_filtersize - get APG Bloom filter size
|
||||||
** count_words - count words in plain dictionary file
|
** count_words - count words in plain dictionary file
|
||||||
***************************************************************************
|
**=============================================================
|
||||||
** hash2bit - generates 4 values (should be 4 values of independent
|
** hash2bit - generates 5 values (should be 5 values of independent
|
||||||
** hash functions) from input string.
|
** hash functions) from input string.
|
||||||
** getbit - get the bit value from file.
|
** getbit - get the bit value from file.
|
||||||
** putbit - put the bit in the file.
|
** putbit - put the bit in the file.
|
||||||
@@ -57,7 +57,7 @@ int putbit(FILE * f, h_val bitnum);
|
|||||||
** char *word - word to incert in the filter
|
** char *word - word to incert in the filter
|
||||||
** FILE *file - filter file descriptor
|
** FILE *file - filter file descriptor
|
||||||
** h_val filter_size - filter size in bits
|
** h_val filter_size - filter size in bits
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** int
|
** int
|
||||||
** 0 - everything OK
|
** 0 - everything OK
|
||||||
** -1 - something wrong
|
** -1 - something wrong
|
||||||
@@ -65,14 +65,14 @@ int putbit(FILE * f, h_val bitnum);
|
|||||||
int
|
int
|
||||||
insert_word(char *word, FILE *file, h_val filter_size)
|
insert_word(char *word, FILE *file, h_val filter_size)
|
||||||
{
|
{
|
||||||
h_val h[4];
|
h_val h[H_NUM];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
hash2bit (word, &h[0]);
|
hash2bit (word, &h[0]);
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < H_NUM; i++)
|
||||||
if (putbit (file, h[i] % filter_size)== -1)
|
if (putbit (file, h[i] % filter_size)== -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -81,7 +81,7 @@ return(0);
|
|||||||
** char *word - word to check
|
** char *word - word to check
|
||||||
** FILE *file - filter file descriptor
|
** FILE *file - filter file descriptor
|
||||||
** h_val filter_size - filter size in bits
|
** h_val filter_size - filter size in bits
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** int
|
** int
|
||||||
** 0 - word is not in dictionary
|
** 0 - word is not in dictionary
|
||||||
** 1 - word is in dictionary
|
** 1 - word is in dictionary
|
||||||
@@ -90,11 +90,11 @@ return(0);
|
|||||||
int
|
int
|
||||||
check_word(char *word, FILE *file, h_val filter_size)
|
check_word(char *word, FILE *file, h_val filter_size)
|
||||||
{
|
{
|
||||||
h_val h[4];
|
h_val h[H_NUM];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
hash2bit (word, &h[0]);
|
hash2bit (word, &h[0]);
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < H_NUM; i++)
|
||||||
{
|
{
|
||||||
switch(getbit(file, h[i] % filter_size))
|
switch(getbit(file, h[i] % filter_size))
|
||||||
{
|
{
|
||||||
@@ -116,24 +116,25 @@ check_word(char *word, FILE *file, h_val filter_size)
|
|||||||
** open filter file and check is this the real bloom filter file
|
** open filter file and check is this the real bloom filter file
|
||||||
** INPUT:
|
** INPUT:
|
||||||
** char * f_name - filter filename
|
** char * f_name - filter filename
|
||||||
** RETURN:
|
** const char *mode - "r" or "r+"
|
||||||
|
** OUTPUT:
|
||||||
** FILE * - file pointer
|
** FILE * - file pointer
|
||||||
** NULL - something wrong.
|
** NULL - something wrong.
|
||||||
*/
|
*/
|
||||||
FILE *
|
FILE *
|
||||||
open_filter(char * f_name)
|
open_filter(char * f_name, const char *mode)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct apg_bf_hdr bf_hdr;
|
struct apg_bf_hdr bf_hdr;
|
||||||
if ((f = fopen (f_name, "r+")) == NULL)
|
if ((f = fopen (f_name, mode)) == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if(fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) < APGBFHDRSIZE)
|
if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) < APGBFHDRSIZE)
|
||||||
if (ferror (f) != 0)
|
if (ferror (f) != 0)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if( (bf_hdr.id[0] != 'A') || (bf_hdr.id[1] != 'P') ||
|
if ((bf_hdr.id[0] != 'A') || (bf_hdr.id[1] != 'P') ||
|
||||||
(bf_hdr.id[2] != 'G') || (bf_hdr.id[3] != 'B') ||
|
(bf_hdr.id[2] != 'G') || (bf_hdr.id[3] != 'B') ||
|
||||||
(bf_hdr.id[4] != 'F') || (bf_hdr.id[5] != '1') ||
|
(bf_hdr.id[4] != 'F') || (bf_hdr.id[5] != '1') ||
|
||||||
(bf_hdr.id[6] != '0') || (bf_hdr.id[7] != '0') ) return (NULL);
|
(bf_hdr.id[6] != '0') || (bf_hdr.id[7] != '1') ) return (NULL);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fseek (f, 0, SEEK_SET) == -1)
|
if (fseek (f, 0, SEEK_SET) == -1)
|
||||||
@@ -142,47 +143,64 @@ 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
|
** get_filtersize - get APG Bloom filter size
|
||||||
** INPUT:
|
** INPUT:
|
||||||
** FILE *f - filter file descriptor
|
** FILE *f - filter file descriptor
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** h_val - size of APG Bloom filter.
|
** h_val - size of APG Bloom filter.
|
||||||
|
** 0 - something wrong
|
||||||
*/
|
*/
|
||||||
h_val
|
h_val
|
||||||
get_filtersize(FILE * f)
|
get_filtersize(FILE * f)
|
||||||
{
|
{
|
||||||
struct apg_bf_hdr bf_hdr;
|
struct apg_bf_hdr bf_hdr;
|
||||||
fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f);
|
if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) < APGBFHDRSIZE)
|
||||||
fseek (f, 0, SEEK_SET);
|
if (ferror (f) != 0)
|
||||||
|
return(0);
|
||||||
|
if (fseek (f, 0, SEEK_SET) == -1)
|
||||||
|
return(0);
|
||||||
return( (h_val)bf_hdr.fs);
|
return( (h_val)bf_hdr.fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** create_filter - create initial(empty) filter file
|
** 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
|
** 0.0001 (0.01%) - probability of false positives
|
||||||
** INPUT:
|
** INPUT:
|
||||||
** char * f_name - filter filename
|
** char * f_name - filter filename
|
||||||
** unsigned long int n_words - number of words in filter
|
** unsigned long int n_words - number of words in filter
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** FILE * - filter file descriptor
|
** FILE * - filter file descriptor
|
||||||
** NULL - something wrong
|
** NULL - something wrong
|
||||||
***********************************************************
|
** NOTES:
|
||||||
** n - number of words in the filter
|
** n - number of words in the filter
|
||||||
** N - size of filter(?)
|
** N - size of filter(?)
|
||||||
**
|
**
|
||||||
** a=(1-(4/N))^n
|
** a=(1-(4/N))^n
|
||||||
** 0.0001=(1-a)^4 ==> 1-a=0.1 ==> a=0.9 ==>
|
** 0.0001=(1-a)^5 ==> 1-a=0.15849... ==> a=0.84151068 ==>
|
||||||
** 0.9=(1-(4/N))^n ==> 0.9^(1/n)=1-(4/N) ==>
|
** 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
|
** 5
|
||||||
** N = ----------
|
** N = -----------------
|
||||||
** 1/n
|
** 1/n
|
||||||
** 1 - 0.9
|
** 1 - 0.84151068
|
||||||
*/
|
*/
|
||||||
FILE *
|
FILE *
|
||||||
create_filter(char * f_name, unsigned long int n_words)
|
create_filter(char * f_name, unsigned long int n_words)
|
||||||
@@ -199,7 +217,7 @@ create_filter(char * f_name, unsigned long int n_words)
|
|||||||
bf_hdr.id[4] = 'F';
|
bf_hdr.id[4] = 'F';
|
||||||
bf_hdr.id[5] = '1';
|
bf_hdr.id[5] = '1';
|
||||||
bf_hdr.id[6] = '0';
|
bf_hdr.id[6] = '0';
|
||||||
bf_hdr.id[7] = '0';
|
bf_hdr.id[7] = '1';
|
||||||
bf_hdr.fs = FSIZE_BIT(n_words);
|
bf_hdr.fs = FSIZE_BIT(n_words);
|
||||||
|
|
||||||
if ((f = fopen (f_name, "w+")) == NULL)
|
if ((f = fopen (f_name, "w+")) == NULL)
|
||||||
@@ -223,18 +241,25 @@ create_filter(char * f_name, unsigned long int n_words)
|
|||||||
** count_words - count words in plain dictionary file
|
** count_words - count words in plain dictionary file
|
||||||
** INPUT:
|
** INPUT:
|
||||||
** FILE *dict_file -plain dicionary file descriptor
|
** FILE *dict_file -plain dicionary file descriptor
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** h_val - amount of words in dictionary file
|
** h_val - amount of words in dictionary file
|
||||||
|
** 0 - something wrong
|
||||||
*/
|
*/
|
||||||
h_val
|
h_val
|
||||||
count_words(FILE *dict_file)
|
count_words(FILE *dict_file)
|
||||||
{
|
{
|
||||||
h_val i = 0L; /* word counter */
|
h_val i = 0L; /* word counter */
|
||||||
char *string; /* temp string holder */
|
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))
|
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);
|
free ((void *) string);
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
@@ -245,19 +270,19 @@ count_words(FILE *dict_file)
|
|||||||
** INPUT:
|
** INPUT:
|
||||||
** char *word - word to hash
|
** char *word - word to hash
|
||||||
** h_val *b - pointer to bitnumber array
|
** h_val *b - pointer to bitnumber array
|
||||||
** RETURN
|
** OUTPUT:
|
||||||
** h_val * - pointer to bitnumber array
|
** h_val * - pointer to bitnumber array
|
||||||
*/
|
*/
|
||||||
h_val *
|
h_val *
|
||||||
hash2bit(char * word, h_val *b)
|
hash2bit(char * word, h_val *b)
|
||||||
{
|
{
|
||||||
struct apg_MD5Context context;
|
apg_SHA_INFO context;
|
||||||
unsigned char cs[16];
|
BYTE cs[SHA_DIGESTSIZE];
|
||||||
|
|
||||||
apg_MD5Init (&context);
|
apg_shaInit (&context);
|
||||||
apg_MD5Update (&context, word, strlen(word));
|
apg_shaUpdate (&context, (BYTE *)word, strlen(word));
|
||||||
apg_MD5Final (cs, &context);
|
apg_shaFinal (&context, cs);
|
||||||
return ( (h_val *)memcpy( (void *)b, (void *)&cs[0], 16));
|
return ( (h_val *)memcpy( (void *)b, (void *)&cs[0], SHA_DIGESTSIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -265,7 +290,7 @@ hash2bit(char * word, h_val *b)
|
|||||||
** INPUT:
|
** INPUT:
|
||||||
** FILE *f - file descriptor
|
** FILE *f - file descriptor
|
||||||
** h_val bitnum - bit number
|
** h_val bitnum - bit number
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** int
|
** int
|
||||||
** 0,1 - bit value
|
** 0,1 - bit value
|
||||||
** -1 - something wrong
|
** -1 - something wrong
|
||||||
@@ -297,7 +322,7 @@ getbit(FILE * f, h_val bitnum)
|
|||||||
** INPUT:
|
** INPUT:
|
||||||
** FILE *f - file descriptor
|
** FILE *f - file descriptor
|
||||||
** h_val bitnum - bit number
|
** h_val bitnum - bit number
|
||||||
** RETURN:
|
** OUTPUT:
|
||||||
** int
|
** int
|
||||||
** 0 - everything OK
|
** 0 - everything OK
|
||||||
** -1 - something wrong
|
** -1 - something wrong
|
||||||
@@ -327,4 +352,4 @@ putbit(FILE * f, h_val bitnum)
|
|||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/* END OF bloom.c file */
|
/* END OF bloom.c file */
|
||||||
|
|||||||
27
bloom.h
27
bloom.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 2001
|
** Copyright (c) 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -41,19 +41,10 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/* Add prototype support. */
|
#include "sha/sha.h"
|
||||||
#ifndef PROTO
|
|
||||||
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
|
|
||||||
#define PROTO(ARGS) ARGS
|
|
||||||
#else
|
|
||||||
#define PROTO(ARGS) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "md5/md5.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)
|
||||||
#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)
|
|
||||||
|
|
||||||
#define APGBFHDRSIZE 12
|
#define APGBFHDRSIZE 12
|
||||||
|
|
||||||
@@ -61,20 +52,22 @@
|
|||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
#define MAX_DICT_STRLEN 255
|
#define MAX_DICT_STRLEN 255
|
||||||
|
#define H_NUM 5
|
||||||
|
|
||||||
typedef unsigned long int h_val; /* should be 32-bit */
|
typedef unsigned long int h_val; /* should be 32-bit */
|
||||||
typedef unsigned short int flag;
|
typedef unsigned short int flag;
|
||||||
|
|
||||||
struct apg_bf_hdr {
|
struct apg_bf_hdr {
|
||||||
char id[8];
|
char id[8]; /* ID */
|
||||||
unsigned long int fs;
|
unsigned long int fs; /* filter size */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int insert_word(char *word, FILE *file, h_val filter_size);
|
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 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 * create_filter(char * f_name, unsigned long int n_words);
|
||||||
extern FILE * open_filter(char * f_name);
|
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 h_val get_filtersize(FILE *f);
|
||||||
extern h_val count_words(FILE *dict_file);
|
extern h_val count_words(FILE *dict_file);
|
||||||
|
|
||||||
#endif /* APG_BLOOM_H */
|
#endif /* APG_BLOOM_H */
|
||||||
|
|||||||
73
doc/APG_TIPS
73
doc/APG_TIPS
@@ -44,3 +44,76 @@ genpw () {
|
|||||||
|
|
||||||
until genpw; do : ; done
|
until genpw; do : ; done
|
||||||
----------[cut here]
|
----------[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.
|
||||||
|
|||||||
138
doc/man/apg.1
138
doc/man/apg.1
@@ -2,17 +2,17 @@
|
|||||||
.\" Licensed under BSD-like License.
|
.\" Licensed under BSD-like License.
|
||||||
.\" Created by Adel I. Mirzazhanov
|
.\" Created by Adel I. Mirzazhanov
|
||||||
.\"
|
.\"
|
||||||
.TH APG 1 "2001 Mar 18" "Automated Password Generator" "User Manual"
|
.TH APG 1 "2002 Jun 11" "Automated Password Generator" "User Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
apg
|
apg
|
||||||
\- generates several random passwords
|
\- generates several random passwords
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B apg
|
.B apg
|
||||||
|
[\fB-a algorithm\fP] [\fB-M mode\fP] [\fB-E char_string\fP]
|
||||||
|
[\fB-n num_of_pass\fP] [\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP]
|
||||||
[\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP]
|
[\fB-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-s\fP] [\fB-c cl_seed\fP] [\fB-d\fP] [\fB-y\fP] [\fB-q\fP] [\fB-h\fP] [\fB-v\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]
|
|
||||||
.PP
|
.PP
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B apg
|
.B apg
|
||||||
@@ -51,6 +51,8 @@ or
|
|||||||
.B RFC1750
|
.B RFC1750
|
||||||
with exception that it uses
|
with exception that it uses
|
||||||
.I CAST
|
.I CAST
|
||||||
|
or
|
||||||
|
.I SHA-1
|
||||||
instead of
|
instead of
|
||||||
.I Triple DES.
|
.I Triple DES.
|
||||||
It uses local time with precision of microseconds (see
|
It uses local time with precision of microseconds (see
|
||||||
@@ -59,16 +61,21 @@ initial random seed.
|
|||||||
.PP
|
.PP
|
||||||
.B apg
|
.B apg
|
||||||
also have the ability to check generated password quality using
|
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
|
.B -r
|
||||||
.I dictfile
|
.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,
|
(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
|
common words, etc. You even can use one of the dictionaries that come with
|
||||||
.I dictionary password crackers.
|
.I dictionary password crackers.
|
||||||
This check is case sensitive. For example, if you want to reject word 'root',
|
Bloom filter file should be created with \fBapgbfm\fP(1) utility included
|
||||||
you should insert in \fIdictfile\fP words: root, Root, RoOt, ... , ROOT.
|
in apg distribution. These checks are case sensitive. For example, if you want
|
||||||
It is not the easiest way to check password quality, but
|
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
|
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.
|
techniques to check passwords (like pattern check) just to make life easier.
|
||||||
.sp
|
.sp
|
||||||
@@ -76,64 +83,56 @@ techniques to check passwords (like pattern check) just to make life easier.
|
|||||||
.TP
|
.TP
|
||||||
.B -M mode
|
.B -M mode
|
||||||
Use symbolsets specified with \fBmode\fP for password generation.
|
Use symbolsets specified with \fBmode\fP for password generation.
|
||||||
\fBmode\fP is a text string consisting of characters \fBS[s]\fP, \fBN[n]\fP,
|
\fBmode\fP is a text string consisting of characters \fBS\fP, \fBs\fP, \fBN\fP, \fBn\fP,
|
||||||
\fBC[c]\fP, \fBL[l]\fP,\fBR[r]\fP. Where:
|
\fBC\fP, \fBc\fP, \fBL\fP, \fBl\fP. Where:
|
||||||
.RS
|
.RS
|
||||||
.TP
|
.TP
|
||||||
.B S[s]
|
.B S
|
||||||
use special symbol set (for random character password generation algorithm only).
|
generator \fBmust\fP use special symbol set for every generated password.
|
||||||
.TP
|
.TP
|
||||||
.B N[n]
|
.B s
|
||||||
use numeral symbol set.
|
generator \fBshould\fP use special symbol set for password generation.
|
||||||
.TP
|
.TP
|
||||||
.B C[c]
|
.B N
|
||||||
use capital symbol set.
|
generator \fBmust\fP use numeral symbol set for every generated password.
|
||||||
.TP
|
.TP
|
||||||
.B L[l]
|
.B n
|
||||||
use small letters symbol set (always present if pronounceable password
|
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).
|
generation algorithm is used).
|
||||||
.TP
|
.TP
|
||||||
.B R[r]
|
.B l
|
||||||
the same as \fBS[s]\fP but it does not generate symbols \fB`\fP, \fB'\fP,
|
generator \fBshould\fP use small letters symbol set for password generation.
|
||||||
\fB"\fP, \fB|\fP, \fB$\fP, \fBbackslash\fP, \fB?\fP. Useful for password generation in
|
.TP
|
||||||
a shell script. (For random character password generation algorithm only).
|
.B R,r
|
||||||
|
not supported any more. Use \fB-E char_string\fP option instead.
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.br
|
.br
|
||||||
\fBmode\fP can not be more then 5 characters in
|
\fBmode\fP can not be more than 4 characters in
|
||||||
length.
|
length.
|
||||||
.PP
|
.PP
|
||||||
|
.B Note:
|
||||||
|
.br
|
||||||
|
Usage of L, M, N, C will slow down password generation process.
|
||||||
|
.PP
|
||||||
.B Examples:
|
.B Examples:
|
||||||
.br
|
.br
|
||||||
\fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP
|
\fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP
|
||||||
.PP
|
.PP
|
||||||
\fB-M mode\fP is the new style password generation mode definition, but the old style
|
\fB-M mode\fP is the new style password generation mode definition. Old style
|
||||||
options(-C, -N, -S, -L, -R) are also supported.
|
options(-C, -N, -S, -L, -R) are not supported any more.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.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
|
.B -a algorithm
|
||||||
use
|
use
|
||||||
.B algorithm
|
.B algorithm
|
||||||
@@ -146,6 +145,36 @@ for password generation.
|
|||||||
- random character password generation
|
- random character password generation
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.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
|
.B -r \fIdictfile\fP
|
||||||
check generated passwords for their appearance in
|
check generated passwords for their appearance in
|
||||||
.I dictfile
|
.I dictfile
|
||||||
@@ -188,18 +217,19 @@ Default maximum password length is 8.
|
|||||||
.B -y
|
.B -y
|
||||||
print generated passwords and crypted passwords (see man \fBcrypt\fP(3))
|
print generated passwords and crypted passwords (see man \fBcrypt\fP(3))
|
||||||
.TP
|
.TP
|
||||||
|
.B -q
|
||||||
|
quiet mode (do not print warnings)
|
||||||
|
.TP
|
||||||
.B -h
|
.B -h
|
||||||
print help information and exit
|
print help information and exit
|
||||||
.TP
|
.TP
|
||||||
.B -v
|
.B -v
|
||||||
print version information and exit
|
print version information and exit
|
||||||
.SH "DEFAULT OPTIONS"
|
.SH "DEFAULT OPTIONS"
|
||||||
\fBapg -a 0 -N -C -L -n 6 -x 8 -m 6\fP (old style)
|
\fBapg -a 0 -M ncl -n 6 -x 8 -m 6\fP (new style)
|
||||||
.br
|
|
||||||
\fBapg -a 0 -M NCL -n 6 -x 8 -m 6\fP (new style)
|
|
||||||
.PP
|
.PP
|
||||||
If you want to generate realy secure passwords,
|
If you want to generate really secure passwords,
|
||||||
you should use option \fB-s\fP. To simlify
|
you should use option \fB-s\fP. To simplify
|
||||||
.B apg
|
.B apg
|
||||||
usage, you can write a small shell script. For example:
|
usage, you can write a small shell script. For example:
|
||||||
.br
|
.br
|
||||||
|
|||||||
@@ -2,29 +2,29 @@
|
|||||||
.\" Licensed under BSD-like License.
|
.\" Licensed under BSD-like License.
|
||||||
.\" Created by Adel I. Mirzazhanov
|
.\" Created by Adel I. Mirzazhanov
|
||||||
.\"
|
.\"
|
||||||
.TH APGBFM 1 "2001 Mar 18" "Automated Password Generator" "User Manual"
|
.TH APGBFM 1 "2002 Jun 12" "Automated Password Generator" "User Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
apg
|
apgbfm
|
||||||
\- APG Bloom filter management program
|
\- APG Bloom filter management program
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B apgbfm
|
.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]
|
||||||
.br
|
.br
|
||||||
.B apgbfm
|
.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]
|
||||||
.br
|
.br
|
||||||
.B apgbfm
|
.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
|
.br
|
||||||
.B apgbfm
|
.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
|
.br
|
||||||
.B apgbfm
|
.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
|
.br
|
||||||
.B apgbfm
|
.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
|
.br
|
||||||
.B apgbfm
|
.B apgbfm
|
||||||
[\fB-v\fP] [\fB-h\fP]
|
[\fB-v\fP] [\fB-h\fP]
|
||||||
@@ -50,7 +50,7 @@ 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
|
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
|
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.
|
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
|
.PP
|
||||||
\fBapgbfm\fP can be used as standalone utility, not only with \fBapg\fP, or
|
\fBapgbfm\fP can be used as standalone utility, not only with \fBapg\fP, or
|
||||||
\fBapgd\fP.
|
\fBapgd\fP.
|
||||||
@@ -73,14 +73,21 @@ want to fill filter dynamicaly.
|
|||||||
.TP
|
.TP
|
||||||
.B -d \fIdictfile\fP
|
.B -d \fIdictfile\fP
|
||||||
create new filter from \fIdictfile\fP. It may take a lot of time to
|
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
|
generate filter from a big dictionary. In that dictionary you may place
|
||||||
\fBapgbfm\fP prints dot for every 100 words added in dictionary.
|
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
|
.TP
|
||||||
.B -a word
|
.B -a word
|
||||||
add \fBword\fP to the filter.
|
add \fBword\fP to the filter.
|
||||||
.TP
|
.TP
|
||||||
.B -A \fIdictfile\fP
|
.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
|
.TP
|
||||||
.B -c word
|
.B -c word
|
||||||
check \fBword\fP for appearance in the filter.
|
check \fBword\fP for appearance in the filter.
|
||||||
@@ -88,6 +95,9 @@ check \fBword\fP for appearance in the filter.
|
|||||||
.B -C \fIdictfile\fP
|
.B -C \fIdictfile\fP
|
||||||
check every word from \fIdictfile\fP for appearance in the filter.
|
check every word from \fIdictfile\fP for appearance in the filter.
|
||||||
.TP
|
.TP
|
||||||
|
.B -q
|
||||||
|
quiet mode.
|
||||||
|
.TP
|
||||||
.B -v
|
.B -v
|
||||||
print version information.
|
print version information.
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
131
doc/man/apgd.8
131
doc/man/apgd.8
@@ -2,16 +2,16 @@
|
|||||||
.\" Licensed under BSD-like License.
|
.\" Licensed under BSD-like License.
|
||||||
.\" Created by Adel I. Mirzazhanov
|
.\" Created by Adel I. Mirzazhanov
|
||||||
.\"
|
.\"
|
||||||
.TH APGD 8 "2001 Mar 18" "Automated Password Generator" "User Manual"
|
.TH APGD 8 "2002 Jun 11" "Automated Password Generator" "User Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
apgd
|
apgd
|
||||||
\- server that generates several random passwords
|
\- server that generates several random passwords
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B apgd
|
.B apgd
|
||||||
|
[\fB-a algorithm\fP] [\fB-M mode\fP] [\fB-E char_string\fP]
|
||||||
|
[\fB-n num_of_pass\fP] [\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP]
|
||||||
[\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP]
|
[\fB-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]
|
|
||||||
.PP
|
.PP
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B apgd
|
.B apgd
|
||||||
@@ -65,6 +65,8 @@ or
|
|||||||
.B RFC1750
|
.B RFC1750
|
||||||
with exception that it uses
|
with exception that it uses
|
||||||
.I CAST
|
.I CAST
|
||||||
|
or
|
||||||
|
.I SHA-1
|
||||||
instead of
|
instead of
|
||||||
.I Triple DES.
|
.I Triple DES.
|
||||||
It uses local time with precision of microseconds (see
|
It uses local time with precision of microseconds (see
|
||||||
@@ -76,15 +78,20 @@ 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 option
|
||||||
.B -r
|
.B -r
|
||||||
.I dictfile
|
.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
|
(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
|
common words, etc. You even can use one of the dictionaries that come with
|
||||||
.I dictionary password crackers.
|
.I dictionary password crackers.
|
||||||
This check is case sensitive. For example, if you want to reject word 'root',
|
Bloom filter file should be created with \fBapgbfm\fP(1) utility included
|
||||||
you should insert in \fIdictfile\fP words: root, Root, RoOt, ... , ROOT.
|
in apg distribution. These checks are case sensitive. For example, if you
|
||||||
It is not the easiest way to check password quality, but
|
want to reject word 'root', you should insert in \fIdictfile\fP words: root,
|
||||||
it is the most powerful way. In future releases I plan to implement some other
|
Root, RoOt, ... , ROOT. It is not the easiest way to check password quality,
|
||||||
techniques to check passwords just to make life easier.
|
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
|
.PP
|
||||||
.B apgd
|
.B apgd
|
||||||
has the ability log user password generation activity and internal debug information. It does this
|
has the ability log user password generation activity and internal debug information. It does this
|
||||||
@@ -112,64 +119,56 @@ See the \fBsyslogd\fP(8) and \fBsyslog.conf\fP(5) man pages for information on h
|
|||||||
.TP
|
.TP
|
||||||
.B -M mode
|
.B -M mode
|
||||||
Use symbolsets specified with \fBmode\fP for password generation.
|
Use symbolsets specified with \fBmode\fP for password generation.
|
||||||
\fBmode\fP is a text string consisting of characters \fBS[s]\fP, \fBN[n]\fP,
|
\fBmode\fP is a text string consisting of characters \fBS\fP, \fBs\fP, \fBN\fP, \fBn\fP,
|
||||||
\fBC[c]\fP, \fBL[l]\fP,\fBR[r]\fP. Where:
|
\fBC\fP, \fBc\fP, \fBL\fP, \fBl\fP. Where:
|
||||||
.RS
|
.RS
|
||||||
.TP
|
.TP
|
||||||
.B S[s]
|
.B S
|
||||||
use special symbol set (for random character password generation algorithm only).
|
generator \fBmust\fP use special symbol set for every generated password.
|
||||||
.TP
|
.TP
|
||||||
.B N[n]
|
.B s
|
||||||
use numeral symbol set.
|
generator \fBshould\fP use special symbol set for password generation.
|
||||||
.TP
|
.TP
|
||||||
.B C[c]
|
.B N
|
||||||
use capital symbol set.
|
generator \fBmust\fP use numeral symbol set for every generated password.
|
||||||
.TP
|
.TP
|
||||||
.B L[l]
|
.B n
|
||||||
use small letters symbol set (always present if pronounceable password
|
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).
|
generation algorithm is used).
|
||||||
.TP
|
.TP
|
||||||
.B R[r]
|
.B l
|
||||||
the same as \fBS[s]\fP but it does not generate symbols \fB`\fP, \fB'\fP,
|
generator \fBshould\fP use small letters symbol set for password generation.
|
||||||
\fB"\fP, \fB|\fP, \fB$\fP, \fBbackslash\fP, \fB?\fP. Useful for password generation in
|
.TP
|
||||||
a shell script. (For random character password generation algorithm only).
|
.B R,r
|
||||||
|
not supported any more. Use \fB-E char_string\fP option instead.
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.br
|
.br
|
||||||
\fBmode\fP can not be more then 5 characters in
|
\fBmode\fP can not be more than 4 characters in
|
||||||
length.
|
length.
|
||||||
.PP
|
.PP
|
||||||
|
.B Note:
|
||||||
|
.br
|
||||||
|
Usage of L, M, N, C will slow down password generation process.
|
||||||
|
.PP
|
||||||
.B Examples:
|
.B Examples:
|
||||||
.br
|
.br
|
||||||
\fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP
|
\fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP
|
||||||
.PP
|
.PP
|
||||||
\fB-M mode\fP is the new style password generation mode definition, but the old style
|
\fB-M mode\fP is the new style password generation mode definition. Old style
|
||||||
options(-C, -N, -S, -L, -R) are also supported.
|
options(-C, -N, -S, -L, -R) are not supported any more.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.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
|
.B -a algorithm
|
||||||
use
|
use
|
||||||
.B algorithm
|
.B algorithm
|
||||||
@@ -182,6 +181,36 @@ for password generation.
|
|||||||
- random character password generation
|
- random character password generation
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.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
|
.B -r \fIdictfile\fP
|
||||||
check generated passwords for their appearance in
|
check generated passwords for their appearance in
|
||||||
.B dictfile
|
.B dictfile
|
||||||
@@ -208,9 +237,7 @@ generate password with maximum length
|
|||||||
If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP.
|
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 8.
|
||||||
.SH "DEFAULT OPTIONS"
|
.SH "DEFAULT OPTIONS"
|
||||||
\fBapgd -a 0 -N -C -L -n 6 -m 6 -x 8\fP (old style)
|
\fBapgd -a 0 -M ncl -n 6 -x 8 -m 6\fP (new style)
|
||||||
.br
|
|
||||||
\fBapgd -a 0 -M NCL -n 6 -x 8 -m 6\fP (new style)
|
|
||||||
.SH "EXIT CODE"
|
.SH "EXIT CODE"
|
||||||
On successful completion of its task,
|
On successful completion of its task,
|
||||||
.B apgd
|
.B apgd
|
||||||
|
|||||||
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
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "errs.h"
|
#include "errs.h"
|
||||||
|
|
||||||
#ifdef CLISERV
|
#ifdef CLISERV
|
||||||
@@ -37,7 +38,14 @@
|
|||||||
#endif
|
#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
|
void
|
||||||
err_sys(const char *string)
|
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
|
void
|
||||||
err_sys_fatal(const char *string)
|
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
|
void
|
||||||
err_app(const char *string, const char * err)
|
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
|
void
|
||||||
err_app_fatal(const char *string, const char *err)
|
err_app_fatal(const char *string, const char *err)
|
||||||
|
|||||||
2
errs.h
2
errs.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
94
getopt.c
Normal file
94
getopt.c
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Modified by Adel I. Mirzazhanov 2002
|
||||||
|
* 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
|
||||||
|
** 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 */
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
#ifndef OWN_TYPES_H
|
#ifndef OWN_TYPES_H
|
||||||
#define OWN_TYPES_H 1
|
#define OWN_TYPES_H 1
|
||||||
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
typedef unsigned short USHORT;
|
typedef unsigned short USHORT;
|
||||||
typedef short int SHORT;
|
typedef short int SHORT;
|
||||||
@@ -40,4 +39,6 @@ typedef unsigned long int UINT32;
|
|||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
|
#define APG_MAX_PASSWORD_LENGTH 255
|
||||||
|
|
||||||
#endif /* OWN_TYPES_H */
|
#endif /* 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/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";
|
||||||
|
?>
|
||||||
341
pronpass.c
341
pronpass.c
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -89,7 +89,7 @@ static struct unit rules[] =
|
|||||||
|
|
||||||
static int digram[][RULE_SIZE] =
|
static int digram[][RULE_SIZE] =
|
||||||
{
|
{
|
||||||
/* aa */ ILLEGAL_PAIR,
|
{/* aa */ ILLEGAL_PAIR,
|
||||||
/* ab */ ANY_COMBINATION,
|
/* ab */ ANY_COMBINATION,
|
||||||
/* ac */ ANY_COMBINATION,
|
/* ac */ ANY_COMBINATION,
|
||||||
/* ad */ ANY_COMBINATION,
|
/* ad */ ANY_COMBINATION,
|
||||||
@@ -122,8 +122,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* ath */ ANY_COMBINATION,
|
/* ath */ ANY_COMBINATION,
|
||||||
/* awh */ ILLEGAL_PAIR,
|
/* awh */ ILLEGAL_PAIR,
|
||||||
/* aqu */ BREAK | NOT_END,
|
/* aqu */ BREAK | NOT_END,
|
||||||
/* ack */ ANY_COMBINATION,
|
/* ack */ ANY_COMBINATION},
|
||||||
/* ba */ ANY_COMBINATION,
|
{/* ba */ ANY_COMBINATION,
|
||||||
/* bb */ NOT_BEGIN | BREAK | NOT_END,
|
/* bb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* bc */ NOT_BEGIN | BREAK | NOT_END,
|
/* bc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* bd */ NOT_BEGIN | BREAK | NOT_END,
|
/* bd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -156,8 +156,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* bth */ NOT_BEGIN | BREAK | NOT_END,
|
/* bth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* bwh */ ILLEGAL_PAIR,
|
/* bwh */ ILLEGAL_PAIR,
|
||||||
/* bqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* bqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* bck */ ILLEGAL_PAIR,
|
/* bck */ ILLEGAL_PAIR },
|
||||||
/* ca */ ANY_COMBINATION,
|
{/* ca */ ANY_COMBINATION,
|
||||||
/* cb */ NOT_BEGIN | BREAK | NOT_END,
|
/* cb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* cc */ NOT_BEGIN | BREAK | NOT_END,
|
/* cc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* cd */ NOT_BEGIN | BREAK | NOT_END,
|
/* cd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -190,8 +190,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* cth */ NOT_BEGIN | BREAK | NOT_END,
|
/* cth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* cwh */ ILLEGAL_PAIR,
|
/* cwh */ ILLEGAL_PAIR,
|
||||||
/* cqu */ NOT_BEGIN | SUFFIX | NOT_END,
|
/* cqu */ NOT_BEGIN | SUFFIX | NOT_END,
|
||||||
/* cck */ ILLEGAL_PAIR,
|
/* cck */ ILLEGAL_PAIR},
|
||||||
/* da */ ANY_COMBINATION,
|
{/* da */ ANY_COMBINATION,
|
||||||
/* db */ NOT_BEGIN | BREAK | NOT_END,
|
/* db */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* dc */ NOT_BEGIN | BREAK | NOT_END,
|
/* dc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* dd */ NOT_BEGIN,
|
/* dd */ NOT_BEGIN,
|
||||||
@@ -224,8 +224,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* dth */ NOT_BEGIN | PREFIX,
|
/* dth */ NOT_BEGIN | PREFIX,
|
||||||
/* dwh */ ILLEGAL_PAIR,
|
/* dwh */ ILLEGAL_PAIR,
|
||||||
/* dqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* dqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* dck */ ILLEGAL_PAIR,
|
/* dck */ ILLEGAL_PAIR },
|
||||||
/* ea */ ANY_COMBINATION,
|
{/* ea */ ANY_COMBINATION,
|
||||||
/* eb */ ANY_COMBINATION,
|
/* eb */ ANY_COMBINATION,
|
||||||
/* ec */ ANY_COMBINATION,
|
/* ec */ ANY_COMBINATION,
|
||||||
/* ed */ ANY_COMBINATION,
|
/* ed */ ANY_COMBINATION,
|
||||||
@@ -258,8 +258,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* eth */ ANY_COMBINATION,
|
/* eth */ ANY_COMBINATION,
|
||||||
/* ewh */ ILLEGAL_PAIR,
|
/* ewh */ ILLEGAL_PAIR,
|
||||||
/* equ */ BREAK | NOT_END,
|
/* equ */ BREAK | NOT_END,
|
||||||
/* eck */ ANY_COMBINATION,
|
/* eck */ ANY_COMBINATION },
|
||||||
/* fa */ ANY_COMBINATION,
|
{/* fa */ ANY_COMBINATION,
|
||||||
/* fb */ NOT_BEGIN | BREAK | NOT_END,
|
/* fb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* fc */ NOT_BEGIN | BREAK | NOT_END,
|
/* fc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* fd */ NOT_BEGIN | BREAK | NOT_END,
|
/* fd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -292,8 +292,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* fth */ NOT_BEGIN | BREAK | NOT_END,
|
/* fth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* fwh */ ILLEGAL_PAIR,
|
/* fwh */ ILLEGAL_PAIR,
|
||||||
/* fqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* fqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* fck */ ILLEGAL_PAIR,
|
/* fck */ ILLEGAL_PAIR },
|
||||||
/* ga */ ANY_COMBINATION,
|
{/* ga */ ANY_COMBINATION,
|
||||||
/* gb */ NOT_BEGIN | BREAK | NOT_END,
|
/* gb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* gc */ NOT_BEGIN | BREAK | NOT_END,
|
/* gc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* gd */ NOT_BEGIN | BREAK | NOT_END,
|
/* gd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -326,8 +326,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* gth */ NOT_BEGIN,
|
/* gth */ NOT_BEGIN,
|
||||||
/* gwh */ ILLEGAL_PAIR,
|
/* gwh */ ILLEGAL_PAIR,
|
||||||
/* gqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* gqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* gck */ ILLEGAL_PAIR,
|
/* gck */ ILLEGAL_PAIR },
|
||||||
/* ha */ ANY_COMBINATION,
|
{/* ha */ ANY_COMBINATION,
|
||||||
/* hb */ NOT_BEGIN | BREAK | NOT_END,
|
/* hb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* hc */ NOT_BEGIN | BREAK | NOT_END,
|
/* hc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* hd */ NOT_BEGIN | BREAK | NOT_END,
|
/* hd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -360,8 +360,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* hth */ NOT_BEGIN | BREAK | NOT_END,
|
/* hth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* hwh */ ILLEGAL_PAIR,
|
/* hwh */ ILLEGAL_PAIR,
|
||||||
/* hqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* hqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* hck */ ILLEGAL_PAIR,
|
/* hck */ ILLEGAL_PAIR },
|
||||||
/* ia */ ANY_COMBINATION,
|
{/* ia */ ANY_COMBINATION,
|
||||||
/* ib */ ANY_COMBINATION,
|
/* ib */ ANY_COMBINATION,
|
||||||
/* ic */ ANY_COMBINATION,
|
/* ic */ ANY_COMBINATION,
|
||||||
/* id */ ANY_COMBINATION,
|
/* id */ ANY_COMBINATION,
|
||||||
@@ -394,8 +394,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* ith */ ANY_COMBINATION,
|
/* ith */ ANY_COMBINATION,
|
||||||
/* iwh */ ILLEGAL_PAIR,
|
/* iwh */ ILLEGAL_PAIR,
|
||||||
/* iqu */ BREAK | NOT_END,
|
/* iqu */ BREAK | NOT_END,
|
||||||
/* ick */ ANY_COMBINATION,
|
/* ick */ ANY_COMBINATION },
|
||||||
/* ja */ ANY_COMBINATION,
|
{/* ja */ ANY_COMBINATION,
|
||||||
/* jb */ NOT_BEGIN | BREAK | NOT_END,
|
/* jb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* jc */ NOT_BEGIN | BREAK | NOT_END,
|
/* jc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* jd */ NOT_BEGIN | BREAK | NOT_END,
|
/* jd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -428,8 +428,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* jth */ NOT_BEGIN | BREAK | NOT_END,
|
/* jth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* jwh */ ILLEGAL_PAIR,
|
/* jwh */ ILLEGAL_PAIR,
|
||||||
/* jqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* jqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* jck */ ILLEGAL_PAIR,
|
/* jck */ ILLEGAL_PAIR },
|
||||||
/* ka */ ANY_COMBINATION,
|
{/* ka */ ANY_COMBINATION,
|
||||||
/* kb */ NOT_BEGIN | BREAK | NOT_END,
|
/* kb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* kc */ NOT_BEGIN | BREAK | NOT_END,
|
/* kc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* kd */ NOT_BEGIN | BREAK | NOT_END,
|
/* kd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -462,8 +462,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* kth */ NOT_BEGIN | BREAK | NOT_END,
|
/* kth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* kwh */ ILLEGAL_PAIR,
|
/* kwh */ ILLEGAL_PAIR,
|
||||||
/* kqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* kqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* kck */ ILLEGAL_PAIR,
|
/* kck */ ILLEGAL_PAIR },
|
||||||
/* la */ ANY_COMBINATION,
|
{/* la */ ANY_COMBINATION,
|
||||||
/* lb */ NOT_BEGIN | PREFIX,
|
/* lb */ NOT_BEGIN | PREFIX,
|
||||||
/* lc */ NOT_BEGIN | BREAK | NOT_END,
|
/* lc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ld */ NOT_BEGIN | PREFIX,
|
/* ld */ NOT_BEGIN | PREFIX,
|
||||||
@@ -496,8 +496,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* lth */ NOT_BEGIN | PREFIX,
|
/* lth */ NOT_BEGIN | PREFIX,
|
||||||
/* lwh */ ILLEGAL_PAIR,
|
/* lwh */ ILLEGAL_PAIR,
|
||||||
/* lqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* lqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* lck */ ILLEGAL_PAIR,
|
/* lck */ ILLEGAL_PAIR },
|
||||||
/* ma */ ANY_COMBINATION,
|
{/* ma */ ANY_COMBINATION,
|
||||||
/* mb */ NOT_BEGIN | BREAK | NOT_END,
|
/* mb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* mc */ NOT_BEGIN | BREAK | NOT_END,
|
/* mc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* md */ NOT_BEGIN | BREAK | NOT_END,
|
/* md */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -530,8 +530,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* mth */ NOT_BEGIN,
|
/* mth */ NOT_BEGIN,
|
||||||
/* mwh */ ILLEGAL_PAIR,
|
/* mwh */ ILLEGAL_PAIR,
|
||||||
/* mqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* mqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* mck */ ILLEGAL_PAIR,
|
/* mck */ ILLEGAL_PAIR },
|
||||||
/* na */ ANY_COMBINATION,
|
{/* na */ ANY_COMBINATION,
|
||||||
/* nb */ NOT_BEGIN | BREAK | NOT_END,
|
/* nb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* nc */ NOT_BEGIN | BREAK | NOT_END,
|
/* nc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* nd */ NOT_BEGIN,
|
/* nd */ NOT_BEGIN,
|
||||||
@@ -564,8 +564,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* nth */ NOT_BEGIN,
|
/* nth */ NOT_BEGIN,
|
||||||
/* nwh */ ILLEGAL_PAIR,
|
/* nwh */ ILLEGAL_PAIR,
|
||||||
/* nqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* nqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* nck */ NOT_BEGIN | PREFIX,
|
/* nck */ NOT_BEGIN | PREFIX },
|
||||||
/* oa */ ANY_COMBINATION,
|
{/* oa */ ANY_COMBINATION,
|
||||||
/* ob */ ANY_COMBINATION,
|
/* ob */ ANY_COMBINATION,
|
||||||
/* oc */ ANY_COMBINATION,
|
/* oc */ ANY_COMBINATION,
|
||||||
/* od */ ANY_COMBINATION,
|
/* od */ ANY_COMBINATION,
|
||||||
@@ -598,8 +598,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* oth */ ANY_COMBINATION,
|
/* oth */ ANY_COMBINATION,
|
||||||
/* owh */ ILLEGAL_PAIR,
|
/* owh */ ILLEGAL_PAIR,
|
||||||
/* oqu */ BREAK | NOT_END,
|
/* oqu */ BREAK | NOT_END,
|
||||||
/* ock */ ANY_COMBINATION,
|
/* ock */ ANY_COMBINATION },
|
||||||
/* pa */ ANY_COMBINATION,
|
{/* pa */ ANY_COMBINATION,
|
||||||
/* pb */ NOT_BEGIN | BREAK | NOT_END,
|
/* pb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* pc */ NOT_BEGIN | BREAK | NOT_END,
|
/* pc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* pd */ NOT_BEGIN | BREAK | NOT_END,
|
/* pd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -632,8 +632,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* pth */ NOT_BEGIN | BREAK | NOT_END,
|
/* pth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* pwh */ ILLEGAL_PAIR,
|
/* pwh */ ILLEGAL_PAIR,
|
||||||
/* pqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* pqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* pck */ ILLEGAL_PAIR,
|
/* pck */ ILLEGAL_PAIR },
|
||||||
/* ra */ ANY_COMBINATION,
|
{/* ra */ ANY_COMBINATION,
|
||||||
/* rb */ NOT_BEGIN | PREFIX,
|
/* rb */ NOT_BEGIN | PREFIX,
|
||||||
/* rc */ NOT_BEGIN | PREFIX,
|
/* rc */ NOT_BEGIN | PREFIX,
|
||||||
/* rd */ NOT_BEGIN | PREFIX,
|
/* rd */ NOT_BEGIN | PREFIX,
|
||||||
@@ -666,8 +666,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* rth */ NOT_BEGIN | PREFIX,
|
/* rth */ NOT_BEGIN | PREFIX,
|
||||||
/* rwh */ ILLEGAL_PAIR,
|
/* rwh */ ILLEGAL_PAIR,
|
||||||
/* rqu */ NOT_BEGIN | PREFIX | NOT_END,
|
/* rqu */ NOT_BEGIN | PREFIX | NOT_END,
|
||||||
/* rck */ NOT_BEGIN | PREFIX,
|
/* rck */ NOT_BEGIN | PREFIX },
|
||||||
/* sa */ ANY_COMBINATION,
|
{/* sa */ ANY_COMBINATION,
|
||||||
/* sb */ NOT_BEGIN | BREAK | NOT_END,
|
/* sb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* sc */ NOT_END,
|
/* sc */ NOT_END,
|
||||||
/* sd */ NOT_BEGIN | BREAK | NOT_END,
|
/* sd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -700,8 +700,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* sth */ NOT_BEGIN | BREAK | NOT_END,
|
/* sth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* swh */ ILLEGAL_PAIR,
|
/* swh */ ILLEGAL_PAIR,
|
||||||
/* squ */ SUFFIX | NOT_END,
|
/* squ */ SUFFIX | NOT_END,
|
||||||
/* sck */ NOT_BEGIN,
|
/* sck */ NOT_BEGIN },
|
||||||
/* ta */ ANY_COMBINATION,
|
{/* ta */ ANY_COMBINATION,
|
||||||
/* tb */ NOT_BEGIN | BREAK | NOT_END,
|
/* tb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* tc */ NOT_BEGIN | BREAK | NOT_END,
|
/* tc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* td */ NOT_BEGIN | BREAK | NOT_END,
|
/* td */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -734,8 +734,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* tth */ NOT_BEGIN | BREAK | NOT_END,
|
/* tth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* twh */ ILLEGAL_PAIR,
|
/* twh */ ILLEGAL_PAIR,
|
||||||
/* tqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* tqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* tck */ ILLEGAL_PAIR,
|
/* tck */ ILLEGAL_PAIR },
|
||||||
/* ua */ NOT_BEGIN | BREAK | NOT_END,
|
{/* ua */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ub */ ANY_COMBINATION,
|
/* ub */ ANY_COMBINATION,
|
||||||
/* uc */ ANY_COMBINATION,
|
/* uc */ ANY_COMBINATION,
|
||||||
/* ud */ ANY_COMBINATION,
|
/* ud */ ANY_COMBINATION,
|
||||||
@@ -768,8 +768,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* uth */ ANY_COMBINATION,
|
/* uth */ ANY_COMBINATION,
|
||||||
/* uwh */ ILLEGAL_PAIR,
|
/* uwh */ ILLEGAL_PAIR,
|
||||||
/* uqu */ BREAK | NOT_END,
|
/* uqu */ BREAK | NOT_END,
|
||||||
/* uck */ ANY_COMBINATION,
|
/* uck */ ANY_COMBINATION },
|
||||||
/* va */ ANY_COMBINATION,
|
{/* va */ ANY_COMBINATION,
|
||||||
/* vb */ NOT_BEGIN | BREAK | NOT_END,
|
/* vb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* vc */ NOT_BEGIN | BREAK | NOT_END,
|
/* vc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* vd */ NOT_BEGIN | BREAK | NOT_END,
|
/* vd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -802,8 +802,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* vth */ NOT_BEGIN | BREAK | NOT_END,
|
/* vth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* vwh */ ILLEGAL_PAIR,
|
/* vwh */ ILLEGAL_PAIR,
|
||||||
/* vqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* vqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* vck */ ILLEGAL_PAIR,
|
/* vck */ ILLEGAL_PAIR },
|
||||||
/* wa */ ANY_COMBINATION,
|
{/* wa */ ANY_COMBINATION,
|
||||||
/* wb */ NOT_BEGIN | PREFIX,
|
/* wb */ NOT_BEGIN | PREFIX,
|
||||||
/* wc */ NOT_BEGIN | BREAK | NOT_END,
|
/* wc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* wd */ NOT_BEGIN | PREFIX | END,
|
/* wd */ NOT_BEGIN | PREFIX | END,
|
||||||
@@ -836,8 +836,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* wth */ NOT_BEGIN,
|
/* wth */ NOT_BEGIN,
|
||||||
/* wwh */ ILLEGAL_PAIR,
|
/* wwh */ ILLEGAL_PAIR,
|
||||||
/* wqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* wqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* wck */ NOT_BEGIN,
|
/* wck */ NOT_BEGIN },
|
||||||
/* xa */ NOT_BEGIN,
|
{/* xa */ NOT_BEGIN,
|
||||||
/* xb */ NOT_BEGIN | BREAK | NOT_END,
|
/* xb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* xc */ NOT_BEGIN | BREAK | NOT_END,
|
/* xc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* xd */ NOT_BEGIN | BREAK | NOT_END,
|
/* xd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -870,8 +870,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* xth */ NOT_BEGIN | BREAK | NOT_END,
|
/* xth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* xwh */ ILLEGAL_PAIR,
|
/* xwh */ ILLEGAL_PAIR,
|
||||||
/* xqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* xqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* xck */ ILLEGAL_PAIR,
|
/* xck */ ILLEGAL_PAIR },
|
||||||
/* ya */ ANY_COMBINATION,
|
{/* ya */ ANY_COMBINATION,
|
||||||
/* yb */ NOT_BEGIN,
|
/* yb */ NOT_BEGIN,
|
||||||
/* yc */ NOT_BEGIN | NOT_END,
|
/* yc */ NOT_BEGIN | NOT_END,
|
||||||
/* yd */ NOT_BEGIN,
|
/* yd */ NOT_BEGIN,
|
||||||
@@ -904,8 +904,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* yth */ NOT_BEGIN | BREAK | NOT_END,
|
/* yth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ywh */ ILLEGAL_PAIR,
|
/* ywh */ ILLEGAL_PAIR,
|
||||||
/* yqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* yqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* yck */ ILLEGAL_PAIR,
|
/* yck */ ILLEGAL_PAIR },
|
||||||
/* za */ ANY_COMBINATION,
|
{/* za */ ANY_COMBINATION,
|
||||||
/* zb */ NOT_BEGIN | BREAK | NOT_END,
|
/* zb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* zc */ NOT_BEGIN | BREAK | NOT_END,
|
/* zc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* zd */ NOT_BEGIN | BREAK | NOT_END,
|
/* zd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -938,8 +938,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* zth */ NOT_BEGIN | BREAK | NOT_END,
|
/* zth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* zwh */ ILLEGAL_PAIR,
|
/* zwh */ ILLEGAL_PAIR,
|
||||||
/* zqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* zqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* zck */ ILLEGAL_PAIR,
|
/* zck */ ILLEGAL_PAIR },
|
||||||
/* cha */ ANY_COMBINATION,
|
{/* cha */ ANY_COMBINATION,
|
||||||
/* chb */ NOT_BEGIN | BREAK | NOT_END,
|
/* chb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* chc */ NOT_BEGIN | BREAK | NOT_END,
|
/* chc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* chd */ NOT_BEGIN | BREAK | NOT_END,
|
/* chd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -972,8 +972,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* chth */ NOT_BEGIN | BREAK | NOT_END,
|
/* chth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* chwh */ ILLEGAL_PAIR,
|
/* chwh */ ILLEGAL_PAIR,
|
||||||
/* chqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* chqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* chck */ ILLEGAL_PAIR,
|
/* chck */ ILLEGAL_PAIR },
|
||||||
/* gha */ ANY_COMBINATION,
|
{/* gha */ ANY_COMBINATION,
|
||||||
/* ghb */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
/* ghb */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||||
/* ghc */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
/* ghc */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||||
/* ghd */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
/* ghd */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||||
@@ -1006,8 +1006,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* ghth */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
/* ghth */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||||
/* ghwh */ ILLEGAL_PAIR,
|
/* ghwh */ ILLEGAL_PAIR,
|
||||||
/* ghqu */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
/* ghqu */ NOT_BEGIN | BREAK | PREFIX | NOT_END,
|
||||||
/* ghck */ ILLEGAL_PAIR,
|
/* ghck */ ILLEGAL_PAIR },
|
||||||
/* pha */ ANY_COMBINATION,
|
{/* pha */ ANY_COMBINATION,
|
||||||
/* phb */ NOT_BEGIN | BREAK | NOT_END,
|
/* phb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* phc */ NOT_BEGIN | BREAK | NOT_END,
|
/* phc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* phd */ NOT_BEGIN | BREAK | NOT_END,
|
/* phd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -1040,8 +1040,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* phth */ NOT_BEGIN | BREAK | NOT_END,
|
/* phth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* phwh */ ILLEGAL_PAIR,
|
/* phwh */ ILLEGAL_PAIR,
|
||||||
/* phqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* phqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* phck */ ILLEGAL_PAIR,
|
/* phck */ ILLEGAL_PAIR },
|
||||||
/* rha */ BEGIN | NOT_END,
|
{/* rha */ BEGIN | NOT_END,
|
||||||
/* rhb */ ILLEGAL_PAIR,
|
/* rhb */ ILLEGAL_PAIR,
|
||||||
/* rhc */ ILLEGAL_PAIR,
|
/* rhc */ ILLEGAL_PAIR,
|
||||||
/* rhd */ ILLEGAL_PAIR,
|
/* rhd */ ILLEGAL_PAIR,
|
||||||
@@ -1074,8 +1074,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* rhth */ ILLEGAL_PAIR,
|
/* rhth */ ILLEGAL_PAIR,
|
||||||
/* rhwh */ ILLEGAL_PAIR,
|
/* rhwh */ ILLEGAL_PAIR,
|
||||||
/* rhqu */ ILLEGAL_PAIR,
|
/* rhqu */ ILLEGAL_PAIR,
|
||||||
/* rhck */ ILLEGAL_PAIR,
|
/* rhck */ ILLEGAL_PAIR },
|
||||||
/* sha */ ANY_COMBINATION,
|
{/* sha */ ANY_COMBINATION,
|
||||||
/* shb */ NOT_BEGIN | BREAK | NOT_END,
|
/* shb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* shc */ NOT_BEGIN | BREAK | NOT_END,
|
/* shc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* shd */ NOT_BEGIN | BREAK | NOT_END,
|
/* shd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -1108,8 +1108,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* shth */ NOT_BEGIN | BREAK | NOT_END,
|
/* shth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* shwh */ ILLEGAL_PAIR,
|
/* shwh */ ILLEGAL_PAIR,
|
||||||
/* shqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* shqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* shck */ ILLEGAL_PAIR,
|
/* shck */ ILLEGAL_PAIR },
|
||||||
/* tha */ ANY_COMBINATION,
|
{/* tha */ ANY_COMBINATION,
|
||||||
/* thb */ NOT_BEGIN | BREAK | NOT_END,
|
/* thb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* thc */ NOT_BEGIN | BREAK | NOT_END,
|
/* thc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* thd */ NOT_BEGIN | BREAK | NOT_END,
|
/* thd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -1142,8 +1142,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* thth */ ILLEGAL_PAIR,
|
/* thth */ ILLEGAL_PAIR,
|
||||||
/* thwh */ ILLEGAL_PAIR,
|
/* thwh */ ILLEGAL_PAIR,
|
||||||
/* thqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* thqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* thck */ ILLEGAL_PAIR,
|
/* thck */ ILLEGAL_PAIR },
|
||||||
/* wha */ BEGIN | NOT_END,
|
{/* wha */ BEGIN | NOT_END,
|
||||||
/* whb */ ILLEGAL_PAIR,
|
/* whb */ ILLEGAL_PAIR,
|
||||||
/* whc */ ILLEGAL_PAIR,
|
/* whc */ ILLEGAL_PAIR,
|
||||||
/* whd */ ILLEGAL_PAIR,
|
/* whd */ ILLEGAL_PAIR,
|
||||||
@@ -1176,8 +1176,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* whth */ ILLEGAL_PAIR,
|
/* whth */ ILLEGAL_PAIR,
|
||||||
/* whwh */ ILLEGAL_PAIR,
|
/* whwh */ ILLEGAL_PAIR,
|
||||||
/* whqu */ ILLEGAL_PAIR,
|
/* whqu */ ILLEGAL_PAIR,
|
||||||
/* whck */ ILLEGAL_PAIR,
|
/* whck */ ILLEGAL_PAIR },
|
||||||
/* qua */ ANY_COMBINATION,
|
{/* qua */ ANY_COMBINATION,
|
||||||
/* qub */ ILLEGAL_PAIR,
|
/* qub */ ILLEGAL_PAIR,
|
||||||
/* quc */ ILLEGAL_PAIR,
|
/* quc */ ILLEGAL_PAIR,
|
||||||
/* qud */ ILLEGAL_PAIR,
|
/* qud */ ILLEGAL_PAIR,
|
||||||
@@ -1210,8 +1210,8 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* quth */ ILLEGAL_PAIR,
|
/* quth */ ILLEGAL_PAIR,
|
||||||
/* quwh */ ILLEGAL_PAIR,
|
/* quwh */ ILLEGAL_PAIR,
|
||||||
/* ququ */ ILLEGAL_PAIR,
|
/* ququ */ ILLEGAL_PAIR,
|
||||||
/* quck */ ILLEGAL_PAIR,
|
/* quck */ ILLEGAL_PAIR },
|
||||||
/* cka */ NOT_BEGIN | BREAK | NOT_END,
|
{/* cka */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ckb */ NOT_BEGIN | BREAK | NOT_END,
|
/* ckb */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ckc */ NOT_BEGIN | BREAK | NOT_END,
|
/* ckc */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ckd */ NOT_BEGIN | BREAK | NOT_END,
|
/* ckd */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
@@ -1244,7 +1244,7 @@ static int digram[][RULE_SIZE] =
|
|||||||
/* ckth */ NOT_BEGIN | BREAK | NOT_END,
|
/* ckth */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ckwh */ ILLEGAL_PAIR,
|
/* ckwh */ ILLEGAL_PAIR,
|
||||||
/* ckqu */ NOT_BEGIN | BREAK | NOT_END,
|
/* ckqu */ NOT_BEGIN | BREAK | NOT_END,
|
||||||
/* ckck */ ILLEGAL_PAIR
|
/* ckck */ ILLEGAL_PAIR}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1273,7 +1273,8 @@ gen_pron_pass (char *word, char *hyphenated_word, USHORT minlen,
|
|||||||
* Check for minlen>maxlen. This is an error.
|
* Check for minlen>maxlen. This is an error.
|
||||||
* and a length of 0.
|
* 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);
|
return (-1);
|
||||||
/*
|
/*
|
||||||
* Check for zero length words. This is technically not an error,
|
* Check for zero length words. This is technically not an error,
|
||||||
@@ -1309,6 +1310,7 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
|||||||
USHORT word_length;
|
USHORT word_length;
|
||||||
USHORT syllable_length;
|
USHORT syllable_length;
|
||||||
char *new_syllable;
|
char *new_syllable;
|
||||||
|
char *syllable_for_hyph;
|
||||||
USHORT *syllable_units;
|
USHORT *syllable_units;
|
||||||
USHORT word_size;
|
USHORT word_size;
|
||||||
USHORT word_place;
|
USHORT word_place;
|
||||||
@@ -1316,6 +1318,7 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
|||||||
USHORT syllable_size;
|
USHORT syllable_size;
|
||||||
UINT tries;
|
UINT tries;
|
||||||
int ch_flag = FALSE;
|
int ch_flag = FALSE;
|
||||||
|
int dsd = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keep count of retries.
|
* Keep count of retries.
|
||||||
@@ -1345,7 +1348,8 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
|||||||
*/
|
*/
|
||||||
if ( (word_units = (USHORT *) calloc (sizeof (USHORT), pwlen+1))==NULL ||
|
if ( (word_units = (USHORT *) calloc (sizeof (USHORT), pwlen+1))==NULL ||
|
||||||
(syllable_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);
|
return(-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1387,18 +1391,33 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
|||||||
** Modify syllable for numeric or capital symbols required
|
** Modify syllable for numeric or capital symbols required
|
||||||
** Should be done after word quality check.
|
** 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);
|
numerize(new_syllable);
|
||||||
ch_flag = TRUE;
|
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))
|
if ( ( (pass_mode & S_CL) > 0) && (ch_flag != TRUE))
|
||||||
capitalize(new_syllable);
|
capitalize(new_syllable);
|
||||||
ch_flag = FALSE;
|
ch_flag = FALSE;
|
||||||
/**/
|
/**/
|
||||||
(void) strcpy (word, new_syllable);
|
(void) strcpy (word, new_syllable);
|
||||||
(void) strcpy (hyphenated_word, new_syllable);
|
if (syllable_length == 1)
|
||||||
bzero ( (void *)new_syllable, (size_t)(pwlen * sizeof(USHORT)+1));
|
{
|
||||||
|
symb2name(new_syllable, syllable_for_hyph);
|
||||||
|
(void) strcpy (hyphenated_word, syllable_for_hyph);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(void) strcpy (hyphenated_word, new_syllable);
|
||||||
|
}
|
||||||
|
(void)memset ( (void *)new_syllable, 0, (size_t)(pwlen * sizeof(USHORT)+1));
|
||||||
|
(void)memset ( (void *)syllable_for_hyph, 0, 20);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1406,19 +1425,34 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
|||||||
** Modify syllable for numeric or capital symbols required
|
** Modify syllable for numeric or capital symbols required
|
||||||
** Should be done after word quality check.
|
** 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);
|
numerize(new_syllable);
|
||||||
ch_flag = TRUE;
|
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))
|
if ( ( (pass_mode & S_CL) > 0) && (ch_flag != TRUE))
|
||||||
capitalize(new_syllable);
|
capitalize(new_syllable);
|
||||||
ch_flag = FALSE;
|
ch_flag = FALSE;
|
||||||
/**/
|
/**/
|
||||||
(void) strcat (word, new_syllable);
|
(void) strcat (word, new_syllable);
|
||||||
(void) strcat (hyphenated_word, "-");
|
(void) strcat (hyphenated_word, "-");
|
||||||
(void) strcat (hyphenated_word, new_syllable);
|
if (syllable_length == 1)
|
||||||
bzero ( (void *)new_syllable, (size_t)(pwlen * sizeof(USHORT)+1));
|
{
|
||||||
|
symb2name(new_syllable, syllable_for_hyph);
|
||||||
|
(void) strcat (hyphenated_word, syllable_for_hyph);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(void) strcat (hyphenated_word, new_syllable);
|
||||||
|
}
|
||||||
|
(void)memset ( (void *)new_syllable, 0, (size_t)(pwlen * sizeof(USHORT)+1));
|
||||||
|
(void)memset ( (void *)syllable_for_hyph, 0, 20);
|
||||||
}
|
}
|
||||||
word_length += syllable_length;
|
word_length += syllable_length;
|
||||||
}
|
}
|
||||||
@@ -1448,6 +1482,7 @@ gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mod
|
|||||||
free ((char *) new_syllable);
|
free ((char *) new_syllable);
|
||||||
free ((char *) syllable_units);
|
free ((char *) syllable_units);
|
||||||
free ((char *) word_units);
|
free ((char *) word_units);
|
||||||
|
free ((char *) syllable_for_hyph);
|
||||||
|
|
||||||
return ((int) word_length);
|
return ((int) word_length);
|
||||||
}
|
}
|
||||||
@@ -2228,11 +2263,19 @@ random_unit (USHORT type)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine should return a uniformly distributed Random number between
|
** get_random() -
|
||||||
* minlen and maxlen inclusive. The Electronic Code Book form of CAST is
|
** This routine should return a uniformly distributed Random number between
|
||||||
* used to produce the Random number. The inputs to CAST are the old pass-
|
** minlen and maxlen inclusive. The Electronic Code Book form of CAST is
|
||||||
* word and a pseudoRandom key generated according to the procedure out-
|
** used to produce the Random number. The inputs to CAST are the old pass-
|
||||||
* lined in Appendix C of ANSI X9.17.
|
** 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
|
USHORT
|
||||||
@@ -2244,10 +2287,16 @@ get_random (USHORT minlen, USHORT maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This routine designed to modify sullable like this:
|
** capitalize() - This routine designed to modify sullable like this:
|
||||||
** adel ----> Adel
|
** adel ----> Adel
|
||||||
** dot ----> Dot
|
** dot ----> Dot
|
||||||
** etc.
|
** etc.
|
||||||
|
** INPUT:
|
||||||
|
** char * - syllable.
|
||||||
|
** OUTPUT:
|
||||||
|
** none.
|
||||||
|
** NOTES:
|
||||||
|
** none.
|
||||||
*/
|
*/
|
||||||
void capitalize (char *syllable)
|
void capitalize (char *syllable)
|
||||||
{
|
{
|
||||||
@@ -2267,27 +2316,141 @@ void capitalize (char *syllable)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
if ( randint(2) == TRUE)
|
if ( randint(2) == TRUE)
|
||||||
{
|
{
|
||||||
bcopy ((void *)syllable, (void *)&tmp, sizeof(tmp));
|
(void)memcpy((void *)&tmp, (void *)syllable, sizeof(tmp));
|
||||||
for(i=0; i < 26; i++)
|
for(i=0; i < 26; i++)
|
||||||
if ( let[i] == tmp ) bcopy ((void *)&clet[i], (void *)syllable, 1);
|
if ( let[i] == tmp )
|
||||||
|
if (is_restricted_symbol(clet[i]) != TRUE)
|
||||||
|
(void)memcpy ((void *)syllable, (void *)&clet[i], 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This routine designed to modify single-letter syllable like this:
|
** numerize() - This routine designed to modify single-letter
|
||||||
|
** syllable like this:
|
||||||
** a ----> 1 or 2 or 3 etc.
|
** a ----> 1 or 2 or 3 etc.
|
||||||
** u ----> 1 or 2 or 3 etc.
|
** u ----> 1 or 2 or 3 etc.
|
||||||
** etc.
|
** etc.
|
||||||
|
** INPUT:
|
||||||
|
** char * - single-letter syllable
|
||||||
|
** OUTPUT:
|
||||||
|
** none.
|
||||||
|
** NOTES:
|
||||||
|
** none.
|
||||||
*/
|
*/
|
||||||
void numerize (char *syllable)
|
void numerize (char *syllable)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
if ( (tmp = (char *)calloc(1, 4)) == NULL)
|
if ( (tmp = (char *)calloc(1, 4)) == NULL)
|
||||||
err_sys_fatal("calloc");
|
err_sys_fatal("calloc");
|
||||||
if ( (randint(2) == TRUE) && (strlen (syllable) == 1) )
|
if ( strlen (syllable) == 1 )
|
||||||
{
|
{
|
||||||
sprintf(tmp, "%d", randint(10));
|
(void) gen_rand_symbol(tmp, S_NB);
|
||||||
bcopy ((void *)tmp, (void *)syllable, 1);
|
(void)memcpy ((void *)syllable, (void *)tmp, 1);
|
||||||
}
|
}
|
||||||
free ((void *)tmp);
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -82,5 +82,8 @@ char *gen_syllable(char *syllable, USHORT pwlen, USHORT *units_in_syllable,
|
|||||||
USHORT *syllable_length);
|
USHORT *syllable_length);
|
||||||
void capitalize (char *syllable);
|
void capitalize (char *syllable);
|
||||||
void numerize (char *syllable);
|
void numerize (char *syllable);
|
||||||
|
void specialize (char *syllable);
|
||||||
|
void r_specialize (char *syllable);
|
||||||
|
void symb2name (char *syllable, char * h_syllable);
|
||||||
|
|
||||||
#endif /* PRONPASS_H */
|
#endif /* PRONPASS_H */
|
||||||
|
|||||||
107
randpass.c
107
randpass.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -37,34 +37,21 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "randpass.h"
|
#include "randpass.h"
|
||||||
|
|
||||||
#include "owntypes.h"
|
#include "owntypes.h"
|
||||||
struct sym
|
#include "smbl.h"
|
||||||
{
|
|
||||||
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}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** gen_rand_pass - generates random password of specified type
|
** 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
|
int
|
||||||
gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode)
|
gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode)
|
||||||
@@ -77,7 +64,8 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
|
|||||||
int max_weight = 0;
|
int max_weight = 0;
|
||||||
int max_weight_element_number = 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);
|
return (-1);
|
||||||
for (i = 0; i <= 93; i++) random_weight[i] = 0;
|
for (i = 0; i <= 93; i++) random_weight[i] = 0;
|
||||||
length = minl + randint(maxl-minl+1);
|
length = minl + randint(maxl-minl+1);
|
||||||
@@ -87,8 +75,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*/
|
/* Asign random weight in weight array if mode is present*/
|
||||||
for (j = 0; j <= 93 ; j++)
|
for (j = 0; j <= 93 ; j++)
|
||||||
/*!!!*/ if ( ((pass_mode & smbl[j].type) > 0) &&
|
if ( ( (pass_mode & smbl[j].type) > 0) &&
|
||||||
!((pass_mode & smbl[j].type) == 0x12))
|
!( (S_RS & smbl[j].type) > 0))
|
||||||
random_weight[j] = 1 + randint(20000);
|
random_weight[j] = 1 + randint(20000);
|
||||||
j = 0;
|
j = 0;
|
||||||
/* Find an element with maximum weight */
|
/* Find an element with maximum weight */
|
||||||
@@ -108,3 +96,66 @@ gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode
|
|||||||
*str_pointer = 0;
|
*str_pointer = 0;
|
||||||
return (length);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
17
randpass.h
17
randpass.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -37,13 +37,26 @@
|
|||||||
#include "rnd.h"
|
#include "rnd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef OWNTYPES_H
|
||||||
|
#include "owntypes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define S_NB 0x01 /* Numeric */
|
#define S_NB 0x01 /* Numeric */
|
||||||
#define S_SS 0x02 /* Special */
|
#define S_SS 0x02 /* Special */
|
||||||
#define S_CL 0x04 /* Capital */
|
#define S_CL 0x04 /* Capital */
|
||||||
#define S_SL 0x08 /* Small */
|
#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); */
|
/* char gen_symbol(unsigned short int symbol_class); */
|
||||||
extern int gen_rand_pass(char* password_string, int minl,
|
extern int gen_rand_pass(char* password_string, int minl,
|
||||||
int maxl, unsigned int pass_mode);
|
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 */
|
#endif /* RANDPASS_H */
|
||||||
|
|||||||
125
restrict.c
125
restrict.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,12 +34,19 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "restrict.h"
|
#include "restrict.h"
|
||||||
|
extern struct sym smbl[94];
|
||||||
/*
|
/*
|
||||||
** Routine that checks if password exist in dictionary
|
** check_pass() - routine that checks if password exist in dictionary
|
||||||
** RETURN -1 - error
|
** INPUT:
|
||||||
** 1 - password exist in dictionary
|
** char * - password to check.
|
||||||
** 0 - password does not exist in dictionary
|
** char * - dictionary filename.
|
||||||
|
** OUTPUT:
|
||||||
|
** int
|
||||||
|
** -1 - error
|
||||||
|
** 1 - password exist in dictionary
|
||||||
|
** 0 - password does not exist in dictionary
|
||||||
|
** NOTES:
|
||||||
|
** none.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
check_pass(char *pass, char *dict)
|
check_pass(char *pass, char *dict)
|
||||||
@@ -58,20 +65,120 @@ check_pass(char *pass, char *dict)
|
|||||||
{
|
{
|
||||||
string = strtok (string," \t\n\0");
|
string = strtok (string," \t\n\0");
|
||||||
if(strlen(string) != strlen(pass)) 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);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free ( (void *)string);
|
free ( (void *)string);
|
||||||
fclose (dct);
|
fclose (dct);
|
||||||
return (0);
|
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
|
int
|
||||||
bloom_check_pass (char *word, char *filter)
|
bloom_check_pass (char *word, char *filter)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
FILE *f_filter;
|
FILE *f_filter;
|
||||||
h_val filter_size = 0L;
|
h_val filter_size = 0L;
|
||||||
if ( (f_filter = open_filter(filter)) == NULL)
|
if ( (f_filter = open_filter(filter,"r")) == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
filter_size = get_filtersize(f_filter);
|
filter_size = get_filtersize(f_filter);
|
||||||
return(check_word (word, f_filter, filter_size));
|
ret = check_word (word, f_filter, filter_size);
|
||||||
|
close_filter(f_filter);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** 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;
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,8 +34,11 @@
|
|||||||
#define RESTRICT_H 1
|
#define RESTRICT_H 1
|
||||||
|
|
||||||
#include "bloom.h"
|
#include "bloom.h"
|
||||||
|
#include "randpass.h"
|
||||||
#define MAX_DICT_STRING_SIZE 255
|
#define MAX_DICT_STRING_SIZE 255
|
||||||
extern int check_pass(char * pass, char *dict);
|
int check_pass(char * pass, char *dict);
|
||||||
extern int bloom_check_pass (char *word, char *filter);
|
int bloom_check_pass (char *word, char *filter);
|
||||||
|
int filter_check_pass(const char * word, unsigned int cond);
|
||||||
|
int set_exclude_list(const char * char_string);
|
||||||
|
|
||||||
#endif /* RESTRICT_H */
|
#endif /* RESTRICT_H */
|
||||||
|
|||||||
108
rnd.c
108
rnd.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -29,24 +29,50 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "rnd.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 */
|
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
|
UINT
|
||||||
randint(int n)
|
randint(int n)
|
||||||
{
|
{
|
||||||
|
#ifndef APG_USE_SHA
|
||||||
return ( (UINT)( x917cast_rnd() % (UINT32)n ) );
|
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
|
** ANSI X9.17 pseudorandom generator that uses CAST algorithm instead of DES
|
||||||
** m = 1
|
** m = 1
|
||||||
|
** INPUT:
|
||||||
|
** none.
|
||||||
|
** OUTPUT:
|
||||||
|
** UINT32 - random number.
|
||||||
|
** NOTES:
|
||||||
|
** none.
|
||||||
*/
|
*/
|
||||||
UINT32
|
UINT32
|
||||||
x917cast_rnd (void)
|
x917cast_rnd (void)
|
||||||
@@ -79,16 +105,71 @@ 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 ) */
|
cast_encrypt (&ky, (u8 *)&Xi_plus_I[0], (u8*)&__rnd_seed[0]); /* s=Ek( Xi (+) I ) */
|
||||||
return (Xi[0]);
|
return (Xi[0]);
|
||||||
}
|
}
|
||||||
|
#else /* APG_USE_SHA */
|
||||||
/*
|
/*
|
||||||
** x917cast_setseed (UINT32 seed) - Initializes seed
|
** ANSI X9.17 pseudorandom generator that uses SHA1 algorithm instead of DES
|
||||||
** UINT32 seed - seed value
|
** 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
|
void
|
||||||
x917cast_setseed (UINT32 seed)
|
x917_setseed (UINT32 seed, int quiet)
|
||||||
{
|
{
|
||||||
FILE * dr;
|
FILE * dr;
|
||||||
UINT32 drs[2];
|
UINT32 drs[2];
|
||||||
|
UINT32 pid = 0;
|
||||||
|
|
||||||
|
pid = (UINT32)getpid();
|
||||||
|
|
||||||
if ( (dr = fopen(APG_DEVRANDOM, "r")) != NULL)
|
if ( (dr = fopen(APG_DEVRANDOM, "r")) != NULL)
|
||||||
{
|
{
|
||||||
@@ -107,11 +188,14 @@ x917cast_setseed (UINT32 seed)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef CLISERV
|
#ifndef CLISERV
|
||||||
fprintf(stderr,"CAN NOT USE /dev/random TO GENERATE RANDOM SEED\n");
|
if (quiet != TRUE)
|
||||||
fprintf(stderr,"USEING LOCAL TIME FOR SEED GENERATION !!!\n");
|
{
|
||||||
fflush(stderr);
|
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 /* CLISERV */
|
#endif /* CLISERV */
|
||||||
__rnd_seed[0] = seed;
|
__rnd_seed[0] = seed ^ pid;
|
||||||
__rnd_seed[1] = seed;
|
__rnd_seed[1] = seed ^ pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
rnd.h
12
rnd.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1999, 2000, 2001
|
** Copyright (c) 1999, 2000, 2001, 2002
|
||||||
** Adel I. Mirzazhanov. All rights reserved
|
** Adel I. Mirzazhanov. All rights reserved
|
||||||
**
|
**
|
||||||
** Redistribution and use in source and binary forms, with or without
|
** Redistribution and use in source and binary forms, with or without
|
||||||
@@ -37,11 +37,19 @@
|
|||||||
extern UINT32 __rnd_seed[2];
|
extern UINT32 __rnd_seed[2];
|
||||||
|
|
||||||
#define RND_MX 0x7FFFFFFF
|
#define RND_MX 0x7FFFFFFF
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
#define APG_DEVRANDOM "/dev/arandom"
|
||||||
|
#else
|
||||||
#define APG_DEVRANDOM "/dev/random"
|
#define APG_DEVRANDOM "/dev/random"
|
||||||
|
#endif /* __OpenBSD__ */
|
||||||
#define APG_DEVURANDOM "/dev/urandom"
|
#define APG_DEVURANDOM "/dev/urandom"
|
||||||
|
|
||||||
extern void x917cast_setseed (UINT32 seed);
|
extern void x917_setseed (UINT32 seed, int quiet);
|
||||||
extern UINT randint (int n);
|
extern UINT randint (int n);
|
||||||
|
#ifndef APG_USE_SHA
|
||||||
UINT32 x917cast_rnd (void);
|
UINT32 x917cast_rnd (void);
|
||||||
|
#else /* APG_USE_SHA */
|
||||||
|
UINT32 x917sha1_rnd (void);
|
||||||
|
#endif /* APG_USE_SHA*/
|
||||||
|
|
||||||
#endif /* RND_H */
|
#endif /* 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
|
||||||
|
** 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}, {'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}, {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