apg-2.2.3.dfsg.1/0000755000175100017510000000000010515125071011137 5ustar mhmhapg-2.2.3.dfsg.1/apgbfm.c0000644000175100017510000002752107730403201012545 0ustar mhmh/* ** Copyright (c) 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include "bloom.h" #include "errs.h" #include "getopt.h" #define VERSION "2.2.3" #define FOUND "FOUND" #define NOT_FOUND "NOT FOUND" /* #define FOUND "YES" #define NOT_FOUND "NO" */ int main (int argc, char *argv[]); void print_help(void); void checkopt(char *opt); void print_filter_info(char * filter); int main (int argc, char *argv[]) { int option = 0; char *dictfile; /* dictionary filename */ FILE *f_dictfile; /* dictionary file descriptor */ char *filter; /* filter file name */ FILE *f_filter; /* filter file descriptor */ char *word; /* word to add or check */ char *tmp; /* just tmp char pointer */ h_val wc = 0L; /* amount of words to build dictionaty */ h_val filter_size =0L; /* filter size in bits */ int dummy_test = 0; /* variable to make dummy test for */ /* options correctness */ h_val i = 0L; /* counter */ f_mode flt_mode = 0x00; /* filter mode */ /* flags */ flag add_word_flag = FALSE; /* -a */ flag add_file_flag = FALSE; /* -A */ flag check_word_flag = FALSE; /* -c */ flag check_file_flag = FALSE; /* -C */ flag new_flag = FALSE; /* -n */ flag new_from_dict_flag = FALSE; /* -d */ flag filter_flag = FALSE; /* -f */ flag silent_flag = FALSE; /* -q */ flag case_insensitive_flag = FALSE; /* -q */ /* end of flags section */ /* Analize options */ if (argc < 2) { print_help(); exit(-1); } while ((option = apg_getopt (argc, argv, "a:A:c:C:n:d:f:i:hvqs")) != -1) { switch(option) { case 'a': word = apg_optarg; add_word_flag = TRUE; dummy_test = dummy_test + 2; break; case 'A': dictfile = apg_optarg; add_file_flag = TRUE; dummy_test = dummy_test + 2; break; case 'c': word = apg_optarg; check_word_flag = TRUE; dummy_test = dummy_test + 2; break; case 'C': dictfile = apg_optarg; check_file_flag = TRUE; dummy_test = dummy_test + 2; break; case 'n': checkopt(apg_optarg); wc = atoi(apg_optarg); new_flag = TRUE; dummy_test = dummy_test + 2; break; case 'd': dictfile = apg_optarg; new_from_dict_flag = TRUE; dummy_test = dummy_test + 2; break; case 'f': filter = apg_optarg; filter_flag = TRUE; dummy_test = dummy_test + 1; break; case 'h': print_help(); return (0); case 'v': printf ("APG Bloom filter management programm"); printf ("\nversion %s", VERSION); printf ("\nCopyright (c) 2001, 2002, 2003 Adel I. Mirzazhanov\n"); return (0); case 'i': print_filter_info(apg_optarg); return (0); case 'q': silent_flag = TRUE; break; case 's': flt_mode = flt_mode | BF_CASE_INSENSITIVE; case_insensitive_flag = TRUE; break; default: print_help(); exit(-1); } } if (filter_flag != TRUE) err_app_fatal ("apg", "-f option is required"); if (dummy_test != 3) err_app_fatal ("apg", "too many options"); /* Main part */ /* At this point we can be sure that all options a correct */ if (add_word_flag == TRUE) /* -a word */ { if ( (f_filter = open_filter(filter, "r+")) == NULL) err_sys_fatal("open_filter"); filter_size = get_filtersize(f_filter); flt_mode = get_filtermode(f_filter); if (filter_size == 0) err_sys_fatal("get_filtersize"); if ( insert_word (word, f_filter, filter_size, flt_mode) == -1) err_sys_fatal("insert_word"); if (silent_flag != TRUE) printf ("Word %s added\n",word); return (0); } if (add_file_flag == TRUE) /* -A dictfile */ { word = (char *) calloc(1,MAX_DICT_STRLEN); if ( (f_dictfile = fopen(dictfile,"r")) == NULL) err_sys_fatal("fopen"); if( (f_filter = open_filter(filter,"r+")) == NULL) err_sys_fatal("open_filter"); filter_size = get_filtersize(f_filter); flt_mode = get_filtermode(f_filter); if (filter_size == 0) err_sys_fatal("get_filtersize"); while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL)) { tmp = (char *)strtok (word," \t\n\0"); if( tmp != NULL) word = tmp; else continue; if ( insert_word (word, f_filter, filter_size, flt_mode) == -1) err_sys_fatal("insert_word"); i++; if (silent_flag != TRUE) { if ( i % 100 == 0) { fprintf (stdout,"."); fflush (stdout); } } (void)memset((void *)word, 0, MAX_DICT_STRLEN); } if (silent_flag != TRUE) printf ("\n"); free ( (void *)word); fclose (f_dictfile); close_filter (f_filter); return (0); } if (check_word_flag == TRUE) /* -c word */ { if ( (f_filter = open_filter(filter, "r")) == NULL) err_sys_fatal("open_filter"); filter_size = get_filtersize(f_filter); flt_mode = get_filtermode(f_filter); if (filter_size == 0) err_sys_fatal("get_filtersize"); switch(check_word (word, f_filter, filter_size, flt_mode)) { case -1: err_sys_fatal("check_word"); break; case 1: printf ("%s: %s \n",word, FOUND); break; case 0: printf ("%s: %s\n",word, NOT_FOUND); break; } return (0); } if (check_file_flag == TRUE) /* -C dictfile */ { word = (char *) calloc(1,MAX_DICT_STRLEN); if ( (f_dictfile = fopen(dictfile,"r")) == NULL) err_sys_fatal("fopen"); wc = count_words (f_dictfile); if (wc == 0) err_sys_fatal("count_words"); if( (f_filter = open_filter(filter, "r")) == NULL) err_sys_fatal("open_filter"); filter_size = get_filtersize(f_filter); flt_mode = get_filtermode(f_filter); if (filter_size == 0) err_sys_fatal("get_filtersize"); while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL)) { tmp = (char *)strtok (word," \t\n\0"); if( tmp != NULL) word = tmp; else continue; switch(check_word (word, f_filter, filter_size, flt_mode)) { case -1: err_sys_fatal("check_word"); break; case 1: printf ("%s: %s\n",word, FOUND); break; case 0: printf ("%s: %s\n",word, NOT_FOUND); break; } (void)memset((void *)word, 0, MAX_DICT_STRLEN); } free ( (void *)word); fclose (f_dictfile); close_filter (f_filter); return (0); } if (new_flag == TRUE) /* -n nwords */ { if ((f_filter = create_filter(filter, wc, flt_mode)) == NULL) err_sys_fatal("create_filter"); close_filter(f_filter); return (0); } if (new_from_dict_flag == TRUE) /* -d dictfile */ { word = (char *) calloc(1,MAX_DICT_STRLEN); if ( (f_dictfile = fopen(dictfile,"r")) == NULL) err_sys_fatal("fopen"); if (silent_flag != TRUE) { fprintf (stdout,"Counting words in dictionary. Please wait...\n"); fflush (stdout); } wc = count_words (f_dictfile); if (wc == 0) err_sys_fatal("count_words"); if( (f_filter = create_filter(filter, wc, flt_mode)) == NULL) err_sys_fatal("create_filter"); filter_size = get_filtersize(f_filter); if (filter_size == 0) err_sys_fatal("get_filtersize"); while ((fgets(word, MAX_DICT_STRLEN, f_dictfile) != NULL)) { tmp = (char *)strtok (word," \t\n\0"); if( tmp != NULL) { word = tmp; } else { continue; } if ( insert_word (word, f_filter, filter_size, flt_mode) == -1) err_sys_fatal("insert_word"); i++; if (silent_flag != TRUE) { if ( i % 100 == 0) { fprintf (stdout, "."); fflush (stdout); } } (void)memset((void *)word, 0, MAX_DICT_STRLEN); } if (silent_flag != TRUE) printf ("\n"); free ( (void *)word); fclose (f_dictfile); close_filter (f_filter); return (0); } return (0); } /* ** print_help() - prints short help info ** INPUT: ** none. ** OUTPUT: ** prints help info to the stdout. ** NOTES: ** none. */ void print_help(void) { printf ("\napgbfm APG Bloom filter management\n"); printf (" Copyright (c) 2001 Adel I. Mirzazhanov\n"); printf ("\napgbfm -f filter < [-a word] | [-A dictfile] | [-n numofwords] |\n"); printf (" [-c word] | [-C dictfile] | [-d dictfile] > [-s]\n"); printf ("apgbfm -i filter\n"); printf ("apgbfm [-v] [-h]\n\n"); printf ("-a word add word to filter\n"); printf ("-A dictfile add words from dictfile to filter\n"); printf ("-c word check word against filter\n"); printf ("-C dictfile check dictfile against filter\n"); printf ("-n numofwords create new empty filter\n"); printf ("-d dictfile create new filter and add all words from dictfile\n"); printf ("-f filtername use filtername as the name for filter\n"); printf ("-q quiet mode (do not print dots for -A and -d)\n"); printf ("-s create case insentive filter\n"); printf ("-i filter print filter information\n"); printf ("-v print version information\n"); printf ("-h print help (this screen)\n"); } /* ** checkopt() - check options ** INPUT: ** char * - option string. ** OUTPUT: ** none. ** NOTES: ** checks only is the option string numeral. */ void checkopt(char *opt) { int i; for(i=0; i < strlen(opt);i++) if(opt[i] != '0' && opt[i] != '1' && opt[i] != '2' && opt[i] != '3' && opt[i] != '4' && opt[i] != '5' && opt[i] != '6' && opt[i] != '7' && opt[i] != '8' && opt[i] != '9') err_app_fatal ("checkopt", "wrong option format"); } /* ** print_filter_info(char * filter) - print filter information ** INPUT: ** char * - filter file name. ** OUTPUT: ** none. ** NOTES: ** none. */ void print_filter_info(char * filter) { FILE * f_filter; if ( (f_filter = open_filter(filter, "r")) == NULL) err_sys_fatal("open_filter"); if (( print_flt_info(f_filter)) == -1) err_sys_fatal("print_flt_info"); close_filter(f_filter); } apg-2.2.3.dfsg.1/bloom.c0000644000175100017510000003075407714471356012445 0ustar mhmh/* ** Copyright (c) 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** C module for APG (Automated Password Generator) ** Bloom filter implementation. ** Functions: ** insert_word - insert word in the filter file ** check_word - check word ** create_filter - create initial(empty) filter file ** open_filter - open APG Bloom filter file ** get_filtersize - get APG Bloom filter size ** get_filtermode - get APG Bloom filter mode ** count_words - count words in plain dictionary file ** print_flt_info - print filter info **============================================================= ** hash2bit - generates 5 values (should be 5 values of independent ** hash functions) from input string. ** getbit - get the bit value from file. ** putbit - put the bit in the file. */ #include "bloom.h" #include "convert.h" #define FSIZE_BIT(word_count) ((unsigned long int)(5.0/(1.0-pow( 0.84151068, 1.0/((double)word_count))))) #define FSIZE_BYTE(word_count) ((((unsigned long int)(5.0/(1.0-pow( 0.84151068, 1.0/((double)word_count)))))/8)+1) h_val * hash2bit(char * word, h_val *b); int getbit(FILE * f, h_val bitnum); int putbit(FILE * f, h_val bitnum); #ifdef APGBFM /* ** print_flt_info - print filter information ** INPUT: ** FILE * filter - filter file descriptor ** OUTPUT: ** int ** 0 - everything OK ** -1 - something wrong */ int print_flt_info(FILE * filter) { struct apg_bf_hdr bf_hdr; int i = 0; if (fseek (filter, 0, SEEK_SET) == -1) return(-1); if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, filter) != 1) if (ferror (filter) != 0) return(-1); printf ("**************************************\n"); printf ("** APGBFM: Bloom-filter information **\n"); printf ("**************************************\n"); printf ("Filter ID : "); for (i=0; i < sizeof(bf_hdr.id); i++) printf ("%c", bf_hdr.id[i]); printf ("\n"); printf ("Filter Version: "); printf ("%c.", bf_hdr.version[0]); printf ("%c.", bf_hdr.version[1]); printf ("%c", bf_hdr.version[2]); printf ("\n"); printf ("Filter size : %lu bits\n", (unsigned long int)bf_hdr.fs); printf ("Filter mode : "); if (bf_hdr.mode == 0x00) printf ("PLAIN\n"); if (bf_hdr.mode == 0x01) printf ("CASE_INSENSITIVE\n"); printf ("**************************************\n"); if (fseek (filter, 0, SEEK_SET) == -1) return(-1); return(0); } #endif /* APGBFM */ /* ** insert_word - insert word in the filter file ** INPUT: ** char *word - word to incert in the filter ** FILE *file - filter file descriptor ** h_val filter_size - filter size in bits ** f_mode mode - filter mode ** OUTPUT: ** int ** 0 - everything OK ** -1 - something wrong */ int insert_word(char *word, FILE *file, h_val filter_size, f_mode mode) { h_val h[H_NUM]; int i = 0; #ifdef APG_DEBUG fprintf (stdout, "DEBUG> insert_word: word to insert: %s\n", word); fflush (stdout); #endif /* APG_DEBUG */ if ((mode & BF_CASE_INSENSITIVE) > 0) { decapitalize(word); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> insert_word: decapitalized word: %s\n", word); fflush (stdout); #endif /* APG_DEBUG */ } hash2bit (word, &h[0]); for(i = 0; i < H_NUM; i++) if (putbit (file, h[i] % filter_size)== -1) return (-1); return(0); } /* ** check_word - check word ** INPUT: ** char *word - word to check ** FILE *file - filter file descriptor ** h_val filter_size - filter size in bits ** f_mode - filter mode ** OUTPUT: ** int ** 0 - word is not in dictionary ** 1 - word is in dictionary ** -1 - something wrong */ int check_word(char *word, FILE *file, h_val filter_size, f_mode mode) { h_val h[H_NUM]; int i = 0; char * tmp_word; if ((tmp_word = (char *) calloc(1,MAX_DICT_STRLEN)) == NULL) return(-1); (void)memcpy ((void *) tmp_word, (void *) word, strlen(word)); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> check_word: word to check: %s\n", word); fflush (stdout); #endif /* APG_DEBUG */ if ((mode & BF_CASE_INSENSITIVE) > 0) { decapitalize(tmp_word); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> check_word: decapitalized word: %s\n", tmp_word); fflush (stdout); #endif /* APG_DEBUG */ } hash2bit (tmp_word, &h[0]); free ((void *)tmp_word); for(i = 0; i < H_NUM; i++) { switch(getbit(file, h[i] % filter_size)) { case 0: return(0); break; case -1: return(-1); break; default: break; } } return (1); } /* ** open_filter - open APG Bloom filter file ** open filter file and check is this the real bloom filter file ** INPUT: ** char * f_name - filter filename ** const char *mode - "r" or "r+" ** OUTPUT: ** FILE * - file pointer ** NULL - something wrong. */ FILE * open_filter(char * f_name, const char *mode) { FILE *f; char etalon_bf_id[] = APGBF_ID; char etalon_bf_ver[] = APGBF_VERSION; struct apg_bf_hdr bf_hdr; if ((f = fopen (f_name, mode)) == NULL) return(NULL); if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1) if (ferror (f) != 0) return(NULL); if ((bf_hdr.id[0] != etalon_bf_id[0]) || (bf_hdr.id[1] != etalon_bf_id[1]) || (bf_hdr.id[2] != etalon_bf_id[2]) || (bf_hdr.id[3] != etalon_bf_id[3]) || (bf_hdr.id[4] != etalon_bf_id[4]) ) return (NULL); if ((bf_hdr.version[0] != etalon_bf_ver[0]) || (bf_hdr.version[1] != etalon_bf_ver[1]) || (bf_hdr.version[2] != etalon_bf_ver[2]) ) return (NULL); else { if (fseek (f, 0, SEEK_SET) == -1) return(NULL); return(f); } } /* ** close_filter - close APG Bloom filter file ** close filter file ** INPUT: ** FILE * f_dsk - filter file pointer ** OUTPUT: ** int - same as fclose() return value */ int close_filter(FILE *f_dsk) { return(fclose(f_dsk)); } /* ** get_filtersize - get APG Bloom filter size ** INPUT: ** FILE *f - filter file descriptor ** OUTPUT: ** h_val - size of APG Bloom filter. ** 0 - something wrong */ h_val get_filtersize(FILE * f) { struct apg_bf_hdr bf_hdr; if (fseek (f, 0, SEEK_SET) == -1) return(0); if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1) if (ferror (f) != 0) return(0); if (fseek (f, 0, SEEK_SET) == -1) return(0); return( (h_val)bf_hdr.fs); } /* ** get_filtermode - get APG Bloom filter mode ** INPUT: ** FILE *f - filter file descriptor ** OUTPUT: ** f_mode - APG Bloom filter mode. ** 0 - something wrong */ f_mode get_filtermode(FILE *f) { struct apg_bf_hdr bf_hdr; if (fseek (f, 0, SEEK_SET) == -1) return(0); if (fread ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1) if (ferror (f) != 0) return(0); if (fseek (f, 0, SEEK_SET) == -1) return(0); return( (f_mode)bf_hdr.mode); } /* ** create_filter - create initial(empty) filter file ** 5 - number of hash functions ** 0.0001 (0.01%) - probability of false positives ** INPUT: ** char * f_name - filter filename ** unsigned long int n_words - number of words in filter ** OUTPUT: ** FILE * - filter file descriptor ** NULL - something wrong ** NOTES: ** n - number of words in the filter ** N - size of filter(?) ** ** a=(1-(4/N))^n ** 0.0001=(1-a)^5 ==> 1-a=0.15849... ==> a=0.84151068 ==> ** 0.84151068=(1-(5/N))^n ==> 0.84151068^(1/n)=1-(5/N) ==> ** ** N=5/(1-[0.84151068^(1/n)]) ** ** 5 ** N = ----------------- ** 1/n ** 1 - 0.84151068 */ FILE * create_filter(char * f_name, unsigned long int n_words, f_mode mode) { FILE *f; char zero = 0x00; long int i = 0L; char etalon_bf_id[] = APGBF_ID; char etalon_bf_ver[] = APGBF_VERSION; struct apg_bf_hdr bf_hdr; bf_hdr.id[0] = etalon_bf_id[0]; bf_hdr.id[1] = etalon_bf_id[1]; bf_hdr.id[2] = etalon_bf_id[2]; bf_hdr.id[3] = etalon_bf_id[3]; bf_hdr.id[4] = etalon_bf_id[4]; bf_hdr.version[0] = etalon_bf_ver[0]; bf_hdr.version[1] = etalon_bf_ver[1]; bf_hdr.version[2] = etalon_bf_ver[2]; bf_hdr.fs = FSIZE_BIT(n_words); bf_hdr.mode = mode; if ((f = fopen (f_name, "w+")) == NULL) return(NULL); if (fwrite ( (void *)&bf_hdr, APGBFHDRSIZE, 1, f) != 1) if (ferror (f) != 0) return(NULL); for (i = 0; i < FSIZE_BYTE(n_words); i++) if ( fwrite ( (void *)&zero, 1, 1, f) < 1) if (ferror (f) != 0) return(NULL); if (fseek (f, 0, SEEK_SET) == -1) return (NULL); return (f); } /* ** count_words - count words in plain dictionary file ** INPUT: ** FILE *dict_file -plain dicionary file descriptor ** OUTPUT: ** h_val - amount of words in dictionary file ** 0 - something wrong */ h_val count_words(FILE *dict_file) { h_val i = 0L; /* word counter */ char *string; /* temp string holder */ 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)) { tmp = (char *)strtok (string," \t\n\0"); if (tmp != NULL) i++; } if (fseek (dict_file, 0, SEEK_SET) == -1) return (0); free ((void *) string); return (i); } /* ** hash2bit - generates 4 values (should be 4 values of independent ** hash functions) from input string. ** INPUT: ** char *word - word to hash ** h_val *b - pointer to bitnumber array ** OUTPUT: ** h_val * - pointer to bitnumber array */ h_val * hash2bit(char * word, h_val *b) { apg_SHA_INFO context; BYTE cs[SHA_DIGESTSIZE]; apg_shaInit (&context); apg_shaUpdate (&context, (BYTE *)word, strlen(word)); apg_shaFinal (&context, cs); return ( (h_val *)memcpy( (void *)b, (void *)&cs[0], SHA_DIGESTSIZE)); } /* ** getbit - get the bit value from file. ** INPUT: ** FILE *f - file descriptor ** h_val bitnum - bit number ** OUTPUT: ** int ** 0,1 - bit value ** -1 - something wrong */ int getbit(FILE * f, h_val bitnum) { long int bytenum = 0L; short int bit_in_byte = 0; unsigned char read_byte = 0x00; unsigned char test_byte = 0x01; int i = 0; bit_in_byte = bitnum % 8; bytenum = APGBFHDRSIZE + (bitnum/8); if (fseek (f, bytenum, SEEK_SET) == -1) return(-1); if (fread ((void*)&read_byte,1,1,f) < 1) if (ferror(f) != 0) return (-1); for (i=0;i < bit_in_byte;i++) test_byte = test_byte*2; if ((read_byte & test_byte) > 0) return (1); else return (0); } /* ** putbit - put the bit in the file. ** INPUT: ** FILE *f - file descriptor ** h_val bitnum - bit number ** OUTPUT: ** int ** 0 - everything OK ** -1 - something wrong */ int putbit(FILE * f, h_val bitnum) { long int bytenum = 0L; short int bit_in_byte = 0; unsigned char read_byte = 0x00; unsigned char test_byte = 0x01; int i = 0; bit_in_byte = bitnum % 8; bytenum = APGBFHDRSIZE + (bitnum/8); if (fseek (f, bytenum, SEEK_SET) == -1) return(-1); if (fread ((void*)&read_byte,1,1,f) < 1) if (ferror(f) != 0) return (-1); for (i=0;i < bit_in_byte;i++) test_byte = test_byte*2; read_byte = read_byte | test_byte; if (fseek (f, bytenum, SEEK_SET) == -1) return(-1); if (fwrite ((void*)&read_byte,1,1,f) < 1) if (ferror(f) != 0) return (-1); return (0); } /* END OF bloom.c file */ apg-2.2.3.dfsg.1/bloom.h0000644000175100017510000000633207714471356012445 0ustar mhmh/* ** Copyright (c) 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** Header file for bloom filter algorithm implementation */ #ifndef APG_BLOOM_H #define APG_BLOOM_H 1 #include #include #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include #endif #include #include "sha/sha.h" #define APGBF_ID "APGBF" #define APGBF_VERSION "110" /* Version 1.1.0 */ /* Bloom filter modes flags */ #define BF_CASE_INSENSITIVE 0x01 #define BF_RESERVED1 0x02 #define BF_RESERVED2 0x04 #define BF_RESERVED3 0x08 #define BF_RESERVED4 0x10 #define BF_RESERVED5 0x20 #define BF_RESERVED6 0x40 #define BF_RESERVED7 0x80 #define APGBFHDRSIZE 13 #define TRUE 1 #define FALSE 0 #define MAX_DICT_STRLEN 255 #define H_NUM 5 typedef unsigned long int h_val; /* should be 32-bit */ typedef unsigned short int flag; typedef unsigned char f_mode; struct apg_bf_hdr { char id[5]; /* filter ID */ char version[3]; /* filter version */ unsigned long int fs; /* filter size */ f_mode mode; /* filter flags */ }; extern int insert_word(char *word, FILE *file, h_val filter_size, f_mode mode); extern int check_word(char *word, FILE *file, h_val filter_size, f_mode mode); extern FILE * create_filter(char * f_name, unsigned long int n_words, f_mode mode); extern FILE * open_filter(char * f_name, const char *mode); extern int close_filter(FILE *f_dsk); extern h_val get_filtersize(FILE *f); extern f_mode get_filtermode(FILE *f); extern h_val count_words(FILE *dict_file); #ifdef APGBFM extern int print_flt_info(FILE * filter); #endif /* APGBFM */ #endif /* APG_BLOOM_H */ apg-2.2.3.dfsg.1/cast/0000755000175100017510000000000007714471356012112 5ustar mhmhapg-2.2.3.dfsg.1/cast/cast.c0000644000175100017510000001526007714471356013214 0ustar mhmh/* * CAST-128 in C * Written by Steve Reid * 100% Public Domain - no warranty * Released 1997.10.11 */ #include "cast.h" #include "cast_sboxes.h" /* Macros to access 8-bit bytes out of a 32-bit word */ #define U8a(x) ( (u8) (x>>24) ) #define U8b(x) ( (u8) ((x>>16)&255) ) #define U8c(x) ( (u8) ((x>>8)&255) ) #define U8d(x) ( (u8) ((x)&255) ) /* Circular left shift */ #define ROL(x, n) ( ((x)<<(n)) | ((x)>>(32-(n))) ) /* CAST-128 uses three different round functions */ #define F1(l, r, i) \ t = ROL(key->xkey[i] + r, key->xkey[i+16]); \ l ^= ((cast_sbox1[U8a(t)] ^ cast_sbox2[U8b(t)]) - \ cast_sbox3[U8c(t)]) + cast_sbox4[U8d(t)]; #define F2(l, r, i) \ t = ROL(key->xkey[i] ^ r, key->xkey[i+16]); \ l ^= ((cast_sbox1[U8a(t)] - cast_sbox2[U8b(t)]) + \ cast_sbox3[U8c(t)]) ^ cast_sbox4[U8d(t)]; #define F3(l, r, i) \ t = ROL(key->xkey[i] - r, key->xkey[i+16]); \ l ^= ((cast_sbox1[U8a(t)] + cast_sbox2[U8b(t)]) ^ \ cast_sbox3[U8c(t)]) - cast_sbox4[U8d(t)]; /***** Encryption Function *****/ void cast_encrypt(cast_key* key, u8* inblock, u8* outblock) { u32 t, l, r; /* Get inblock into l,r */ l = ((u32)inblock[0] << 24) | ((u32)inblock[1] << 16) | ((u32)inblock[2] << 8) | (u32)inblock[3]; r = ((u32)inblock[4] << 24) | ((u32)inblock[5] << 16) | ((u32)inblock[6] << 8) | (u32)inblock[7]; /* Do the work */ F1(l, r, 0); F2(r, l, 1); F3(l, r, 2); F1(r, l, 3); F2(l, r, 4); F3(r, l, 5); F1(l, r, 6); F2(r, l, 7); F3(l, r, 8); F1(r, l, 9); F2(l, r, 10); F3(r, l, 11); /* Only do full 16 rounds if key length > 80 bits */ if (key->rounds > 12) { F1(l, r, 12); F2(r, l, 13); F3(l, r, 14); F1(r, l, 15); } /* Put l,r into outblock */ outblock[0] = U8a(r); outblock[1] = U8b(r); outblock[2] = U8c(r); outblock[3] = U8d(r); outblock[4] = U8a(l); outblock[5] = U8b(l); outblock[6] = U8c(l); outblock[7] = U8d(l); /* Wipe clean */ t = l = r = 0; } /***** Decryption Function *****/ void cast_decrypt(cast_key* key, u8* inblock, u8* outblock) { u32 t, l, r; /* Get inblock into l,r */ r = ((u32)inblock[0] << 24) | ((u32)inblock[1] << 16) | ((u32)inblock[2] << 8) | (u32)inblock[3]; l = ((u32)inblock[4] << 24) | ((u32)inblock[5] << 16) | ((u32)inblock[6] << 8) | (u32)inblock[7]; /* Do the work */ /* Only do full 16 rounds if key length > 80 bits */ if (key->rounds > 12) { F1(r, l, 15); F3(l, r, 14); F2(r, l, 13); F1(l, r, 12); } F3(r, l, 11); F2(l, r, 10); F1(r, l, 9); F3(l, r, 8); F2(r, l, 7); F1(l, r, 6); F3(r, l, 5); F2(l, r, 4); F1(r, l, 3); F3(l, r, 2); F2(r, l, 1); F1(l, r, 0); /* Put l,r into outblock */ outblock[0] = U8a(l); outblock[1] = U8b(l); outblock[2] = U8c(l); outblock[3] = U8d(l); outblock[4] = U8a(r); outblock[5] = U8b(r); outblock[6] = U8c(r); outblock[7] = U8d(r); /* Wipe clean */ t = l = r = 0; } /***** Key Schedual *****/ void cast_setkey(cast_key* key, u8* rawkey, int keybytes) { u32 t[4], z[4], x[4]; int i; /* Set number of rounds to 12 or 16, depending on key length */ key->rounds = (keybytes <= 10 ? 12 : 16); /* Copy key to workspace x */ for (i = 0; i < 4; i++) { x[i] = 0; if ((i*4+0) < keybytes) x[i] = (u32)rawkey[i*4+0] << 24; if ((i*4+1) < keybytes) x[i] |= (u32)rawkey[i*4+1] << 16; if ((i*4+2) < keybytes) x[i] |= (u32)rawkey[i*4+2] << 8; if ((i*4+3) < keybytes) x[i] |= (u32)rawkey[i*4+3]; } /* Generate 32 subkeys, four at a time */ for (i = 0; i < 32; i+=4) { switch (i & 4) { case 0: t[0] = z[0] = x[0] ^ cast_sbox5[U8b(x[3])] ^ cast_sbox6[U8d(x[3])] ^ cast_sbox7[U8a(x[3])] ^ cast_sbox8[U8c(x[3])] ^ cast_sbox7[U8a(x[2])]; t[1] = z[1] = x[2] ^ cast_sbox5[U8a(z[0])] ^ cast_sbox6[U8c(z[0])] ^ cast_sbox7[U8b(z[0])] ^ cast_sbox8[U8d(z[0])] ^ cast_sbox8[U8c(x[2])]; t[2] = z[2] = x[3] ^ cast_sbox5[U8d(z[1])] ^ cast_sbox6[U8c(z[1])] ^ cast_sbox7[U8b(z[1])] ^ cast_sbox8[U8a(z[1])] ^ cast_sbox5[U8b(x[2])]; t[3] = z[3] = x[1] ^ cast_sbox5[U8c(z[2])] ^ cast_sbox6[U8b(z[2])] ^ cast_sbox7[U8d(z[2])] ^ cast_sbox8[U8a(z[2])] ^ cast_sbox6[U8d(x[2])]; break; case 4: t[0] = x[0] = z[2] ^ cast_sbox5[U8b(z[1])] ^ cast_sbox6[U8d(z[1])] ^ cast_sbox7[U8a(z[1])] ^ cast_sbox8[U8c(z[1])] ^ cast_sbox7[U8a(z[0])]; t[1] = x[1] = z[0] ^ cast_sbox5[U8a(x[0])] ^ cast_sbox6[U8c(x[0])] ^ cast_sbox7[U8b(x[0])] ^ cast_sbox8[U8d(x[0])] ^ cast_sbox8[U8c(z[0])]; t[2] = x[2] = z[1] ^ cast_sbox5[U8d(x[1])] ^ cast_sbox6[U8c(x[1])] ^ cast_sbox7[U8b(x[1])] ^ cast_sbox8[U8a(x[1])] ^ cast_sbox5[U8b(z[0])]; t[3] = x[3] = z[3] ^ cast_sbox5[U8c(x[2])] ^ cast_sbox6[U8b(x[2])] ^ cast_sbox7[U8d(x[2])] ^ cast_sbox8[U8a(x[2])] ^ cast_sbox6[U8d(z[0])]; break; } switch (i & 12) { case 0: case 12: key->xkey[i+0] = cast_sbox5[U8a(t[2])] ^ cast_sbox6[U8b(t[2])] ^ cast_sbox7[U8d(t[1])] ^ cast_sbox8[U8c(t[1])]; key->xkey[i+1] = cast_sbox5[U8c(t[2])] ^ cast_sbox6[U8d(t[2])] ^ cast_sbox7[U8b(t[1])] ^ cast_sbox8[U8a(t[1])]; key->xkey[i+2] = cast_sbox5[U8a(t[3])] ^ cast_sbox6[U8b(t[3])] ^ cast_sbox7[U8d(t[0])] ^ cast_sbox8[U8c(t[0])]; key->xkey[i+3] = cast_sbox5[U8c(t[3])] ^ cast_sbox6[U8d(t[3])] ^ cast_sbox7[U8b(t[0])] ^ cast_sbox8[U8a(t[0])]; break; case 4: case 8: key->xkey[i+0] = cast_sbox5[U8d(t[0])] ^ cast_sbox6[U8c(t[0])] ^ cast_sbox7[U8a(t[3])] ^ cast_sbox8[U8b(t[3])]; key->xkey[i+1] = cast_sbox5[U8b(t[0])] ^ cast_sbox6[U8a(t[0])] ^ cast_sbox7[U8c(t[3])] ^ cast_sbox8[U8d(t[3])]; key->xkey[i+2] = cast_sbox5[U8d(t[1])] ^ cast_sbox6[U8c(t[1])] ^ cast_sbox7[U8a(t[2])] ^ cast_sbox8[U8b(t[2])]; key->xkey[i+3] = cast_sbox5[U8b(t[1])] ^ cast_sbox6[U8a(t[1])] ^ cast_sbox7[U8c(t[2])] ^ cast_sbox8[U8d(t[2])]; break; } switch (i & 12) { case 0: key->xkey[i+0] ^= cast_sbox5[U8c(z[0])]; key->xkey[i+1] ^= cast_sbox6[U8c(z[1])]; key->xkey[i+2] ^= cast_sbox7[U8b(z[2])]; key->xkey[i+3] ^= cast_sbox8[U8a(z[3])]; break; case 4: key->xkey[i+0] ^= cast_sbox5[U8a(x[2])]; key->xkey[i+1] ^= cast_sbox6[U8b(x[3])]; key->xkey[i+2] ^= cast_sbox7[U8d(x[0])]; key->xkey[i+3] ^= cast_sbox8[U8d(x[1])]; break; case 8: key->xkey[i+0] ^= cast_sbox5[U8b(z[2])]; key->xkey[i+1] ^= cast_sbox6[U8a(z[3])]; key->xkey[i+2] ^= cast_sbox7[U8c(z[0])]; key->xkey[i+3] ^= cast_sbox8[U8c(z[1])]; break; case 12: key->xkey[i+0] ^= cast_sbox5[U8d(x[0])]; key->xkey[i+1] ^= cast_sbox6[U8d(x[1])]; key->xkey[i+2] ^= cast_sbox7[U8a(x[2])]; key->xkey[i+3] ^= cast_sbox8[U8b(x[3])]; break; } if (i >= 16) { key->xkey[i+0] &= 31; key->xkey[i+1] &= 31; key->xkey[i+2] &= 31; key->xkey[i+3] &= 31; } } /* Wipe clean */ for (i = 0; i < 4; i++) { t[i] = x[i] = z[i] = 0; } } /* Made in Canada */ apg-2.2.3.dfsg.1/cast/cast.h0000644000175100017510000000113207714471356013212 0ustar mhmh/* * CAST-128 in C * Written by Steve Reid * 100% Public Domain - no warranty * Released 1997.10.11 */ #ifndef _CAST_H_ #define _CAST_H_ typedef unsigned char u8; /* 8-bit unsigned */ typedef unsigned long u32; /* 32-bit unsigned */ typedef struct { u32 xkey[32]; /* Key, after expansion */ int rounds; /* Number of rounds to use, 12 or 16 */ } cast_key; void cast_setkey(cast_key* key, u8* rawkey, int keybytes); void cast_encrypt(cast_key* key, u8* inblock, u8* outblock); void cast_decrypt(cast_key* key, u8* inblock, u8* outblock); #endif /* ifndef _CAST_H_ */ apg-2.2.3.dfsg.1/cast/cast_sboxes.h0000644000175100017510000006170407714471356014610 0ustar mhmh/* * CAST-128 in C * Written by Steve Reid * 100% Public Domain - no warranty * Released 1997.10.11 */ static const u32 cast_sbox1[256] = { 0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A, 0x1E213F2F, 0x9C004DD3, 0x6003E540, 0xCF9FC949, 0xBFD4AF27, 0x88BBBDB5, 0xE2034090, 0x98D09675, 0x6E63A0E0, 0x15C361D2, 0xC2E7661D, 0x22D4FF8E, 0x28683B6F, 0xC07FD059, 0xFF2379C8, 0x775F50E2, 0x43C340D3, 0xDF2F8656, 0x887CA41A, 0xA2D2BD2D, 0xA1C9E0D6, 0x346C4819, 0x61B76D87, 0x22540F2F, 0x2ABE32E1, 0xAA54166B, 0x22568E3A, 0xA2D341D0, 0x66DB40C8, 0xA784392F, 0x004DFF2F, 0x2DB9D2DE, 0x97943FAC, 0x4A97C1D8, 0x527644B7, 0xB5F437A7, 0xB82CBAEF, 0xD751D159, 0x6FF7F0ED, 0x5A097A1F, 0x827B68D0, 0x90ECF52E, 0x22B0C054, 0xBC8E5935, 0x4B6D2F7F, 0x50BB64A2, 0xD2664910, 0xBEE5812D, 0xB7332290, 0xE93B159F, 0xB48EE411, 0x4BFF345D, 0xFD45C240, 0xAD31973F, 0xC4F6D02E, 0x55FC8165, 0xD5B1CAAD, 0xA1AC2DAE, 0xA2D4B76D, 0xC19B0C50, 0x882240F2, 0x0C6E4F38, 0xA4E4BFD7, 0x4F5BA272, 0x564C1D2F, 0xC59C5319, 0xB949E354, 0xB04669FE, 0xB1B6AB8A, 0xC71358DD, 0x6385C545, 0x110F935D, 0x57538AD5, 0x6A390493, 0xE63D37E0, 0x2A54F6B3, 0x3A787D5F, 0x6276A0B5, 0x19A6FCDF, 0x7A42206A, 0x29F9D4D5, 0xF61B1891, 0xBB72275E, 0xAA508167, 0x38901091, 0xC6B505EB, 0x84C7CB8C, 0x2AD75A0F, 0x874A1427, 0xA2D1936B, 0x2AD286AF, 0xAA56D291, 0xD7894360, 0x425C750D, 0x93B39E26, 0x187184C9, 0x6C00B32D, 0x73E2BB14, 0xA0BEBC3C, 0x54623779, 0x64459EAB, 0x3F328B82, 0x7718CF82, 0x59A2CEA6, 0x04EE002E, 0x89FE78E6, 0x3FAB0950, 0x325FF6C2, 0x81383F05, 0x6963C5C8, 0x76CB5AD6, 0xD49974C9, 0xCA180DCF, 0x380782D5, 0xC7FA5CF6, 0x8AC31511, 0x35E79E13, 0x47DA91D0, 0xF40F9086, 0xA7E2419E, 0x31366241, 0x051EF495, 0xAA573B04, 0x4A805D8D, 0x548300D0, 0x00322A3C, 0xBF64CDDF, 0xBA57A68E, 0x75C6372B, 0x50AFD341, 0xA7C13275, 0x915A0BF5, 0x6B54BFAB, 0x2B0B1426, 0xAB4CC9D7, 0x449CCD82, 0xF7FBF265, 0xAB85C5F3, 0x1B55DB94, 0xAAD4E324, 0xCFA4BD3F, 0x2DEAA3E2, 0x9E204D02, 0xC8BD25AC, 0xEADF55B3, 0xD5BD9E98, 0xE31231B2, 0x2AD5AD6C, 0x954329DE, 0xADBE4528, 0xD8710F69, 0xAA51C90F, 0xAA786BF6, 0x22513F1E, 0xAA51A79B, 0x2AD344CC, 0x7B5A41F0, 0xD37CFBAD, 0x1B069505, 0x41ECE491, 0xB4C332E6, 0x032268D4, 0xC9600ACC, 0xCE387E6D, 0xBF6BB16C, 0x6A70FB78, 0x0D03D9C9, 0xD4DF39DE, 0xE01063DA, 0x4736F464, 0x5AD328D8, 0xB347CC96, 0x75BB0FC3, 0x98511BFB, 0x4FFBCC35, 0xB58BCF6A, 0xE11F0ABC, 0xBFC5FE4A, 0xA70AEC10, 0xAC39570A, 0x3F04442F, 0x6188B153, 0xE0397A2E, 0x5727CB79, 0x9CEB418F, 0x1CACD68D, 0x2AD37C96, 0x0175CB9D, 0xC69DFF09, 0xC75B65F0, 0xD9DB40D8, 0xEC0E7779, 0x4744EAD4, 0xB11C3274, 0xDD24CB9E, 0x7E1C54BD, 0xF01144F9, 0xD2240EB1, 0x9675B3FD, 0xA3AC3755, 0xD47C27AF, 0x51C85F4D, 0x56907596, 0xA5BB15E6, 0x580304F0, 0xCA042CF1, 0x011A37EA, 0x8DBFAADB, 0x35BA3E4A, 0x3526FFA0, 0xC37B4D09, 0xBC306ED9, 0x98A52666, 0x5648F725, 0xFF5E569D, 0x0CED63D0, 0x7C63B2CF, 0x700B45E1, 0xD5EA50F1, 0x85A92872, 0xAF1FBDA7, 0xD4234870, 0xA7870BF3, 0x2D3B4D79, 0x42E04198, 0x0CD0EDE7, 0x26470DB8, 0xF881814C, 0x474D6AD7, 0x7C0C5E5C, 0xD1231959, 0x381B7298, 0xF5D2F4DB, 0xAB838653, 0x6E2F1E23, 0x83719C9E, 0xBD91E046, 0x9A56456E, 0xDC39200C, 0x20C8C571, 0x962BDA1C, 0xE1E696FF, 0xB141AB08, 0x7CCA89B9, 0x1A69E783, 0x02CC4843, 0xA2F7C579, 0x429EF47D, 0x427B169C, 0x5AC9F049, 0xDD8F0F00, 0x5C8165BF }; static const u32 cast_sbox2[256] = { 0x1F201094, 0xEF0BA75B, 0x69E3CF7E, 0x393F4380, 0xFE61CF7A, 0xEEC5207A, 0x55889C94, 0x72FC0651, 0xADA7EF79, 0x4E1D7235, 0xD55A63CE, 0xDE0436BA, 0x99C430EF, 0x5F0C0794, 0x18DCDB7D, 0xA1D6EFF3, 0xA0B52F7B, 0x59E83605, 0xEE15B094, 0xE9FFD909, 0xDC440086, 0xEF944459, 0xBA83CCB3, 0xE0C3CDFB, 0xD1DA4181, 0x3B092AB1, 0xF997F1C1, 0xA5E6CF7B, 0x01420DDB, 0xE4E7EF5B, 0x25A1FF41, 0xE180F806, 0x1FC41080, 0x179BEE7A, 0xD37AC6A9, 0xFE5830A4, 0x98DE8B7F, 0x77E83F4E, 0x79929269, 0x24FA9F7B, 0xE113C85B, 0xACC40083, 0xD7503525, 0xF7EA615F, 0x62143154, 0x0D554B63, 0x5D681121, 0xC866C359, 0x3D63CF73, 0xCEE234C0, 0xD4D87E87, 0x5C672B21, 0x071F6181, 0x39F7627F, 0x361E3084, 0xE4EB573B, 0x602F64A4, 0xD63ACD9C, 0x1BBC4635, 0x9E81032D, 0x2701F50C, 0x99847AB4, 0xA0E3DF79, 0xBA6CF38C, 0x10843094, 0x2537A95E, 0xF46F6FFE, 0xA1FF3B1F, 0x208CFB6A, 0x8F458C74, 0xD9E0A227, 0x4EC73A34, 0xFC884F69, 0x3E4DE8DF, 0xEF0E0088, 0x3559648D, 0x8A45388C, 0x1D804366, 0x721D9BFD, 0xA58684BB, 0xE8256333, 0x844E8212, 0x128D8098, 0xFED33FB4, 0xCE280AE1, 0x27E19BA5, 0xD5A6C252, 0xE49754BD, 0xC5D655DD, 0xEB667064, 0x77840B4D, 0xA1B6A801, 0x84DB26A9, 0xE0B56714, 0x21F043B7, 0xE5D05860, 0x54F03084, 0x066FF472, 0xA31AA153, 0xDADC4755, 0xB5625DBF, 0x68561BE6, 0x83CA6B94, 0x2D6ED23B, 0xECCF01DB, 0xA6D3D0BA, 0xB6803D5C, 0xAF77A709, 0x33B4A34C, 0x397BC8D6, 0x5EE22B95, 0x5F0E5304, 0x81ED6F61, 0x20E74364, 0xB45E1378, 0xDE18639B, 0x881CA122, 0xB96726D1, 0x8049A7E8, 0x22B7DA7B, 0x5E552D25, 0x5272D237, 0x79D2951C, 0xC60D894C, 0x488CB402, 0x1BA4FE5B, 0xA4B09F6B, 0x1CA815CF, 0xA20C3005, 0x8871DF63, 0xB9DE2FCB, 0x0CC6C9E9, 0x0BEEFF53, 0xE3214517, 0xB4542835, 0x9F63293C, 0xEE41E729, 0x6E1D2D7C, 0x50045286, 0x1E6685F3, 0xF33401C6, 0x30A22C95, 0x31A70850, 0x60930F13, 0x73F98417, 0xA1269859, 0xEC645C44, 0x52C877A9, 0xCDFF33A6, 0xA02B1741, 0x7CBAD9A2, 0x2180036F, 0x50D99C08, 0xCB3F4861, 0xC26BD765, 0x64A3F6AB, 0x80342676, 0x25A75E7B, 0xE4E6D1FC, 0x20C710E6, 0xCDF0B680, 0x17844D3B, 0x31EEF84D, 0x7E0824E4, 0x2CCB49EB, 0x846A3BAE, 0x8FF77888, 0xEE5D60F6, 0x7AF75673, 0x2FDD5CDB, 0xA11631C1, 0x30F66F43, 0xB3FAEC54, 0x157FD7FA, 0xEF8579CC, 0xD152DE58, 0xDB2FFD5E, 0x8F32CE19, 0x306AF97A, 0x02F03EF8, 0x99319AD5, 0xC242FA0F, 0xA7E3EBB0, 0xC68E4906, 0xB8DA230C, 0x80823028, 0xDCDEF3C8, 0xD35FB171, 0x088A1BC8, 0xBEC0C560, 0x61A3C9E8, 0xBCA8F54D, 0xC72FEFFA, 0x22822E99, 0x82C570B4, 0xD8D94E89, 0x8B1C34BC, 0x301E16E6, 0x273BE979, 0xB0FFEAA6, 0x61D9B8C6, 0x00B24869, 0xB7FFCE3F, 0x08DC283B, 0x43DAF65A, 0xF7E19798, 0x7619B72F, 0x8F1C9BA4, 0xDC8637A0, 0x16A7D3B1, 0x9FC393B7, 0xA7136EEB, 0xC6BCC63E, 0x1A513742, 0xEF6828BC, 0x520365D6, 0x2D6A77AB, 0x3527ED4B, 0x821FD216, 0x095C6E2E, 0xDB92F2FB, 0x5EEA29CB, 0x145892F5, 0x91584F7F, 0x5483697B, 0x2667A8CC, 0x85196048, 0x8C4BACEA, 0x833860D4, 0x0D23E0F9, 0x6C387E8A, 0x0AE6D249, 0xB284600C, 0xD835731D, 0xDCB1C647, 0xAC4C56EA, 0x3EBD81B3, 0x230EABB0, 0x6438BC87, 0xF0B5B1FA, 0x8F5EA2B3, 0xFC184642, 0x0A036B7A, 0x4FB089BD, 0x649DA589, 0xA345415E, 0x5C038323, 0x3E5D3BB9, 0x43D79572, 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF, 0x7160A539, 0x73BFBE70, 0x83877605, 0x4523ECF1 }; static const u32 cast_sbox3[256] = { 0x8DEFC240, 0x25FA5D9F, 0xEB903DBF, 0xE810C907, 0x47607FFF, 0x369FE44B, 0x8C1FC644, 0xAECECA90, 0xBEB1F9BF, 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE, 0x920E8806, 0xF0AD0548, 0xE13C8D83, 0x927010D5, 0x11107D9F, 0x07647DB9, 0xB2E3E4D4, 0x3D4F285E, 0xB9AFA820, 0xFADE82E0, 0xA067268B, 0x8272792E, 0x553FB2C0, 0x489AE22B, 0xD4EF9794, 0x125E3FBC, 0x21FFFCEE, 0x825B1BFD, 0x9255C5ED, 0x1257A240, 0x4E1A8302, 0xBAE07FFF, 0x528246E7, 0x8E57140E, 0x3373F7BF, 0x8C9F8188, 0xA6FC4EE8, 0xC982B5A5, 0xA8C01DB7, 0x579FC264, 0x67094F31, 0xF2BD3F5F, 0x40FFF7C1, 0x1FB78DFC, 0x8E6BD2C1, 0x437BE59B, 0x99B03DBF, 0xB5DBC64B, 0x638DC0E6, 0x55819D99, 0xA197C81C, 0x4A012D6E, 0xC5884A28, 0xCCC36F71, 0xB843C213, 0x6C0743F1, 0x8309893C, 0x0FEDDD5F, 0x2F7FE850, 0xD7C07F7E, 0x02507FBF, 0x5AFB9A04, 0xA747D2D0, 0x1651192E, 0xAF70BF3E, 0x58C31380, 0x5F98302E, 0x727CC3C4, 0x0A0FB402, 0x0F7FEF82, 0x8C96FDAD, 0x5D2C2AAE, 0x8EE99A49, 0x50DA88B8, 0x8427F4A0, 0x1EAC5790, 0x796FB449, 0x8252DC15, 0xEFBD7D9B, 0xA672597D, 0xADA840D8, 0x45F54504, 0xFA5D7403, 0xE83EC305, 0x4F91751A, 0x925669C2, 0x23EFE941, 0xA903F12E, 0x60270DF2, 0x0276E4B6, 0x94FD6574, 0x927985B2, 0x8276DBCB, 0x02778176, 0xF8AF918D, 0x4E48F79E, 0x8F616DDF, 0xE29D840E, 0x842F7D83, 0x340CE5C8, 0x96BBB682, 0x93B4B148, 0xEF303CAB, 0x984FAF28, 0x779FAF9B, 0x92DC560D, 0x224D1E20, 0x8437AA88, 0x7D29DC96, 0x2756D3DC, 0x8B907CEE, 0xB51FD240, 0xE7C07CE3, 0xE566B4A1, 0xC3E9615E, 0x3CF8209D, 0x6094D1E3, 0xCD9CA341, 0x5C76460E, 0x00EA983B, 0xD4D67881, 0xFD47572C, 0xF76CEDD9, 0xBDA8229C, 0x127DADAA, 0x438A074E, 0x1F97C090, 0x081BDB8A, 0x93A07EBE, 0xB938CA15, 0x97B03CFF, 0x3DC2C0F8, 0x8D1AB2EC, 0x64380E51, 0x68CC7BFB, 0xD90F2788, 0x12490181, 0x5DE5FFD4, 0xDD7EF86A, 0x76A2E214, 0xB9A40368, 0x925D958F, 0x4B39FFFA, 0xBA39AEE9, 0xA4FFD30B, 0xFAF7933B, 0x6D498623, 0x193CBCFA, 0x27627545, 0x825CF47A, 0x61BD8BA0, 0xD11E42D1, 0xCEAD04F4, 0x127EA392, 0x10428DB7, 0x8272A972, 0x9270C4A8, 0x127DE50B, 0x285BA1C8, 0x3C62F44F, 0x35C0EAA5, 0xE805D231, 0x428929FB, 0xB4FCDF82, 0x4FB66A53, 0x0E7DC15B, 0x1F081FAB, 0x108618AE, 0xFCFD086D, 0xF9FF2889, 0x694BCC11, 0x236A5CAE, 0x12DECA4D, 0x2C3F8CC5, 0xD2D02DFE, 0xF8EF5896, 0xE4CF52DA, 0x95155B67, 0x494A488C, 0xB9B6A80C, 0x5C8F82BC, 0x89D36B45, 0x3A609437, 0xEC00C9A9, 0x44715253, 0x0A874B49, 0xD773BC40, 0x7C34671C, 0x02717EF6, 0x4FEB5536, 0xA2D02FFF, 0xD2BF60C4, 0xD43F03C0, 0x50B4EF6D, 0x07478CD1, 0x006E1888, 0xA2E53F55, 0xB9E6D4BC, 0xA2048016, 0x97573833, 0xD7207D67, 0xDE0F8F3D, 0x72F87B33, 0xABCC4F33, 0x7688C55D, 0x7B00A6B0, 0x947B0001, 0x570075D2, 0xF9BB88F8, 0x8942019E, 0x4264A5FF, 0x856302E0, 0x72DBD92B, 0xEE971B69, 0x6EA22FDE, 0x5F08AE2B, 0xAF7A616D, 0xE5C98767, 0xCF1FEBD2, 0x61EFC8C2, 0xF1AC2571, 0xCC8239C2, 0x67214CB8, 0xB1E583D1, 0xB7DC3E62, 0x7F10BDCE, 0xF90A5C38, 0x0FF0443D, 0x606E6DC6, 0x60543A49, 0x5727C148, 0x2BE98A1D, 0x8AB41738, 0x20E1BE24, 0xAF96DA0F, 0x68458425, 0x99833BE5, 0x600D457D, 0x282F9350, 0x8334B362, 0xD91D1120, 0x2B6D8DA0, 0x642B1E31, 0x9C305A00, 0x52BCE688, 0x1B03588A, 0xF7BAEFD5, 0x4142ED9C, 0xA4315C11, 0x83323EC5, 0xDFEF4636, 0xA133C501, 0xE9D3531C, 0xEE353783 }; static const u32 cast_sbox4[256] = { 0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF, 0xD273A298, 0x4A4F7BDB, 0x64AD8C57, 0x85510443, 0xFA020ED1, 0x7E287AFF, 0xE60FB663, 0x095F35A1, 0x79EBF120, 0xFD059D43, 0x6497B7B1, 0xF3641F63, 0x241E4ADF, 0x28147F5F, 0x4FA2B8CD, 0xC9430040, 0x0CC32220, 0xFDD30B30, 0xC0A5374F, 0x1D2D00D9, 0x24147B15, 0xEE4D111A, 0x0FCA5167, 0x71FF904C, 0x2D195FFE, 0x1A05645F, 0x0C13FEFE, 0x081B08CA, 0x05170121, 0x80530100, 0xE83E5EFE, 0xAC9AF4F8, 0x7FE72701, 0xD2B8EE5F, 0x06DF4261, 0xBB9E9B8A, 0x7293EA25, 0xCE84FFDF, 0xF5718801, 0x3DD64B04, 0xA26F263B, 0x7ED48400, 0x547EEBE6, 0x446D4CA0, 0x6CF3D6F5, 0x2649ABDF, 0xAEA0C7F5, 0x36338CC1, 0x503F7E93, 0xD3772061, 0x11B638E1, 0x72500E03, 0xF80EB2BB, 0xABE0502E, 0xEC8D77DE, 0x57971E81, 0xE14F6746, 0xC9335400, 0x6920318F, 0x081DBB99, 0xFFC304A5, 0x4D351805, 0x7F3D5CE3, 0xA6C866C6, 0x5D5BCCA9, 0xDAEC6FEA, 0x9F926F91, 0x9F46222F, 0x3991467D, 0xA5BF6D8E, 0x1143C44F, 0x43958302, 0xD0214EEB, 0x022083B8, 0x3FB6180C, 0x18F8931E, 0x281658E6, 0x26486E3E, 0x8BD78A70, 0x7477E4C1, 0xB506E07C, 0xF32D0A25, 0x79098B02, 0xE4EABB81, 0x28123B23, 0x69DEAD38, 0x1574CA16, 0xDF871B62, 0x211C40B7, 0xA51A9EF9, 0x0014377B, 0x041E8AC8, 0x09114003, 0xBD59E4D2, 0xE3D156D5, 0x4FE876D5, 0x2F91A340, 0x557BE8DE, 0x00EAE4A7, 0x0CE5C2EC, 0x4DB4BBA6, 0xE756BDFF, 0xDD3369AC, 0xEC17B035, 0x06572327, 0x99AFC8B0, 0x56C8C391, 0x6B65811C, 0x5E146119, 0x6E85CB75, 0xBE07C002, 0xC2325577, 0x893FF4EC, 0x5BBFC92D, 0xD0EC3B25, 0xB7801AB7, 0x8D6D3B24, 0x20C763EF, 0xC366A5FC, 0x9C382880, 0x0ACE3205, 0xAAC9548A, 0xECA1D7C7, 0x041AFA32, 0x1D16625A, 0x6701902C, 0x9B757A54, 0x31D477F7, 0x9126B031, 0x36CC6FDB, 0xC70B8B46, 0xD9E66A48, 0x56E55A79, 0x026A4CEB, 0x52437EFF, 0x2F8F76B4, 0x0DF980A5, 0x8674CDE3, 0xEDDA04EB, 0x17A9BE04, 0x2C18F4DF, 0xB7747F9D, 0xAB2AF7B4, 0xEFC34D20, 0x2E096B7C, 0x1741A254, 0xE5B6A035, 0x213D42F6, 0x2C1C7C26, 0x61C2F50F, 0x6552DAF9, 0xD2C231F8, 0x25130F69, 0xD8167FA2, 0x0418F2C8, 0x001A96A6, 0x0D1526AB, 0x63315C21, 0x5E0A72EC, 0x49BAFEFD, 0x187908D9, 0x8D0DBD86, 0x311170A7, 0x3E9B640C, 0xCC3E10D7, 0xD5CAD3B6, 0x0CAEC388, 0xF73001E1, 0x6C728AFF, 0x71EAE2A1, 0x1F9AF36E, 0xCFCBD12F, 0xC1DE8417, 0xAC07BE6B, 0xCB44A1D8, 0x8B9B0F56, 0x013988C3, 0xB1C52FCA, 0xB4BE31CD, 0xD8782806, 0x12A3A4E2, 0x6F7DE532, 0x58FD7EB6, 0xD01EE900, 0x24ADFFC2, 0xF4990FC5, 0x9711AAC5, 0x001D7B95, 0x82E5E7D2, 0x109873F6, 0x00613096, 0xC32D9521, 0xADA121FF, 0x29908415, 0x7FBB977F, 0xAF9EB3DB, 0x29C9ED2A, 0x5CE2A465, 0xA730F32C, 0xD0AA3FE8, 0x8A5CC091, 0xD49E2CE7, 0x0CE454A9, 0xD60ACD86, 0x015F1919, 0x77079103, 0xDEA03AF6, 0x78A8565E, 0xDEE356DF, 0x21F05CBE, 0x8B75E387, 0xB3C50651, 0xB8A5C3EF, 0xD8EEB6D2, 0xE523BE77, 0xC2154529, 0x2F69EFDF, 0xAFE67AFB, 0xF470C4B2, 0xF3E0EB5B, 0xD6CC9876, 0x39E4460C, 0x1FDA8538, 0x1987832F, 0xCA007367, 0xA99144F8, 0x296B299E, 0x492FC295, 0x9266BEAB, 0xB5676E69, 0x9BD3DDDA, 0xDF7E052F, 0xDB25701C, 0x1B5E51EE, 0xF65324E6, 0x6AFCE36C, 0x0316CC04, 0x8644213E, 0xB7DC59D0, 0x7965291F, 0xCCD6FD43, 0x41823979, 0x932BCDF6, 0xB657C34D, 0x4EDFD282, 0x7AE5290C, 0x3CB9536B, 0x851E20FE, 0x9833557E, 0x13ECF0B0, 0xD3FFB372, 0x3F85C5C1, 0x0AEF7ED2 }; static const u32 cast_sbox5[256] = { 0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF, 0xA6337911, 0xB86A7FFF, 0x1DD358F5, 0x44DD9D44, 0x1731167F, 0x08FBF1FA, 0xE7F511CC, 0xD2051B00, 0x735ABA00, 0x2AB722D8, 0x386381CB, 0xACF6243A, 0x69BEFD7A, 0xE6A2E77F, 0xF0C720CD, 0xC4494816, 0xCCF5C180, 0x38851640, 0x15B0A848, 0xE68B18CB, 0x4CAADEFF, 0x5F480A01, 0x0412B2AA, 0x259814FC, 0x41D0EFE2, 0x4E40B48D, 0x248EB6FB, 0x8DBA1CFE, 0x41A99B02, 0x1A550A04, 0xBA8F65CB, 0x7251F4E7, 0x95A51725, 0xC106ECD7, 0x97A5980A, 0xC539B9AA, 0x4D79FE6A, 0xF2F3F763, 0x68AF8040, 0xED0C9E56, 0x11B4958B, 0xE1EB5A88, 0x8709E6B0, 0xD7E07156, 0x4E29FEA7, 0x6366E52D, 0x02D1C000, 0xC4AC8E05, 0x9377F571, 0x0C05372A, 0x578535F2, 0x2261BE02, 0xD642A0C9, 0xDF13A280, 0x74B55BD2, 0x682199C0, 0xD421E5EC, 0x53FB3CE8, 0xC8ADEDB3, 0x28A87FC9, 0x3D959981, 0x5C1FF900, 0xFE38D399, 0x0C4EFF0B, 0x062407EA, 0xAA2F4FB1, 0x4FB96976, 0x90C79505, 0xB0A8A774, 0xEF55A1FF, 0xE59CA2C2, 0xA6B62D27, 0xE66A4263, 0xDF65001F, 0x0EC50966, 0xDFDD55BC, 0x29DE0655, 0x911E739A, 0x17AF8975, 0x32C7911C, 0x89F89468, 0x0D01E980, 0x524755F4, 0x03B63CC9, 0x0CC844B2, 0xBCF3F0AA, 0x87AC36E9, 0xE53A7426, 0x01B3D82B, 0x1A9E7449, 0x64EE2D7E, 0xCDDBB1DA, 0x01C94910, 0xB868BF80, 0x0D26F3FD, 0x9342EDE7, 0x04A5C284, 0x636737B6, 0x50F5B616, 0xF24766E3, 0x8ECA36C1, 0x136E05DB, 0xFEF18391, 0xFB887A37, 0xD6E7F7D4, 0xC7FB7DC9, 0x3063FCDF, 0xB6F589DE, 0xEC2941DA, 0x26E46695, 0xB7566419, 0xF654EFC5, 0xD08D58B7, 0x48925401, 0xC1BACB7F, 0xE5FF550F, 0xB6083049, 0x5BB5D0E8, 0x87D72E5A, 0xAB6A6EE1, 0x223A66CE, 0xC62BF3CD, 0x9E0885F9, 0x68CB3E47, 0x086C010F, 0xA21DE820, 0xD18B69DE, 0xF3F65777, 0xFA02C3F6, 0x407EDAC3, 0xCBB3D550, 0x1793084D, 0xB0D70EBA, 0x0AB378D5, 0xD951FB0C, 0xDED7DA56, 0x4124BBE4, 0x94CA0B56, 0x0F5755D1, 0xE0E1E56E, 0x6184B5BE, 0x580A249F, 0x94F74BC0, 0xE327888E, 0x9F7B5561, 0xC3DC0280, 0x05687715, 0x646C6BD7, 0x44904DB3, 0x66B4F0A3, 0xC0F1648A, 0x697ED5AF, 0x49E92FF6, 0x309E374F, 0x2CB6356A, 0x85808573, 0x4991F840, 0x76F0AE02, 0x083BE84D, 0x28421C9A, 0x44489406, 0x736E4CB8, 0xC1092910, 0x8BC95FC6, 0x7D869CF4, 0x134F616F, 0x2E77118D, 0xB31B2BE1, 0xAA90B472, 0x3CA5D717, 0x7D161BBA, 0x9CAD9010, 0xAF462BA2, 0x9FE459D2, 0x45D34559, 0xD9F2DA13, 0xDBC65487, 0xF3E4F94E, 0x176D486F, 0x097C13EA, 0x631DA5C7, 0x445F7382, 0x175683F4, 0xCDC66A97, 0x70BE0288, 0xB3CDCF72, 0x6E5DD2F3, 0x20936079, 0x459B80A5, 0xBE60E2DB, 0xA9C23101, 0xEBA5315C, 0x224E42F2, 0x1C5C1572, 0xF6721B2C, 0x1AD2FFF3, 0x8C25404E, 0x324ED72F, 0x4067B7FD, 0x0523138E, 0x5CA3BC78, 0xDC0FD66E, 0x75922283, 0x784D6B17, 0x58EBB16E, 0x44094F85, 0x3F481D87, 0xFCFEAE7B, 0x77B5FF76, 0x8C2302BF, 0xAAF47556, 0x5F46B02A, 0x2B092801, 0x3D38F5F7, 0x0CA81F36, 0x52AF4A8A, 0x66D5E7C0, 0xDF3B0874, 0x95055110, 0x1B5AD7A8, 0xF61ED5AD, 0x6CF6E479, 0x20758184, 0xD0CEFA65, 0x88F7BE58, 0x4A046826, 0x0FF6F8F3, 0xA09C7F70, 0x5346ABA0, 0x5CE96C28, 0xE176EDA3, 0x6BAC307F, 0x376829D2, 0x85360FA9, 0x17E3FE2A, 0x24B79767, 0xF5A96B20, 0xD6CD2595, 0x68FF1EBF, 0x7555442C, 0xF19F06BE, 0xF9E0659A, 0xEEB9491D, 0x34010718, 0xBB30CAB8, 0xE822FE15, 0x88570983, 0x750E6249, 0xDA627E55, 0x5E76FFA8, 0xB1534546, 0x6D47DE08, 0xEFE9E7D4 }; static const u32 cast_sbox6[256] = { 0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867, 0xE2337F7C, 0x95DB08E7, 0x016843B4, 0xECED5CBC, 0x325553AC, 0xBF9F0960, 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9, 0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732, 0x8989B138, 0x33F14961, 0xC01937BD, 0xF506C6DA, 0xE4625E7E, 0xA308EA99, 0x4E23E33C, 0x79CBD7CC, 0x48A14367, 0xA3149619, 0xFEC94BD5, 0xA114174A, 0xEAA01866, 0xA084DB2D, 0x09A8486F, 0xA888614A, 0x2900AF98, 0x01665991, 0xE1992863, 0xC8F30C60, 0x2E78EF3C, 0xD0D51932, 0xCF0FEC14, 0xF7CA07D2, 0xD0A82072, 0xFD41197E, 0x9305A6B0, 0xE86BE3DA, 0x74BED3CD, 0x372DA53C, 0x4C7F4448, 0xDAB5D440, 0x6DBA0EC3, 0x083919A7, 0x9FBAEED9, 0x49DBCFB0, 0x4E670C53, 0x5C3D9C01, 0x64BDB941, 0x2C0E636A, 0xBA7DD9CD, 0xEA6F7388, 0xE70BC762, 0x35F29ADB, 0x5C4CDD8D, 0xF0D48D8C, 0xB88153E2, 0x08A19866, 0x1AE2EAC8, 0x284CAF89, 0xAA928223, 0x9334BE53, 0x3B3A21BF, 0x16434BE3, 0x9AEA3906, 0xEFE8C36E, 0xF890CDD9, 0x80226DAE, 0xC340A4A3, 0xDF7E9C09, 0xA694A807, 0x5B7C5ECC, 0x221DB3A6, 0x9A69A02F, 0x68818A54, 0xCEB2296F, 0x53C0843A, 0xFE893655, 0x25BFE68A, 0xB4628ABC, 0xCF222EBF, 0x25AC6F48, 0xA9A99387, 0x53BDDB65, 0xE76FFBE7, 0xE967FD78, 0x0BA93563, 0x8E342BC1, 0xE8A11BE9, 0x4980740D, 0xC8087DFC, 0x8DE4BF99, 0xA11101A0, 0x7FD37975, 0xDA5A26C0, 0xE81F994F, 0x9528CD89, 0xFD339FED, 0xB87834BF, 0x5F04456D, 0x22258698, 0xC9C4C83B, 0x2DC156BE, 0x4F628DAA, 0x57F55EC5, 0xE2220ABE, 0xD2916EBF, 0x4EC75B95, 0x24F2C3C0, 0x42D15D99, 0xCD0D7FA0, 0x7B6E27FF, 0xA8DC8AF0, 0x7345C106, 0xF41E232F, 0x35162386, 0xE6EA8926, 0x3333B094, 0x157EC6F2, 0x372B74AF, 0x692573E4, 0xE9A9D848, 0xF3160289, 0x3A62EF1D, 0xA787E238, 0xF3A5F676, 0x74364853, 0x20951063, 0x4576698D, 0xB6FAD407, 0x592AF950, 0x36F73523, 0x4CFB6E87, 0x7DA4CEC0, 0x6C152DAA, 0xCB0396A8, 0xC50DFE5D, 0xFCD707AB, 0x0921C42F, 0x89DFF0BB, 0x5FE2BE78, 0x448F4F33, 0x754613C9, 0x2B05D08D, 0x48B9D585, 0xDC049441, 0xC8098F9B, 0x7DEDE786, 0xC39A3373, 0x42410005, 0x6A091751, 0x0EF3C8A6, 0x890072D6, 0x28207682, 0xA9A9F7BE, 0xBF32679D, 0xD45B5B75, 0xB353FD00, 0xCBB0E358, 0x830F220A, 0x1F8FB214, 0xD372CF08, 0xCC3C4A13, 0x8CF63166, 0x061C87BE, 0x88C98F88, 0x6062E397, 0x47CF8E7A, 0xB6C85283, 0x3CC2ACFB, 0x3FC06976, 0x4E8F0252, 0x64D8314D, 0xDA3870E3, 0x1E665459, 0xC10908F0, 0x513021A5, 0x6C5B68B7, 0x822F8AA0, 0x3007CD3E, 0x74719EEF, 0xDC872681, 0x073340D4, 0x7E432FD9, 0x0C5EC241, 0x8809286C, 0xF592D891, 0x08A930F6, 0x957EF305, 0xB7FBFFBD, 0xC266E96F, 0x6FE4AC98, 0xB173ECC0, 0xBC60B42A, 0x953498DA, 0xFBA1AE12, 0x2D4BD736, 0x0F25FAAB, 0xA4F3FCEB, 0xE2969123, 0x257F0C3D, 0x9348AF49, 0x361400BC, 0xE8816F4A, 0x3814F200, 0xA3F94043, 0x9C7A54C2, 0xBC704F57, 0xDA41E7F9, 0xC25AD33A, 0x54F4A084, 0xB17F5505, 0x59357CBE, 0xEDBD15C8, 0x7F97C5AB, 0xBA5AC7B5, 0xB6F6DEAF, 0x3A479C3A, 0x5302DA25, 0x653D7E6A, 0x54268D49, 0x51A477EA, 0x5017D55B, 0xD7D25D88, 0x44136C76, 0x0404A8C8, 0xB8E5A121, 0xB81A928A, 0x60ED5869, 0x97C55B96, 0xEAEC991B, 0x29935913, 0x01FDB7F1, 0x088E8DFA, 0x9AB6F6F5, 0x3B4CBF9F, 0x4A5DE3AB, 0xE6051D35, 0xA0E1D855, 0xD36B4CF1, 0xF544EDEB, 0xB0E93524, 0xBEBB8FBD, 0xA2D762CF, 0x49C92F54, 0x38B5F331, 0x7128A454, 0x48392905, 0xA65B1DB8, 0x851C97BD, 0xD675CF2F }; static const u32 cast_sbox7[256] = { 0x85E04019, 0x332BF567, 0x662DBFFF, 0xCFC65693, 0x2A8D7F6F, 0xAB9BC912, 0xDE6008A1, 0x2028DA1F, 0x0227BCE7, 0x4D642916, 0x18FAC300, 0x50F18B82, 0x2CB2CB11, 0xB232E75C, 0x4B3695F2, 0xB28707DE, 0xA05FBCF6, 0xCD4181E9, 0xE150210C, 0xE24EF1BD, 0xB168C381, 0xFDE4E789, 0x5C79B0D8, 0x1E8BFD43, 0x4D495001, 0x38BE4341, 0x913CEE1D, 0x92A79C3F, 0x089766BE, 0xBAEEADF4, 0x1286BECF, 0xB6EACB19, 0x2660C200, 0x7565BDE4, 0x64241F7A, 0x8248DCA9, 0xC3B3AD66, 0x28136086, 0x0BD8DFA8, 0x356D1CF2, 0x107789BE, 0xB3B2E9CE, 0x0502AA8F, 0x0BC0351E, 0x166BF52A, 0xEB12FF82, 0xE3486911, 0xD34D7516, 0x4E7B3AFF, 0x5F43671B, 0x9CF6E037, 0x4981AC83, 0x334266CE, 0x8C9341B7, 0xD0D854C0, 0xCB3A6C88, 0x47BC2829, 0x4725BA37, 0xA66AD22B, 0x7AD61F1E, 0x0C5CBAFA, 0x4437F107, 0xB6E79962, 0x42D2D816, 0x0A961288, 0xE1A5C06E, 0x13749E67, 0x72FC081A, 0xB1D139F7, 0xF9583745, 0xCF19DF58, 0xBEC3F756, 0xC06EBA30, 0x07211B24, 0x45C28829, 0xC95E317F, 0xBC8EC511, 0x38BC46E9, 0xC6E6FA14, 0xBAE8584A, 0xAD4EBC46, 0x468F508B, 0x7829435F, 0xF124183B, 0x821DBA9F, 0xAFF60FF4, 0xEA2C4E6D, 0x16E39264, 0x92544A8B, 0x009B4FC3, 0xABA68CED, 0x9AC96F78, 0x06A5B79A, 0xB2856E6E, 0x1AEC3CA9, 0xBE838688, 0x0E0804E9, 0x55F1BE56, 0xE7E5363B, 0xB3A1F25D, 0xF7DEBB85, 0x61FE033C, 0x16746233, 0x3C034C28, 0xDA6D0C74, 0x79AAC56C, 0x3CE4E1AD, 0x51F0C802, 0x98F8F35A, 0x1626A49F, 0xEED82B29, 0x1D382FE3, 0x0C4FB99A, 0xBB325778, 0x3EC6D97B, 0x6E77A6A9, 0xCB658B5C, 0xD45230C7, 0x2BD1408B, 0x60C03EB7, 0xB9068D78, 0xA33754F4, 0xF430C87D, 0xC8A71302, 0xB96D8C32, 0xEBD4E7BE, 0xBE8B9D2D, 0x7979FB06, 0xE7225308, 0x8B75CF77, 0x11EF8DA4, 0xE083C858, 0x8D6B786F, 0x5A6317A6, 0xFA5CF7A0, 0x5DDA0033, 0xF28EBFB0, 0xF5B9C310, 0xA0EAC280, 0x08B9767A, 0xA3D9D2B0, 0x79D34217, 0x021A718D, 0x9AC6336A, 0x2711FD60, 0x438050E3, 0x069908A8, 0x3D7FEDC4, 0x826D2BEF, 0x4EEB8476, 0x488DCF25, 0x36C9D566, 0x28E74E41, 0xC2610ACA, 0x3D49A9CF, 0xBAE3B9DF, 0xB65F8DE6, 0x92AEAF64, 0x3AC7D5E6, 0x9EA80509, 0xF22B017D, 0xA4173F70, 0xDD1E16C3, 0x15E0D7F9, 0x50B1B887, 0x2B9F4FD5, 0x625ABA82, 0x6A017962, 0x2EC01B9C, 0x15488AA9, 0xD716E740, 0x40055A2C, 0x93D29A22, 0xE32DBF9A, 0x058745B9, 0x3453DC1E, 0xD699296E, 0x496CFF6F, 0x1C9F4986, 0xDFE2ED07, 0xB87242D1, 0x19DE7EAE, 0x053E561A, 0x15AD6F8C, 0x66626C1C, 0x7154C24C, 0xEA082B2A, 0x93EB2939, 0x17DCB0F0, 0x58D4F2AE, 0x9EA294FB, 0x52CF564C, 0x9883FE66, 0x2EC40581, 0x763953C3, 0x01D6692E, 0xD3A0C108, 0xA1E7160E, 0xE4F2DFA6, 0x693ED285, 0x74904698, 0x4C2B0EDD, 0x4F757656, 0x5D393378, 0xA132234F, 0x3D321C5D, 0xC3F5E194, 0x4B269301, 0xC79F022F, 0x3C997E7E, 0x5E4F9504, 0x3FFAFBBD, 0x76F7AD0E, 0x296693F4, 0x3D1FCE6F, 0xC61E45BE, 0xD3B5AB34, 0xF72BF9B7, 0x1B0434C0, 0x4E72B567, 0x5592A33D, 0xB5229301, 0xCFD2A87F, 0x60AEB767, 0x1814386B, 0x30BCC33D, 0x38A0C07D, 0xFD1606F2, 0xC363519B, 0x589DD390, 0x5479F8E6, 0x1CB8D647, 0x97FD61A9, 0xEA7759F4, 0x2D57539D, 0x569A58CF, 0xE84E63AD, 0x462E1B78, 0x6580F87E, 0xF3817914, 0x91DA55F4, 0x40A230F3, 0xD1988F35, 0xB6E318D2, 0x3FFA50BC, 0x3D40F021, 0xC3C0BDAE, 0x4958C24C, 0x518F36B2, 0x84B1D370, 0x0FEDCE83, 0x878DDADA, 0xF2A279C7, 0x94E01BE8, 0x90716F4B, 0x954B8AA3 }; static const u32 cast_sbox8[256] = { 0xE216300D, 0xBBDDFFFC, 0xA7EBDABD, 0x35648095, 0x7789F8B7, 0xE6C1121B, 0x0E241600, 0x052CE8B5, 0x11A9CFB0, 0xE5952F11, 0xECE7990A, 0x9386D174, 0x2A42931C, 0x76E38111, 0xB12DEF3A, 0x37DDDDFC, 0xDE9ADEB1, 0x0A0CC32C, 0xBE197029, 0x84A00940, 0xBB243A0F, 0xB4D137CF, 0xB44E79F0, 0x049EEDFD, 0x0B15A15D, 0x480D3168, 0x8BBBDE5A, 0x669DED42, 0xC7ECE831, 0x3F8F95E7, 0x72DF191B, 0x7580330D, 0x94074251, 0x5C7DCDFA, 0xABBE6D63, 0xAA402164, 0xB301D40A, 0x02E7D1CA, 0x53571DAE, 0x7A3182A2, 0x12A8DDEC, 0xFDAA335D, 0x176F43E8, 0x71FB46D4, 0x38129022, 0xCE949AD4, 0xB84769AD, 0x965BD862, 0x82F3D055, 0x66FB9767, 0x15B80B4E, 0x1D5B47A0, 0x4CFDE06F, 0xC28EC4B8, 0x57E8726E, 0x647A78FC, 0x99865D44, 0x608BD593, 0x6C200E03, 0x39DC5FF6, 0x5D0B00A3, 0xAE63AFF2, 0x7E8BD632, 0x70108C0C, 0xBBD35049, 0x2998DF04, 0x980CF42A, 0x9B6DF491, 0x9E7EDD53, 0x06918548, 0x58CB7E07, 0x3B74EF2E, 0x522FFFB1, 0xD24708CC, 0x1C7E27CD, 0xA4EB215B, 0x3CF1D2E2, 0x19B47A38, 0x424F7618, 0x35856039, 0x9D17DEE7, 0x27EB35E6, 0xC9AFF67B, 0x36BAF5B8, 0x09C467CD, 0xC18910B1, 0xE11DBF7B, 0x06CD1AF8, 0x7170C608, 0x2D5E3354, 0xD4DE495A, 0x64C6D006, 0xBCC0C62C, 0x3DD00DB3, 0x708F8F34, 0x77D51B42, 0x264F620F, 0x24B8D2BF, 0x15C1B79E, 0x46A52564, 0xF8D7E54E, 0x3E378160, 0x7895CDA5, 0x859C15A5, 0xE6459788, 0xC37BC75F, 0xDB07BA0C, 0x0676A3AB, 0x7F229B1E, 0x31842E7B, 0x24259FD7, 0xF8BEF472, 0x835FFCB8, 0x6DF4C1F2, 0x96F5B195, 0xFD0AF0FC, 0xB0FE134C, 0xE2506D3D, 0x4F9B12EA, 0xF215F225, 0xA223736F, 0x9FB4C428, 0x25D04979, 0x34C713F8, 0xC4618187, 0xEA7A6E98, 0x7CD16EFC, 0x1436876C, 0xF1544107, 0xBEDEEE14, 0x56E9AF27, 0xA04AA441, 0x3CF7C899, 0x92ECBAE6, 0xDD67016D, 0x151682EB, 0xA842EEDF, 0xFDBA60B4, 0xF1907B75, 0x20E3030F, 0x24D8C29E, 0xE139673B, 0xEFA63FB8, 0x71873054, 0xB6F2CF3B, 0x9F326442, 0xCB15A4CC, 0xB01A4504, 0xF1E47D8D, 0x844A1BE5, 0xBAE7DFDC, 0x42CBDA70, 0xCD7DAE0A, 0x57E85B7A, 0xD53F5AF6, 0x20CF4D8C, 0xCEA4D428, 0x79D130A4, 0x3486EBFB, 0x33D3CDDC, 0x77853B53, 0x37EFFCB5, 0xC5068778, 0xE580B3E6, 0x4E68B8F4, 0xC5C8B37E, 0x0D809EA2, 0x398FEB7C, 0x132A4F94, 0x43B7950E, 0x2FEE7D1C, 0x223613BD, 0xDD06CAA2, 0x37DF932B, 0xC4248289, 0xACF3EBC3, 0x5715F6B7, 0xEF3478DD, 0xF267616F, 0xC148CBE4, 0x9052815E, 0x5E410FAB, 0xB48A2465, 0x2EDA7FA4, 0xE87B40E4, 0xE98EA084, 0x5889E9E1, 0xEFD390FC, 0xDD07D35B, 0xDB485694, 0x38D7E5B2, 0x57720101, 0x730EDEBC, 0x5B643113, 0x94917E4F, 0x503C2FBA, 0x646F1282, 0x7523D24A, 0xE0779695, 0xF9C17A8F, 0x7A5B2121, 0xD187B896, 0x29263A4D, 0xBA510CDF, 0x81F47C9F, 0xAD1163ED, 0xEA7B5965, 0x1A00726E, 0x11403092, 0x00DA6D77, 0x4A0CDD61, 0xAD1F4603, 0x605BDFB0, 0x9EEDC364, 0x22EBE6A8, 0xCEE7D28A, 0xA0E736A0, 0x5564A6B9, 0x10853209, 0xC7EB8F37, 0x2DE705CA, 0x8951570F, 0xDF09822B, 0xBD691A6C, 0xAA12E4F2, 0x87451C0F, 0xE0F6A27A, 0x3ADA4819, 0x4CF1764F, 0x0D771C2B, 0x67CDB156, 0x350D8384, 0x5938FA0F, 0x42399EF3, 0x36997B07, 0x0E84093D, 0x4AA93E61, 0x8360D87B, 0x1FA98B0C, 0x1149382C, 0xE97625A5, 0x0614D1B7, 0x0E25244B, 0x0C768347, 0x589E8D82, 0x0D2059D1, 0xA466BB1E, 0xF8DA0A82, 0x04F19130, 0xBA6E4EC0, 0x99265164, 0x1EE7230D, 0x50B2AD80, 0xEAEE6801, 0x8DB2A283, 0xEA8BF59E }; apg-2.2.3.dfsg.1/CHANGES0000644000175100017510000001215707730403247012151 0ustar mhmhapg-2.2.3 Fixed version info (-v). apg-2.2.2 Fixed permissions for source distribution. apg-2.2.1 Changed manpages of apg and apgd. apg-2.2.0 Added polish translation for APG PHP frontend. Added option -p (see apg(1) apgd(8)). Added option -t (see apg(1) apgd(8)). Added option -l (see apg(1)). Changed format of the bloom-filter file. Added converter utility to convert old format to the new one (bfconvert). Added option -i (see apgbfm(1)). Fixed some bugs. Some compatibility changes. Changed default apg options. apg-2.1.0 Some code cleanup. apg-2.1.0b1 Option [-E char_string] now works for pronounceable password generation too (see apg(1), apgd(8)). apg-2.1.0b0 Added new option [-e char_string] that allow to exclude some characters from password generation process. (works only for random password generation yet) apg-2.1.0a0 Added support for /dev/arandom for OpenBSD apg-2.1.0a0 Fixed some typing errors in the man pages System getopt() replaced with own apg_getopt(). All calls of bcopy() and bzero() replaced with memcpy() and memset(). Changed documentation. PRNG algorithm changed to use PID as an element of initial seed. Redesigned PHP frontend. Added support for German language. Implemented password quality ckeck based on filter. Now you can enforce APG to generate passwords that must contain numbers, special characters etc. Removed support for old style password generation mode definition. apg-2.0.0final Changed PHP frontend to work with PHP safe-mode. Version numbers of apg, apgd, apgbfm, apgonline changed to 2.0.0final. apg-2.0.0b1 Fixed error that has forced user to set world-write privileges on Bloom-filter file. (Thanks to Mike Robbins ) Fixed PHP frontend to clean-up generated HTML code. (Thanks to Mike Robbins ) apg-2.0.0b0 Some code style fixes. Support for "special" symbol-set usage for password generation in pronounceable mode (S mode). Support for "resticted special" symbol-set usage for password generation in pronounceable mode (R mode). New style of hyphenated password output for pronounceable password generation mode. apg-2.0.0a3 Better error handling in apgbfm. Added -q option for apgbfm and apg (quiet mode). Added PHP frontend for APG. apg-2.0.0a2 Added support for SHA1 algorithm used for random numbers and hash generation. Hash function used in apgbfm changed to SHA1. Added info to APG_TIPS file. apg-2.0.0a1 (not published) Finaly fixed some warnings during compilation process. Added support for OpenBSD. Added info to APG_TIPS file. apg-2.0.0a0 Added new algorithm (-b option) to check generated passwords quality (Bloom filter). Added utility apgbfm to manage Bloom filter. Some code style fixes. Added APG_TIPS file in documentation. apg-1.2.13 Added support for NetBSD. (Thanks to Tomasz Luchowski ). apg-1.2.12 Added support for AIX, and some compatibility reports. (Thanks to Philip Le Riche ). apg-1.2.11 Changed default owner of apg and apgd (now it is root). Some cosmetic changes. apg-1.2.1 Changed -R option. Changed documentation. apg-1.2.1b Changed impementation of -y option. Now you can disable it before compilation. Added option -M for new style password modes specification. (see apg(1) apgd(8)). Added support for IRIX. (Thanks to Andrew J. Caird ) apg-1.2.1a2 Added option -y (see apg(1)). (Thanks to Andrew J. Caird ) Some minior fixes for APG for Solaris. apg-1.2.1alpha Added option -R (see apg(1) and apgd(8)). apg-1.2.0 Changed random character password generation algorithm. Changed user random seed generation procedures. apg-1.1.61b Fixed directory permissions (thanks to Adrian Ho ). Fixed random segfault when run with the -s argument (thanks to Peter Pentchev ) apg-1.1.6b Fixed random number generation error. (Thanks to Rainer Wichmann ) Now RNG uses local time with precision of microseconds as initial seed. (Thanks to Rainer Wichmann ) Fixed error that was the reason of random APG crashes. Added support for /dev/random for seed generation. apg-1.1.5 Fixed some compiler warnings Fixed pronounceable password generation error with modes -C -N. But there is another bug ;-( Sorry... It is no more an error if min_pass_len > max_pass_len. Changed installation procedure Added option -d (see apg(1)). apg-1.1.4 Modified pronounceable password generation algorithm. Now support -N and -C options, but still pronounceable ;-) apg-1.0.4 Added option -c (see apg(1)).Changed apg.c, apg.1 manpage. apg-1.0.3 Fixed some code style errors. Changed INSTALL, apgd.8 manpage. apg-1.0.2 Improved event logging of apgd. Changed INSTALL. apg-1.0.1 Fixed password length error apg-2.2.3.dfsg.1/COPYING0000644000175100017510000000271507714471356012220 0ustar mhmhCopyright (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. apg-2.2.3.dfsg.1/doc/0000755000175100017510000000000010515124510011701 5ustar mhmhapg-2.2.3.dfsg.1/doc/APG_TIPS0000644000175100017510000000745507714471356013131 0ustar mhmh============================================================ = TIPS FOR APG = ============================================================ = This file contains some tips for APG. = = = = 1. If You wish to submit a tip please send an email to = = and if i find it useful i'll put = = Your tip in the APG_TIPS file of the next release. = = I will also put Your tip on the APG website as soon = = as it posible. = = 2. If you wish to remove or update Your tip please send = = en email to . I will remove/update = = Your tip in the APG_TIPS file of the next release. = = I'll remove/update Your tip on the APG website as = = soon as it posible. = = = = Adel I Mirzazhanov = = a-del@iname.com = ============================================================ ###################################################### # 1. Elimination of certain characters from the output # by Barton Hodges ###################################################### I don't like to use "o"'s or "l"'s in my passwords because they looke like zeros and ones instead of O's and L's. I hacked together a little shell script to accomplish the elimination of certain characters from the output. ----------[cut here] #!/bin/sh genpw () { PW=$(/usr/local/bin/apg -L -m 10 -x 10 -n 1 | egrep -v [owl]) if [ "$PW" != "" ]; then echo $PW return 0; else return 1; fi } until genpw; do : ; done ----------[cut here] Note: Since apg-2.1.0b0 you can use [-e char_string] option to do the same thing. ####################################################### # 2. APG and xinetd # by Tomaz Zupan ####################################################### 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]
      
    
--------> [cut here] ###################################################### # 4. APG v2.1.0b0 and [R,r] letters in mode string # by Adel I. Mirzazhanov ###################################################### 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. apg-2.2.3.dfsg.1/doc/man/0000755000175100017510000000000007714471356012500 5ustar mhmhapg-2.2.3.dfsg.1/doc/man/apg.10000644000175100017510000001715107714471356013336 0ustar mhmh.\" Man page for apg. .\" Licensed under BSD-like License. .\" Created by Adel I. Mirzazhanov .\" .TH APG 1 "2003 Aug 04" "Automated Password Generator" "User Manual" .SH NAME apg \- generates several random passwords .SH SYNOPSIS .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-p min_substr_len\fP] [\fB-s\fP] [\fB-c cl_seed\fP] [\fB-d\fP] [\fB-y\fP] [\fB-l\fP] [\fB-t\fP] [\fB-q\fP] [\fB-h\fP] [\fB-v\fP] .PP .SH DESCRIPTION .B apg generates several random passwords. It uses several password generation algorithms (currently two) and a built-in pseudo random number generator. .PP Default algorithm is pronounceable password generation algorithm designed by .B Morrie Gasser and described in .B "A Random Word Generator For Pronounceable Passwords" .I National Technical Information Service (NTIS) .B AD-A-017676. The original paper is very old and had never been put online, so I have to use .I NIST implementation described in .B FIPS-181. .PP Another algorithm is simple random character generation algorithm, but it uses four user-defined symbol sets to produce random password. It means that user can choose type of symbols that should appear in password. Symbol sets are: numeric symbol set .I (0,...,9) , capital letters symbol set .I (A,...,Z) , small letters symbol set .I (a,...,z) and special symbols symbol set .I (#,@,!,...). .PP Built-in pseudo random number generator is an implementation of algorithm described in .B Appendix C of ANSI X9.17 or .B RFC1750 with exception that it uses .I CAST or .I SHA-1 instead of .I Triple DES. It uses local time with precision of microseconds (see \fBgettimeofday\fP(2)) and \fI/dev/random\fP (if available) to produce initial random seed. .PP .B apg also have the ability to check generated password quality using dictionary. You can use this ability if you specify command-line options .B -r .I dictfile or .B -b .I filtername where \fIdictfile\fP is the dictionary file name and \fIfiltername\fP is the name of Bloom filter file. In that dictionary you may place words (one per line) that should not appear as generated passwords. For example: user names, common words, etc. You even can use one of the dictionaries that come with .I dictionary password crackers. Bloom filter file should be created with \fBapgbfm\fP(1) utility included in apg distribution. In future releases I plan to implement some other techniques to check passwords (like pattern check) just to make life easier. .sp .SH "OPTIONS" .SS "Password generation modes options" .TP .B -a algorithm use .B algorithm for password generation. .RS .B 0 - (default) pronounceable password generation .br .B 1 - random character password generation .RE .TP .B -n num_of_pass generate .B num_of_pass number of passwords. Default is 6. .TP .B -m min_pass_len generate password with minimum length .B min_pass_len. If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. Default minimum password length is 8. .TP .B -x max_pass_len generate password with maximum length .B max_pass_len. If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. Default maximum password length is 10. .TP .B -M mode Use symbolsets specified with \fBmode\fP for password generation. \fBmode\fP is a text string consisting of characters \fBS\fP, \fBs\fP, \fBN\fP, \fBn\fP, \fBC\fP, \fBc\fP, \fBL\fP, \fBl\fP. Where: .RS .TP .B S generator \fBmust\fP use special symbol set for every generated password. .TP .B s generator \fBshould\fP use special symbol set for password generation. .TP .B N generator \fBmust\fP use numeral symbol set for every generated password. .TP .B n generator \fBshould\fP use numeral symbol set for password generation. .TP .B C generator \fBmust\fP use capital symbol set for every generated password. .TP .B c generator \fBshould\fP use capital symbol set for password generation. .TP .B L generator \fBmust\fP use small letters symbol set for every generated password (always present if pronounceable password generation algorithm is used). .TP .B l generator \fBshould\fP use small letters symbol set for password generation. .TP .B R,r not supported any more. Use \fB-E char_string\fP option instead. .RE .RS .br \fBmode\fP can not be more than 4 characters in length. .PP .B Note: .br Usage of L, M, N, C will slow down password generation process. .PP .B Examples: .br \fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP .RE .TP .B -E char_string exclude characters in \fBchar_string\fP from password generation process (in pronounceable password generation mode you can not exclude small letters). To include special symbols that can be recognized by shell (apostrophe, quotes, dollar sign, etc.) in \fBchar_string\fP use the backslashed versions. .RS .PP .B Examples: .PP Command \fBapg -a 1 -M n -n 3 -m 8 -E 23456789\fP will generate a set of passwords that will look like this .br \fB10100110\fP .br \fB01111000\fP .br \fB11011101\fP .br .PP Command \fBapg -a 1 -M nc -n 3 -m 26 -E GHIJKLMNOPQRSTUVWXYZ\fP will generate a set of passwords that will look like this .br \fB16A1653CD4DE5E7BD9584A3476\fP .br \fBC8F78E06944AFD57FB9CB882BC\fP .br \fB8C8DF37CD792D36D056BBD5002\fP .br .RE .SS "Password quality control options" .TP .B -r \fIdictfile\fP check generated passwords for their appearance in .I dictfile .TP .B -b \fIfilter_file\fP check generated passwords for their appearance in \fIfilter_file\fP. \fIfilter_file\fP should be created with \fBapgbfm\fP(1) utility. .TP .B -p min_substr_len this option tells \fBapg\fP(1) to check every substring of the generated password for appearance in \fIfilter_file\fP. If any of such substrings would be found in the \fIfilter_file\fP then generated password would be rejected and apg(1) will generate another one. \fBmin_substr_len\fP specifies minimum substring length to check. This option is active only if \fB-b\fP option is defined. .SS "Pseudo random number generator options" .TP .B -s ask user for random sequence for password generation .TP .B -c cl_seed use .B cl_seed as a random seed for password generation. I use it when i have to generate passwords in a shell script. .SS "Password output options" .br .TP .B -d do NOT use any delimiters between generated passwords. I use it when i have to generate passwords in a shell script. .TP .B -y print generated passwords and crypted passwords (see man \fBcrypt\fP(3)) .TP .B -q quiet mode (do not print warnings) .TP .B -l spell genetated passwords. Useful when you want to read generated password by telephone. .RS .B WARNING: Think twice before read your password by phone. .RE .TP .B -t print pronunciation for generated pronounceable password .TP .B -h print help information and exit .TP .B -v print version information and exit .SH "DEFAULT OPTIONS" \fBapg -a 0 -M sncl -n 6 -x 10 -m 8\fP (new style) .PP If you want to generate really secure passwords, you should use option \fB-s\fP. To simplify .B apg usage, you can write a small shell script. For example: .br \fB[begin]----> pwgen.sh\fP .br \fB#!/bin/sh\fP .br \fB/usr/local/bin/apg -m 8 -x 12 -s\fP .br \fB[ end ]----> pwgen.sh\fP .SH "EXIT CODE" On successful completion of its task, .B apg will complete with exit code 0. An exit code of -1 indicates an error occurred. Textual errors are written to the standard error stream. .SH "DIAGNOSTICS" If \fI/dev/random\fP is not available, \fBapg\fP will display a message about it. .SH "FILES" .B None. .SH "BUGS" .B None. If you've found one, please send bug description to the author. .SH "SEE ALSO" \fBapgd\fP(8), \fBapgbfm\fP(1) .SH "AUTHOR" Adel I. Mirzazhanov, .br Project home page: http://www.adel.nursat.kz/apg/ apg-2.2.3.dfsg.1/doc/man/apgbfm.10000644000175100017510000000772307714471356014027 0ustar mhmh.\" Man page for apgbfm. .\" Licensed under BSD-like License. .\" Created by Adel I. Mirzazhanov .\" .TH APGBFM 1 "2003 Jun 19" "Automated Password Generator" "User Manual" .SH NAME apgbfm \- APG Bloom filter management program .SH SYNOPSIS .B apgbfm \fB-f\fP \fIfilter\fP \fB-n\fP \fBnumofwords\fP [\fB-q\fP] [\fB-s\fP] .br .B apgbfm \fB-f\fP \fIfilter\fP \fB-d\fP \fIdictfile\fP [\fB-q\fP] [\fB-s\fP] .br .B apgbfm \fB-f\fP \fIfilter\fP \fB-a\fP \fBword\fP [\fB-q\fP] .br .B apgbfm \fB-f\fP \fIfilter\fP \fB-A\fP \fIdictfile\fP [\fB-q\fP] .br .B apgbfm \fB-f\fP \fIfilter\fP \fB-c\fP \fBword\fP [\fB-q\fP] .br .B apgbfm \fB-f\fP \fIfilter\fP \fB-C\fP \fIdictfile\fP [\fB-q\fP] .br .B apgbfm \fB-i\fP \fIfilter\fP .br .B apgbfm [\fB-v\fP] [\fB-h\fP] .PP .SH DESCRIPTION .B apgbfm is used to manage Bloom filter that is used to restrict password generation in \fBAPG\fP pasword generation software. Usage of the Bloom filter allows to speed up password check for large dictionaries and has some other benefits. .PP The idea to use Bloom filter for that purpose is came from the description of the \fBOPUS\fP project \fBOPUS: Preventing Weak Password Choices\fP \fIPurdue Technical Report CSD-TR 92-028\fP writen by \fIEugene H. Spafford\fP. .PP You can obtain this article from: .br \fIhttp://www.cerias.purdue.edu/homes/spaf/tech-reps/9128.ps\fP .br It has very nice description of Bloom filter and it's advantages for password checking systems. .PP In simple words, \fBapgbfm\fP generates \fIn\fP hash values for every word and sets corresponding bits in filter file to 1. To check the word \fBapgbfm\fP generates the same hash functions for that word and if all \fIn\fP corresponding bits in filter file are set to 1 then it suppose that word exists in dicionary. \fBapgbfm\fP uses \fBSHA-1\fP as a hash function. .PP \fBapgbfm\fP can be used as standalone utility, not only with \fBapg\fP, or \fBapgd\fP. .PP .TP .B WARNING !!! Filter file format can be changed in the future. I'll try to make file formats compatible but i can not guaranty this. .TP .B WARNING !!! \fBapgbfm\fP may slow down your computer during filter creation. .SH "OPTIONS" .TP .B -f \fIfilter\fP use \fIfilter\fP as the name for Bloom filter filename. .TP .B -i \fIfilter\fP print information about \fIfilter\fP. .TP .B -n numofwords create new empty filter for \fBnumofwords\fP number of words. Useful when you want to fill filter dynamicaly. .TP .B -d \fIdictfile\fP create new filter from \fIdictfile\fP. It may take a lot of time to generate filter from a big dictionary. In that dictionary you may place words (one per line) that should not appear as generated passwords. For example: user names common words, etc. You even can use one of the dictionaries that come with \fIdictionary password crackers\fP. This check is case sensitive. For example, if you want to reject word 'root', you should insert in \fIdictfile\fP words: root, Root, RoOt, ... , ROOT. To indicate that program is working \fBapgbfm\fP prints dot for every 100 words added in dictionary. .TP .B -a word add \fBword\fP to the filter. .TP .B -A \fIdictfile\fP add all words from \fIdictfile\fP to the filter. To indicate that program is working \fBapgbfm\fP prints dot for every 100 words added in dictionary. .TP .B -c word check \fBword\fP for appearance in the filter. .TP .B -C \fIdictfile\fP check every word from \fIdictfile\fP for appearance in the filter. .TP .B -q quiet mode. .TP .B -s create new filter in case-insensitive mode. .TP .B -v print version information. .TP .B -h print help information. .SH "EXIT CODE" On successful completion of its task, .B apgbfm will complete with exit code 0. An exit code of -1 indicates an error occurred. Textual errors are written to the standard error stream. .SH "FILES" .B None. .SH "BUGS" .B None. If you've found one, please send bug description to the author. .PP This man page is Alpha too. .SH "SEE ALSO" \fBapgd\fP(8), \fBapg\fP(1) .SH "AUTHOR" Adel I. Mirzazhanov, .br Project home page: http://www.adel.nursat.kz/apg/ apg-2.2.3.dfsg.1/doc/man/apgd.80000644000175100017510000001646707714471356013522 0ustar mhmh.\" Man page for apgd. .\" Licensed under BSD-like License. .\" Created by Adel I. Mirzazhanov .\" .TH APGD 8 "2003 Aug 4" "Automated Password Generator" "User Manual" .SH NAME apgd \- server that generates several random passwords .SH SYNOPSIS .B apgd [\fB-a algorithm\fP] [\fB-M mode\fP] [\fB-E char_string\fP] [\fB-n num_of_pass\fP] [\fB-m min_pass_len\fP] [\fB-x max_pass_len\fP] [\fB-r\fP \fIdictfile\fP] [\fB-b\fP \fIfilter_file\fP] [\fB-p min_substr_len\fP] [\fB-t\fP] [\fB-l\fP] .PP .SH DESCRIPTION .B apgd program is a server that supports .B "Password Generation Protocol" described in .B RFC972. It uses several password generation algorithms (currently two) and a built-in pseudo random number generator. .PP .B apgd is normally invoked by the Internet superserver (see .B inetd (8)) for requests to connect to the pwdgen port (pwdgen port is 129 according to .B RFC1700 ) as indicated by the .I /etc/services file (see .B services (5)). .PP Default algorithm is pronounceable password generation algorithm designed by .B Morrie Gasser and described in .B """A Random Word Generator For Pronounceable Passwords""" .I National Technical Information Service (NTIS) .B AD-A-017676. The original paper is very old and had never been put online, so I have to use .I NIST implementation described in .B FIPS-181. .PP Another algorithm is simple random character generation algorithm, but it uses four user-defined symbol sets to produce random password. It means that user can choose type of symbols that should appear in password. Symbol sets are: numeric symbol set .I (0,...,9) , capital letters symbol set .I (A,...,Z) , small letters symbol set .I (a,...,z) and special symbols symbol set .I (#,@,!,...). .PP Built-in pseudo random number generator is an implementation of algorithm described in .B Appendix C of ANSI X9.17 or .B RFC1750 with exception that it uses .I CAST or .I SHA-1 instead of .I Triple DES. It uses local time with precision of microseconds (see \fBgettimeofday\fP(2)) and \fI/dev/random\fP (if available) to produce initial random seed. .PP .B apgd also have the ability to check generated password quality using dictionary. You can use this ability if you specify command-line option .B -r .I dictfile or .B -b .I filtername where \fIdictfile\fP is dictionary file name and \fIfiltername\fP is the name of Bloom filter file. In that dictionary you may place words (one per line) that should not appear as generated passwords. For example: user names common words, etc. You even can use one of the dictionaries that come with .I dictionary password crackers. Bloom filter file should be created with \fBapgbfm\fP(1) utility included in apg distribution. In future releases I plan to implement some other techniques to check passwords just to make life easier. .PP .B apgd has the ability log user password generation activity and internal debug information. It does this using .br .I facility = .I daemon .RS .br .I priority = .I info for user password generation activity logging .br .I priority = .I debug for internal debug information .br .RE See the \fBsyslogd\fP(8) and \fBsyslog.conf\fP(5) man pages for information on how to configure your syslog daemon. .sp .SH "OPTIONS" .SS "Password generation modes options" .TP .B -a algorithm use .B algorithm for password generation. .RS .B 0 - (default) pronounceable password generation .br .B 1 - random character password generation .RE .TP .B -n num_of_pass generate .B num_of_pass number of passwords. Default is 6. .TP .B -m min_pass_len generate password with minimum length .B min_pass_len. If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. Default minimum password length is 8. .TP .B -x max_pass_len generate password with maximum length .B max_pass_len If \fBmin_pass_len > max_pass_len\fP then \fBmax_pass_len = min_pass_len\fP. Default maximum password length is 10. .TP .B -M mode Use symbolsets specified with \fBmode\fP for password generation. \fBmode\fP is a text string consisting of characters \fBS\fP, \fBs\fP, \fBN\fP, \fBn\fP, \fBC\fP, \fBc\fP, \fBL\fP, \fBl\fP. Where: .RS .TP .B S generator \fBmust\fP use special symbol set for every generated password. .TP .B s generator \fBshould\fP use special symbol set for password generation. .TP .B N generator \fBmust\fP use numeral symbol set for every generated password. .TP .B n generator \fBshould\fP use numeral symbol set for password generation. .TP .B C generator \fBmust\fP use capital symbol set for every generated password. .TP .B c generator \fBshould\fP use capital symbol set for password generation. .TP .B L generator \fBmust\fP use small letters symbol set for every generated password (always present if pronounceable password generation algorithm is used). .TP .B l generator \fBshould\fP use small letters symbol set for password generation. .TP .B R,r not supported any more. Use \fB-E char_string\fP option instead. .RE .RS .br \fBmode\fP can not be more than 4 characters in length. .PP .B Note: .br Usage of L, M, N, C will slow down password generation process. .PP .B Examples: .br \fB-M sncl\fP or \fB-M SNCL\fP or \fB-M Cn\fP .RE .TP .B -E char_string exclude characters in \fBchar_string\fP from password generation process (in pronounceable password generation mode you can not exclude small letters). To include special symbols that can be recognized by shell (apostrophe, quotes, dollar sign, etc.) in \fBchar_string\fP use the backslashed versions. .RS .PP .B Examples: .PP Command \fBapgd -a 1 -M n -n 3 -m 8 -e 23456789\fP will generate a set of passwords that will look like this .br \fB10100110\fP .br \fB01111000\fP .br \fB11011101\fP .br .PP Command \fBapgd -a 1 -M nc -n 3 -m 26 -e GHIJKLMNOPQRSTUVWXYZ\fP will generate a set of passwords that will look like this .br \fB16A1653CD4DE5E7BD9584A3476\fP .br \fBC8F78E06944AFD57FB9CB882BC\fP .br \fB8C8DF37CD792D36D056BBD5002\fP .br .RE .SS "Password quality control options" .TP .B -r \fIdictfile\fP check generated passwords for their appearance in .B dictfile .TP .B -b \fIfilter_file\fP check generated passwords for their appearance in \fIfilter_file\fP. \fIfilter_file\fP should be created with \fBapgbfm\fP(1) utility. .TP .B -p min_substr_len this option tells \fBapg\fP(1) to check every substring of the generated password for appearance in \fIfilter_file\fP. If any of such substrings would be found in the \fIfilter_file\fP then generated password would be rejected and apg(1) will generate another one. \fBmin_substr_len\fP is specifies minimum substring length to check. This option is active only if \fB-b\fP option is defined. .SS "Password output options" .TP .B -l spell genetated passwords. Useful when you want to read generated password by telephone. .RS .B WARNING: Think twice before read your password by phone. .RE .TP .B -t print pronunciation for generated pronounceable password .SH "DEFAULT OPTIONS" \fBapgd -a 0 -M sncl -n 6 -x 10 -m 8\fP (new style) .SH "EXIT CODE" On successful completion of its task, .B apgd will complete with exit code 0. An exit code of -1 indicates an error occurred. Textual errors are written to the .B syslogd (8). .SH "DIAGNOSTICS" All textual info is written to the \fBsyslogd\fP(8). .SH "FILES" .B None. .SH "BUGS" .B None. If you've found one, please send bug description to the author. .SH "SEE ALSO" \fBapg\fP(1), \fBapgbfm\fP(1) .SH "AUTHOR" Adel I. Mirzazhanov, .br Project home page: http://www.adel.nursat.kz/apg/ apg-2.2.3.dfsg.1/doc/man/wapg.txt0000644000175100017510000001767507714471356014217 0ustar mhmhWAPG(1) User Manual WAPG(1) NAME WAPG - generates several random passwords SYNOPSIS WAPG [-a algorithm] [-M mode] [-E char_string] [-n num_of_pass] [-m min_pass_len] [-x max_pass_len] [-r dictfile] [-b filter_file] [-p min_substr_len] [-c cl_seed] [-d] [-l] [-t] [-q] [-h] [-v] DESCRIPTION WAPG generates several random passwords. It uses several password gener- ation algorithms (currently two) and a built-in pseudo random number generator. Default algorithm is pronounceable password generation algorithm designed by Morrie Gasser and described in A Random Word Generator For Pronounceable Passwords National Technical Information Service (NTIS) AD-A-017676. The original paper is very old and had never been put online, so I have to use NIST implementation described in FIPS-181. Another algorithm is simple random character generation algorithm, but it uses four user-defined symbol sets to produce random password. It means that user can choose type of symbols that should appear in pass- word. Symbol sets are: numeric symbol set (0,...,9) , capital letters symbol set (A,...,Z) , small letters symbol set (a,...,z) and special symbols symbol set (#,@,!,...). Built-in pseudo random number generator is an implementation of algo- rithm described in Appendix C of ANSI X9.17 or RFC1750 with exception that it uses CAST or SHA-1 instead of Triple DES. It uses local time with precision of microseconds (see gettimeofday(2)) and /dev/random (if available) to produce initial random seed. WAPG also have the ability to check generated password quality using dictionary. You can use this ability if you specify command-line options -r dictfile or -b filtername where dictfile is the dictionary file name and filtername is the name of Bloom filter file. In that dic- tionary you may place words (one per line) that should not appear as generated passwords. For example: user names, common words, etc. You even can use one of the dictionaries that come with dictionary password crackers. Bloom filter file should be created with WAPGbfm(1) utility included in WAPG distribution. These checks are case sensitive. For example, if you want to reject word 'root', you should insert in dict- file words: root, Root, RoOt, ... , ROOT. It is not the easiest way to check password quality, but it is the most powerful way. In future releases I plan to implement some other techniques to check passwords (like pattern check) just to make life easier. OPTIONS -M mode Use symbolsets specified with mode for password generation. mode is a text string consisting of characters S, s, N, n, C, c, L, l. Where: S generator must use special symbol set for every generated password. s generator should use special symbol set for password gen- eration. N generator must use numeral symbol set for every generated password. n generator should use numeral symbol set for password gen- eration. C generator must use capital symbol set for every generated password. c generator should use capital symbol set for password gen- eration. L generator must use small letters symbol set for every generated password (always present if pronounceable pass- word generation algorithm is used). l generator should use small letters symbol set for pass- word generation. R,r not supported any more. Use -E char_string option instead. mode can not be more than 4 characters in length. Note: Usage of L, M, N, C will slow down password generation process. Examples: -M sncl or -M SNCL or -M Cn -a algorithm use algorithm for password generation. 0 - (default) pronounceable password generation 1 - random character password generation -E char_string exclude characters in char_string from password generation pro- cess (in pronounceable password generation mode you can not exclude small letters). To include special symbols that can be recognized by shell (apostrophe, quotes, dollar sign, etc.) in char_string use the backslashed versions. Examples: Command WAPG -a 1 -M n -n 3 -m 8 -e 23456789 will generate a set of passwords that will look like this 10100110 01111000 11011101 Command WAPG -a 1 -M nc -n 3 -m 26 -e GHIJKLMNOPQRSTUVWXYZ will generate a set of passwords that will look like this 16A1653CD4DE5E7BD9584A3476 C8F78E06944AFD57FB9CB882BC 8C8DF37CD792D36D056BBD5002 -r dictfile check generated passwords for their appearance in dictfile -b filter_file check generated passwords for their appearance in filter_file. filter_file should be created with WAPGBFM utility. -p min_substr_len this option tells WAPG to check every substring of the gener- ated password for appearance in filter_file. If any of such sub- strings would be found in the filter_file then generated password would be rejected and WAPG will generate another one. min_substr_len specifies minimum substring length to check. This option is active only if -b option is defined. -c cl_seed use cl_seed as a random seed for password generation. I use it when i have to generate passwords in a shell script. -d do NOT use any delimiters between generated passwords. I use it when i have to generate passwords in a shell script. -n num_of_pass generate num_of_pass number of passwords. Default is 6. -m min_pass_len generate password with minimum length min_pass_len. If min_pass_len > max_pass_len then max_pass_len = min_pass_len. Default minimum password length is 8. -x max_pass_len generate password with maximum length max_pass_len. If min_pass_len > max_pass_len then max_pass_len = min_pass_len. Default maximum password length is 10. -q quiet mode (do not print warnings) -l spell genetated passwords. Useful when you want to read gener- ated password by telephone. WARNING: Think twice before read your password by phone. -t print pronunciation for generated pronounceable password -h print help information and exit -v print version information and exit DEFAULT OPTIONS WAPG -a 0 -M sncl -n 6 -x 10 -m 8 (new style) EXIT CODE On successful completion of its task, WAPG will complete with exit code 0. An exit code of -1 indicates an error occurred. Textual errors are written to the standard error stream. FILES None. BUGS None. If you've found one, please send bug description to the author. SEE ALSO WAPGBFM.TXT AUTHOR Adel I. Mirzazhanov, Project home page: http://www.adel.nursat.kz/WAPG/ Automated Password Generator 2003 Jun 19 WAPG(1)apg-2.2.3.dfsg.1/doc/man/wapgbfm.txt0000644000175100017510000001002207714471356014657 0ustar mhmhWAPGBFM User Manual WAPGBFM NAME WAPGBFM - APG Bloom filter management program SYNOPSIS WAPGBFM -f filter -n numofwords [-q] [-s] WAPGBFM -f filter -d dictfile [-q] [-s] WAPGBFM -f filter -a word [-q] WAPGBFM -f filter -A dictfile [-q] WAPGBFM -f filter -c word [-q] WAPGBFM -f filter -C dictfile [-q] WAPGBFM -i filter WAPGBFM [-v] [-h] DESCRIPTION WAPGBFM is used to manage Bloom filter that is used to restrict password generation in WAPG pasword generation software. Usage of the Bloom fil- ter allows to speed up password check for large dictionaries and has some other benefits. The idea to use Bloom filter for that purpose is came from the descrip- tion of the OPUS project OPUS: Preventing Weak Password Choices Purdue Technical Report CSD-TR 92-028 writen by Eugene H. Spafford. You can obtain this article from: http://www.cerias.purdue.edu/homes/spaf/tech-reps/9128.ps It has very nice description of Bloom filter and it's advantages for password checking systems. In simple words, WAPGBFM generates n hash values for every word and sets corresponding bits in filter file to 1. To check the word WAPGBFM gener- ates the same hash functions for that word and if all n corresponding bits in filter file are set to 1 then it suppose that word exists in dicionary. WAPGBFM uses SHA-1 as a hash function. WAPGBFM can be used as standalone utility, not only with apg, or apgd. WARNING !!! Filter file format can be changed in the future. I'll try to make file formats compatible but i can not guaranty this. WARNING !!! WAPGBFM may slow down your computer during filter creation. OPTIONS -f filter use filter as the name for Bloom filter filename. -i filter print information about filter. -n numofwords create new empty filter for numofwords number of words. Useful when you want to fill filter dynamicaly. -d dictfile create new filter from dictfile. It may take a lot of time to generate filter from a big dictionary. In that dictionary you may place words (one per line) that should not appear as gener- ated passwords. For example: user names common words, etc. You even can use one of the dictionaries that come with dictionary password crackers. This check is case sensitive. For example, if you want to reject word 'root', you should insert in dictfile words: root, Root, RoOt, ... , ROOT. To indicate that program is working WAPGBFM prints dot for every 100 words added in dic- tionary. -a word add word to the filter. -A dictfile add all words from dictfile to the filter. To indicate that pro- gram is working WAPGBFM prints dot for every 100 words added in dictionary. -c word check word for appearance in the filter. -C dictfile check every word from dictfile for appearance in the filter. -q quiet mode. -s create new filter in case-insensitive mode. -v print version information. -h print help information. EXIT CODE On successful completion of its task, WAPGBFM will complete with exit code 0. An exit code of -1 indicates an error occurred. Textual errors are written to the standard error stream. FILES None. BUGS None. If you've found one, please send bug description to the author. SEE ALSO WAPG.TXT AUTHOR Adel I. Mirzazhanov, Project home page: http://www.adel.nursat.kz/apg/ Automated Password Generator 2003 Jun 19 WAPGBFM apg-2.2.3.dfsg.1/doc/pronun.txt0000644000175100017510000002134007714471356014007 0ustar mhmh 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 apg-2.2.3.dfsg.1/errors.c0000644000175100017510000000644307714471356012647 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "errs.h" #ifdef CLISERV # include #endif /* ** err_sys() - routine that handles non-fatal system errors ** like calloc, open, etc. ** INPUT: ** const char * - error name. ** OUTPUT: ** prints error to stderr. ** NOTES: ** none. */ void err_sys(const char *string) { #ifndef CLISERV perror(string); #else syslog (LOG_DEBUG, "%s: %s",string, (char *)strerror(errno)); #endif } /* ** err_sus_fatal() - routine that handles fatal system errors ** like calloc, open, etc. ** INPUT: ** const char * - error name. ** OUTPUT: ** prints error to stderr and then exit. ** NOTES: ** none. */ void err_sys_fatal(const char *string) { #ifndef CLISERV perror(string); #else syslog (LOG_DEBUG, "%s: %s", string, (char *)strerror(errno)); closelog(); close(0); #endif exit (-1); } /* ** err_app() - routine that handles non-fatal application errors. ** INPUT: ** const char * - error name. ** const char * - error description. ** OUTPUT: ** prints error to stderr. ** NOTES: ** none. */ void err_app(const char *string, const char * err) { #ifndef CLISERV fprintf (stderr, "%s: ", string); fprintf (stderr, "%s\n", err); fflush (stderr); #else syslog (LOG_DEBUG, "%s: %s",string, err); #endif } /* ** err_app_fatal() - routine that handles fatal application errors. ** INPUT: ** const char * - error name. ** const char * - error description. ** OUTPUT: ** prints error to stderr and then exit. ** NOTES: ** none. */ void err_app_fatal(const char *string, const char *err) { #ifndef CLISERV fprintf (stderr, "%s: ", string); fprintf (stderr, "%s\n", err); fflush (stderr); #else syslog (LOG_DEBUG, "%s: %s",string, err); closelog(); close(0); #endif exit (-1); } apg-2.2.3.dfsg.1/errs.h0000644000175100017510000000350207714471356012304 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_ERRS_H #define APG_ERRS_H 1 #include extern void err_sys(const char *string); extern void err_sys_fatal(const char *string); extern void err_app(const char *string, const char *err); extern void err_app_fatal(const char *string, const char *err); #endif /* APG_ERRS_H */ apg-2.2.3.dfsg.1/getopt.c0000644000175100017510000000422307714471356012627 0ustar mhmh/* * Modified by Adel I. Mirzazhanov 2002, 2003 * getopt - get option letter from argv * * This is a version of the public domain getopt() implementation by * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V). * It allows rescanning of an option list by setting optind to 0 before * calling, which is why we use it even if the system has its own (in fact, * this one has a unique name so as not to conflict with the system's). * Thanks to Dennis Ferguson for the appropriate modifications. * * This file is in the Public Domain. */ #include #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); } apg-2.2.3.dfsg.1/getopt.h0000644000175100017510000000337607714471356012644 0ustar mhmh/* ** Copyright (c) 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_GETOPT_H #define APG_GETOPT_H 1 extern char * apg_optarg; /* global argument pointer */ extern int apg_optind; /* global argv index */ extern int apg_getopt(int argc,char *argv[],const char *optstring); #endif /* APG_GETOPT_H */ apg-2.2.3.dfsg.1/INSTALL0000644000175100017510000000451707714471356012220 0ustar mhmhInstallation There are 2 types of installation: (1) stand-alone, (2) client-server (See README for details). You can use each type separetly or you can use them together. The simplest way to install this package is: 1. untar the distribution and cd to the top: % gzip -d -c apg-2.X.XX.tar.gz | tar xf - % cd apg-2.X.XX If you are reading this file, you probably have already done this! 2. Edit the Makefile 3. make the software: For stand-alone: % make standalone For client-server: % make cliserv For both: % make all During the make process compiler will generate some warnings Just ignore this fact. I'm working to fix them. 4. install the binaries and man pages. You may need to be superuser to do this (depending on where you are installing things): % su # make install 5. You can remove the program binaries and object files from the source code directory by typing % make clean NOTE: THE REST IS FOR CLIENT-SERVER INSTALLATION ONLY !!! 6. Modify your /etc/inetd.conf file to contain the line below. You may have to modify it to support your version of the file. pwdgen stream tcp nowait nobody /usr/local/sbin/apgd apgd [options] or pwdgen stream tcp nowait nobody /usr/sbin/tcpd /usr/local/sbin/apgd [options] if you use tcp_wrapers. (for options see apgd(8) manpage) For all OS versions you must modify, your /etc/services file needs to include the following line: pwdgen 129/tcp # PWDGEN service 7. Restart inetd with a # kill -HUP inetdpid 8. Configure your syslogd daemon to handle events `daemon.info' and `daemon.debug' see syslogd(8) and syslog.conf(5) 9. Check that apgd is working % telnet your.host.name 129 or % telnet your.host.name pwdgen 10. Customize your apgcli.pl - APG client Edit apgcli.pl file that can be found in src/perl directory of source distribution tree ----------------------------------> src/perl/apgcli.pl #!/usr/bin/perl -w # Put here the real location of perl $host = "localhost"; # Put here the name of your APG server use IO::Socket; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "pwdgen(129)", ) or die "cannot connect to pwdgen port at $host"; while ( <$remote> ) { print } ----------------------------------> src/perl/apgcli.pl END apg-2.2.3.dfsg.1/INSTALL.CYGWIN0000644000175100017510000000221007714471356013203 0ustar mhmhInstallation of APG toolkit for CYGWIN Generaly there are 2 types of installation: (1) standalone (2) client-server but only standalone installation implemented for CYGWIN yet. APGD(server) works too, but it has some bugs and i could not recommend to use it. The instruction below IS FOR STANDALONE INSTALLATION ONLY The simplest way to install this package is: 1. untar the distribution and cd to the top: % gzip -d -c apg-2.X.XX.tar.gz | tar xf - % cd apg-2.X.XX If you are reading this file, you probably have already done this! 2. Edit the Makefile 3. make the software: For standalone: % make cygwin 4. install the binaries and man pages. There are some problems with install for CYGWIN. Sorry... But you have to do it manualy % make install-cygwin 5. You can remove the program binaries and object files from the source code directory by typing % make clean NOTE: You can use APG without CYGWIN, you need only cygwin*.dll. Copy APG.EXE to the directory you want and copy CYGWIN*.DLL in the same directory. Now you can run APG.EXE in the MS-DOS Prompt or just cliking on it. Adel I. Mirzazhanov a-del@iname.com apg-2.2.3.dfsg.1/install-sh0000755000175100017510000001273607714471356013175 0ustar mhmh#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 apg-2.2.3.dfsg.1/mkinstalldirs0000755000175100017510000000132207714471356013764 0ustar mhmh#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here apg-2.2.3.dfsg.1/owntypes.h0000644000175100017510000000353207714471356013224 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_OWN_TYPES_H #define APG_OWN_TYPES_H 1 typedef unsigned int UINT; typedef unsigned short USHORT; typedef short int SHORT; typedef int boolean; typedef unsigned long int UINT32; #define TRUE 1 #define FALSE 0 #define APG_MAX_PASSWORD_LENGTH 255 #endif /* APG_OWN_TYPES_H */ apg-2.2.3.dfsg.1/perl/0000755000175100017510000000000007714471356012122 5ustar mhmhapg-2.2.3.dfsg.1/perl/apgcli.pl0000755000175100017510000000037407714471356013725 0ustar mhmh#!/usr/bin/perl -w $host = "localhost"; use IO::Socket; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "pwdgen(129)", ) or die "cannot connect to pwdgen port at $host"; while ( <$remote> ) { print } apg-2.2.3.dfsg.1/php/0000755000175100017510000000000007714471356011747 5ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/0000755000175100017510000000000007714471356013723 5ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/index.php0000644000175100017510000005770207714471356015556 0ustar mhmh"; print "$text"; } ################# # 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 "\n"; print "\n"; print "\n"; print " \n"; print " APGOnline\n"; print "\n"; print "\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 "
\n"; print "
\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_header_font_face,"0",$p_header_font_color,$apg_title); print "
\n"; print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_algorithm); print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_pronounceable); print"
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_random); print "
\n"; print "
\n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_symbol_sets); print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_small_lerrers); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes); print" "; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no); print"
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_cap_letters); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes); print" "; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no); print"
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_numbers); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes); print" "; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no); print"
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_spec_symbols); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_yes); print" "; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_no); print"
\n"; print "
\n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_amount_length); print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_num_of_pass); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_up_to); print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_min_pass_len); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_up_to); print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_max_pass_len); print ""; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_up_to); print "
\n"; print "
\n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_user_random_seed); print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$submessage_seed); print "
\n"; print "
\n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_remove_saved); print "
\n"; print "
\n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$message_save_settings); print "\n"; print "
\n"; print "
\n"; print " \n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_generated_pass); print "
\n"; print "
\n"; print " \n"; $max_i = count ($outpasswords); for ($i = 0; $i < $max_i; $i++) { print " \n"; if ($i % 2 == 0) print " \n"; else print " \n"; print " \n"; } $i = 0; unset($outpasswords); print "
$outpasswords[$i]$outpasswords[$i]
\n"; print "
\n"; print "
\n"; print "\n"; if ($print_command_line == "true") { print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_header_font_face, $p_header_font_size, $p_header_font_color,$message_command_line); print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print_text($p_body_font_face,$p_body_font_size,$p_body_font_color,$generator); print "
\n"; print "
\n"; print " \n"; } print "
\n"; #################################### # Copyright dada # print "Copyright (c) 2001 Adel I. Mirzazhanov
\n"; print "APG Homepage
\n"; print "\n"; print "\n"; ?> apg-2.2.3.dfsg.1/php/apgonline/lang/0000755000175100017510000000000007714471356014644 5ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/lang/english.php0000644000175100017510000000202707714471356017007 0ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/lang/german.php0000644000175100017510000000222707714471356016631 0ustar mhmh apg-2.2.3.dfsg.1/php/apgonline/lang/rus-1251.php0000644000175100017510000000213107714471356016551 0ustar mhmh apg-2.2.3.dfsg.1/php/apgonline/lang/rus-koi8r.php0000644000175100017510000000212307714471356017216 0ustar mhmh apg-2.2.3.dfsg.1/php/apgonline/lang/polish.php0000644000175100017510000000212407714471356016652 0ustar mhmh apg-2.2.3.dfsg.1/php/apgonline/README0000644000175100017510000000242407714471356014605 0ustar mhmhAPG 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. apg-2.2.3.dfsg.1/php/apgonline/themes/0000755000175100017510000000000007714471356015210 5ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/themes/black-green.php0000644000175100017510000000161107714471356020072 0ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/themes/black-orange.php0000644000175100017510000000161107714471356020245 0ustar mhmhapg-2.2.3.dfsg.1/php/apgonline/themes/default.php0000644000175100017510000000161207714471356017345 0ustar mhmhapg-2.2.3.dfsg.1/pronpass.c0000644000175100017510000023340507714471356013200 0ustar mhmh/* ** This module uses code from the NIST implementation of FIPS-181, ** but the algorythm is CHANGED and I think that I CAN ** copyright it. See copiright notes below. */ /* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include #endif #include #include #include "pronpass.h" #include "randpass.h" #include "convert.h" #include "errs.h" struct unit { char unit_code[5]; USHORT flags; }; static struct unit rules[] = { {"a", VOWEL}, {"b", NO_SPECIAL_RULE}, {"c", NO_SPECIAL_RULE}, {"d", NO_SPECIAL_RULE}, {"e", NO_FINAL_SPLIT | VOWEL}, {"f", NO_SPECIAL_RULE}, {"g", NO_SPECIAL_RULE}, {"h", NO_SPECIAL_RULE}, {"i", VOWEL}, {"j", NO_SPECIAL_RULE}, {"k", NO_SPECIAL_RULE}, {"l", NO_SPECIAL_RULE}, {"m", NO_SPECIAL_RULE}, {"n", NO_SPECIAL_RULE}, {"o", VOWEL}, {"p", NO_SPECIAL_RULE}, {"r", NO_SPECIAL_RULE}, {"s", NO_SPECIAL_RULE}, {"t", NO_SPECIAL_RULE}, {"u", VOWEL}, {"v", NO_SPECIAL_RULE}, {"w", NO_SPECIAL_RULE}, {"x", NOT_BEGIN_SYLLABLE}, {"y", ALTERNATE_VOWEL | VOWEL}, {"z", NO_SPECIAL_RULE}, {"ch", NO_SPECIAL_RULE}, {"gh", NO_SPECIAL_RULE}, {"ph", NO_SPECIAL_RULE}, {"rh", NO_SPECIAL_RULE}, {"sh", NO_SPECIAL_RULE}, {"th", NO_SPECIAL_RULE}, {"wh", NO_SPECIAL_RULE}, {"qu", NO_SPECIAL_RULE}, {"ck", NOT_BEGIN_SYLLABLE} }; static int digram[][RULE_SIZE] = { {/* aa */ ILLEGAL_PAIR, /* ab */ ANY_COMBINATION, /* ac */ ANY_COMBINATION, /* ad */ ANY_COMBINATION, /* ae */ ILLEGAL_PAIR, /* af */ ANY_COMBINATION, /* ag */ ANY_COMBINATION, /* ah */ NOT_BEGIN | BREAK | NOT_END, /* ai */ ANY_COMBINATION, /* aj */ ANY_COMBINATION, /* ak */ ANY_COMBINATION, /* al */ ANY_COMBINATION, /* am */ ANY_COMBINATION, /* an */ ANY_COMBINATION, /* ao */ ILLEGAL_PAIR, /* ap */ ANY_COMBINATION, /* ar */ ANY_COMBINATION, /* as */ ANY_COMBINATION, /* at */ ANY_COMBINATION, /* au */ ANY_COMBINATION, /* av */ ANY_COMBINATION, /* aw */ ANY_COMBINATION, /* ax */ ANY_COMBINATION, /* ay */ ANY_COMBINATION, /* az */ ANY_COMBINATION, /* ach */ ANY_COMBINATION, /* agh */ ILLEGAL_PAIR, /* aph */ ANY_COMBINATION, /* arh */ ILLEGAL_PAIR, /* ash */ ANY_COMBINATION, /* ath */ ANY_COMBINATION, /* awh */ ILLEGAL_PAIR, /* aqu */ BREAK | NOT_END, /* ack */ ANY_COMBINATION}, {/* ba */ ANY_COMBINATION, /* bb */ NOT_BEGIN | BREAK | NOT_END, /* bc */ NOT_BEGIN | BREAK | NOT_END, /* bd */ NOT_BEGIN | BREAK | NOT_END, /* be */ ANY_COMBINATION, /* bf */ NOT_BEGIN | BREAK | NOT_END, /* bg */ NOT_BEGIN | BREAK | NOT_END, /* bh */ NOT_BEGIN | BREAK | NOT_END, /* bi */ ANY_COMBINATION, /* bj */ NOT_BEGIN | BREAK | NOT_END, /* bk */ NOT_BEGIN | BREAK | NOT_END, /* bl */ BEGIN | SUFFIX | NOT_END, /* bm */ NOT_BEGIN | BREAK | NOT_END, /* bn */ NOT_BEGIN | BREAK | NOT_END, /* bo */ ANY_COMBINATION, /* bp */ NOT_BEGIN | BREAK | NOT_END, /* br */ BEGIN | END, /* bs */ NOT_BEGIN, /* bt */ NOT_BEGIN | BREAK | NOT_END, /* bu */ ANY_COMBINATION, /* bv */ NOT_BEGIN | BREAK | NOT_END, /* bw */ NOT_BEGIN | BREAK | NOT_END, /* bx */ ILLEGAL_PAIR, /* by */ ANY_COMBINATION, /* bz */ NOT_BEGIN | BREAK | NOT_END, /* bch */ NOT_BEGIN | BREAK | NOT_END, /* bgh */ ILLEGAL_PAIR, /* bph */ NOT_BEGIN | BREAK | NOT_END, /* brh */ ILLEGAL_PAIR, /* bsh */ NOT_BEGIN | BREAK | NOT_END, /* bth */ NOT_BEGIN | BREAK | NOT_END, /* bwh */ ILLEGAL_PAIR, /* bqu */ NOT_BEGIN | BREAK | NOT_END, /* bck */ ILLEGAL_PAIR }, {/* ca */ ANY_COMBINATION, /* cb */ NOT_BEGIN | BREAK | NOT_END, /* cc */ NOT_BEGIN | BREAK | NOT_END, /* cd */ NOT_BEGIN | BREAK | NOT_END, /* ce */ ANY_COMBINATION, /* cf */ NOT_BEGIN | BREAK | NOT_END, /* cg */ NOT_BEGIN | BREAK | NOT_END, /* ch */ NOT_BEGIN | BREAK | NOT_END, /* ci */ ANY_COMBINATION, /* cj */ NOT_BEGIN | BREAK | NOT_END, /* ck */ NOT_BEGIN | BREAK | NOT_END, /* cl */ SUFFIX | NOT_END, /* cm */ NOT_BEGIN | BREAK | NOT_END, /* cn */ NOT_BEGIN | BREAK | NOT_END, /* co */ ANY_COMBINATION, /* cp */ NOT_BEGIN | BREAK | NOT_END, /* cr */ NOT_END, /* cs */ NOT_BEGIN | END, /* ct */ NOT_BEGIN | PREFIX, /* cu */ ANY_COMBINATION, /* cv */ NOT_BEGIN | BREAK | NOT_END, /* cw */ NOT_BEGIN | BREAK | NOT_END, /* cx */ ILLEGAL_PAIR, /* cy */ ANY_COMBINATION, /* cz */ NOT_BEGIN | BREAK | NOT_END, /* cch */ ILLEGAL_PAIR, /* cgh */ ILLEGAL_PAIR, /* cph */ NOT_BEGIN | BREAK | NOT_END, /* crh */ ILLEGAL_PAIR, /* csh */ NOT_BEGIN | BREAK | NOT_END, /* cth */ NOT_BEGIN | BREAK | NOT_END, /* cwh */ ILLEGAL_PAIR, /* cqu */ NOT_BEGIN | SUFFIX | NOT_END, /* cck */ ILLEGAL_PAIR}, {/* da */ ANY_COMBINATION, /* db */ NOT_BEGIN | BREAK | NOT_END, /* dc */ NOT_BEGIN | BREAK | NOT_END, /* dd */ NOT_BEGIN, /* de */ ANY_COMBINATION, /* df */ NOT_BEGIN | BREAK | NOT_END, /* dg */ NOT_BEGIN | BREAK | NOT_END, /* dh */ NOT_BEGIN | BREAK | NOT_END, /* di */ ANY_COMBINATION, /* dj */ NOT_BEGIN | BREAK | NOT_END, /* dk */ NOT_BEGIN | BREAK | NOT_END, /* dl */ NOT_BEGIN | BREAK | NOT_END, /* dm */ NOT_BEGIN | BREAK | NOT_END, /* dn */ NOT_BEGIN | BREAK | NOT_END, /* do */ ANY_COMBINATION, /* dp */ NOT_BEGIN | BREAK | NOT_END, /* dr */ BEGIN | NOT_END, /* ds */ NOT_BEGIN | END, /* dt */ NOT_BEGIN | BREAK | NOT_END, /* du */ ANY_COMBINATION, /* dv */ NOT_BEGIN | BREAK | NOT_END, /* dw */ NOT_BEGIN | BREAK | NOT_END, /* dx */ ILLEGAL_PAIR, /* dy */ ANY_COMBINATION, /* dz */ NOT_BEGIN | BREAK | NOT_END, /* dch */ NOT_BEGIN | BREAK | NOT_END, /* dgh */ NOT_BEGIN | BREAK | NOT_END, /* dph */ NOT_BEGIN | BREAK | NOT_END, /* drh */ ILLEGAL_PAIR, /* dsh */ NOT_BEGIN | NOT_END, /* dth */ NOT_BEGIN | PREFIX, /* dwh */ ILLEGAL_PAIR, /* dqu */ NOT_BEGIN | BREAK | NOT_END, /* dck */ ILLEGAL_PAIR }, {/* ea */ ANY_COMBINATION, /* eb */ ANY_COMBINATION, /* ec */ ANY_COMBINATION, /* ed */ ANY_COMBINATION, /* ee */ ANY_COMBINATION, /* ef */ ANY_COMBINATION, /* eg */ ANY_COMBINATION, /* eh */ NOT_BEGIN | BREAK | NOT_END, /* ei */ NOT_END, /* ej */ ANY_COMBINATION, /* ek */ ANY_COMBINATION, /* el */ ANY_COMBINATION, /* em */ ANY_COMBINATION, /* en */ ANY_COMBINATION, /* eo */ BREAK, /* ep */ ANY_COMBINATION, /* er */ ANY_COMBINATION, /* es */ ANY_COMBINATION, /* et */ ANY_COMBINATION, /* eu */ ANY_COMBINATION, /* ev */ ANY_COMBINATION, /* ew */ ANY_COMBINATION, /* ex */ ANY_COMBINATION, /* ey */ ANY_COMBINATION, /* ez */ ANY_COMBINATION, /* ech */ ANY_COMBINATION, /* egh */ NOT_BEGIN | BREAK | NOT_END, /* eph */ ANY_COMBINATION, /* erh */ ILLEGAL_PAIR, /* esh */ ANY_COMBINATION, /* eth */ ANY_COMBINATION, /* ewh */ ILLEGAL_PAIR, /* equ */ BREAK | NOT_END, /* eck */ ANY_COMBINATION }, {/* fa */ ANY_COMBINATION, /* fb */ NOT_BEGIN | BREAK | NOT_END, /* fc */ NOT_BEGIN | BREAK | NOT_END, /* fd */ NOT_BEGIN | BREAK | NOT_END, /* fe */ ANY_COMBINATION, /* ff */ NOT_BEGIN, /* fg */ NOT_BEGIN | BREAK | NOT_END, /* fh */ NOT_BEGIN | BREAK | NOT_END, /* fi */ ANY_COMBINATION, /* fj */ NOT_BEGIN | BREAK | NOT_END, /* fk */ NOT_BEGIN | BREAK | NOT_END, /* fl */ BEGIN | SUFFIX | NOT_END, /* fm */ NOT_BEGIN | BREAK | NOT_END, /* fn */ NOT_BEGIN | BREAK | NOT_END, /* fo */ ANY_COMBINATION, /* fp */ NOT_BEGIN | BREAK | NOT_END, /* fr */ BEGIN | NOT_END, /* fs */ NOT_BEGIN, /* ft */ NOT_BEGIN, /* fu */ ANY_COMBINATION, /* fv */ NOT_BEGIN | BREAK | NOT_END, /* fw */ NOT_BEGIN | BREAK | NOT_END, /* fx */ ILLEGAL_PAIR, /* fy */ NOT_BEGIN, /* fz */ NOT_BEGIN | BREAK | NOT_END, /* fch */ NOT_BEGIN | BREAK | NOT_END, /* fgh */ NOT_BEGIN | BREAK | NOT_END, /* fph */ NOT_BEGIN | BREAK | NOT_END, /* frh */ ILLEGAL_PAIR, /* fsh */ NOT_BEGIN | BREAK | NOT_END, /* fth */ NOT_BEGIN | BREAK | NOT_END, /* fwh */ ILLEGAL_PAIR, /* fqu */ NOT_BEGIN | BREAK | NOT_END, /* fck */ ILLEGAL_PAIR }, {/* ga */ ANY_COMBINATION, /* gb */ NOT_BEGIN | BREAK | NOT_END, /* gc */ NOT_BEGIN | BREAK | NOT_END, /* gd */ NOT_BEGIN | BREAK | NOT_END, /* ge */ ANY_COMBINATION, /* gf */ NOT_BEGIN | BREAK | NOT_END, /* gg */ NOT_BEGIN, /* gh */ NOT_BEGIN | BREAK | NOT_END, /* gi */ ANY_COMBINATION, /* gj */ NOT_BEGIN | BREAK | NOT_END, /* gk */ ILLEGAL_PAIR, /* gl */ BEGIN | SUFFIX | NOT_END, /* gm */ NOT_BEGIN | BREAK | NOT_END, /* gn */ NOT_BEGIN | BREAK | NOT_END, /* go */ ANY_COMBINATION, /* gp */ NOT_BEGIN | BREAK | NOT_END, /* gr */ BEGIN | NOT_END, /* gs */ NOT_BEGIN | END, /* gt */ NOT_BEGIN | BREAK | NOT_END, /* gu */ ANY_COMBINATION, /* gv */ NOT_BEGIN | BREAK | NOT_END, /* gw */ NOT_BEGIN | BREAK | NOT_END, /* gx */ ILLEGAL_PAIR, /* gy */ NOT_BEGIN, /* gz */ NOT_BEGIN | BREAK | NOT_END, /* gch */ NOT_BEGIN | BREAK | NOT_END, /* ggh */ ILLEGAL_PAIR, /* gph */ NOT_BEGIN | BREAK | NOT_END, /* grh */ ILLEGAL_PAIR, /* gsh */ NOT_BEGIN, /* gth */ NOT_BEGIN, /* gwh */ ILLEGAL_PAIR, /* gqu */ NOT_BEGIN | BREAK | NOT_END, /* gck */ ILLEGAL_PAIR }, {/* ha */ ANY_COMBINATION, /* hb */ NOT_BEGIN | BREAK | NOT_END, /* hc */ NOT_BEGIN | BREAK | NOT_END, /* hd */ NOT_BEGIN | BREAK | NOT_END, /* he */ ANY_COMBINATION, /* hf */ NOT_BEGIN | BREAK | NOT_END, /* hg */ NOT_BEGIN | BREAK | NOT_END, /* hh */ ILLEGAL_PAIR, /* hi */ ANY_COMBINATION, /* hj */ NOT_BEGIN | BREAK | NOT_END, /* hk */ NOT_BEGIN | BREAK | NOT_END, /* hl */ NOT_BEGIN | BREAK | NOT_END, /* hm */ NOT_BEGIN | BREAK | NOT_END, /* hn */ NOT_BEGIN | BREAK | NOT_END, /* ho */ ANY_COMBINATION, /* hp */ NOT_BEGIN | BREAK | NOT_END, /* hr */ NOT_BEGIN | BREAK | NOT_END, /* hs */ NOT_BEGIN | BREAK | NOT_END, /* ht */ NOT_BEGIN | BREAK | NOT_END, /* hu */ ANY_COMBINATION, /* hv */ NOT_BEGIN | BREAK | NOT_END, /* hw */ NOT_BEGIN | BREAK | NOT_END, /* hx */ ILLEGAL_PAIR, /* hy */ ANY_COMBINATION, /* hz */ NOT_BEGIN | BREAK | NOT_END, /* hch */ NOT_BEGIN | BREAK | NOT_END, /* hgh */ NOT_BEGIN | BREAK | NOT_END, /* hph */ NOT_BEGIN | BREAK | NOT_END, /* hrh */ ILLEGAL_PAIR, /* hsh */ NOT_BEGIN | BREAK | NOT_END, /* hth */ NOT_BEGIN | BREAK | NOT_END, /* hwh */ ILLEGAL_PAIR, /* hqu */ NOT_BEGIN | BREAK | NOT_END, /* hck */ ILLEGAL_PAIR }, {/* ia */ ANY_COMBINATION, /* ib */ ANY_COMBINATION, /* ic */ ANY_COMBINATION, /* id */ ANY_COMBINATION, /* ie */ NOT_BEGIN, /* if */ ANY_COMBINATION, /* ig */ ANY_COMBINATION, /* ih */ NOT_BEGIN | BREAK | NOT_END, /* ii */ ILLEGAL_PAIR, /* ij */ ANY_COMBINATION, /* ik */ ANY_COMBINATION, /* il */ ANY_COMBINATION, /* im */ ANY_COMBINATION, /* in */ ANY_COMBINATION, /* io */ BREAK, /* ip */ ANY_COMBINATION, /* ir */ ANY_COMBINATION, /* is */ ANY_COMBINATION, /* it */ ANY_COMBINATION, /* iu */ NOT_BEGIN | BREAK | NOT_END, /* iv */ ANY_COMBINATION, /* iw */ NOT_BEGIN | BREAK | NOT_END, /* ix */ ANY_COMBINATION, /* iy */ NOT_BEGIN | BREAK | NOT_END, /* iz */ ANY_COMBINATION, /* ich */ ANY_COMBINATION, /* igh */ NOT_BEGIN, /* iph */ ANY_COMBINATION, /* irh */ ILLEGAL_PAIR, /* ish */ ANY_COMBINATION, /* ith */ ANY_COMBINATION, /* iwh */ ILLEGAL_PAIR, /* iqu */ BREAK | NOT_END, /* ick */ ANY_COMBINATION }, {/* ja */ ANY_COMBINATION, /* jb */ NOT_BEGIN | BREAK | NOT_END, /* jc */ NOT_BEGIN | BREAK | NOT_END, /* jd */ NOT_BEGIN | BREAK | NOT_END, /* je */ ANY_COMBINATION, /* jf */ NOT_BEGIN | BREAK | NOT_END, /* jg */ ILLEGAL_PAIR, /* jh */ NOT_BEGIN | BREAK | NOT_END, /* ji */ ANY_COMBINATION, /* jj */ ILLEGAL_PAIR, /* jk */ NOT_BEGIN | BREAK | NOT_END, /* jl */ NOT_BEGIN | BREAK | NOT_END, /* jm */ NOT_BEGIN | BREAK | NOT_END, /* jn */ NOT_BEGIN | BREAK | NOT_END, /* jo */ ANY_COMBINATION, /* jp */ NOT_BEGIN | BREAK | NOT_END, /* jr */ NOT_BEGIN | BREAK | NOT_END, /* js */ NOT_BEGIN | BREAK | NOT_END, /* jt */ NOT_BEGIN | BREAK | NOT_END, /* ju */ ANY_COMBINATION, /* jv */ NOT_BEGIN | BREAK | NOT_END, /* jw */ NOT_BEGIN | BREAK | NOT_END, /* jx */ ILLEGAL_PAIR, /* jy */ NOT_BEGIN, /* jz */ NOT_BEGIN | BREAK | NOT_END, /* jch */ NOT_BEGIN | BREAK | NOT_END, /* jgh */ NOT_BEGIN | BREAK | NOT_END, /* jph */ NOT_BEGIN | BREAK | NOT_END, /* jrh */ ILLEGAL_PAIR, /* jsh */ NOT_BEGIN | BREAK | NOT_END, /* jth */ NOT_BEGIN | BREAK | NOT_END, /* jwh */ ILLEGAL_PAIR, /* jqu */ NOT_BEGIN | BREAK | NOT_END, /* jck */ ILLEGAL_PAIR }, {/* ka */ ANY_COMBINATION, /* kb */ NOT_BEGIN | BREAK | NOT_END, /* kc */ NOT_BEGIN | BREAK | NOT_END, /* kd */ NOT_BEGIN | BREAK | NOT_END, /* ke */ ANY_COMBINATION, /* kf */ NOT_BEGIN | BREAK | NOT_END, /* kg */ NOT_BEGIN | BREAK | NOT_END, /* kh */ NOT_BEGIN | BREAK | NOT_END, /* ki */ ANY_COMBINATION, /* kj */ NOT_BEGIN | BREAK | NOT_END, /* kk */ NOT_BEGIN | BREAK | NOT_END, /* kl */ SUFFIX | NOT_END, /* km */ NOT_BEGIN | BREAK | NOT_END, /* kn */ BEGIN | SUFFIX | NOT_END, /* ko */ ANY_COMBINATION, /* kp */ NOT_BEGIN | BREAK | NOT_END, /* kr */ SUFFIX | NOT_END, /* ks */ NOT_BEGIN | END, /* kt */ NOT_BEGIN | BREAK | NOT_END, /* ku */ ANY_COMBINATION, /* kv */ NOT_BEGIN | BREAK | NOT_END, /* kw */ NOT_BEGIN | BREAK | NOT_END, /* kx */ ILLEGAL_PAIR, /* ky */ NOT_BEGIN, /* kz */ NOT_BEGIN | BREAK | NOT_END, /* kch */ NOT_BEGIN | BREAK | NOT_END, /* kgh */ NOT_BEGIN | BREAK | NOT_END, /* kph */ NOT_BEGIN | PREFIX, /* krh */ ILLEGAL_PAIR, /* ksh */ NOT_BEGIN, /* kth */ NOT_BEGIN | BREAK | NOT_END, /* kwh */ ILLEGAL_PAIR, /* kqu */ NOT_BEGIN | BREAK | NOT_END, /* kck */ ILLEGAL_PAIR }, {/* la */ ANY_COMBINATION, /* lb */ NOT_BEGIN | PREFIX, /* lc */ NOT_BEGIN | BREAK | NOT_END, /* ld */ NOT_BEGIN | PREFIX, /* le */ ANY_COMBINATION, /* lf */ NOT_BEGIN | PREFIX, /* lg */ NOT_BEGIN | PREFIX, /* lh */ NOT_BEGIN | BREAK | NOT_END, /* li */ ANY_COMBINATION, /* lj */ NOT_BEGIN | PREFIX, /* lk */ NOT_BEGIN | PREFIX, /* ll */ NOT_BEGIN | PREFIX, /* lm */ NOT_BEGIN | PREFIX, /* ln */ NOT_BEGIN | BREAK | NOT_END, /* lo */ ANY_COMBINATION, /* lp */ NOT_BEGIN | PREFIX, /* lr */ NOT_BEGIN | BREAK | NOT_END, /* ls */ NOT_BEGIN, /* lt */ NOT_BEGIN | PREFIX, /* lu */ ANY_COMBINATION, /* lv */ NOT_BEGIN | PREFIX, /* lw */ NOT_BEGIN | BREAK | NOT_END, /* lx */ ILLEGAL_PAIR, /* ly */ ANY_COMBINATION, /* lz */ NOT_BEGIN | BREAK | NOT_END, /* lch */ NOT_BEGIN | PREFIX, /* lgh */ NOT_BEGIN | BREAK | NOT_END, /* lph */ NOT_BEGIN | PREFIX, /* lrh */ ILLEGAL_PAIR, /* lsh */ NOT_BEGIN | PREFIX, /* lth */ NOT_BEGIN | PREFIX, /* lwh */ ILLEGAL_PAIR, /* lqu */ NOT_BEGIN | BREAK | NOT_END, /* lck */ ILLEGAL_PAIR }, {/* ma */ ANY_COMBINATION, /* mb */ NOT_BEGIN | BREAK | NOT_END, /* mc */ NOT_BEGIN | BREAK | NOT_END, /* md */ NOT_BEGIN | BREAK | NOT_END, /* me */ ANY_COMBINATION, /* mf */ NOT_BEGIN | BREAK | NOT_END, /* mg */ NOT_BEGIN | BREAK | NOT_END, /* mh */ NOT_BEGIN | BREAK | NOT_END, /* mi */ ANY_COMBINATION, /* mj */ NOT_BEGIN | BREAK | NOT_END, /* mk */ NOT_BEGIN | BREAK | NOT_END, /* ml */ NOT_BEGIN | BREAK | NOT_END, /* mm */ NOT_BEGIN, /* mn */ NOT_BEGIN | BREAK | NOT_END, /* mo */ ANY_COMBINATION, /* mp */ NOT_BEGIN, /* mr */ NOT_BEGIN | BREAK | NOT_END, /* ms */ NOT_BEGIN, /* mt */ NOT_BEGIN, /* mu */ ANY_COMBINATION, /* mv */ NOT_BEGIN | BREAK | NOT_END, /* mw */ NOT_BEGIN | BREAK | NOT_END, /* mx */ ILLEGAL_PAIR, /* my */ ANY_COMBINATION, /* mz */ NOT_BEGIN | BREAK | NOT_END, /* mch */ NOT_BEGIN | PREFIX, /* mgh */ NOT_BEGIN | BREAK | NOT_END, /* mph */ NOT_BEGIN, /* mrh */ ILLEGAL_PAIR, /* msh */ NOT_BEGIN, /* mth */ NOT_BEGIN, /* mwh */ ILLEGAL_PAIR, /* mqu */ NOT_BEGIN | BREAK | NOT_END, /* mck */ ILLEGAL_PAIR }, {/* na */ ANY_COMBINATION, /* nb */ NOT_BEGIN | BREAK | NOT_END, /* nc */ NOT_BEGIN | BREAK | NOT_END, /* nd */ NOT_BEGIN, /* ne */ ANY_COMBINATION, /* nf */ NOT_BEGIN | BREAK | NOT_END, /* ng */ NOT_BEGIN | PREFIX, /* nh */ NOT_BEGIN | BREAK | NOT_END, /* ni */ ANY_COMBINATION, /* nj */ NOT_BEGIN | BREAK | NOT_END, /* nk */ NOT_BEGIN | PREFIX, /* nl */ NOT_BEGIN | BREAK | NOT_END, /* nm */ NOT_BEGIN | BREAK | NOT_END, /* nn */ NOT_BEGIN, /* no */ ANY_COMBINATION, /* np */ NOT_BEGIN | BREAK | NOT_END, /* nr */ NOT_BEGIN | BREAK | NOT_END, /* ns */ NOT_BEGIN, /* nt */ NOT_BEGIN, /* nu */ ANY_COMBINATION, /* nv */ NOT_BEGIN | BREAK | NOT_END, /* nw */ NOT_BEGIN | BREAK | NOT_END, /* nx */ ILLEGAL_PAIR, /* ny */ NOT_BEGIN, /* nz */ NOT_BEGIN | BREAK | NOT_END, /* nch */ NOT_BEGIN | PREFIX, /* ngh */ NOT_BEGIN | BREAK | NOT_END, /* nph */ NOT_BEGIN | PREFIX, /* nrh */ ILLEGAL_PAIR, /* nsh */ NOT_BEGIN, /* nth */ NOT_BEGIN, /* nwh */ ILLEGAL_PAIR, /* nqu */ NOT_BEGIN | BREAK | NOT_END, /* nck */ NOT_BEGIN | PREFIX }, {/* oa */ ANY_COMBINATION, /* ob */ ANY_COMBINATION, /* oc */ ANY_COMBINATION, /* od */ ANY_COMBINATION, /* oe */ ILLEGAL_PAIR, /* of */ ANY_COMBINATION, /* og */ ANY_COMBINATION, /* oh */ NOT_BEGIN | BREAK | NOT_END, /* oi */ ANY_COMBINATION, /* oj */ ANY_COMBINATION, /* ok */ ANY_COMBINATION, /* ol */ ANY_COMBINATION, /* om */ ANY_COMBINATION, /* on */ ANY_COMBINATION, /* oo */ ANY_COMBINATION, /* op */ ANY_COMBINATION, /* or */ ANY_COMBINATION, /* os */ ANY_COMBINATION, /* ot */ ANY_COMBINATION, /* ou */ ANY_COMBINATION, /* ov */ ANY_COMBINATION, /* ow */ ANY_COMBINATION, /* ox */ ANY_COMBINATION, /* oy */ ANY_COMBINATION, /* oz */ ANY_COMBINATION, /* och */ ANY_COMBINATION, /* ogh */ NOT_BEGIN, /* oph */ ANY_COMBINATION, /* orh */ ILLEGAL_PAIR, /* osh */ ANY_COMBINATION, /* oth */ ANY_COMBINATION, /* owh */ ILLEGAL_PAIR, /* oqu */ BREAK | NOT_END, /* ock */ ANY_COMBINATION }, {/* pa */ ANY_COMBINATION, /* pb */ NOT_BEGIN | BREAK | NOT_END, /* pc */ NOT_BEGIN | BREAK | NOT_END, /* pd */ NOT_BEGIN | BREAK | NOT_END, /* pe */ ANY_COMBINATION, /* pf */ NOT_BEGIN | BREAK | NOT_END, /* pg */ NOT_BEGIN | BREAK | NOT_END, /* ph */ NOT_BEGIN | BREAK | NOT_END, /* pi */ ANY_COMBINATION, /* pj */ NOT_BEGIN | BREAK | NOT_END, /* pk */ NOT_BEGIN | BREAK | NOT_END, /* pl */ SUFFIX | NOT_END, /* pm */ NOT_BEGIN | BREAK | NOT_END, /* pn */ NOT_BEGIN | BREAK | NOT_END, /* po */ ANY_COMBINATION, /* pp */ NOT_BEGIN | PREFIX, /* pr */ NOT_END, /* ps */ NOT_BEGIN | END, /* pt */ NOT_BEGIN | END, /* pu */ NOT_BEGIN | END, /* pv */ NOT_BEGIN | BREAK | NOT_END, /* pw */ NOT_BEGIN | BREAK | NOT_END, /* px */ ILLEGAL_PAIR, /* py */ ANY_COMBINATION, /* pz */ NOT_BEGIN | BREAK | NOT_END, /* pch */ NOT_BEGIN | BREAK | NOT_END, /* pgh */ NOT_BEGIN | BREAK | NOT_END, /* pph */ NOT_BEGIN | BREAK | NOT_END, /* prh */ ILLEGAL_PAIR, /* psh */ NOT_BEGIN | BREAK | NOT_END, /* pth */ NOT_BEGIN | BREAK | NOT_END, /* pwh */ ILLEGAL_PAIR, /* pqu */ NOT_BEGIN | BREAK | NOT_END, /* pck */ ILLEGAL_PAIR }, {/* ra */ ANY_COMBINATION, /* rb */ NOT_BEGIN | PREFIX, /* rc */ NOT_BEGIN | PREFIX, /* rd */ NOT_BEGIN | PREFIX, /* re */ ANY_COMBINATION, /* rf */ NOT_BEGIN | PREFIX, /* rg */ NOT_BEGIN | PREFIX, /* rh */ NOT_BEGIN | BREAK | NOT_END, /* ri */ ANY_COMBINATION, /* rj */ NOT_BEGIN | PREFIX, /* rk */ NOT_BEGIN | PREFIX, /* rl */ NOT_BEGIN | PREFIX, /* rm */ NOT_BEGIN | PREFIX, /* rn */ NOT_BEGIN | PREFIX, /* ro */ ANY_COMBINATION, /* rp */ NOT_BEGIN | PREFIX, /* rr */ NOT_BEGIN | PREFIX, /* rs */ NOT_BEGIN | PREFIX, /* rt */ NOT_BEGIN | PREFIX, /* ru */ ANY_COMBINATION, /* rv */ NOT_BEGIN | PREFIX, /* rw */ NOT_BEGIN | BREAK | NOT_END, /* rx */ ILLEGAL_PAIR, /* ry */ ANY_COMBINATION, /* rz */ NOT_BEGIN | PREFIX, /* rch */ NOT_BEGIN | PREFIX, /* rgh */ NOT_BEGIN | BREAK | NOT_END, /* rph */ NOT_BEGIN | PREFIX, /* rrh */ ILLEGAL_PAIR, /* rsh */ NOT_BEGIN | PREFIX, /* rth */ NOT_BEGIN | PREFIX, /* rwh */ ILLEGAL_PAIR, /* rqu */ NOT_BEGIN | PREFIX | NOT_END, /* rck */ NOT_BEGIN | PREFIX }, {/* sa */ ANY_COMBINATION, /* sb */ NOT_BEGIN | BREAK | NOT_END, /* sc */ NOT_END, /* sd */ NOT_BEGIN | BREAK | NOT_END, /* se */ ANY_COMBINATION, /* sf */ NOT_BEGIN | BREAK | NOT_END, /* sg */ NOT_BEGIN | BREAK | NOT_END, /* sh */ NOT_BEGIN | BREAK | NOT_END, /* si */ ANY_COMBINATION, /* sj */ NOT_BEGIN | BREAK | NOT_END, /* sk */ ANY_COMBINATION, /* sl */ BEGIN | SUFFIX | NOT_END, /* sm */ SUFFIX | NOT_END, /* sn */ PREFIX | SUFFIX | NOT_END, /* so */ ANY_COMBINATION, /* sp */ ANY_COMBINATION, /* sr */ NOT_BEGIN | NOT_END, /* ss */ NOT_BEGIN | PREFIX, /* st */ ANY_COMBINATION, /* su */ ANY_COMBINATION, /* sv */ NOT_BEGIN | BREAK | NOT_END, /* sw */ BEGIN | SUFFIX | NOT_END, /* sx */ ILLEGAL_PAIR, /* sy */ ANY_COMBINATION, /* sz */ NOT_BEGIN | BREAK | NOT_END, /* sch */ BEGIN | SUFFIX | NOT_END, /* sgh */ NOT_BEGIN | BREAK | NOT_END, /* sph */ NOT_BEGIN | BREAK | NOT_END, /* srh */ ILLEGAL_PAIR, /* ssh */ NOT_BEGIN | BREAK | NOT_END, /* sth */ NOT_BEGIN | BREAK | NOT_END, /* swh */ ILLEGAL_PAIR, /* squ */ SUFFIX | NOT_END, /* sck */ NOT_BEGIN }, {/* ta */ ANY_COMBINATION, /* tb */ NOT_BEGIN | BREAK | NOT_END, /* tc */ NOT_BEGIN | BREAK | NOT_END, /* td */ NOT_BEGIN | BREAK | NOT_END, /* te */ ANY_COMBINATION, /* tf */ NOT_BEGIN | BREAK | NOT_END, /* tg */ NOT_BEGIN | BREAK | NOT_END, /* th */ NOT_BEGIN | BREAK | NOT_END, /* ti */ ANY_COMBINATION, /* tj */ NOT_BEGIN | BREAK | NOT_END, /* tk */ NOT_BEGIN | BREAK | NOT_END, /* tl */ NOT_BEGIN | BREAK | NOT_END, /* tm */ NOT_BEGIN | BREAK | NOT_END, /* tn */ NOT_BEGIN | BREAK | NOT_END, /* to */ ANY_COMBINATION, /* tp */ NOT_BEGIN | BREAK | NOT_END, /* tr */ NOT_END, /* ts */ NOT_BEGIN | END, /* tt */ NOT_BEGIN | PREFIX, /* tu */ ANY_COMBINATION, /* tv */ NOT_BEGIN | BREAK | NOT_END, /* tw */ BEGIN | SUFFIX | NOT_END, /* tx */ ILLEGAL_PAIR, /* ty */ ANY_COMBINATION, /* tz */ NOT_BEGIN | BREAK | NOT_END, /* tch */ NOT_BEGIN, /* tgh */ NOT_BEGIN | BREAK | NOT_END, /* tph */ NOT_BEGIN | END, /* trh */ ILLEGAL_PAIR, /* tsh */ NOT_BEGIN | END, /* tth */ NOT_BEGIN | BREAK | NOT_END, /* twh */ ILLEGAL_PAIR, /* tqu */ NOT_BEGIN | BREAK | NOT_END, /* tck */ ILLEGAL_PAIR }, {/* ua */ NOT_BEGIN | BREAK | NOT_END, /* ub */ ANY_COMBINATION, /* uc */ ANY_COMBINATION, /* ud */ ANY_COMBINATION, /* ue */ NOT_BEGIN, /* uf */ ANY_COMBINATION, /* ug */ ANY_COMBINATION, /* uh */ NOT_BEGIN | BREAK | NOT_END, /* ui */ NOT_BEGIN | BREAK | NOT_END, /* uj */ ANY_COMBINATION, /* uk */ ANY_COMBINATION, /* ul */ ANY_COMBINATION, /* um */ ANY_COMBINATION, /* un */ ANY_COMBINATION, /* uo */ NOT_BEGIN | BREAK, /* up */ ANY_COMBINATION, /* ur */ ANY_COMBINATION, /* us */ ANY_COMBINATION, /* ut */ ANY_COMBINATION, /* uu */ ILLEGAL_PAIR, /* uv */ ANY_COMBINATION, /* uw */ NOT_BEGIN | BREAK | NOT_END, /* ux */ ANY_COMBINATION, /* uy */ NOT_BEGIN | BREAK | NOT_END, /* uz */ ANY_COMBINATION, /* uch */ ANY_COMBINATION, /* ugh */ NOT_BEGIN | PREFIX, /* uph */ ANY_COMBINATION, /* urh */ ILLEGAL_PAIR, /* ush */ ANY_COMBINATION, /* uth */ ANY_COMBINATION, /* uwh */ ILLEGAL_PAIR, /* uqu */ BREAK | NOT_END, /* uck */ ANY_COMBINATION }, {/* va */ ANY_COMBINATION, /* vb */ NOT_BEGIN | BREAK | NOT_END, /* vc */ NOT_BEGIN | BREAK | NOT_END, /* vd */ NOT_BEGIN | BREAK | NOT_END, /* ve */ ANY_COMBINATION, /* vf */ NOT_BEGIN | BREAK | NOT_END, /* vg */ NOT_BEGIN | BREAK | NOT_END, /* vh */ NOT_BEGIN | BREAK | NOT_END, /* vi */ ANY_COMBINATION, /* vj */ NOT_BEGIN | BREAK | NOT_END, /* vk */ NOT_BEGIN | BREAK | NOT_END, /* vl */ NOT_BEGIN | BREAK | NOT_END, /* vm */ NOT_BEGIN | BREAK | NOT_END, /* vn */ NOT_BEGIN | BREAK | NOT_END, /* vo */ ANY_COMBINATION, /* vp */ NOT_BEGIN | BREAK | NOT_END, /* vr */ NOT_BEGIN | BREAK | NOT_END, /* vs */ NOT_BEGIN | BREAK | NOT_END, /* vt */ NOT_BEGIN | BREAK | NOT_END, /* vu */ ANY_COMBINATION, /* vv */ NOT_BEGIN | BREAK | NOT_END, /* vw */ NOT_BEGIN | BREAK | NOT_END, /* vx */ ILLEGAL_PAIR, /* vy */ NOT_BEGIN, /* vz */ NOT_BEGIN | BREAK | NOT_END, /* vch */ NOT_BEGIN | BREAK | NOT_END, /* vgh */ NOT_BEGIN | BREAK | NOT_END, /* vph */ NOT_BEGIN | BREAK | NOT_END, /* vrh */ ILLEGAL_PAIR, /* vsh */ NOT_BEGIN | BREAK | NOT_END, /* vth */ NOT_BEGIN | BREAK | NOT_END, /* vwh */ ILLEGAL_PAIR, /* vqu */ NOT_BEGIN | BREAK | NOT_END, /* vck */ ILLEGAL_PAIR }, {/* wa */ ANY_COMBINATION, /* wb */ NOT_BEGIN | PREFIX, /* wc */ NOT_BEGIN | BREAK | NOT_END, /* wd */ NOT_BEGIN | PREFIX | END, /* we */ ANY_COMBINATION, /* wf */ NOT_BEGIN | PREFIX, /* wg */ NOT_BEGIN | PREFIX | END, /* wh */ NOT_BEGIN | BREAK | NOT_END, /* wi */ ANY_COMBINATION, /* wj */ NOT_BEGIN | BREAK | NOT_END, /* wk */ NOT_BEGIN | PREFIX, /* wl */ NOT_BEGIN | PREFIX | SUFFIX, /* wm */ NOT_BEGIN | PREFIX, /* wn */ NOT_BEGIN | PREFIX, /* wo */ ANY_COMBINATION, /* wp */ NOT_BEGIN | PREFIX, /* wr */ BEGIN | SUFFIX | NOT_END, /* ws */ NOT_BEGIN | PREFIX, /* wt */ NOT_BEGIN | PREFIX, /* wu */ ANY_COMBINATION, /* wv */ NOT_BEGIN | PREFIX, /* ww */ NOT_BEGIN | BREAK | NOT_END, /* wx */ NOT_BEGIN | PREFIX, /* wy */ ANY_COMBINATION, /* wz */ NOT_BEGIN | PREFIX, /* wch */ NOT_BEGIN, /* wgh */ NOT_BEGIN | BREAK | NOT_END, /* wph */ NOT_BEGIN, /* wrh */ ILLEGAL_PAIR, /* wsh */ NOT_BEGIN, /* wth */ NOT_BEGIN, /* wwh */ ILLEGAL_PAIR, /* wqu */ NOT_BEGIN | BREAK | NOT_END, /* wck */ NOT_BEGIN }, {/* xa */ NOT_BEGIN, /* xb */ NOT_BEGIN | BREAK | NOT_END, /* xc */ NOT_BEGIN | BREAK | NOT_END, /* xd */ NOT_BEGIN | BREAK | NOT_END, /* xe */ NOT_BEGIN, /* xf */ NOT_BEGIN | BREAK | NOT_END, /* xg */ NOT_BEGIN | BREAK | NOT_END, /* xh */ NOT_BEGIN | BREAK | NOT_END, /* xi */ NOT_BEGIN, /* xj */ NOT_BEGIN | BREAK | NOT_END, /* xk */ NOT_BEGIN | BREAK | NOT_END, /* xl */ NOT_BEGIN | BREAK | NOT_END, /* xm */ NOT_BEGIN | BREAK | NOT_END, /* xn */ NOT_BEGIN | BREAK | NOT_END, /* xo */ NOT_BEGIN, /* xp */ NOT_BEGIN | BREAK | NOT_END, /* xr */ NOT_BEGIN | BREAK | NOT_END, /* xs */ NOT_BEGIN | BREAK | NOT_END, /* xt */ NOT_BEGIN | BREAK | NOT_END, /* xu */ NOT_BEGIN, /* xv */ NOT_BEGIN | BREAK | NOT_END, /* xw */ NOT_BEGIN | BREAK | NOT_END, /* xx */ ILLEGAL_PAIR, /* xy */ NOT_BEGIN, /* xz */ NOT_BEGIN | BREAK | NOT_END, /* xch */ NOT_BEGIN | BREAK | NOT_END, /* xgh */ NOT_BEGIN | BREAK | NOT_END, /* xph */ NOT_BEGIN | BREAK | NOT_END, /* xrh */ ILLEGAL_PAIR, /* xsh */ NOT_BEGIN | BREAK | NOT_END, /* xth */ NOT_BEGIN | BREAK | NOT_END, /* xwh */ ILLEGAL_PAIR, /* xqu */ NOT_BEGIN | BREAK | NOT_END, /* xck */ ILLEGAL_PAIR }, {/* ya */ ANY_COMBINATION, /* yb */ NOT_BEGIN, /* yc */ NOT_BEGIN | NOT_END, /* yd */ NOT_BEGIN, /* ye */ ANY_COMBINATION, /* yf */ NOT_BEGIN | NOT_END, /* yg */ NOT_BEGIN, /* yh */ NOT_BEGIN | BREAK | NOT_END, /* yi */ BEGIN | NOT_END, /* yj */ NOT_BEGIN | NOT_END, /* yk */ NOT_BEGIN, /* yl */ NOT_BEGIN | NOT_END, /* ym */ NOT_BEGIN, /* yn */ NOT_BEGIN, /* yo */ ANY_COMBINATION, /* yp */ NOT_BEGIN, /* yr */ NOT_BEGIN | BREAK | NOT_END, /* ys */ NOT_BEGIN, /* yt */ NOT_BEGIN, /* yu */ ANY_COMBINATION, /* yv */ NOT_BEGIN | NOT_END, /* yw */ NOT_BEGIN | BREAK | NOT_END, /* yx */ NOT_BEGIN, /* yy */ ILLEGAL_PAIR, /* yz */ NOT_BEGIN, /* ych */ NOT_BEGIN | BREAK | NOT_END, /* ygh */ NOT_BEGIN | BREAK | NOT_END, /* yph */ NOT_BEGIN | BREAK | NOT_END, /* yrh */ ILLEGAL_PAIR, /* ysh */ NOT_BEGIN | BREAK | NOT_END, /* yth */ NOT_BEGIN | BREAK | NOT_END, /* ywh */ ILLEGAL_PAIR, /* yqu */ NOT_BEGIN | BREAK | NOT_END, /* yck */ ILLEGAL_PAIR }, {/* za */ ANY_COMBINATION, /* zb */ NOT_BEGIN | BREAK | NOT_END, /* zc */ NOT_BEGIN | BREAK | NOT_END, /* zd */ NOT_BEGIN | BREAK | NOT_END, /* ze */ ANY_COMBINATION, /* zf */ NOT_BEGIN | BREAK | NOT_END, /* zg */ NOT_BEGIN | BREAK | NOT_END, /* zh */ NOT_BEGIN | BREAK | NOT_END, /* zi */ ANY_COMBINATION, /* zj */ NOT_BEGIN | BREAK | NOT_END, /* zk */ NOT_BEGIN | BREAK | NOT_END, /* zl */ NOT_BEGIN | BREAK | NOT_END, /* zm */ NOT_BEGIN | BREAK | NOT_END, /* zn */ NOT_BEGIN | BREAK | NOT_END, /* zo */ ANY_COMBINATION, /* zp */ NOT_BEGIN | BREAK | NOT_END, /* zr */ NOT_BEGIN | NOT_END, /* zs */ NOT_BEGIN | BREAK | NOT_END, /* zt */ NOT_BEGIN, /* zu */ ANY_COMBINATION, /* zv */ NOT_BEGIN | BREAK | NOT_END, /* zw */ SUFFIX | NOT_END, /* zx */ ILLEGAL_PAIR, /* zy */ ANY_COMBINATION, /* zz */ NOT_BEGIN, /* zch */ NOT_BEGIN | BREAK | NOT_END, /* zgh */ NOT_BEGIN | BREAK | NOT_END, /* zph */ NOT_BEGIN | BREAK | NOT_END, /* zrh */ ILLEGAL_PAIR, /* zsh */ NOT_BEGIN | BREAK | NOT_END, /* zth */ NOT_BEGIN | BREAK | NOT_END, /* zwh */ ILLEGAL_PAIR, /* zqu */ NOT_BEGIN | BREAK | NOT_END, /* zck */ ILLEGAL_PAIR }, {/* cha */ ANY_COMBINATION, /* chb */ NOT_BEGIN | BREAK | NOT_END, /* chc */ NOT_BEGIN | BREAK | NOT_END, /* chd */ NOT_BEGIN | BREAK | NOT_END, /* che */ ANY_COMBINATION, /* chf */ NOT_BEGIN | BREAK | NOT_END, /* chg */ NOT_BEGIN | BREAK | NOT_END, /* chh */ NOT_BEGIN | BREAK | NOT_END, /* chi */ ANY_COMBINATION, /* chj */ NOT_BEGIN | BREAK | NOT_END, /* chk */ NOT_BEGIN | BREAK | NOT_END, /* chl */ NOT_BEGIN | BREAK | NOT_END, /* chm */ NOT_BEGIN | BREAK | NOT_END, /* chn */ NOT_BEGIN | BREAK | NOT_END, /* cho */ ANY_COMBINATION, /* chp */ NOT_BEGIN | BREAK | NOT_END, /* chr */ NOT_END, /* chs */ NOT_BEGIN | BREAK | NOT_END, /* cht */ NOT_BEGIN | BREAK | NOT_END, /* chu */ ANY_COMBINATION, /* chv */ NOT_BEGIN | BREAK | NOT_END, /* chw */ NOT_BEGIN | NOT_END, /* chx */ ILLEGAL_PAIR, /* chy */ ANY_COMBINATION, /* chz */ NOT_BEGIN | BREAK | NOT_END, /* chch */ ILLEGAL_PAIR, /* chgh */ NOT_BEGIN | BREAK | NOT_END, /* chph */ NOT_BEGIN | BREAK | NOT_END, /* chrh */ ILLEGAL_PAIR, /* chsh */ NOT_BEGIN | BREAK | NOT_END, /* chth */ NOT_BEGIN | BREAK | NOT_END, /* chwh */ ILLEGAL_PAIR, /* chqu */ NOT_BEGIN | BREAK | NOT_END, /* chck */ ILLEGAL_PAIR }, {/* gha */ ANY_COMBINATION, /* ghb */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghc */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghd */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghe */ ANY_COMBINATION, /* ghf */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghg */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghh */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghi */ BEGIN | NOT_END, /* ghj */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghk */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghl */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghm */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghn */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* gho */ BEGIN | NOT_END, /* ghp */ NOT_BEGIN | BREAK | NOT_END, /* ghr */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghs */ NOT_BEGIN | PREFIX, /* ght */ NOT_BEGIN | PREFIX, /* ghu */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghv */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghw */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghx */ ILLEGAL_PAIR, /* ghy */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghz */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghch */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghgh */ ILLEGAL_PAIR, /* ghph */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghrh */ ILLEGAL_PAIR, /* ghsh */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghth */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghwh */ ILLEGAL_PAIR, /* ghqu */ NOT_BEGIN | BREAK | PREFIX | NOT_END, /* ghck */ ILLEGAL_PAIR }, {/* pha */ ANY_COMBINATION, /* phb */ NOT_BEGIN | BREAK | NOT_END, /* phc */ NOT_BEGIN | BREAK | NOT_END, /* phd */ NOT_BEGIN | BREAK | NOT_END, /* phe */ ANY_COMBINATION, /* phf */ NOT_BEGIN | BREAK | NOT_END, /* phg */ NOT_BEGIN | BREAK | NOT_END, /* phh */ NOT_BEGIN | BREAK | NOT_END, /* phi */ ANY_COMBINATION, /* phj */ NOT_BEGIN | BREAK | NOT_END, /* phk */ NOT_BEGIN | BREAK | NOT_END, /* phl */ BEGIN | SUFFIX | NOT_END, /* phm */ NOT_BEGIN | BREAK | NOT_END, /* phn */ NOT_BEGIN | BREAK | NOT_END, /* pho */ ANY_COMBINATION, /* php */ NOT_BEGIN | BREAK | NOT_END, /* phr */ NOT_END, /* phs */ NOT_BEGIN, /* pht */ NOT_BEGIN, /* phu */ ANY_COMBINATION, /* phv */ NOT_BEGIN | NOT_END, /* phw */ NOT_BEGIN | NOT_END, /* phx */ ILLEGAL_PAIR, /* phy */ NOT_BEGIN, /* phz */ NOT_BEGIN | BREAK | NOT_END, /* phch */ NOT_BEGIN | BREAK | NOT_END, /* phgh */ NOT_BEGIN | BREAK | NOT_END, /* phph */ ILLEGAL_PAIR, /* phrh */ ILLEGAL_PAIR, /* phsh */ NOT_BEGIN | BREAK | NOT_END, /* phth */ NOT_BEGIN | BREAK | NOT_END, /* phwh */ ILLEGAL_PAIR, /* phqu */ NOT_BEGIN | BREAK | NOT_END, /* phck */ ILLEGAL_PAIR }, {/* rha */ BEGIN | NOT_END, /* rhb */ ILLEGAL_PAIR, /* rhc */ ILLEGAL_PAIR, /* rhd */ ILLEGAL_PAIR, /* rhe */ BEGIN | NOT_END, /* rhf */ ILLEGAL_PAIR, /* rhg */ ILLEGAL_PAIR, /* rhh */ ILLEGAL_PAIR, /* rhi */ BEGIN | NOT_END, /* rhj */ ILLEGAL_PAIR, /* rhk */ ILLEGAL_PAIR, /* rhl */ ILLEGAL_PAIR, /* rhm */ ILLEGAL_PAIR, /* rhn */ ILLEGAL_PAIR, /* rho */ BEGIN | NOT_END, /* rhp */ ILLEGAL_PAIR, /* rhr */ ILLEGAL_PAIR, /* rhs */ ILLEGAL_PAIR, /* rht */ ILLEGAL_PAIR, /* rhu */ BEGIN | NOT_END, /* rhv */ ILLEGAL_PAIR, /* rhw */ ILLEGAL_PAIR, /* rhx */ ILLEGAL_PAIR, /* rhy */ BEGIN | NOT_END, /* rhz */ ILLEGAL_PAIR, /* rhch */ ILLEGAL_PAIR, /* rhgh */ ILLEGAL_PAIR, /* rhph */ ILLEGAL_PAIR, /* rhrh */ ILLEGAL_PAIR, /* rhsh */ ILLEGAL_PAIR, /* rhth */ ILLEGAL_PAIR, /* rhwh */ ILLEGAL_PAIR, /* rhqu */ ILLEGAL_PAIR, /* rhck */ ILLEGAL_PAIR }, {/* sha */ ANY_COMBINATION, /* shb */ NOT_BEGIN | BREAK | NOT_END, /* shc */ NOT_BEGIN | BREAK | NOT_END, /* shd */ NOT_BEGIN | BREAK | NOT_END, /* she */ ANY_COMBINATION, /* shf */ NOT_BEGIN | BREAK | NOT_END, /* shg */ NOT_BEGIN | BREAK | NOT_END, /* shh */ ILLEGAL_PAIR, /* shi */ ANY_COMBINATION, /* shj */ NOT_BEGIN | BREAK | NOT_END, /* shk */ NOT_BEGIN, /* shl */ BEGIN | SUFFIX | NOT_END, /* shm */ BEGIN | SUFFIX | NOT_END, /* shn */ BEGIN | SUFFIX | NOT_END, /* sho */ ANY_COMBINATION, /* shp */ NOT_BEGIN, /* shr */ BEGIN | SUFFIX | NOT_END, /* shs */ NOT_BEGIN | BREAK | NOT_END, /* sht */ SUFFIX, /* shu */ ANY_COMBINATION, /* shv */ NOT_BEGIN | BREAK | NOT_END, /* shw */ SUFFIX | NOT_END, /* shx */ ILLEGAL_PAIR, /* shy */ ANY_COMBINATION, /* shz */ NOT_BEGIN | BREAK | NOT_END, /* shch */ NOT_BEGIN | BREAK | NOT_END, /* shgh */ NOT_BEGIN | BREAK | NOT_END, /* shph */ NOT_BEGIN | BREAK | NOT_END, /* shrh */ ILLEGAL_PAIR, /* shsh */ ILLEGAL_PAIR, /* shth */ NOT_BEGIN | BREAK | NOT_END, /* shwh */ ILLEGAL_PAIR, /* shqu */ NOT_BEGIN | BREAK | NOT_END, /* shck */ ILLEGAL_PAIR }, {/* tha */ ANY_COMBINATION, /* thb */ NOT_BEGIN | BREAK | NOT_END, /* thc */ NOT_BEGIN | BREAK | NOT_END, /* thd */ NOT_BEGIN | BREAK | NOT_END, /* the */ ANY_COMBINATION, /* thf */ NOT_BEGIN | BREAK | NOT_END, /* thg */ NOT_BEGIN | BREAK | NOT_END, /* thh */ NOT_BEGIN | BREAK | NOT_END, /* thi */ ANY_COMBINATION, /* thj */ NOT_BEGIN | BREAK | NOT_END, /* thk */ NOT_BEGIN | BREAK | NOT_END, /* thl */ NOT_BEGIN | BREAK | NOT_END, /* thm */ NOT_BEGIN | BREAK | NOT_END, /* thn */ NOT_BEGIN | BREAK | NOT_END, /* tho */ ANY_COMBINATION, /* thp */ NOT_BEGIN | BREAK | NOT_END, /* thr */ NOT_END, /* ths */ NOT_BEGIN | END, /* tht */ NOT_BEGIN | BREAK | NOT_END, /* thu */ ANY_COMBINATION, /* thv */ NOT_BEGIN | BREAK | NOT_END, /* thw */ SUFFIX | NOT_END, /* thx */ ILLEGAL_PAIR, /* thy */ ANY_COMBINATION, /* thz */ NOT_BEGIN | BREAK | NOT_END, /* thch */ NOT_BEGIN | BREAK | NOT_END, /* thgh */ NOT_BEGIN | BREAK | NOT_END, /* thph */ NOT_BEGIN | BREAK | NOT_END, /* thrh */ ILLEGAL_PAIR, /* thsh */ NOT_BEGIN | BREAK | NOT_END, /* thth */ ILLEGAL_PAIR, /* thwh */ ILLEGAL_PAIR, /* thqu */ NOT_BEGIN | BREAK | NOT_END, /* thck */ ILLEGAL_PAIR }, {/* wha */ BEGIN | NOT_END, /* whb */ ILLEGAL_PAIR, /* whc */ ILLEGAL_PAIR, /* whd */ ILLEGAL_PAIR, /* whe */ BEGIN | NOT_END, /* whf */ ILLEGAL_PAIR, /* whg */ ILLEGAL_PAIR, /* whh */ ILLEGAL_PAIR, /* whi */ BEGIN | NOT_END, /* whj */ ILLEGAL_PAIR, /* whk */ ILLEGAL_PAIR, /* whl */ ILLEGAL_PAIR, /* whm */ ILLEGAL_PAIR, /* whn */ ILLEGAL_PAIR, /* who */ BEGIN | NOT_END, /* whp */ ILLEGAL_PAIR, /* whr */ ILLEGAL_PAIR, /* whs */ ILLEGAL_PAIR, /* wht */ ILLEGAL_PAIR, /* whu */ ILLEGAL_PAIR, /* whv */ ILLEGAL_PAIR, /* whw */ ILLEGAL_PAIR, /* whx */ ILLEGAL_PAIR, /* why */ BEGIN | NOT_END, /* whz */ ILLEGAL_PAIR, /* whch */ ILLEGAL_PAIR, /* whgh */ ILLEGAL_PAIR, /* whph */ ILLEGAL_PAIR, /* whrh */ ILLEGAL_PAIR, /* whsh */ ILLEGAL_PAIR, /* whth */ ILLEGAL_PAIR, /* whwh */ ILLEGAL_PAIR, /* whqu */ ILLEGAL_PAIR, /* whck */ ILLEGAL_PAIR }, {/* qua */ ANY_COMBINATION, /* qub */ ILLEGAL_PAIR, /* quc */ ILLEGAL_PAIR, /* qud */ ILLEGAL_PAIR, /* que */ ANY_COMBINATION, /* quf */ ILLEGAL_PAIR, /* qug */ ILLEGAL_PAIR, /* quh */ ILLEGAL_PAIR, /* qui */ ANY_COMBINATION, /* quj */ ILLEGAL_PAIR, /* quk */ ILLEGAL_PAIR, /* qul */ ILLEGAL_PAIR, /* qum */ ILLEGAL_PAIR, /* qun */ ILLEGAL_PAIR, /* quo */ ANY_COMBINATION, /* qup */ ILLEGAL_PAIR, /* qur */ ILLEGAL_PAIR, /* qus */ ILLEGAL_PAIR, /* qut */ ILLEGAL_PAIR, /* quu */ ILLEGAL_PAIR, /* quv */ ILLEGAL_PAIR, /* quw */ ILLEGAL_PAIR, /* qux */ ILLEGAL_PAIR, /* quy */ ILLEGAL_PAIR, /* quz */ ILLEGAL_PAIR, /* quch */ ILLEGAL_PAIR, /* qugh */ ILLEGAL_PAIR, /* quph */ ILLEGAL_PAIR, /* qurh */ ILLEGAL_PAIR, /* qush */ ILLEGAL_PAIR, /* quth */ ILLEGAL_PAIR, /* quwh */ ILLEGAL_PAIR, /* ququ */ ILLEGAL_PAIR, /* quck */ ILLEGAL_PAIR }, {/* cka */ NOT_BEGIN | BREAK | NOT_END, /* ckb */ NOT_BEGIN | BREAK | NOT_END, /* ckc */ NOT_BEGIN | BREAK | NOT_END, /* ckd */ NOT_BEGIN | BREAK | NOT_END, /* cke */ NOT_BEGIN | BREAK | NOT_END, /* ckf */ NOT_BEGIN | BREAK | NOT_END, /* ckg */ NOT_BEGIN | BREAK | NOT_END, /* ckh */ NOT_BEGIN | BREAK | NOT_END, /* cki */ NOT_BEGIN | BREAK | NOT_END, /* ckj */ NOT_BEGIN | BREAK | NOT_END, /* ckk */ NOT_BEGIN | BREAK | NOT_END, /* ckl */ NOT_BEGIN | BREAK | NOT_END, /* ckm */ NOT_BEGIN | BREAK | NOT_END, /* ckn */ NOT_BEGIN | BREAK | NOT_END, /* cko */ NOT_BEGIN | BREAK | NOT_END, /* ckp */ NOT_BEGIN | BREAK | NOT_END, /* ckr */ NOT_BEGIN | BREAK | NOT_END, /* cks */ NOT_BEGIN, /* ckt */ NOT_BEGIN | BREAK | NOT_END, /* cku */ NOT_BEGIN | BREAK | NOT_END, /* ckv */ NOT_BEGIN | BREAK | NOT_END, /* ckw */ NOT_BEGIN | BREAK | NOT_END, /* ckx */ ILLEGAL_PAIR, /* cky */ NOT_BEGIN, /* ckz */ NOT_BEGIN | BREAK | NOT_END, /* ckch */ NOT_BEGIN | BREAK | NOT_END, /* ckgh */ NOT_BEGIN | BREAK | NOT_END, /* ckph */ NOT_BEGIN | BREAK | NOT_END, /* ckrh */ ILLEGAL_PAIR, /* cksh */ NOT_BEGIN | BREAK | NOT_END, /* ckth */ NOT_BEGIN | BREAK | NOT_END, /* ckwh */ ILLEGAL_PAIR, /* ckqu */ NOT_BEGIN | BREAK | NOT_END, /* ckck */ ILLEGAL_PAIR} }; /* ** gen_pron_pass will generate a Random word and place it in the ** buffer word. Also, the hyphenated word will be placed into ** the buffer hyphenated_word. Both word and hyphenated_word must ** be pre-allocated. The words generated will have sizes between ** minlen and maxlen. If restrict is TRUE, words will not be generated that ** appear as login names or as entries in the on-line dictionary. ** This algorithm was initially worded out by Morrie Gasser in 1975. ** Any changes here are minimal so that as many word combinations ** can be produced as possible (and thus keep the words Random). ** The seed is used on first use of the routine. ** The length of the unhyphenated word is returned, or -1 if there ** were an error (length settings are wrong or dictionary checking ** could not be done. */ int gen_pron_pass (char *word, char *hyphenated_word, USHORT minlen, USHORT maxlen, unsigned int pass_mode) { int pwlen; /* * Check for minlen>maxlen. This is an error. * and a length of 0. */ if (minlen > maxlen || minlen > APG_MAX_PASSWORD_LENGTH || maxlen > APG_MAX_PASSWORD_LENGTH) return (-1); /* * Check for zero length words. This is technically not an error, * so we take the short cut and return a null word and a length of 0. */ if (maxlen == 0) { word[0] = '\0'; hyphenated_word[0] = '\0'; return (0); } /* * Find password. */ pwlen = gen_word (word, hyphenated_word, get_random (minlen, maxlen), pass_mode); return (pwlen); } /* * This is the routine that returns a Random word -- as * yet unchecked against the passwd file or the dictionary. * It collects Random syllables until a predetermined * word length is found. If a retry threshold is reached, * another word is tried. Given that the Random number * generator is uniformly distributed, eventually a word * will be found if the retry limit is adequately large enough. */ int gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mode) { USHORT word_length; USHORT syllable_length; char *new_syllable; char *syllable_for_hyph; USHORT *syllable_units; USHORT word_size; USHORT word_place; USHORT *word_units; USHORT syllable_size; UINT tries; int ch_flag = FALSE; int dsd = 0; /* * Keep count of retries. */ tries = 0; /* * The length of the word in characters. */ word_length = 0; /* * The length of the word in character units (each of which is one or * two characters long. */ word_size = 0; /* * Initialize the array storing the word units. Since we know the * length of the word, we only need one of that length. This method is * preferable to a static array, since it allows us flexibility in * choosing arbitrarily long word lengths. Since a word can contain one * syllable, we should make syllable_units, the array holding the * analogous units for an individual syllable, the same length. No * explicit rule limits the length of syllables, but digram rules and * heuristics do so indirectly. */ if ( (word_units = (USHORT *) calloc (sizeof (USHORT), pwlen+1))==NULL || (syllable_units = (USHORT *) calloc (sizeof (USHORT), pwlen+1))==NULL || (new_syllable = (char *) calloc (sizeof (USHORT), pwlen+1)) ==NULL || (syllable_for_hyph = (char *) calloc (sizeof(char), 20))==NULL) return(-1); /* * Find syllables until the entire word is constructed. */ while (word_length < pwlen) { /* * Get the syllable and find its length. */ (void) gen_syllable (new_syllable, pwlen - word_length, syllable_units, &syllable_size); syllable_length = strlen (new_syllable); /* * Append the syllable units to the word units. */ for (word_place = 0; word_place <= syllable_size; word_place++) word_units[word_size + word_place] = syllable_units[word_place]; word_size += syllable_size + 1; /* * If the word has been improperly formed, throw out * the syllable. The checks performed here are those * that must be formed on a word basis. The other * tests are performed entirely within the syllable. * Otherwise, append the syllable to the word and * append the syllable to the hyphenated version of * the word. */ if (improper_word (word_units, word_size) || ((word_length == 0) && have_initial_y (syllable_units, syllable_size)) || ((word_length + syllable_length == pwlen) && have_final_split (syllable_units, syllable_size))) word_size -= syllable_size + 1; else { if (word_length == 0) { /* ** Modify syllable for numeric or capital symbols required ** Should be done after word quality check. */ dsd = randint(2); if ( ((pass_mode & S_NB) > 0) && (syllable_length == 1) && dsd == 0) { numerize(new_syllable); ch_flag = TRUE; } if ( ((pass_mode & S_SS) > 0) && (syllable_length == 1) && (dsd == 1)) { specialize(new_syllable); ch_flag = TRUE; } if ( ( (pass_mode & S_CL) > 0) && (ch_flag != TRUE)) capitalize(new_syllable); ch_flag = FALSE; /**/ (void) strcpy (word, new_syllable); if (syllable_length == 1) { symb2name(new_syllable, syllable_for_hyph); (void) strcpy (hyphenated_word, syllable_for_hyph); } else { (void) strcpy (hyphenated_word, new_syllable); } (void)memset ( (void *)new_syllable, 0, (size_t)(pwlen * sizeof(USHORT)+1)); (void)memset ( (void *)syllable_for_hyph, 0, 20); } else { /* ** Modify syllable for numeric or capital symbols required ** Should be done after word quality check. */ dsd = randint(2); if ( ((pass_mode & S_NB) > 0) && (syllable_length == 1) && (dsd == 0)) { numerize(new_syllable); ch_flag = TRUE; } if ( ( (pass_mode & S_SS) > 0) && (syllable_length == 1) && (dsd == 1)) { specialize(new_syllable); ch_flag = TRUE; } if ( ( (pass_mode & S_CL) > 0) && (ch_flag != TRUE)) capitalize(new_syllable); ch_flag = FALSE; /**/ (void) strcat (word, new_syllable); (void) strcat (hyphenated_word, "-"); if (syllable_length == 1) { symb2name(new_syllable, syllable_for_hyph); (void) strcat (hyphenated_word, syllable_for_hyph); } else { (void) strcat (hyphenated_word, new_syllable); } (void)memset ( (void *)new_syllable, 0, (size_t)(pwlen * sizeof(USHORT)+1)); (void)memset ( (void *)syllable_for_hyph, 0, 20); } word_length += syllable_length; } /* * Keep track of the times we have tried to get * syllables. If we have exceeded the threshold, * reinitialize the pwlen and word_size variables, clear * out the word arrays, and start from scratch. */ tries++; if (tries > MAX_RETRIES) { word_length = 0; word_size = 0; tries = 0; (void) strcpy (word, ""); (void) strcpy (hyphenated_word, ""); } } /* * The units arrays and syllable storage are internal to this * routine. Since the caller has no need for them, we * release the space. */ free ((char *) new_syllable); free ((char *) syllable_units); free ((char *) word_units); free ((char *) syllable_for_hyph); return ((int) word_length); } /* * Check that the word does not contain illegal combinations * that may span syllables. Specifically, these are: * 1. An illegal pair of units between syllables. * 2. Three consecutive vowel units. * 3. Three consecutive consonant units. * The checks are made against units (1 or 2 letters), not against * the individual letters, so three consecutive units can have * the length of 6 at most. */ boolean improper_word (USHORT *units, USHORT word_size) { USHORT unit_count; boolean failure; failure = FALSE; for (unit_count = 0; !failure && (unit_count < word_size); unit_count++) { /* * Check for ILLEGAL_PAIR. This should have been caught * for units within a syllable, but in some cases it * would have gone unnoticed for units between syllables * (e.g., when saved_unit's in gen_syllable() were not * used). */ if ((unit_count != 0) && (digram[units[unit_count - 1]][units[unit_count]] & ILLEGAL_PAIR)) failure = TRUE; /* * Check for consecutive vowels or consonants. Because * the initial y of a syllable is treated as a consonant * rather than as a vowel, we exclude y from the first * vowel in the vowel test. The only problem comes when * y ends a syllable and two other vowels start the next, * like fly-oint. Since such words are still * pronounceable, we accept this. */ if (!failure && (unit_count >= 2)) { /* * Vowel check. */ if ((((rules[units[unit_count - 2]].flags & VOWEL) && !(rules[units[unit_count - 2]].flags & ALTERNATE_VOWEL)) && (rules[units[unit_count - 1]].flags & VOWEL) && (rules[units[unit_count]].flags & VOWEL)) || /* * Consonant check. */ (!(rules[units[unit_count - 2]].flags & VOWEL) && !(rules[units[unit_count - 1]].flags & VOWEL) && !(rules[units[unit_count]].flags & VOWEL))) failure = TRUE; } } return (failure); } /* * Treating y as a vowel is sometimes a problem. Some words * get formed that look irregular. One special group is when * y starts a word and is the only vowel in the first syllable. * The word ycl is one example. We discard words like these. */ boolean have_initial_y (USHORT *units, USHORT unit_size) { USHORT unit_count; USHORT vowel_count; USHORT normal_vowel_count; vowel_count = 0; normal_vowel_count = 0; for (unit_count = 0; unit_count <= unit_size; unit_count++) /* * Count vowels. */ if (rules[units[unit_count]].flags & VOWEL) { vowel_count++; /* * Count the vowels that are not: 1. y, 2. at the start of * the word. */ if (!(rules[units[unit_count]].flags & ALTERNATE_VOWEL) || (unit_count != 0)) normal_vowel_count++; } return ((vowel_count <= 1) && (normal_vowel_count == 0)); } /* * Besides the problem with the letter y, there is one with * a silent e at the end of words, like face or nice. We * allow this silent e, but we do not allow it as the only * vowel at the end of the word or syllables like ble will * be generated. */ boolean have_final_split (USHORT *units, USHORT unit_size) { USHORT unit_count; USHORT vowel_count; vowel_count = 0; /* * Count all the vowels in the word. */ for (unit_count = 0; unit_count <= unit_size; unit_count++) if (rules[units[unit_count]].flags & VOWEL) vowel_count++; /* * Return TRUE iff the only vowel was e, found at the end if the * word. */ return ((vowel_count == 1) && (rules[units[unit_size]].flags & NO_FINAL_SPLIT)); } /* * Generate next unit to password, making sure that it follows * these rules: * 1. Each syllable must contain exactly 1 or 2 consecutive * vowels, where y is considered a vowel. * 2. Syllable end is determined as follows: * a. Vowel is generated and previous unit is a * consonant and syllable already has a vowel. In * this case, new syllable is started and already * contains a vowel. * b. A pair determined to be a "break" pair is encountered. * In this case new syllable is started with second unit * of this pair. * c. End of password is encountered. * d. "begin" pair is encountered legally. New syllable is * started with this pair. * e. "end" pair is legally encountered. New syllable has * nothing yet. * 3. Try generating another unit if: * a. third consecutive vowel and not y. * b. "break" pair generated but no vowel yet in current * or previous 2 units are "not_end". * c. "begin" pair generated but no vowel in syllable * preceding begin pair, or both previous 2 pairs are * designated "not_end". * d. "end" pair generated but no vowel in current syllable * or in "end" pair. * e. "not_begin" pair generated but new syllable must * begin (because previous syllable ended as defined in * 2 above). * f. vowel is generated and 2a is satisfied, but no syllable * break is possible in previous 3 pairs. * g. Second and third units of syllable must begin, and * first unit is "alternate_vowel". */ char * gen_syllable (char *syllable, USHORT pwlen, USHORT *units_in_syllable, USHORT *syllable_length) { USHORT unit = 0; SHORT current_unit = 0; USHORT vowel_count = 0; boolean rule_broken; boolean want_vowel; boolean want_another_unit; UINT tries = 0; USHORT last_unit = 0; SHORT length_left = 0; USHORT hold_saved_unit = 0; static USHORT saved_unit; static USHORT saved_pair[2]; /* * This is needed if the saved_unit is tries and the syllable then * discarded because of the retry limit. Since the saved_unit is OK and * fits in nicely with the preceding syllable, we will always use it. */ hold_saved_unit = saved_unit; /* * Loop until valid syllable is found. */ do { /* * Try for a new syllable. Initialize all pertinent * syllable variables. */ tries = 0; saved_unit = hold_saved_unit; (void) strcpy (syllable, ""); vowel_count = 0; current_unit = 0; length_left = (short int) pwlen; want_another_unit = TRUE; /* * This loop finds all the units for the syllable. */ do { want_vowel = FALSE; /* * This loop continues until a valid unit is found for the * current position within the syllable. */ do { /* * If there are saved_unit's from the previous * syllable, use them up first. */ if (saved_unit != 0) { /* * If there were two saved units, the first is * guaranteed (by checks performed in the previous * syllable) to be valid. We ignore the checks * and place it in this syllable manually. */ if (saved_unit == 2) { units_in_syllable[0] = saved_pair[1]; if (rules[saved_pair[1]].flags & VOWEL) vowel_count++; current_unit++; (void) strcpy (syllable, rules[saved_pair[1]].unit_code); length_left -= strlen (syllable); } /* * The unit becomes the last unit checked in the * previous syllable. */ unit = saved_pair[0]; /* * The saved units have been used. Do not try to * reuse them in this syllable (unless this particular * syllable is rejected at which point we start to rebuild * it with these same saved units. */ saved_unit = 0; } else /* * If we don't have to scoff the saved units, * we generate a Random one. If we know it has * to be a vowel, we get one rather than looping * through until one shows up. */ if (want_vowel) unit = random_unit (VOWEL); else unit = random_unit (NO_SPECIAL_RULE); length_left -= (short int) strlen (rules[unit].unit_code); /* * Prevent having a word longer than expected. */ if (length_left < 0) rule_broken = TRUE; else rule_broken = FALSE; /* * First unit of syllable. This is special because the * digram tests require 2 units and we don't have that yet. * Nevertheless, we can perform some checks. */ if (current_unit == 0) { /* * If the shouldn't begin a syllable, don't * use it. */ if (rules[unit].flags & NOT_BEGIN_SYLLABLE) rule_broken = TRUE; else /* * If this is the last unit of a word, * we have a one unit syllable. Since each * syllable must have a vowel, we make sure * the unit is a vowel. Otherwise, we * discard it. */ if (length_left == 0) { if (rules[unit].flags & VOWEL) want_another_unit = FALSE; else rule_broken = TRUE; } } else { /* * There are some digram tests that are * universally true. We test them out. */ /* * Reject ILLEGAL_PAIRS of units. */ if ((ALLOWED (ILLEGAL_PAIR)) || /* * Reject units that will be split between syllables * when the syllable has no vowels in it. */ (ALLOWED (BREAK) && (vowel_count == 0)) || /* * Reject a unit that will end a syllable when no * previous unit was a vowel and neither is this one. */ (ALLOWED (END) && (vowel_count == 0) && !(rules[unit].flags & VOWEL))) rule_broken = TRUE; if (current_unit == 1) { /* * Reject the unit if we are at te starting digram of * a syllable and it does not fit. */ if (ALLOWED (NOT_BEGIN)) rule_broken = TRUE; } else { /* * We are not at the start of a syllable. * Save the previous unit for later tests. */ last_unit = units_in_syllable[current_unit - 1]; /* * Do not allow syllables where the first letter is y * and the next pair can begin a syllable. This may * lead to splits where y is left alone in a syllable. * Also, the combination does not sound to good even * if not split. */ if (((current_unit == 2) && (ALLOWED (BEGIN)) && (rules[units_in_syllable[0]].flags & ALTERNATE_VOWEL)) || /* * If this is the last unit of a word, we should * reject any digram that cannot end a syllable. */ (ALLOWED (NOT_END) && (length_left == 0)) || /* * Reject the unit if the digram it forms wants * to break the syllable, but the resulting * digram that would end the syllable is not * allowed to end a syllable. */ (ALLOWED (BREAK) && (digram[units_in_syllable [current_unit - 2]] [last_unit] & NOT_END)) || /* * Reject the unit if the digram it forms * expects a vowel preceding it and there is * none. */ (ALLOWED (PREFIX) && !(rules[units_in_syllable [current_unit - 2]].flags & VOWEL))) rule_broken = TRUE; /* * The following checks occur when the current unit * is a vowel and we are not looking at a word ending * with an e. */ if (!rule_broken && (rules[unit].flags & VOWEL) && ((length_left > 0) || !(rules[last_unit].flags & NO_FINAL_SPLIT))) { /* * Don't allow 3 consecutive vowels in a * syllable. Although some words formed like this * are OK, like beau, most are not. */ if ((vowel_count > 1) && (rules[last_unit].flags & VOWEL)) rule_broken = TRUE; else /* * Check for the case of * vowels-consonants-vowel, which is only * legal if the last vowel is an e and we are * the end of the word (wich is not * happening here due to a previous check. */ if ((vowel_count != 0) && !(rules[last_unit].flags & VOWEL)) { /* * Try to save the vowel for the next * syllable, but if the syllable left here * is not proper (i.e., the resulting last * digram cannot legally end it), just * discard it and try for another. */ if (digram[units_in_syllable [current_unit - 2]] [last_unit] & NOT_END) rule_broken = TRUE; else { saved_unit = 1; saved_pair[0] = unit; want_another_unit = FALSE; } } } } /* * The unit picked and the digram formed are legal. * We now determine if we can end the syllable. It may, * in some cases, mean the last unit(s) may be deferred to * the next syllable. We also check here to see if the * digram formed expects a vowel to follow. */ if (!rule_broken && want_another_unit) { /* * This word ends in a silent e. */ /******/ if (((vowel_count != 0) && (rules[unit].flags & NO_FINAL_SPLIT) && (length_left == 0) && !(rules[last_unit].flags & VOWEL)) || /* * This syllable ends either because the digram * is an END pair or we would otherwise exceed * the length of the word. */ (ALLOWED (END) || (length_left == 0))) { want_another_unit = FALSE; } else /* * Since we have a vowel in the syllable * already, if the digram calls for the end of the * syllable, we can legally split it off. We also * make sure that we are not at the end of the * dangerous because that syllable may not have * vowels, or it may not be a legal syllable end, * and the retrying mechanism will loop infinitely * with the same digram. */ if ((vowel_count != 0) && (length_left > 0)) { /* * If we must begin a syllable, we do so if * the only vowel in THIS syllable is not part * of the digram we are pushing to the next * syllable. */ if (ALLOWED (BEGIN) && (current_unit > 1) && !((vowel_count == 1) && (rules[last_unit].flags & VOWEL))) { saved_unit = 2; saved_pair[0] = unit; saved_pair[1] = last_unit; want_another_unit = FALSE; } else if (ALLOWED (BREAK)) { saved_unit = 1; saved_pair[0] = unit; want_another_unit = FALSE; } } else if (ALLOWED (SUFFIX)) { want_vowel = TRUE; } } } /********/ tries++; /* * If this unit was illegal, redetermine the amount of * letters left to go in the word. */ if (rule_broken) length_left += (short int) strlen (rules[unit].unit_code); } while (rule_broken && (tries <= MAX_RETRIES)); /* * The unit fit OK. */ if (tries <= MAX_RETRIES) { /* * If the unit were a vowel, count it in. * However, if the unit were a y and appear * at the start of the syllable, treat it * like a constant (so that words like year can * appear and not conflict with the 3 consecutive * vowel rule. */ if ((rules[unit].flags & VOWEL) && ((current_unit > 0) || !(rules[unit].flags & ALTERNATE_VOWEL))) vowel_count++; /* * If a unit or units were to be saved, we must * adjust the syllable formed. Otherwise, we * append the current unit to the syllable. */ switch (saved_unit) { case 0: units_in_syllable[current_unit] = unit; (void) strcat (syllable, rules[unit].unit_code); break; case 1: current_unit--; break; case 2: (void) strcpy (&syllable[strlen (syllable) - strlen (rules[last_unit].unit_code)],""); length_left += (short int) strlen (rules[last_unit].unit_code); current_unit -= 2; break; } } else /* * Whoops! Too many tries. We set rule_broken so we can * loop in the outer loop and try another syllable. */ rule_broken = TRUE; /* * ...and the syllable length grows. */ *syllable_length = current_unit; current_unit++; } while ((tries <= MAX_RETRIES) && want_another_unit); } while (rule_broken || illegal_placement (units_in_syllable, *syllable_length)); return (syllable); } /* * This routine goes through an individual syllable and checks * for illegal combinations of letters that go beyond looking * at digrams. We look at things like 3 consecutive vowels or * consonants, or syllables with consonants between vowels (unless * one of them is the final silent e). */ boolean illegal_placement (USHORT *units, USHORT pwlen) { USHORT vowel_count; USHORT unit_count; boolean failure; vowel_count = 0; failure = FALSE; for (unit_count = 0; !failure && (unit_count <= pwlen); unit_count++) { if (unit_count >= 1) { /* * Don't allow vowels to be split with consonants in * a single syllable. If we find such a combination * (except for the silent e) we have to discard the * syllable). */ if ((!(rules[units[unit_count - 1]].flags & VOWEL) && (rules[units[unit_count]].flags & VOWEL) && !((rules[units[unit_count]].flags & NO_FINAL_SPLIT) && (unit_count == pwlen)) && (vowel_count != 0)) || /* * Perform these checks when we have at least 3 units. */ ((unit_count >= 2) && /* * Disallow 3 consecutive consonants. */ ((!(rules[units[unit_count - 2]].flags & VOWEL) && !(rules[units[unit_count - 1]].flags & VOWEL) && !(rules[units[unit_count]].flags & VOWEL)) || /* * Disallow 3 consecutive vowels, where the first is * not a y. */ (((rules[units[unit_count - 2]].flags & VOWEL) && !((rules[units[0]].flags & ALTERNATE_VOWEL) && (unit_count == 2))) && (rules[units[unit_count - 1]].flags & VOWEL) && (rules[units[unit_count]].flags & VOWEL))))) failure = TRUE; } /* * Count the vowels in the syllable. As mentioned somewhere * above, exclude the initial y of a syllable. Instead, * treat it as a consonant. */ if ((rules[units[unit_count]].flags & VOWEL) && !((rules[units[0]].flags & ALTERNATE_VOWEL) && (unit_count == 0) && (pwlen != 0))) vowel_count++; } return (failure); } /* * This is the standard Random unit generating routine for * gen_syllable(). It does not reference the digrams, but * assumes that it contains 34 units in a particular order. * This routine attempts to return unit indexes with a distribution * approaching that of the distribution of the 34 units in * English. In order to do this, a Random number (supposedly * uniformly distributed) is used to do a table lookup into an * array containing unit indices. There are 211 entries in * the array for the random_unit entry point. The probability * of a particular unit being generated is equal to the * fraction of those 211 entries that contain that unit index. * For example, the letter `a' is unit number 1. Since unit * index 1 appears 10 times in the array, the probability of * selecting an `a' is 10/211. * * Changes may be made to the digram table without affect to this * procedure providing the letter-to-number correspondence of * the units does not change. Likewise, the distribution of the * 34 units may be altered (and the array size may be changed) * in this procedure without affecting the digram table or any other * programs using the Random_word subroutine. */ static USHORT numbers[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33 }; /* * This structure has a typical English frequency of vowels. * The value of an entry is the vowel position (a=0, e=4, i=8, * o=14, u=19, y=23) in the rules array. The number of times * the value appears is the frequency. Thus, the letter "a" * is assumed to appear 2/12 = 1/6 of the time. This array * may be altered if better data is obtained. The routines that * use vowel_numbers will adjust to the size difference automatically. */ static USHORT vowel_numbers[] = { 0, 0, 4, 4, 4, 8, 8, 14, 14, 19, 19, 23 }; /* * Select a unit (a letter or a consonant group). If a vowel is * expected, use the vowel_numbers array rather than looping through * the numbers array until a vowel is found. */ USHORT random_unit (USHORT type) { USHORT number; /* * Sometimes, we are asked to explicitly get a vowel (i.e., if * a digram pair expects one following it). This is a shortcut * to do that and avoid looping with rejected consonants. */ if (type & VOWEL) number = vowel_numbers[get_random (0, (sizeof (vowel_numbers) / sizeof (USHORT))-1)]; else /* * Get any letter according to the English distribution. */ number = numbers[get_random (0, (sizeof (numbers) / sizeof (USHORT))-1)]; return (number); } /* ** get_random() - ** This routine should return a uniformly distributed Random number between ** minlen and maxlen inclusive. The Electronic Code Book form of CAST is ** used to produce the Random number. The inputs to CAST are the old pass- ** word and a pseudoRandom key generated according to the procedure out- ** lined in Appendix C of ANSI X9.17. ** INPUT: ** USHORT - minimum ** USHORT - maximum ** OUTPUT: ** USHORT - random number ** NOTES: ** none. */ USHORT get_random (USHORT minlen, USHORT maxlen) { USHORT ret = 0; ret = minlen + (USHORT) randint ((int) (maxlen - minlen + 1)); return (ret); } apg-2.2.3.dfsg.1/pronpass.h0000644000175100017510000000642607714471356013206 0ustar mhmh/* ** This module uses code from the NIST implementation of FIPS-181, ** but the algorythm is CHANGED and I think that I CAN ** copyright it. See copiright notes below. */ /* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_PRONPASS_H #define APG_PRONPASS_H 1 #ifndef APG_OWN_TYPES_H #include "owntypes.h" #endif /* APG_OWN_TYPES_H */ #ifndef APG_RND_H #include "rnd.h" #endif /* APG_RND_H */ #define RULE_SIZE (sizeof(rules)/sizeof(struct unit)) #define ALLOWED(flag) (digram[units_in_syllable[current_unit -1]][unit] & (flag)) #define MAX_UNACCEPTABLE 20 #define MAX_RETRIES (4 * (int) pwlen + RULE_SIZE) #define NOT_BEGIN_SYLLABLE 010 #define NO_FINAL_SPLIT 04 #define VOWEL 02 #define ALTERNATE_VOWEL 01 #define NO_SPECIAL_RULE 0 #define BEGIN 0200 #define NOT_BEGIN 0100 #define BREAK 040 #define PREFIX 020 #define ILLEGAL_PAIR 010 #define SUFFIX 04 #define END 02 #define NOT_END 01 #define ANY_COMBINATION 0 extern int gen_pron_pass (char *word, char *hyphenated_word, USHORT minlen, USHORT maxlen, unsigned int pass_mode); USHORT random_unit (USHORT type); USHORT get_random (USHORT minlen, USHORT maxlen); boolean have_initial_y (USHORT *units, USHORT unit_size); boolean illegal_placement (USHORT *units, USHORT pwlen); boolean improper_word (USHORT *units, USHORT word_size); boolean have_final_split (USHORT *units, USHORT unit_size); int gen_word (char *word, char *hyphenated_word, USHORT pwlen, unsigned int pass_mode); char *gen_syllable(char *syllable, USHORT pwlen, USHORT *units_in_syllable, USHORT *syllable_length); #endif /* APG_PRONPASS_H */ apg-2.2.3.dfsg.1/randpass.c0000644000175100017510000001135507714471356013144 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** randpass.c - Random password generation module of PWGEN program */ #include #include #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include #endif #include #include "randpass.h" #include "owntypes.h" #include "smbl.h" /* ** gen_rand_pass - generates random password of specified type ** INPUT: ** char * - password string. ** int - minimum password length. ** int - maximum password length. ** unsigned int - password generation mode. ** OUTPUT: ** int - password length or -1 on error. ** NOTES: ** none. */ int gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode) { int i = 0; int j = 0; int length = 0; char *str_pointer; int random_weight[94]; int max_weight = 0; int max_weight_element_number = 0; if (minl > APG_MAX_PASSWORD_LENGTH || maxl > APG_MAX_PASSWORD_LENGTH || minl < 1 || maxl < 1 || minl > maxl) return (-1); for (i = 0; i <= 93; i++) random_weight[i] = 0; length = minl + randint(maxl-minl+1); str_pointer = password_string; for (i = 0; i < length; i++) { /* Asign random weight in weight array if mode is present*/ for (j = 0; j <= 93 ; j++) if ( ( (pass_mode & smbl[j].type) > 0) && !( (S_RS & smbl[j].type) > 0)) random_weight[j] = 1 + randint(20000); j = 0; /* Find an element with maximum weight */ 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; str_pointer++; max_weight = 0; max_weight_element_number = 0; for (j = 0; j <= 93; j++) random_weight[j] = 0; } *str_pointer = 0; return (length); } /* ** gen_rand_symbol - generates random password of specified type ** INPUT: ** char * - symbol. ** unsigned int - symbol type. ** OUTPUT: ** int - password length or -1 on error. ** NOTES: ** none. */ int gen_rand_symbol (char *symbol, unsigned int mode) { int j = 0; char *str_pointer; int random_weight[94]; int max_weight = 0; int max_weight_element_number = 0; for (j = 0; j <= 93; j++) random_weight[j] = 0; str_pointer = symbol; j = 0; /* Asign random weight in weight array if mode is present*/ for (j = 0; j <= 93 ; j++) if ( ( (mode & smbl[j].type) > 0) && !( (S_RS & smbl[j].type) > 0)) random_weight[j] = 1 + randint(20000); j = 0; /* Find an element with maximum weight */ for (j = 0; j <= 93; j++) if (random_weight[j] > max_weight) { max_weight = random_weight[j]; max_weight_element_number = j; } /* Get password symbol */ *str_pointer = smbl[max_weight_element_number].ch; max_weight = 0; max_weight_element_number = 0; return (0); } /* ** is_restricted_symbol - detcts if symbol is restricted rigt now ** INPUT: ** char - symbol. ** OUTPUT: ** int - 0 - not restricted ** 1 - restricted ** NOTES: ** none. */ int is_restricted_symbol (char symbol) { int j = 0; for (j = 0; j <= 93 ; j++) if (symbol == smbl[j].ch) if ((S_RS & smbl[j].type) > 0) return(1); return(0); } apg-2.2.3.dfsg.1/randpass.h0000644000175100017510000000432007714471356013143 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** randpass.h */ #ifndef APG_RANDPASS_H #define APG_RANDPASS_H 1 #ifndef APG_RND_H #include "rnd.h" #endif #ifndef APG_OWN_TYPES_H #include "owntypes.h" #endif #define S_NB 0x01 /* Numeric */ #define S_SS 0x02 /* Special */ #define S_CL 0x04 /* Capital */ #define S_SL 0x08 /* Small */ #define S_RS 0x10 /* Restricted Symbol*/ struct sym { char ch; USHORT type; }; /* char gen_symbol(unsigned short int symbol_class); */ extern int gen_rand_pass(char* password_string, int minl, int maxl, unsigned int pass_mode); extern int gen_rand_symbol (char *symbol, unsigned int mode); extern int is_restricted_symbol (char symbol); #endif /* RANDPASS_H */ apg-2.2.3.dfsg.1/README0000644000175100017510000000113407714471356012037 0ustar mhmhAPG v2.2.0 was tested and found working on: i386 FreeBSD 5.0-RELEASE Intel Solaris 8 gcc-2.95.2 QNX PRP 6.0 RedHat Linux 7.2 Mandrake Linux 9.1 Win 2000 Pro NOTE: This release (APG v2.2.0) is NOT compatible with TkAPG (Tcl/Tk frontend for APG) Any compatibility reports are welcome * For installation instructions see INSTALL * For usage instructions see manpages * For tips see doc/APG_TIPS * For copying information see COPYING See also APG Homepage at: http://www.adel.nursat.kz/apg/ ANY PATCHES OR SUGGESTIONS ARE WELCOME Adel I. Mirzazhanov E-mail: a-del@iname.com apg-2.2.3.dfsg.1/README.CYGWIN0000644000175100017510000000047707714471356013047 0ustar mhmhAPG is now supports CYGWIN (thanks to Graham Bloice ) * For installation instructions see INSTALL.CYGWIN * For usage instructions see manpages * For copying information see COPYING See also APG Homepage at: http://www.adel.nursat.kz/apg/ Adel I. Mirzazhanov E-mail: a-del@iname.comapg-2.2.3.dfsg.1/sha/0000755000175100017510000000000007714471356011733 5ustar mhmhapg-2.2.3.dfsg.1/sha/sha.c0000644000175100017510000002425207714471356012657 0ustar mhmh/***************************************************************************/ /* 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 #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; countdigest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff ; } /* apg_shaFinal */ apg-2.2.3.dfsg.1/sha/sha.h0000644000175100017510000000226207714471356012661 0ustar mhmh/***************************************************************************/ /* 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_ */ apg-2.2.3.dfsg.1/restrict.c0000644000175100017510000001707207714471356013172 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** restrict.c */ #include #include #include #include "restrict.h" extern struct sym smbl[94]; /* ** check_pass() - routine that checks if password exist in dictionary ** INPUT: ** char * - password to check. ** char * - dictionary filename. ** OUTPUT: ** int ** -1 - error ** 1 - password exist in dictionary ** 0 - password does not exist in dictionary ** NOTES: ** none. */ int check_pass(char *pass, char *dict) { FILE *dct; char *string; char *tmp; if( (string = (char *) calloc(1,MAX_DICT_STRING_SIZE)) == NULL) return(-1); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> check_pass: ck pass: %s\n", pass); fflush (stdout); #endif /* APG_DEBUG */ /* ** Open dict file an report of error */ if ( (dct = fopen(dict,"r")) == NULL) return(-1); while ((fgets(string, MAX_DICT_STRING_SIZE, dct) != NULL)) { tmp = strtok (string," \t\n\0"); if( tmp != NULL) string = tmp; else continue; if(strlen(string) != strlen(pass)) continue; else if (strncmp(string, pass, strlen(pass)) == 0) { free ( (void *)string); fclose (dct); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> check_pass: password found in dictionary: %s\n", pass); fflush (stdout); #endif /* APG_DEBUG */ return (1); } } free ( (void *)string); fclose (dct); return (0); } /* ** bloom_check_pass() - routine that checks if password exist in dictionary ** using Bloom filter. ** INPUT: ** char * - password to check. ** char * - bloom-filter filename. ** OUTPUT: ** int ** -1 - error ** 1 - password exist in dictionary ** 0 - password does not exist in dictionary ** NOTES: ** none. */ int bloom_check_pass (char *word, char *filter) { int ret = 0; FILE *f_filter; h_val filter_size = 0L; f_mode flt_mode = 0x00; if ( (f_filter = open_filter(filter,"r")) == NULL) return(-1); filter_size = get_filtersize(f_filter); flt_mode = get_filtermode(f_filter); ret = check_word (word, f_filter, filter_size, flt_mode); close_filter(f_filter); return(ret); } /* ** paranoid_bloom_check_pass() - routine that checks if password or any ** substring of the password exist in dictionary using Bloom filter. ** INPUT: ** char * - password to check. ** char * - bloom-filter filename. ** USHORT - minimum substring length ** OUTPUT: ** int ** -1 - error ** 1 - password exist in dictionary ** 0 - password does not exist in dictionary ** NOTES: ** none. */ int paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len) { char * substring; int len = strlen(password); /* string length */ int c_substr_start_pos = 0; /* current start position */ int substr_len = 0; /* substring length (LEN-I >= substr_len >= 2) */ int k = 0; /* counter */ int c = 0; /* counter */ int ret = 0; if (s_len < 2) s_len = 2; if (s_len > len) return (bloom_check_pass(password, filter)); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: ck pass: %s\n", password); fflush (stdout); #endif /* APG_DEBUG */ if ((substring = (char *)calloc(1, (size_t)len))==NULL) return (-1); for (c_substr_start_pos = 0; c_substr_start_pos <= len-s_len; c_substr_start_pos++) for (substr_len = s_len; substr_len <= len-c_substr_start_pos; substr_len++) { c = 0; for (k = c_substr_start_pos; k <= c_substr_start_pos + substr_len-1; k++) { substring[c]=password[k]; c++; } #ifdef APG_DEBUG fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: ck substr: %s\n", substring); fflush (stdout); #endif /* APG_DEBUG */ if((ret = bloom_check_pass(substring, filter)) == 1) { #ifdef APG_DEBUG fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: substr found in filter: %s\n", substring); fflush (stdout); #endif /* APG_DEBUG */ return(1); } else if (ret == -1) return(-1); (void)memset(substring,0,(size_t)len); } return(0); } /* ** filter_check_pass() - routine that checks password against filter string ** ** INPUT: ** char * - password to check. ** char * - bloom-filter filename. ** OUTPUT: ** int ** -1 - error ** 1 - password do not pass the filter ** 0 - password pass the filter ** NOTES: ** none. */ int filter_check_pass(const char * word, unsigned int cond) { int i = 0; int sl_ret = 0; int cl_ret = 0; int nb_ret = 0; int ss_ret = 0; #ifdef APG_DEBUG fprintf (stdout, "DEBUG> filter_check_pass: ck pass: %s\n", word); fflush (stdout); #endif /* APG_DEBUG */ if ((cond & S_SS) > 0) for (i=0; i < 94; i++) if ((smbl[i].type & S_SS) > 0) if ((strchr(word,smbl[i].ch)) != NULL) ss_ret = 1; i = 0; if ((cond & S_SL) > 0) for (i=0; i < 94; i++) if ((smbl[i].type & S_SL) > 0) if ((strchr(word,smbl[i].ch)) != NULL) sl_ret = 1; i = 0; if ((cond & S_CL) > 0) for (i=0; i < 94; i++) if ((smbl[i].type & S_CL) > 0) if ((strchr(word,smbl[i].ch)) != NULL) cl_ret = 1; i = 0; if ((cond & S_NB) > 0) for (i=0; i < 94; i++) if ((smbl[i].type & S_NB) > 0) if ((strchr(word,smbl[i].ch)) != NULL) nb_ret = 1; if (((cond & S_SS) > 0) &&(ss_ret != 1)) return (1); if (((cond & S_SL) > 0) &&(sl_ret != 1)) return (1); if (((cond & S_CL) > 0) &&(cl_ret != 1)) return (1); if (((cond & S_NB) > 0) &&(nb_ret != 1)) return (1); #ifdef APG_DEBUG fprintf (stdout, "DEBUG> filter_check_pass: password %s pass the filter\n", word); fflush (stdout); #endif /* APG_DEBUG */ return(0); } /* ** set_exclude_list() - set up character list that should ** be excluded from password generation process ** ** INPUT: ** char * - string of characters. ** OUTPUT: ** int - return code ** 0 - OK ** -1 - char_string is too long (max 93) ** NOTES: ** none. */ int set_exclude_list(const char * char_string) { int i = 0; if (strlen(char_string) > 93) return(-1); for(i=0; i < 94; i++) if ((strchr(char_string, smbl[i].ch)) != NULL) smbl[i].type = smbl[i].type | S_RS; return(0); } apg-2.2.3.dfsg.1/restrict.h0000644000175100017510000000373207714471356013175 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** restrict.h */ #ifndef APG_RESTRICT_H #define APG_RESTRICT_H 1 #include "bloom.h" #include "randpass.h" #define MAX_DICT_STRING_SIZE 255 int check_pass(char * pass, char *dict); int bloom_check_pass (char *word, char *filter); int paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len); int filter_check_pass(const char * word, unsigned int cond); int set_exclude_list(const char * char_string); #endif /* APG_RESTRICT_H */ apg-2.2.3.dfsg.1/rnd.c0000644000175100017510000001546107714471356012116 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include #endif #include #include #include #include #include "rnd.h" #ifndef APG_USE_SHA # include "./cast/cast.h" #else /* APG_USE_SHA */ # include "./sha/sha.h" #endif /* APG_USE_SHA */ UINT32 __rnd_seed[2]; /* Random Seed 2*32=64 */ /* ** randint(int n) - Produces a Random number from 0 to n-1. ** INPUT: ** int - limit ** OUTPUT: ** UINT - pandom number. ** NOTES: ** none. */ UINT randint(int n) { #ifndef APG_USE_SHA return ( (UINT)( x917cast_rnd() % (UINT32)n ) ); #else /* APG_USE_SHA */ return ( (UINT)( x917sha1_rnd() % (UINT32)n ) ); #endif /* APG_USE_SHA */ } #ifndef APG_USE_SHA /* ** ANSI X9.17 pseudorandom generator that uses CAST algorithm instead of DES ** m = 1 ** INPUT: ** none. ** OUTPUT: ** UINT32 - random number. ** NOTES: ** none. */ UINT32 x917cast_rnd (void) { #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) struct timeval local_time; #else clock_t local_time[2]; /* clock ticks for win32 */ #endif UINT32 I[2] = {0L,0L}; UINT32 I_plus_s[2] = {0L,0L}; UINT32 Xi[2] = {0L,0L}; UINT32 Xi_plus_I[2] = {0L,0L}; cast_key ky; /********************************************************************** * ENCRYPTION KEY HEX : 0x000102030405060708090A0B0C0D0E0F (128-bit) * * YOU CAN CHANGE IT IF YOU WANT * **********************************************************************/ u8 ro_key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; /********************************************************************** * ENCRYPTION KEY HEX : 0x000102030405060708090A0B0C0D0E0F (128-bit) * * YOU CAN CHANGE IT IF YOU WANT * **********************************************************************/ #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) (void) gettimeofday (&local_time, 0); #else local_time[0] = clock(); local_time[1] = clock(); #endif cast_setkey(&ky, (u8*)&ro_key[0], 16); cast_encrypt (&ky, (u8 *)&local_time, (u8*)&I[0]); /* I=Ek(D), D-time */ I_plus_s[0] = I[0] ^ __rnd_seed[0]; /* I0 (+) s0 */ I_plus_s[1] = I[1] ^ __rnd_seed[1]; /* I1 (+) s1 */ cast_encrypt (&ky, (u8 *)&I_plus_s[0], (u8*)&Xi[0]); /* Xi=Ek( I (+) s ) */ Xi_plus_I[0] = Xi[0] ^ I[0]; /* Xi0 (+) I0 */ Xi_plus_I[1] = Xi[1] ^ I[1]; /* Xi1 (+) I1 */ cast_encrypt (&ky, (u8 *)&Xi_plus_I[0], (u8*)&__rnd_seed[0]); /* s=Ek( Xi (+) I ) */ return (Xi[0]); } #else /* APG_USE_SHA */ /* ** ANSI X9.17 pseudorandom generator that uses SHA1 algorithm instead of DES ** m=1 ** INPUT: ** none. ** OUTPUT: ** UINT32 - random number. ** NOTES: ** none. */ UINT32 x917sha1_rnd (void) { struct timeval local_time; UINT32 I[2] = {0L,0L}; UINT32 I_plus_s[2] = {0L,0L}; UINT32 Xi[2] = {0L,0L}; UINT32 Xi_plus_I[2] = {0L,0L}; BYTE hash [SHA_DIGESTSIZE]; apg_SHA_INFO shaInfo; (void) gettimeofday (&local_time, 0); apg_shaInit ( &shaInfo ); apg_shaUpdate ( &shaInfo, (BYTE *)&local_time, 8); apg_shaFinal ( &shaInfo, hash ); (void)memcpy ( (void *)&I[0], (void *)&hash[0], sizeof(I)); I_plus_s[0] = I[0] ^ __rnd_seed[0]; /* I0 (+) s0 */ I_plus_s[1] = I[1] ^ __rnd_seed[1]; /* I1 (+) s1 */ apg_shaInit(&shaInfo); apg_shaUpdate( &shaInfo, (BYTE *)&I_plus_s, 8); apg_shaFinal( &shaInfo, hash ); (void)memcpy ( (void *)&Xi[0], (void *)&hash[0], sizeof(Xi)); /* Xi=Ek( I (+) s ) */ Xi_plus_I[0] = Xi[0] ^ I[0]; /* Xi0 (+) I0 */ Xi_plus_I[1] = Xi[1] ^ I[1]; /* Xi1 (+) I1 */ apg_shaInit(&shaInfo); apg_shaUpdate( &shaInfo, (BYTE *)&Xi_plus_I, 8); apg_shaFinal(&shaInfo, hash); (void)memcpy ( (void *)&__rnd_seed[0], (void *)&hash[0], sizeof(__rnd_seed)); /* s=Ek( Xi (+) I ) */ return (Xi[0]); } #endif /* APG_USE_SHA */ /* ** x917_setseed (UINT32 seed) - Initializes seed ** INPUT: ** UINT32 - seed value ** int - quiet mode flag ** OUTPUT: ** none. ** NOTES: ** none. */ void x917_setseed (UINT32 seed, int quiet) { FILE * dr; UINT32 drs[2]; UINT32 pid = 0; pid = (UINT32)getpid(); if ( (dr = fopen(APG_DEVRANDOM, "r")) != NULL) { (void)fread( (void *)&drs[0], 8, 1, dr); __rnd_seed[0] = seed ^ drs[0]; __rnd_seed[1] = seed ^ drs[1]; (void) fclose(dr); } else if ( (dr = fopen(APG_DEVURANDOM, "r")) != NULL) { (void)fread( (void *)&drs[0], 8, 1, dr); __rnd_seed[0] = seed ^ drs[0]; __rnd_seed[1] = seed ^ drs[1]; (void) fclose(dr); } else { #ifndef CLISERV #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) if (quiet != TRUE) { fprintf(stderr,"CAN NOT USE RANDOM DEVICE TO GENERATE RANDOM SEED\n"); fprintf(stderr,"USING LOCAL TIME AND PID FOR SEED GENERATION !!!\n"); fflush(stderr); } #endif /* WIN32 */ #endif /* CLISERV */ __rnd_seed[0] = seed ^ pid; __rnd_seed[1] = seed ^ pid; } } apg-2.2.3.dfsg.1/rnd.h0000644000175100017510000000410707714471356012116 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_RND_H #define APG_RND_H 1 #ifndef APG_OWN_TYPES_H #include "owntypes.h" #endif /* OWN_TYPES_H */ extern UINT32 __rnd_seed[2]; #define RND_MX 0x7FFFFFFF #ifdef __OpenBSD__ #define APG_DEVRANDOM "/dev/arandom" #else #define APG_DEVRANDOM "/dev/random" #endif /* __OpenBSD__ */ #define APG_DEVURANDOM "/dev/urandom" extern void x917_setseed (UINT32 seed, int quiet); extern UINT randint (int n); #ifndef APG_USE_SHA UINT32 x917cast_rnd (void); #else /* APG_USE_SHA */ UINT32 x917sha1_rnd (void); #endif /* APG_USE_SHA*/ #endif /* APG_RND_H */ apg-2.2.3.dfsg.1/smbl.h0000644000175100017510000000551607714471356012275 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_SMBL_H #define APG_SMBL_H 1 struct sym smbl[94] = { {'a', S_SL}, {'b', S_SL}, {'c', S_SL}, {'d', S_SL}, {'e', S_SL}, {'f', S_SL}, {'g', S_SL}, {'h', S_SL}, {'i', S_SL}, {'j', S_SL}, {'k', S_SL}, {'l', S_SL}, {'m', S_SL}, {'n', S_SL}, {'o', S_SL}, {'p', S_SL}, {'q', S_SL}, {'r', S_SL}, {'s', S_SL}, {'t', S_SL}, {'u', S_SL}, {'v', S_SL}, {'w', S_SL}, {'x', S_SL}, {'y', S_SL}, {'z', S_SL}, {'A', S_CL}, {'B', S_CL}, {'C', S_CL}, {'D', S_CL}, {'E', S_CL}, {'F', S_CL}, {'G', S_CL}, {'H', S_CL}, {'I', S_CL}, {'J', S_CL}, {'K', S_CL}, {'L', S_CL}, {'M', S_CL}, {'N', S_CL}, {'O', S_CL}, {'P', S_CL}, {'Q', S_CL}, {'R', S_CL}, {'S', S_CL}, {'T', S_CL}, {'U', S_CL}, {'V', S_CL}, {'W', S_CL}, {'X', S_CL}, {'Y', S_CL}, {'Z', S_CL}, {'1', S_NB}, {'2', S_NB}, {'3', S_NB}, {'4', S_NB}, {'5', S_NB}, {'6', S_NB}, {'7', S_NB}, {'8', S_NB}, {'9', S_NB}, {'0', S_NB}, {33 , S_SS}, {34 , S_SS}, {35 , S_SS}, {36 , S_SS}, {37 , S_SS}, {38 , S_SS}, {39 , S_SS}, {40 , S_SS}, {41 , S_SS}, {42 , S_SS}, {43 , S_SS}, {44 , S_SS}, {45 , S_SS}, {46 , S_SS}, {47 , S_SS}, {58 , S_SS}, {59 , S_SS}, {60 , S_SS}, {61 , S_SS}, {62 , S_SS}, {63 , S_SS}, {64 , S_SS}, {91 , S_SS}, {92 , S_SS}, {93 , S_SS}, {94 , S_SS}, {95 , S_SS}, {96 , S_SS}, {123, S_SS}, {124, S_SS}, {125, S_SS}, {126, S_SS} }; #endif /* APG_SMBL_H */ apg-2.2.3.dfsg.1/THANKS0000644000175100017510000000215607714471356012077 0ustar mhmhGraham Bloice Rainer Wichmann Andreas Ehliar Chris Foote Robert Kovacs Peter Pentchev Adrian Ho Andrew J. Caird Alexander J Pierce Philip Le Riche Tomasz Luchowski Barton Hodges Rick VanNorman Tomaz Zupan Marc Haber Tom Schutter Matt Mullins Mike Robbins Bernhard Wesely Allen Wells Jose Nazario Sebastian Stark Joseph P. Crotty Schlies, Peter Eugene Podkopaev Bill Plesko Bartosz Sobolewski - Worthy James Mancini Arno Wilhelm Michael Matthews apg-2.2.3.dfsg.1/TODO0000644000175100017510000000055507714471356011655 0ustar mhmhTODO ---- Priority Hi: * Fix some code style or other errors if any. * Make some kind of configuration file to avoid command line parameter typing. Priority Medium: * Include support for some other random number generation algorithms (Blum-Blum-Shub, FIPS 186-3) * Make some interfase for plug-in language modules for pronounceable password generation. apg-2.2.3.dfsg.1/convert.c0000644000175100017510000002367207714471356013016 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include #endif #ifndef APGBFM # include "errs.h" # include "randpass.h" #endif #include "convert.h" /* ** GLOBALS */ /* small letters */ char let[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'w', 'z' }; /* capital letters */ char clet[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'W', 'Z' }; /* ** FUNCTIONS */ /* ** decapitalize() - This routine replaces all capital letters ** to small letters in the word: ** INPUT: ** char * - word. ** OUTPUT: ** none. ** NOTES: ** none. */ void decapitalize (char *word) { int i = 0; /* counter */ int j = 0; /* counter */ int str_len = strlen(word); for(j = 0; j < str_len; j++) for(i=0; i < 26; i++) if(word[j] == clet[i]) word[j] = let[i]; } #ifndef APGBFM /* ** capitalize() - This routine designed to modify sullable like this: ** adel ----> Adel ** dot ----> Dot ** etc. ** INPUT: ** char * - syllable. ** OUTPUT: ** none. ** NOTES: ** none. */ void capitalize (char *syllable) { char tmp = 0x00; int i = 0; if ( randint(2) == TRUE) { (void)memcpy((void *)&tmp, (void *)syllable, sizeof(tmp)); for(i=0; i < 26; i++) if ( let[i] == tmp ) if (is_restricted_symbol(clet[i]) != TRUE) (void)memcpy ((void *)syllable, (void *)&clet[i], 1); } } /* ** numerize() - This routine designed to modify single-letter ** syllable like this: ** a ----> 1 or 2 or 3 etc. ** u ----> 1 or 2 or 3 etc. ** etc. ** INPUT: ** char * - single-letter syllable ** OUTPUT: ** none. ** NOTES: ** none. */ void numerize (char *syllable) { char *tmp; if ( (tmp = (char *)calloc(1, 4)) == NULL) err_sys_fatal("calloc"); if ( strlen (syllable) == 1 ) { (void) gen_rand_symbol(tmp, S_NB); (void)memcpy ((void *)syllable, (void *)tmp, 1); } free ((void *)tmp); } /* ** specialize() - This routine designed to modify single-letter syllable ** like this: ** a ----> # or $ or % etc. ** u ----> # or $ or % etc. ** etc. ** INPUT: ** char * - single-letter syllable. ** OUTPUT: ** none. ** NOTES: ** none. */ void specialize (char *syllable) { char *tmp; if ( (tmp = (char *)calloc(1, 4)) == NULL) err_sys_fatal("calloc"); if ( strlen (syllable) == 1 ) { (void) gen_rand_symbol(tmp, S_SS); (void)memcpy ((void *)syllable, (void *)tmp, 1); } free ((void *)tmp); } /* ** symb2name - convert symbol to it's name ** INPUT: ** char * - one symbol syllable ** OUTPUT: ** none. ** NOTES: ** none. */ void symb2name(char * syllable, char * h_syllable) { struct ssymb_names { char symbol; char *name; }; static struct ssymb_names ssn[42] = { {'1',"ONE"}, {'2',"TWO"}, {'3',"THREE"}, {'4',"FOUR"}, {'5',"FIVE"}, {'6',"SIX"}, {'7',"SEVEN"}, {'8',"EIGHT"}, {'9',"NINE"}, {'0',"ZERO"}, {33, "EXCLAMATION_POINT"}, {34, "QUOTATION_MARK"}, {35, "CROSSHATCH"}, {36, "DOLLAR_SIGN"}, {37, "PERCENT_SIGN"}, {38, "AMPERSAND"}, {39, "APOSTROPHE"}, {40, "LEFT_PARENTHESIS"}, {41, "RIGHT_PARENTHESIS"}, {42, "ASTERISK"}, {43, "PLUS_SIGN"}, {44, "COMMA"}, {45, "HYPHEN"}, {46, "PERIOD"}, {47, "SLASH"}, {58, "COLON"}, {59, "SEMICOLON"}, {60, "LESS_THAN"}, {61, "EQUAL_SIGN"}, {62, "GREATER_THAN"}, {63, "QUESTION_MARK"}, {64, "AT_SIGN"}, {91, "LEFT_BRACKET"}, {92, "BACKSLASH"}, {93, "RIGHT_BRACKET"}, {94, "CIRCUMFLEX"}, {95, "UNDERSCORE"}, {96, "GRAVE"}, {123, "LEFT_BRACE"}, {124, "VERTICAL_BAR"}, {125, "RIGHT_BRACE"}, {126, "TILDE"} }; int i = 0; int flag = FALSE; if (strlen(syllable) == 1) { for (i = 0; i < 42; i++) { if(*syllable == ssn[i].symbol) { (void)memcpy((void*)h_syllable, (void*)ssn[i].name, strlen(ssn[i].name)); flag = TRUE; } } if (flag != TRUE) (void)memcpy((void*)h_syllable, (void*)syllable, strlen(syllable)); } } /* ** spell_word - spell the word ** INPUT: ** char * - pointer to the word ** char * - pointer to the spelled word ** OUTPUT: ** char * - pointer to the spelled word ** NULL - something is wrong ** NOTES: ** You should free() memory pointed by spelled_word after each use of spell_word */ char * spell_word(char * word, char * spelled_word) { struct char_spell { char symbol; char *name; }; static struct char_spell cs[94] = { {'1',"ONE" }, {'2',"TWO" }, {'3',"THREE" }, {'4',"FOUR" }, {'5',"FIVE" }, {'6',"SIX" }, {'7',"SEVEN" }, {'8',"EIGHT" }, {'9',"NINE" }, {'0',"ZERO" }, {'A', "Alfa" }, {'B', "Bravo" }, {'C', "Charlie" }, {'D', "Delta" }, {'E', "Echo" }, {'F', "Foxtrot" }, {'G', "Golf" }, {'H', "Hotel" }, {'I', "India" }, {'J', "Juliett" }, {'K', "Kilo" }, {'L', "Lima" }, {'M', "Mike" }, {'N', "November" }, {'O', "Oscar" }, {'P', "Papa" }, {'Q', "Quebec" }, {'R', "Romeo" }, {'S', "Sierra" }, {'T', "Tango" }, {'U', "Uniform" }, {'V', "Victor" }, {'W', "Whiskey" }, {'X', "X_ray" }, {'Y', "Yankee" }, {'Z', "Zulu" }, {'a', "alfa" }, {'b', "bravo" }, {'c', "charlie" }, {'d', "delta" }, {'e', "echo" }, {'f', "foxtrot" }, {'g', "golf" }, {'h', "hotel" }, {'i', "india" }, {'j', "juliett" }, {'k', "kilo" }, {'l', "lima" }, {'m', "mike" }, {'n', "november" }, {'o', "oscar" }, {'p', "papa" }, {'q', "quebec" }, {'r', "romeo" }, {'s', "sierra" }, {'t', "tango" }, {'u', "uniform" }, {'v', "victor" }, {'w', "whiskey" }, {'x', "x_ray" }, {'y', "yankee" }, {'z', "zulu" }, {33, "EXCLAMATION_POINT"}, {34, "QUOTATION_MARK" }, {35, "CROSSHATCH" }, {36, "DOLLAR_SIGN" }, {37, "PERCENT_SIGN" }, {38, "AMPERSAND" }, {39, "APOSTROPHE" }, {40, "LEFT_PARENTHESIS" }, {41, "RIGHT_PARENTHESIS"}, {42, "ASTERISK" }, {43, "PLUS_SIGN" }, {44, "COMMA" }, {45, "HYPHEN" }, {46, "PERIOD" }, {47, "SLASH" }, {58, "COLON" }, {59, "SEMICOLON" }, {60, "LESS_THAN" }, {61, "EQUAL_SIGN" }, {62, "GREATER_THAN" }, {63, "QUESTION_MARK" }, {64, "AT_SIGN" }, {91, "LEFT_BRACKET" }, {92, "BACKSLASH" }, {93, "RIGHT_BRACKET" }, {94, "CIRCUMFLEX" }, {95, "UNDERSCORE" }, {96, "GRAVE" }, {123, "LEFT_BRACE" }, {124, "VERTICAL_BAR" }, {125, "RIGHT_BRACE" }, {126, "TILDE" } }; int s_length = 0; int i = 0; int j = 0; int word_len = strlen(word); char * tmp_ptr; char hyphen = '-'; char zero = 0x00; /* Count the length of the spelled word */ for (i=0; i <= word_len; i++) for (j=0; j < 94; j++) if (word[i] == cs[j].symbol) { s_length = s_length + strlen(cs[j].name) + 1; continue; } /* Allocate memory for spelled word */ if ( (spelled_word = (char *)calloc(1, (size_t)s_length)) == NULL) return(NULL); /* Construct spelled word */ tmp_ptr = spelled_word; for (i=0; i < word_len; i++) for (j=0; j < 94; j++) if (word[i] == cs[j].symbol) { (void) memcpy((void *)tmp_ptr, (void *)cs[j].name, strlen(cs[j].name)); tmp_ptr = tmp_ptr + strlen(cs[j].name); /* Place the hyphen after each symbol */ (void) memcpy((void *)(tmp_ptr), (void *)&hyphen, 1); tmp_ptr = tmp_ptr + 1; continue; } /* Remove hyphen at the end of the word */ tmp_ptr = tmp_ptr - 1; (void) memcpy((void *)(tmp_ptr), (void *)&zero, 1); return (spelled_word); } #endif /* APGBFM */ apg-2.2.3.dfsg.1/convert.h0000644000175100017510000000356507714471356013022 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef APG_CONVERT_H #define APG_CONVERT_H 1 void decapitalize (char *word); #ifndef APGBFM void capitalize (char *syllable); void numerize (char *syllable); void specialize (char *syllable); void symb2name(char * syllable, char * h_syllable); char* spell_word(char * word, char * spelled_word); #endif /* APGBFM */ #endif /* APG_CONVERT_H */ apg-2.2.3.dfsg.1/apg.c0000644000175100017510000005603507730403163012071 0ustar mhmh/* ** Copyright (c) 1999, 2000, 2001, 2002, 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3.The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ** Main Module of apg programm */ #include #include #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) #include #endif #include #include #ifndef APG_USE_SHA #define APG_VERSION "2.2.3 (PRNG: X9.17/CAST)" #else /* APG_USE_SHA */ #define APG_VERSION "2.2.3 (PRNG: X9.17/SHA-1)" #endif /* APG_USE_SHA */ #ifdef __NetBSD__ #include #endif #if defined(__sun) || defined(sun) || defined(linux) || defined(__linux) || defined(__linux__) #include #endif #define MAX_MODE_LENGTH 4 #define DEFAULT_MIN_PASS_LEN 8 #define DEFAULT_MAX_PASS_LEN 10 #define DEFAULT_NUM_OF_PASS 6 #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE #endif #ifndef __NetBSD__ #include #endif #ifdef __CYGWIN__ #undef APG_USE_CRYPT #endif /* __CYGWIN__ */ #ifdef CLISERV #include #include #include #include #define MAXSOCKADDDR 128 #endif /* CLISERV */ #include "owntypes.h" #include "pronpass.h" #include "randpass.h" #include "restrict.h" #include "bloom.h" #include "rnd.h" #include "errs.h" #include "getopt.h" #include "convert.h" struct pass_m { unsigned int pass; /* password generation mode */ unsigned int filter; /* password generation mode */ }; #ifndef CLISERV UINT32 get_user_seq (void); UINT32 com_line_user_seq (char * seq); char *crypt_passstring (const char *p); void print_help (void); #endif /* CLISERV */ int main (int argc, char *argv[]); void checkopt(char *opt); int construct_mode(char *str_mode, struct pass_m * mde); /* ** main() */ int main (int argc, char *argv[]) { int i = 0; int restrict_res = 0; char *pass_string; char *hyph_pass_string; time_t tme; int option = 0; /* programm option */ int algorithm = 0; /* algorithm for generation */ int restrictions_present = FALSE; /* restrictions flag */ int plain_restrictions_present = FALSE; /* dictionary restrictions_flag */ int bloom_restrict_present = FALSE; /* bloom filter restrictions flag */ int paranoid_bloom_restrict_present = FALSE; /* paranoid bloom filter restrictions flag */ int filter_restrict_present = FALSE; /* filter restrictions flag */ int exclude_list_present = FALSE; /* exclude list present */ int quiet_present = FALSE; /* quiet mode flag */ int hyph_req_present = FALSE; /* Request to print hyphenated password */ char *restrictions_file; /* dictionary file name */ char *plain_restrictions_file; /* dictionary file name */ struct pass_m mode; unsigned int pass_mode_present = FALSE; /* password generation mode flag */ USHORT min_pass_length = DEFAULT_MIN_PASS_LEN; /* min password length */ USHORT max_pass_length = DEFAULT_MAX_PASS_LEN; /* max password length */ USHORT min_substr_len = 0; /* min substring length to check if ** paranoid check is used */ int number_of_pass = DEFAULT_NUM_OF_PASS; /* number of passwords to generate */ UINT32 user_defined_seed = 0L; /* user defined random seed */ int user_defined_seed_present = FALSE; /* user defined random seed flag */ char *str_mode; /* string mode pointer */ #ifndef CLISERV char *com_line_seq; char *spell_pass_string; int spell_present = FALSE; /* spell password mode flag */ unsigned int delimiter_flag_present = FALSE; #ifdef APG_USE_CRYPT char *crypt_string; unsigned int show_crypt_text = FALSE; /* display crypt(3)'d text flag */ #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ #ifdef CLISERV #if defined(sgi) || defined(__APPLE__) || defined(__QNX__) /* Thanks to Andrew J. Caird */ typedef unsigned int socklen_t; #endif socklen_t len; struct sockaddr_in *cliaddr; char delim[2]={0x0d,0x0a}; char *out_pass; char *peer_ip_unknown = "UNKNOWN"; char *peer_ip; openlog(argv[0], LOG_PID, LOG_DAEMON); cliaddr = (struct sockaddr_in *)calloc(1,MAXSOCKADDDR); len = MAXSOCKADDDR; if( getpeername(0, (struct sockaddr *)cliaddr, &len) != 0) { err_sys("getpeername"); peer_ip = peer_ip_unknown; } else { peer_ip = inet_ntoa(cliaddr->sin_addr); } syslog (LOG_INFO, "password generation request from %s.%d\n", peer_ip, htons(cliaddr->sin_port)); #endif /* CLISERV */ /* ** Analize options */ #ifndef CLISERV #ifdef APG_USE_CRYPT while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:sdc:n:m:x:htvylq")) != -1) #else /* APG_USE_CRYPT */ while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:sdc:n:m:x:htvlq")) != -1) #endif /* APG_USE_CRYPT */ #else /* CLISERV */ while ((option = apg_getopt (argc, argv, "M:E:a:r:b:p:n:m:x:vt")) != -1) #endif /* CLISERV */ { switch (option) { case 'M': /* mode parameter */ str_mode = apg_optarg; if( (construct_mode(str_mode,&mode)) == -1) err_app_fatal("construct_mode","wrong parameter"); pass_mode_present = TRUE; if(mode.filter != 0) { filter_restrict_present = TRUE; restrictions_present = TRUE; } break; case 'E': /* exclude char */ if(set_exclude_list(apg_optarg)==-1) err_app_fatal("set_exclude_list","string is too long (max. 93 characters)"); exclude_list_present = TRUE; break; case 'a': /* algorithm specification */ checkopt(apg_optarg); algorithm = atoi (apg_optarg); break; case 'r': /* restrictions */ restrictions_present = TRUE; plain_restrictions_present = TRUE; plain_restrictions_file = apg_optarg; break; case 'b': /* bloom restrictions */ restrictions_present = TRUE; bloom_restrict_present = TRUE; restrictions_file = apg_optarg; break; case 'p': /* paranoid bloom restrictions */ checkopt(apg_optarg); min_substr_len = atoi (apg_optarg); paranoid_bloom_restrict_present = TRUE; break; #ifndef CLISERV case 'l': spell_present = TRUE; break; #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) case 's': /* user random seed required */ user_defined_seed = get_user_seq (); user_defined_seed_present = TRUE; break; #endif /* WIN32 */ case 'c': /* user random seed given in command line */ com_line_seq = apg_optarg; user_defined_seed = com_line_user_seq (com_line_seq); user_defined_seed_present = TRUE; break; case 'd': /* no delimiters option */ delimiter_flag_present = TRUE; break; case 'q': /* quiet mode */ quiet_present = TRUE; break; #ifdef APG_USE_CRYPT case 'y': /* display crypt(3)'d text next to passwords */ show_crypt_text = TRUE; break; #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ case 'n': /* number of password specification */ checkopt(apg_optarg); number_of_pass = atoi (apg_optarg); break; case 'm': /* min password length */ checkopt(apg_optarg); min_pass_length = (USHORT) atoi (apg_optarg); break; case 'x': /* max password length */ checkopt(apg_optarg); max_pass_length = (USHORT) atoi (apg_optarg); break; case 't': /* request to print hyphenated password */ hyph_req_present = TRUE; break; #ifndef CLISERV case 'h': /* print help */ print_help (); return (0); #endif /* CLISERV */ case 'v': /* print version */ printf ("APG (Automated Password Generator)"); printf ("\nversion %s", APG_VERSION); printf ("\nCopyright (c) 1999, 2000, 2001, 2002, 2003 Adel I. Mirzazhanov\n"); return (0); default: /* print help end exit */ #ifndef CLISERV print_help (); #endif /* CLISERV */ exit (-1); } } if (pass_mode_present != TRUE) mode.pass = S_SS | S_NB | S_CL | S_SL; if (exclude_list_present == TRUE) mode.pass = mode.pass | S_RS; if( (tme = time(NULL)) == ( (time_t)-1)) err_sys("time"); if (user_defined_seed_present != TRUE) x917_setseed ( (UINT32)tme, quiet_present); else x917_setseed (user_defined_seed ^ (UINT32)tme, quiet_present); if (min_pass_length > max_pass_length) max_pass_length = min_pass_length; /* main code section */ /* ** reserv space for password and hyphenated password and report of errors ** 18 because the maximum length of element for hyphenated password is 17 */ if ( (pass_string = (char *)calloc (1, (size_t)(max_pass_length + 1)))==NULL || (hyph_pass_string = (char *)calloc (1, (size_t)(max_pass_length*18)))==NULL) err_sys_fatal("calloc"); #ifndef CLISERV #ifdef APG_USE_CRYPT if (show_crypt_text == TRUE) if ((crypt_string = (char *)calloc (1, 255))==NULL) err_sys_fatal("calloc"); #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ #ifdef CLISERV if ( (out_pass = (char *)calloc(1, (size_t)(max_pass_length*19 + 4))) == NULL) err_sys_fatal("calloc"); #endif /* CLISERV */ /* ** generate required amount of passwords using specified algorithm ** and check for restrictions if specified with command line parameters */ while (i < number_of_pass) { if (algorithm == 0) { if (gen_pron_pass(pass_string, hyph_pass_string, min_pass_length, max_pass_length, mode.pass) == -1) err_app_fatal("apg","wrong password length parameter"); #ifndef CLISERV #ifdef APG_USE_CRYPT if (show_crypt_text == TRUE) (void) memcpy ((void *)crypt_string, (void *)crypt_passstring (pass_string), 255); #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ /*************************************** ** ALGORITHM = 0 RESTRICTIONS = PRESENT ****************************************/ if (restrictions_present == TRUE) { /* Filter check */ if (filter_restrict_present == TRUE) restrict_res = filter_check_pass(pass_string, mode.filter); /* Bloom-filter check */ if (restrict_res == 0) { if (bloom_restrict_present == TRUE) { if(paranoid_bloom_restrict_present != TRUE) restrict_res = bloom_check_pass(pass_string, restrictions_file); else restrict_res = paranoid_bloom_check_pass(pass_string, restrictions_file, min_substr_len); } } /* Dictionary check */ if (restrict_res == 0) if (plain_restrictions_present == TRUE) restrict_res = check_pass(pass_string, plain_restrictions_file); switch (restrict_res) { case 0: #ifndef CLISERV fprintf (stdout, "%s", pass_string); if (hyph_req_present == TRUE) fprintf (stdout, " (%s)", hyph_pass_string); #ifdef APG_USE_CRYPT if (show_crypt_text == TRUE) fprintf (stdout, " %s", crypt_string); #endif /* APG_USE_CRYPT */ if (spell_present == TRUE) { spell_pass_string = spell_word(pass_string, spell_pass_string); fprintf (stdout, (" %s"), spell_pass_string); free((void*)spell_pass_string); } if ( delimiter_flag_present == FALSE ) fprintf (stdout, "\n"); fflush (stdout); #else /* CLISERV */ if (hyph_req_present == TRUE) snprintf(out_pass, max_pass_length*19 + 4, "%s (%s)", pass_string, hyph_pass_string); else snprintf(out_pass, max_pass_length*19 + 4, "%s", pass_string); write (0, (void*) out_pass, strlen(out_pass)); write (0, (void*)&delim[0],2); #endif /* CLISERV */ i++; break; case 1: break; case -1: err_sys_fatal ("check_pass"); default: break; } /* switch */ } /****************************************** ** ALGORITHM = 0 RESTRICTIONS = NOT_PRESENT *******************************************/ else { #ifndef CLISERV fprintf (stdout, "%s", pass_string); if (hyph_req_present == TRUE) fprintf (stdout, " (%s)", hyph_pass_string); #ifdef APG_USE_CRYPT if (show_crypt_text == TRUE) fprintf (stdout, " %s", crypt_string); #endif /* APG_USE_CRYPT */ if (spell_present == TRUE) { spell_pass_string = spell_word(pass_string, spell_pass_string); fprintf (stdout, (" %s"), spell_pass_string); free((void*)spell_pass_string); } if ( delimiter_flag_present == FALSE ) fprintf (stdout, "\n"); fflush (stdout); #else /* CLISERV */ if (hyph_req_present == TRUE) snprintf(out_pass, max_pass_length*19 + 4, "%s (%s)", pass_string, hyph_pass_string); else snprintf(out_pass, max_pass_length*19 + 4, "%s", pass_string); write (0, (void*) out_pass, strlen(out_pass)); write (0, (void*)&delim[0],2); #endif /* CLISERV */ i++; } } /*************************************** ** ALGORITHM = 1 ****************************************/ else if (algorithm == 1) { if (gen_rand_pass(pass_string, min_pass_length, max_pass_length, mode.pass) == -1) err_app_fatal("apg","wrong password length parameter"); #ifndef CLISERV #ifdef APG_USE_CRYPT if (show_crypt_text == TRUE) (void)memcpy ((void *)crypt_string, (void *)crypt_passstring(pass_string), 255); #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ /*************************************** ** ALGORITHM = 1 RESTRICTIONS = PRESENT ****************************************/ if ( (restrictions_present == TRUE)) { /* Filter check */ if (filter_restrict_present == TRUE) restrict_res = filter_check_pass(pass_string, mode.filter); /* Bloom-filter check */ if (restrict_res == 0) { if (bloom_restrict_present == TRUE) { if(paranoid_bloom_restrict_present != TRUE) restrict_res = bloom_check_pass(pass_string, restrictions_file); else restrict_res = paranoid_bloom_check_pass(pass_string, restrictions_file, min_substr_len); } } /* Dictionary check */ if (restrict_res == 0) if (plain_restrictions_present == TRUE) restrict_res = check_pass(pass_string, plain_restrictions_file); switch (restrict_res) { case 0: #ifndef CLISERV #ifdef APG_USE_CRYPT if (show_crypt_text==TRUE) fprintf (stdout, "%s %s", pass_string, crypt_string); else #endif /* APG_USE_CRYPT */ fprintf (stdout, "%s", pass_string); if (spell_present == TRUE) { spell_pass_string = spell_word(pass_string, spell_pass_string); fprintf (stdout, (" %s"), spell_pass_string); free((void*)spell_pass_string); } if ( delimiter_flag_present == FALSE ) fprintf (stdout, "\n"); fflush (stdout); #else /* CLISERV */ write (0, (void*)pass_string, strlen(pass_string)); write (0, (void*)&delim[0],2); #endif /* CLISERV */ i++; break; case 1: break; case -1: err_sys_fatal ("check_pass"); default: break; } /* switch */ } /*************************************** ** ALGORITHM = 1 RESTRICTIONS = PRESENT ****************************************/ else { #ifndef CLISERV #ifdef APG_USE_CRYPT if (show_crypt_text==TRUE) fprintf (stdout, "%s %s", pass_string, crypt_string); else #endif /* APG_USE_CRYPT */ fprintf (stdout, "%s", pass_string); if (spell_present == TRUE) { spell_pass_string = spell_word(pass_string, spell_pass_string); fprintf (stdout, (" %s"), spell_pass_string); free((void*)spell_pass_string); } if ( delimiter_flag_present == FALSE ) fprintf (stdout, "\n"); fflush (stdout); #else /* CLISERV */ write (0, (void*)pass_string, strlen(pass_string)); write (0, (void*)&delim[0],2); #endif /* CLISERV */ i++; } } /* end of if (algorithm == 1) */ else err_app_fatal ("apg","wrong algorithm type"); restrict_res = 0; } /* end of while (i <= number_of_pass) */ free((void*)pass_string); free((void*)hyph_pass_string); #ifndef CLISERV #ifdef APG_USE_CRYPT if (show_crypt_text==TRUE) free((void*)crypt_string); #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ #ifdef CLISERV free ((void *)out_pass); free ((void *)cliaddr); close (0); closelog(); #endif /* CLISERV */ return(0); } /* end of main */ #ifndef CLISERV #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) /* ** get_user_seq() - Routine that gets user random sequense ** and generates sutable random seed according to it. ** INPUT: ** void ** OUTPUT: ** UINT32 - random seed ** NOTES: ** none */ UINT32 get_user_seq (void) { char * seq; UINT32 prom[2] = { 0L, 0L }; UINT32 sdres = 0L; printf ("\nPlease enter some random data (only first %d are significant)\n", sizeof(prom)); seq = (char *)getpass("(eg. your old password):>"); if (strlen(seq) < sizeof(prom)) (void)memcpy((void *)&prom[0], (void *)seq, (int)strlen(seq)); else (void)memcpy((void *)&prom[0], (void *)seq, sizeof(prom)); sdres = prom[0]^prom[1]; return (sdres); } #endif /* WIN32 */ /* ** com_line_user_seq() - Routine that gets user random sequense ** from command line and generates sutable random seed according to it ** INPUT: ** char * - command line seed ** OUTPUT: ** UINT32 - random seed ** NOTES: ** none */ UINT32 com_line_user_seq (char * seq) { UINT32 prom[2] = { 0L, 0L }; UINT32 sdres = 0L; if (strlen(seq) < sizeof (prom)) (void)memcpy((void *)&prom[0], (void *)seq, (int)strlen(seq)); else (void)memcpy((void *)&prom[0], (void *)seq, sizeof(prom)); sdres = prom[0]^prom[1]; return (sdres); } /* ** print_help() - print help :))) ** INPUT: ** none. ** OUTPUT: ** help info to the stdout. ** NOTES: ** none. */ void print_help (void) { printf ("\napg Automated Password Generator\n"); printf (" Copyright (c) Adel I. Mirzazhanov\n"); printf ("\napg [-a algorithm] [-r file] \n"); printf (" [-M mode] [-E char_string] [-n num_of_pass] [-m min_pass_len]\n"); printf (" [-x max_pass_len] [-c cl_seed] [-d] [-s] [-h] [-y] [-q]\n"); printf ("\n-M mode new style password modes\n"); printf ("-E char_string exclude characters from password generation process\n"); printf ("-r file apply dictionary check against file\n"); printf ("-b filter_file apply bloom filter check against filter_file\n"); printf (" (filter_file should be created with apgbfm(1) utility)\n"); printf ("-p substr_len paranoid modifier for bloom filter check\n"); printf ("-a algorithm choose algorithm\n"); printf (" 1 - random password generation according to\n"); printf (" password modes\n"); printf (" 0 - pronounceable password generation\n"); printf ("-n num_of_pass generate num_of_pass passwords\n"); printf ("-m min_pass_len minimum password length\n"); printf ("-x max_pass_len maximum password length\n"); #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__) printf ("-s ask user for a random seed for password\n"); printf (" generation\n"); #endif /* WIN32 */ printf ("-c cl_seed use cl_seed as a random seed for password\n"); printf ("-d do NOT use any delimiters between generated passwords\n"); printf ("-l spell generated password\n"); printf ("-t print pronunciation for generated pronounceable password\n"); #ifdef APG_USE_CRYPT printf ("-y print crypted passwords\n"); #endif /* APG_USE_CRYPT */ printf ("-q quiet mode (do not print warnings)\n"); printf ("-h print this help screen\n"); printf ("-v print version information\n"); } #ifdef APG_USE_CRYPT /* ** crypt_passstring() - produce crypted password. ** INPUT: ** const char * - password string ** OUTPUT: ** char * - crypted password ** NOTES: ** none. */ char * crypt_passstring (const char *p) { char salt[10]; gen_rand_pass (salt, 10, 10, S_SL|S_CL|S_NB); return (crypt(p, salt)); } #endif /* APG_USE_CRYPT */ #endif /* CLISERV */ /* ** checkopt() - check options. ** INPUT: ** char * - options string. ** OUTPUT: ** none. ** NOTES: ** option should contain only numeral symbols. */ void checkopt(char *opt) { int i; for(i=0; i < strlen(opt);i++) if(opt[i] != '0' && opt[i] != '1' && opt[i] != '2' && opt[i] != '3' && opt[i] != '4' && opt[i] != '5' && opt[i] != '6' && opt[i] != '7' && opt[i] != '8' && opt[i] != '9') err_app_fatal ("checkopt", "wrong option format"); } /* ** construct_mode() - construct mode for password ** generation from string. ** INPUT: ** char * - string mode. ** OUTPUT: ** int - return code. ** 0 - OK ** -1 - ERROR ** NOTES: ** none. */ int construct_mode(char *s_mode, struct pass_m * mde) { unsigned int mode = 0; unsigned int filter = 0; int ch = 0; int i = 0; int str_length = 0; str_length = strlen(s_mode); if (str_length > MAX_MODE_LENGTH) return(-1); for (i=0; i < str_length; i++) { ch = (int)*s_mode; switch(ch) { case 'S': mode = mode | S_SS; filter = filter | S_SS; break; case 'N': mode = mode | S_NB; filter = filter | S_NB; break; case 'C': mode = mode | S_CL; filter = filter | S_CL; break; case 'L': mode = mode | S_SL; filter = filter | S_SL; break; case 's': mode = mode | S_SS; break; case 'n': mode = mode | S_NB; break; case 'c': mode = mode | S_CL; break; case 'l': mode = mode | S_SL; break; default: return(-1); break; } s_mode++; } mde->pass = mode; mde->filter = filter; return (0); } apg-2.2.3.dfsg.1/Makefile0000644000175100017510000001117007714471356012620 0ustar mhmh################################################################## # You can modify CC variable if you have compiler other than GCC # But the code was designed and tested with GCC CC = gcc ################################################################## # Compilation flags # You should comment the line below for AIX+native cc FLAGS = -Wall ################################################################## # Libraries # # You should comment the line below ('LIBS= -lcrypt')for QNX RTP # 6.1.0, OpenBSD 2.8 and above, WIN32 (+MinGW) LIBS = -lcrypt LIBM = -lm # Use lines below for cygwin # LIBS = # LIBM = ################################################################## # Support for crypted passwords # # DO NOT EDIT THE LINE BELOW !!! CRYPTED_PASS = APG_DONOTUSE_CRYPT # Coment this if you do not want to use crypted passwords output # or trying to build programm for win32 CRYPTED_PASS = APG_USE_CRYPT ################################################################## # Support for ANSI X9.17/SHA1 PRNG # # DO NOT EDIT THE LINE BELOW !!! USE_SHA = APG_USE_SHA # Coment this if you want to use PRNG X9.17 with SHA-1 USE_SHA = APG_DONOTUSE_SHA ################################################################## # Directories # Install dirs INSTALL_PREFIX = /usr/local APG_BIN_DIR = /bin APG_MAN_DIR = /man/man1 APGD_BIN_DIR = /sbin APGD_MAN_DIR = /man/man8 #################################################################### # If you plan to install APG daemon you should look at lines below # #################################################################### #################################################################### # FreeBSD # # Uncoment NOTHING for FreeBSD # #################################################################### # Linux # # Uncoment line below for LINUX #CS_LIBS = -lnsl #################################################################### # Solaris # # Uncoment line below for Solaris #CS_LIBS = -lnsl -lsocket #################################################################### # QNX RTP 6.1.0 # # Uncoment line below for QNX RTP 6.1.0 #CS_LIBS = -lsocket # ====== YOU DO NOT NEED TO MODIFY ANYTHING BELOW THIS LINE ====== # Find group ID for user root FIND_GROUP = `grep '^root:' /etc/passwd | awk -F: '{ print $$4 }'` PROGNAME = apg CS_PROGNAME = apgd BFM_PROGNAME = apgbfm BFM_SOURCES = apgbfm.c bloom.c sha/sha.c errors.c getopt.c convert.c SOURCES = bloom.c ./sha/sha.c ./cast/cast.c rnd.c pronpass.c \ randpass.c restrict.c errors.c apg.c getopt.c convert.c HEADERS = owntypes.h pronpass.h randpass.h restrict.h errs.h rnd.h \ ./cast/cast.h ./cast/cast_sboxes.h getopt.h convert.h OBJECTS = rnd.o ./cast/cast.o pronpass.o randpass.o restrict.o apg.o errors.o standalone: apg apgbfm all: cliserv standalone cliserv: apgd apgbfm cygwin: standalone apg: ${CC} ${FLAGS} -D${CRYPTED_PASS} -D${USE_SHA} -o ${PROGNAME} ${SOURCES} ${LIBS} ${LIBM} apgd: ${CC} ${FLAGS} -DCLISERV -D${USE_SHA} -o ${CS_PROGNAME} ${SOURCES} ${CS_LIBS} ${LIBM} apgbfm: ${CC} ${FLAGS} -DAPGBFM -o ${BFM_PROGNAME} ${BFM_SOURCES} ${LIBM} strip: strip ${PROGNAME} strip ${CS_PROGNAME} strip ${BFM_PROGNAME} install: if test -x ./apg; then \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_MAN_DIR}; \ ./install-sh -c -m 0755 -o root -g ${FIND_GROUP} ./apg ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./install-sh -c -m 0444 ./doc/man/apg.1 ${INSTALL_PREFIX}${APG_MAN_DIR}; \ fi if test -x ./apgd; then \ ./mkinstalldirs ${INSTALL_PREFIX}${APGD_BIN_DIR}; \ ./mkinstalldirs ${INSTALL_PREFIX}${APGD_MAN_DIR}; \ ./install-sh -c -m 0755 -o root -g ${FIND_GROUP} ./apgd ${INSTALL_PREFIX}${APGD_BIN_DIR}; \ ./install-sh -c -m 0444 ./doc/man/apgd.8 ${INSTALL_PREFIX}${APGD_MAN_DIR}; \ fi if test -x ./apgbfm; then \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_MAN_DIR}; \ ./install-sh -c -m 0755 -o root -g ${FIND_GROUP} ./apgbfm ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./install-sh -c -m 0444 ./doc/man/apgbfm.1 ${INSTALL_PREFIX}${APG_MAN_DIR}; \ fi install-cygwin: if test -x ./apg.exe; then \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_MAN_DIR}; \ ./install-sh -c -m 0755 ./apg.exe ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./install-sh -c -m 0444 ./doc/man/apg.1 ${INSTALL_PREFIX}${APG_MAN_DIR}; \ fi if test -x ./apgbfm.exe; then \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./mkinstalldirs ${INSTALL_PREFIX}${APG_MAN_DIR}; \ ./install-sh -c -m 0755 ./apgbfm.exe ${INSTALL_PREFIX}${APG_BIN_DIR}; \ ./install-sh -c -m 0444 ./doc/man/apgbfm.1 ${INSTALL_PREFIX}${APG_MAN_DIR}; \ fi clean: rm -f ${CS_PROGNAME} ${PROGNAME} ${BFM_PROGNAME} ${OBJECTS} *core* apg-2.2.3.dfsg.1/bfconvert/0000755000175100017510000000000007714471356013150 5ustar mhmhapg-2.2.3.dfsg.1/bfconvert/bfconvert.c0000644000175100017510000001276307714471356015315 0ustar mhmh/* ** Copyright (c) 2003 ** Adel I. Mirzazhanov. All rights reserved ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1.Redistributions of source code must retain the above ** copyright notice, this list of conditions and the following ** disclaimer. ** 2.Redistributions in binary form must reproduce the above ** copyright notice, this list of conditions and the following ** disclaimer in the documentation and/or other materials ** provided with the distribution. ** 3.The name of the author may not be used to endorse or ** promote products derived from this software without ** specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* *************************************************************** ** NAME : BFCONVERT ** ** DESCRIPTION : convert APG Bloom-filter version 1.0.1 to ** ** version 1.1.0 ** ** USAGE : bfconvert old_bf_file_name new_bf_file_name ** ** RETURN : 0 - success ** ** -1 - something wrong ** *************************************************************** */ #include #define OLD_APGBF_HEADER_LEN 12 #define OLD_APGBF_HEADER_ID "APGBF101" #define NEW_APGBF_HEADER_LEN 13 #define NEW_APGBF_HEADER_ID "APGBF" #define NEW_APGBF_HEADER_VER "110" #define NEW_APGBF_HEADER_MODE 0x00 int main (int argc, char *argv[]); int main(int argc, char *argv[]) { typedef unsigned char f_mode; struct new_apg_bf_hdr { char id[5]; /* filter ID */ char version[3]; /* filter version */ unsigned long int fs; /* filter size */ f_mode mode; /* filter flags */ }; struct old_apg_bf_hdr { char id[8]; /* ID */ unsigned long int fs; /* filter size */ }; struct new_apg_bf_hdr new_bf_hdr; struct old_apg_bf_hdr old_bf_hdr; char old_etalon_bf_id[] = OLD_APGBF_HEADER_ID; char new_etalon_bf_id[] = NEW_APGBF_HEADER_ID; char new_etalon_bf_ver[] = NEW_APGBF_HEADER_VER; FILE *old_f; /* old filter file descriptor */ FILE *new_f; /* new filter file descriptor */ unsigned char tmp_buf; /* Temporary buffer */ /* Checking arguments */ if (argc != 3) { printf ("Usage: bfconvert old_bf_file_name new_bf_file_name\n"); return(-1); } /* Opening input and output files */ if ((old_f = fopen (argv[1], "r")) == NULL) { perror("open the old bloom-filter file"); return(-1); } if ((new_f = fopen (argv[2], "w")) == NULL) { perror("open the new bloom-filter file"); return(-1); } if (fread ( (void *)&old_bf_hdr, OLD_APGBF_HEADER_LEN, 1, old_f) != 1) if (ferror (old_f) != 0) { perror("read from the old bloom-filter file"); return(-1); } /* Checking input file */ if ((old_bf_hdr.id[0] != old_etalon_bf_id[0]) || (old_bf_hdr.id[1] != old_etalon_bf_id[1]) || (old_bf_hdr.id[2] != old_etalon_bf_id[2]) || (old_bf_hdr.id[3] != old_etalon_bf_id[3]) || (old_bf_hdr.id[4] != old_etalon_bf_id[4]) || (old_bf_hdr.id[5] != old_etalon_bf_id[5]) || (old_bf_hdr.id[6] != old_etalon_bf_id[6]) || (old_bf_hdr.id[7] != old_etalon_bf_id[7]) ) { fprintf(stderr,"Input file is not APG bloom filter file v1.0.1\n"); fflush (stderr); return (-1); } /* Constructing output BF file header */ new_bf_hdr.id[0] = new_etalon_bf_id[0]; new_bf_hdr.id[1] = new_etalon_bf_id[1]; new_bf_hdr.id[2] = new_etalon_bf_id[2]; new_bf_hdr.id[3] = new_etalon_bf_id[3]; new_bf_hdr.id[4] = new_etalon_bf_id[4]; new_bf_hdr.version[0] = new_etalon_bf_ver[0]; new_bf_hdr.version[1] = new_etalon_bf_ver[1]; new_bf_hdr.version[2] = new_etalon_bf_ver[2]; new_bf_hdr.fs = old_bf_hdr.fs; new_bf_hdr.mode = NEW_APGBF_HEADER_MODE; /* Writing new filter header to output file */ if (fwrite ( (void *)&new_bf_hdr, NEW_APGBF_HEADER_LEN, 1, new_f) != 1) { perror("write to the new bloom-filter file"); return(-1); } /* Reading filter content from the old BF file and writing it to the new BF file */ while (fread ( (void *)&tmp_buf, 1, 1, old_f) == 1) { if(fwrite( (void *)&tmp_buf, 1, 1, new_f) != 1) { perror("write to the new bloom-filter file"); return(-1); } } if (ferror (old_f) != 0) { perror("read from the old bloom-filter file"); return(-1); } /* Close input and output files */ if (fclose(old_f) == EOF) { perror("close old bloom-filter file"); return(-1); } if (fclose(new_f) == EOF) { perror("close new bloom-filter file"); return(-1); } printf("\nInput file has been successfuly converted\n"); return(0); } apg-2.2.3.dfsg.1/bfconvert/Makefile0000644000175100017510000000146507714471356014616 0ustar mhmh################################################################## # You can modify CC variable if you have compiler other than GCC # But the code was designed and tested with GCC CC = gcc ################################################################## # Compilation flags # You should comment the line below for AIX+native cc FLAGS = -Wall ECHO = echo PROGNAME = bfconvert SOURCES = bfconvert.c all: ${CC} ${FLAGS} -o ${PROGNAME} ${SOURCES} strip: strip ${PROGNAME} install: @${ECHO} "**********************************************" @${ECHO} "* This program shold be used to convert your *" @${ECHO} "* filters once. So if you want to install *" @${ECHO} "* this program you have to do it manualy :-) *" @${ECHO} "**********************************************" clean: rm -f ${PROGNAME} *.o *core apg-2.2.3.dfsg.1/bfconvert/README0000644000175100017510000000064107714471356014031 0ustar mhmhNAME bfconvert DESCRIPTION Convert APG Bloom-filter version 1.0.1 to version 1.1.0 BUILD Just type `make' and hit [Enter] at the command prompt. USAGE bfconvert old_bf_file_name new_bf_file_name RETURN 0 - success -1 - something wrong NOTE Converted filter will be case sensitive. Conversion to the case insensitive filter is impossible because of the bloom-filter nature. apg-2.2.3.dfsg.1/Debian.dfsg.Changes0000664000175100017510000000055410515125071014543 0ustar mhmhapg 2.2.3.dfsg.1 * For the Debian package of apg, the files doc/rfc0972.txt and doc/rfc1750.txt were removed from the original upstream tarball since they are not DFSG-free and we thus cannot distribute them from Debian main. You can pull them from any RFC archive. -- Marc Haber Tue, 17 Oct 2006 10:00:41 +0000