Skip to content

Commit 515f461

Browse files
committedMar 9, 2012
broken release
0 parents  commit 515f461

27 files changed

+6527
-0
lines changed
 

‎Makefile.am

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
2+
AM_CFLAGS = -c -D_GNU_SOURCE -O2 -ggdb3 --std=gnu99 -fPIC $(CFLAGS) -ggdb
3+
lib_LTLIBRARIES = libapg.la
4+
libapg_la_SOURCES = src/bloom.c src/convert.c src/apg.h src/apg.c\
5+
src/convert.h src/errors.c src/errs.h src/owntypes.h\
6+
src/pronpass.c\
7+
src/pronpass.h src/randpass.c src/randpass.h\
8+
src/restrict.c src/restrict.h src/rnd.c src/rnd.h smbl.h\
9+
src/cast/cast.h src/cast/cast_sboxes.h src/sha/sha.c\
10+
src/sha/sha.h src/cast/cast.c\
11+
libapg_la_LDFLAGS= -lcrypto
12+
include_HEADERS = src/apg.h

‎configure.ac

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- Autoconf -*-
2+
# Process this file with autoconf to produce a configure script.
3+
4+
AC_PREREQ([2.68])
5+
AC_INIT([libapg], [0.1], [http://git.hub])
6+
AC_CONFIG_HEADERS([config.h])
7+
AM_INIT_AUTOMAKE([-Wall])
8+
AC_PROG_LIBTOOL
9+
AC_CONFIG_MACRO_DIR([m4])
10+
11+
# Checks for programs.
12+
AC_PROG_AWK
13+
AC_PROG_CC
14+
AC_PROG_INSTALL
15+
16+
# Checks for libraries.
17+
# FIXME: Replace `main' with a function in `-lcrypt':
18+
AC_CHECK_LIB([crypt], [main])
19+
# FIXME: Replace `main' with a function in `-lcrypto':
20+
AC_CHECK_LIB([crypto], [main])
21+
# FIXME: Replace `main' with a function in `-lm':
22+
AC_CHECK_LIB([m], [main])
23+
24+
# Checks for header files.
25+
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h syslog.h unistd.h])
26+
27+
# Checks for typedefs, structures, and compiler characteristics.
28+
AC_TYPE_SIZE_T
29+
30+
# Checks for library functions.
31+
AC_CHECK_FUNCS([getpass gettimeofday inet_ntoa memset strchr strerror])
32+
33+
AC_CONFIG_FILES([Makefile])
34+
AC_OUTPUT

‎src/_apg.c

+760
Large diffs are not rendered by default.

‎src/apg.c

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <stdio.h>
2+
#include <time.h>
3+
4+
#include "apg.h"
5+
#include "pronpass.h"
6+
#include "rnd.h"
7+
#include "restrict.h"
8+
9+
#define S_NB 0x01 /* Numeric */
10+
#define S_SS 0x02 /* Special */
11+
#define S_CL 0x04 /* Capital */
12+
#define S_SL 0x08 /* Small */
13+
14+
APGPassword *
15+
apg_password(APGPasswordProps *props, APGMode *mode)
16+
{
17+
}
18+
19+
void
20+
test_apg() {
21+
APGPassword* apgpasswd;
22+
//char * pstr;
23+
//char * pho;
24+
//time_t t;
25+
int filter_check_result = 0;
26+
27+
//t = time(NULL);
28+
//x917_setseed((UINT32)time(NULL), FALSE);
29+
apgpasswd->password = (char *)calloc(1, (size_t)(10+1));
30+
apgpasswd->phonetic = (char *)calloc(1, (size_t)(10*18));
31+
//apgpasswd->password = calloc(max_len, sizeof(char *));
32+
//apgpasswd->phonetic = calloc(max_len, sizeof( (char *) * 18));
33+
34+
do {
35+
36+
37+
printf("password creation\n");
38+
//gen_pron_pass(apgpasswd->password, apgpasswd->phonetic, 5, 10, S_NB|S_SS|S_CL);
39+
//printf("passwd is %s phonetic %s\n\n", apgpasswd->password, apgpasswd->phonetic);
40+
//filter_check_result = filter_check_pass(apgpasswd->password, S_NB|S_SS|S_CL);
41+
//printf("filter %i\n", filter_check_result);
42+
43+
//free((void*)apgpasswd->password);
44+
//free((void*)apgpasswd->phonetic);
45+
filter_check_result++;
46+
47+
} while(filter_check_result < 4);
48+
49+
}
50+

‎src/apg.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
typedef struct _APGPassword APGPassword;
3+
typedef struct _APGPasswords APGPasswords;
4+
typedef struct _APGPasswordProps APGPasswordProps;
5+
typedef enum _APGMode APGMode;
6+
7+
struct _APGPasswords {
8+
/* array of generated passwords */
9+
//GList * passwords;
10+
int nothing;
11+
};
12+
13+
struct _APGPassword {
14+
/* should be in secure memory */
15+
char * phonetic;
16+
char * password;
17+
};
18+
19+
enum APGMode {
20+
USE_SYMBOLS = 0x1,
21+
USE_NUMBERIC = 0x2,
22+
USED_MIXED_CASE = 0x4
23+
};
24+
25+
struct _APGPasswordProps {
26+
unsigned short min_pass_len;
27+
unsigned short max_pass_len;
28+
/* cl_seed random seed */
29+
};
30+
31+
APGPassword * apg_password(APGPasswordProps *props, APGMode *mode);
32+
APGPasswords * agg_password_list(APGPasswordProps *props, APGMode *mode);
33+
34+
void test_apg();

‎src/bloom.c

+479
Large diffs are not rendered by default.

‎src/bloom.h

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
** Copyright (c) 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
31+
32+
/*
33+
** Header file for bloom filter algorithm implementation
34+
*/
35+
#ifndef APG_BLOOM_H
36+
#define APG_BLOOM_H 1
37+
38+
#include <stdio.h>
39+
#include <stdlib.h>
40+
#include <string.h>
41+
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
42+
#include <strings.h>
43+
#endif
44+
#include <math.h>
45+
46+
#include "sha/sha.h"
47+
48+
#define APGBF_ID "APGBF"
49+
#define APGBF_VERSION "110" /* Version 1.1.0 */
50+
51+
/* Bloom filter modes flags */
52+
#define BF_CASE_INSENSITIVE 0x01
53+
#define BF_RESERVED1 0x02
54+
#define BF_RESERVED2 0x04
55+
#define BF_RESERVED3 0x08
56+
#define BF_RESERVED4 0x10
57+
#define BF_RESERVED5 0x20
58+
#define BF_RESERVED6 0x40
59+
#define BF_RESERVED7 0x80
60+
61+
#define APGBFHDRSIZE 13
62+
63+
#define TRUE 1
64+
#define FALSE 0
65+
66+
#define MAX_DICT_STRLEN 255
67+
#define H_NUM 5
68+
69+
typedef unsigned long int h_val; /* should be 32-bit */
70+
typedef unsigned short int flag;
71+
typedef unsigned char f_mode;
72+
73+
struct apg_bf_hdr {
74+
char id[5]; /* filter ID */
75+
char version[3]; /* filter version */
76+
unsigned long int fs; /* filter size */
77+
f_mode mode; /* filter flags */
78+
};
79+
80+
extern int insert_word(char *word, FILE *file, h_val filter_size, f_mode mode);
81+
extern int check_word(char *word, FILE *file, h_val filter_size, f_mode mode);
82+
extern FILE * create_filter(char * f_name, unsigned long int n_words, f_mode mode);
83+
extern FILE * open_filter(char * f_name, const char *mode);
84+
extern int close_filter(FILE *f_dsk);
85+
extern h_val get_filtersize(FILE *f);
86+
extern f_mode get_filtermode(FILE *f);
87+
extern h_val count_words(FILE *dict_file);
88+
#ifdef APGBFM
89+
extern int print_flt_info(FILE * filter);
90+
#endif /* APGBFM */
91+
#endif /* APG_BLOOM_H */

‎src/cast/cast.c

+239
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/*
2+
* CAST-128 in C
3+
* Written by Steve Reid <sreid@sea-to-sky.net>
4+
* 100% Public Domain - no warranty
5+
* Released 1997.10.11
6+
*/
7+
8+
#include "cast.h"
9+
#include "cast_sboxes.h"
10+
11+
/* Macros to access 8-bit bytes out of a 32-bit word */
12+
#define U8a(x) ( (u8) (x>>24) )
13+
#define U8b(x) ( (u8) ((x>>16)&255) )
14+
#define U8c(x) ( (u8) ((x>>8)&255) )
15+
#define U8d(x) ( (u8) ((x)&255) )
16+
17+
/* Circular left shift */
18+
#define ROL(x, n) ( ((x)<<(n)) | ((x)>>(32-(n))) )
19+
20+
/* CAST-128 uses three different round functions */
21+
#define F1(l, r, i) \
22+
t = ROL(key->xkey[i] + r, key->xkey[i+16]); \
23+
l ^= ((cast_sbox1[U8a(t)] ^ cast_sbox2[U8b(t)]) - \
24+
cast_sbox3[U8c(t)]) + cast_sbox4[U8d(t)];
25+
#define F2(l, r, i) \
26+
t = ROL(key->xkey[i] ^ r, key->xkey[i+16]); \
27+
l ^= ((cast_sbox1[U8a(t)] - cast_sbox2[U8b(t)]) + \
28+
cast_sbox3[U8c(t)]) ^ cast_sbox4[U8d(t)];
29+
#define F3(l, r, i) \
30+
t = ROL(key->xkey[i] - r, key->xkey[i+16]); \
31+
l ^= ((cast_sbox1[U8a(t)] + cast_sbox2[U8b(t)]) ^ \
32+
cast_sbox3[U8c(t)]) - cast_sbox4[U8d(t)];
33+
34+
35+
/***** Encryption Function *****/
36+
37+
void cast_encrypt(cast_key* key, u8* inblock, u8* outblock)
38+
{
39+
u32 t, l, r;
40+
41+
/* Get inblock into l,r */
42+
l = ((u32)inblock[0] << 24) | ((u32)inblock[1] << 16) |
43+
((u32)inblock[2] << 8) | (u32)inblock[3];
44+
r = ((u32)inblock[4] << 24) | ((u32)inblock[5] << 16) |
45+
((u32)inblock[6] << 8) | (u32)inblock[7];
46+
/* Do the work */
47+
F1(l, r, 0);
48+
F2(r, l, 1);
49+
F3(l, r, 2);
50+
F1(r, l, 3);
51+
F2(l, r, 4);
52+
F3(r, l, 5);
53+
F1(l, r, 6);
54+
F2(r, l, 7);
55+
F3(l, r, 8);
56+
F1(r, l, 9);
57+
F2(l, r, 10);
58+
F3(r, l, 11);
59+
/* Only do full 16 rounds if key length > 80 bits */
60+
if (key->rounds > 12) {
61+
F1(l, r, 12);
62+
F2(r, l, 13);
63+
F3(l, r, 14);
64+
F1(r, l, 15);
65+
}
66+
/* Put l,r into outblock */
67+
outblock[0] = U8a(r);
68+
outblock[1] = U8b(r);
69+
outblock[2] = U8c(r);
70+
outblock[3] = U8d(r);
71+
outblock[4] = U8a(l);
72+
outblock[5] = U8b(l);
73+
outblock[6] = U8c(l);
74+
outblock[7] = U8d(l);
75+
/* Wipe clean */
76+
t = l = r = 0;
77+
}
78+
79+
80+
/***** Decryption Function *****/
81+
82+
void cast_decrypt(cast_key* key, u8* inblock, u8* outblock)
83+
{
84+
u32 t, l, r;
85+
86+
/* Get inblock into l,r */
87+
r = ((u32)inblock[0] << 24) | ((u32)inblock[1] << 16) |
88+
((u32)inblock[2] << 8) | (u32)inblock[3];
89+
l = ((u32)inblock[4] << 24) | ((u32)inblock[5] << 16) |
90+
((u32)inblock[6] << 8) | (u32)inblock[7];
91+
/* Do the work */
92+
/* Only do full 16 rounds if key length > 80 bits */
93+
if (key->rounds > 12) {
94+
F1(r, l, 15);
95+
F3(l, r, 14);
96+
F2(r, l, 13);
97+
F1(l, r, 12);
98+
}
99+
F3(r, l, 11);
100+
F2(l, r, 10);
101+
F1(r, l, 9);
102+
F3(l, r, 8);
103+
F2(r, l, 7);
104+
F1(l, r, 6);
105+
F3(r, l, 5);
106+
F2(l, r, 4);
107+
F1(r, l, 3);
108+
F3(l, r, 2);
109+
F2(r, l, 1);
110+
F1(l, r, 0);
111+
/* Put l,r into outblock */
112+
outblock[0] = U8a(l);
113+
outblock[1] = U8b(l);
114+
outblock[2] = U8c(l);
115+
outblock[3] = U8d(l);
116+
outblock[4] = U8a(r);
117+
outblock[5] = U8b(r);
118+
outblock[6] = U8c(r);
119+
outblock[7] = U8d(r);
120+
/* Wipe clean */
121+
t = l = r = 0;
122+
}
123+
124+
125+
/***** Key Schedual *****/
126+
127+
void cast_setkey(cast_key* key, u8* rawkey, int keybytes)
128+
{
129+
u32 t[4], z[4], x[4];
130+
int i;
131+
132+
/* Set number of rounds to 12 or 16, depending on key length */
133+
key->rounds = (keybytes <= 10 ? 12 : 16);
134+
135+
/* Copy key to workspace x */
136+
for (i = 0; i < 4; i++) {
137+
x[i] = 0;
138+
if ((i*4+0) < keybytes) x[i] = (u32)rawkey[i*4+0] << 24;
139+
if ((i*4+1) < keybytes) x[i] |= (u32)rawkey[i*4+1] << 16;
140+
if ((i*4+2) < keybytes) x[i] |= (u32)rawkey[i*4+2] << 8;
141+
if ((i*4+3) < keybytes) x[i] |= (u32)rawkey[i*4+3];
142+
}
143+
/* Generate 32 subkeys, four at a time */
144+
for (i = 0; i < 32; i+=4) {
145+
switch (i & 4) {
146+
case 0:
147+
t[0] = z[0] = x[0] ^ cast_sbox5[U8b(x[3])] ^
148+
cast_sbox6[U8d(x[3])] ^ cast_sbox7[U8a(x[3])] ^
149+
cast_sbox8[U8c(x[3])] ^ cast_sbox7[U8a(x[2])];
150+
t[1] = z[1] = x[2] ^ cast_sbox5[U8a(z[0])] ^
151+
cast_sbox6[U8c(z[0])] ^ cast_sbox7[U8b(z[0])] ^
152+
cast_sbox8[U8d(z[0])] ^ cast_sbox8[U8c(x[2])];
153+
t[2] = z[2] = x[3] ^ cast_sbox5[U8d(z[1])] ^
154+
cast_sbox6[U8c(z[1])] ^ cast_sbox7[U8b(z[1])] ^
155+
cast_sbox8[U8a(z[1])] ^ cast_sbox5[U8b(x[2])];
156+
t[3] = z[3] = x[1] ^ cast_sbox5[U8c(z[2])] ^
157+
cast_sbox6[U8b(z[2])] ^ cast_sbox7[U8d(z[2])] ^
158+
cast_sbox8[U8a(z[2])] ^ cast_sbox6[U8d(x[2])];
159+
break;
160+
case 4:
161+
t[0] = x[0] = z[2] ^ cast_sbox5[U8b(z[1])] ^
162+
cast_sbox6[U8d(z[1])] ^ cast_sbox7[U8a(z[1])] ^
163+
cast_sbox8[U8c(z[1])] ^ cast_sbox7[U8a(z[0])];
164+
t[1] = x[1] = z[0] ^ cast_sbox5[U8a(x[0])] ^
165+
cast_sbox6[U8c(x[0])] ^ cast_sbox7[U8b(x[0])] ^
166+
cast_sbox8[U8d(x[0])] ^ cast_sbox8[U8c(z[0])];
167+
t[2] = x[2] = z[1] ^ cast_sbox5[U8d(x[1])] ^
168+
cast_sbox6[U8c(x[1])] ^ cast_sbox7[U8b(x[1])] ^
169+
cast_sbox8[U8a(x[1])] ^ cast_sbox5[U8b(z[0])];
170+
t[3] = x[3] = z[3] ^ cast_sbox5[U8c(x[2])] ^
171+
cast_sbox6[U8b(x[2])] ^ cast_sbox7[U8d(x[2])] ^
172+
cast_sbox8[U8a(x[2])] ^ cast_sbox6[U8d(z[0])];
173+
break;
174+
}
175+
switch (i & 12) {
176+
case 0:
177+
case 12:
178+
key->xkey[i+0] = cast_sbox5[U8a(t[2])] ^ cast_sbox6[U8b(t[2])] ^
179+
cast_sbox7[U8d(t[1])] ^ cast_sbox8[U8c(t[1])];
180+
key->xkey[i+1] = cast_sbox5[U8c(t[2])] ^ cast_sbox6[U8d(t[2])] ^
181+
cast_sbox7[U8b(t[1])] ^ cast_sbox8[U8a(t[1])];
182+
key->xkey[i+2] = cast_sbox5[U8a(t[3])] ^ cast_sbox6[U8b(t[3])] ^
183+
cast_sbox7[U8d(t[0])] ^ cast_sbox8[U8c(t[0])];
184+
key->xkey[i+3] = cast_sbox5[U8c(t[3])] ^ cast_sbox6[U8d(t[3])] ^
185+
cast_sbox7[U8b(t[0])] ^ cast_sbox8[U8a(t[0])];
186+
break;
187+
case 4:
188+
case 8:
189+
key->xkey[i+0] = cast_sbox5[U8d(t[0])] ^ cast_sbox6[U8c(t[0])] ^
190+
cast_sbox7[U8a(t[3])] ^ cast_sbox8[U8b(t[3])];
191+
key->xkey[i+1] = cast_sbox5[U8b(t[0])] ^ cast_sbox6[U8a(t[0])] ^
192+
cast_sbox7[U8c(t[3])] ^ cast_sbox8[U8d(t[3])];
193+
key->xkey[i+2] = cast_sbox5[U8d(t[1])] ^ cast_sbox6[U8c(t[1])] ^
194+
cast_sbox7[U8a(t[2])] ^ cast_sbox8[U8b(t[2])];
195+
key->xkey[i+3] = cast_sbox5[U8b(t[1])] ^ cast_sbox6[U8a(t[1])] ^
196+
cast_sbox7[U8c(t[2])] ^ cast_sbox8[U8d(t[2])];
197+
break;
198+
}
199+
switch (i & 12) {
200+
case 0:
201+
key->xkey[i+0] ^= cast_sbox5[U8c(z[0])];
202+
key->xkey[i+1] ^= cast_sbox6[U8c(z[1])];
203+
key->xkey[i+2] ^= cast_sbox7[U8b(z[2])];
204+
key->xkey[i+3] ^= cast_sbox8[U8a(z[3])];
205+
break;
206+
case 4:
207+
key->xkey[i+0] ^= cast_sbox5[U8a(x[2])];
208+
key->xkey[i+1] ^= cast_sbox6[U8b(x[3])];
209+
key->xkey[i+2] ^= cast_sbox7[U8d(x[0])];
210+
key->xkey[i+3] ^= cast_sbox8[U8d(x[1])];
211+
break;
212+
case 8:
213+
key->xkey[i+0] ^= cast_sbox5[U8b(z[2])];
214+
key->xkey[i+1] ^= cast_sbox6[U8a(z[3])];
215+
key->xkey[i+2] ^= cast_sbox7[U8c(z[0])];
216+
key->xkey[i+3] ^= cast_sbox8[U8c(z[1])];
217+
break;
218+
case 12:
219+
key->xkey[i+0] ^= cast_sbox5[U8d(x[0])];
220+
key->xkey[i+1] ^= cast_sbox6[U8d(x[1])];
221+
key->xkey[i+2] ^= cast_sbox7[U8a(x[2])];
222+
key->xkey[i+3] ^= cast_sbox8[U8b(x[3])];
223+
break;
224+
}
225+
if (i >= 16) {
226+
key->xkey[i+0] &= 31;
227+
key->xkey[i+1] &= 31;
228+
key->xkey[i+2] &= 31;
229+
key->xkey[i+3] &= 31;
230+
}
231+
}
232+
/* Wipe clean */
233+
for (i = 0; i < 4; i++) {
234+
t[i] = x[i] = z[i] = 0;
235+
}
236+
}
237+
238+
/* Made in Canada */
239+

‎src/cast/cast.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* CAST-128 in C
3+
* Written by Steve Reid <sreid@sea-to-sky.net>
4+
* 100% Public Domain - no warranty
5+
* Released 1997.10.11
6+
*/
7+
8+
#ifndef _CAST_H_
9+
#define _CAST_H_
10+
11+
typedef unsigned char u8; /* 8-bit unsigned */
12+
typedef unsigned long u32; /* 32-bit unsigned */
13+
14+
typedef struct {
15+
u32 xkey[32]; /* Key, after expansion */
16+
int rounds; /* Number of rounds to use, 12 or 16 */
17+
} cast_key;
18+
19+
void cast_setkey(cast_key* key, u8* rawkey, int keybytes);
20+
void cast_encrypt(cast_key* key, u8* inblock, u8* outblock);
21+
void cast_decrypt(cast_key* key, u8* inblock, u8* outblock);
22+
23+
#endif /* ifndef _CAST_H_ */
24+

‎src/cast/cast_sboxes.h

+543
Large diffs are not rendered by default.

‎src/convert.c

+407
Large diffs are not rendered by default.

‎src/convert.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef APG_CONVERT_H
31+
#define APG_CONVERT_H 1
32+
33+
void decapitalize (char *word);
34+
35+
#ifndef APGBFM
36+
void capitalize (char *syllable);
37+
void numerize (char *syllable);
38+
void specialize (char *syllable);
39+
void symb2name(char * syllable, char * h_syllable);
40+
char* spell_word(char * word, char * spelled_word);
41+
#endif /* APGBFM */
42+
43+
#endif /* APG_CONVERT_H */

‎src/errors.c

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#include <stdio.h>
31+
#include <string.h>
32+
#include <unistd.h>
33+
#include <stdlib.h>
34+
#include "errs.h"
35+
36+
#ifdef CLISERV
37+
# include <syslog.h>
38+
#endif
39+
40+
/*
41+
** err_sys() - routine that handles non-fatal system errors
42+
** like calloc, open, etc.
43+
** INPUT:
44+
** const char * - error name.
45+
** OUTPUT:
46+
** prints error to stderr.
47+
** NOTES:
48+
** none.
49+
*/
50+
void
51+
err_sys(const char *string)
52+
{
53+
54+
#ifndef CLISERV
55+
perror(string);
56+
#else
57+
syslog (LOG_DEBUG, "%s: %s",string, (char *)strerror(errno));
58+
#endif
59+
}
60+
61+
/*
62+
** err_sus_fatal() - routine that handles fatal system errors
63+
** like calloc, open, etc.
64+
** INPUT:
65+
** const char * - error name.
66+
** OUTPUT:
67+
** prints error to stderr and then exit.
68+
** NOTES:
69+
** none.
70+
*/
71+
void
72+
err_sys_fatal(const char *string)
73+
{
74+
75+
#ifndef CLISERV
76+
perror(string);
77+
#else
78+
syslog (LOG_DEBUG, "%s: %s", string, (char *)strerror(errno));
79+
closelog();
80+
close(0);
81+
#endif
82+
exit (-1);
83+
}
84+
85+
/*
86+
** err_app() - routine that handles non-fatal application errors.
87+
** INPUT:
88+
** const char * - error name.
89+
** const char * - error description.
90+
** OUTPUT:
91+
** prints error to stderr.
92+
** NOTES:
93+
** none.
94+
*/
95+
void
96+
err_app(const char *string, const char * err)
97+
{
98+
#ifndef CLISERV
99+
fprintf (stderr, "%s: ", string);
100+
fprintf (stderr, "%s\n", err);
101+
fflush (stderr);
102+
#else
103+
syslog (LOG_DEBUG, "%s: %s",string, err);
104+
#endif
105+
}
106+
107+
/*
108+
** err_app_fatal() - routine that handles fatal application errors.
109+
** INPUT:
110+
** const char * - error name.
111+
** const char * - error description.
112+
** OUTPUT:
113+
** prints error to stderr and then exit.
114+
** NOTES:
115+
** none.
116+
*/
117+
void
118+
err_app_fatal(const char *string, const char *err)
119+
{
120+
121+
#ifndef CLISERV
122+
fprintf (stderr, "%s: ", string);
123+
fprintf (stderr, "%s\n", err);
124+
fflush (stderr);
125+
#else
126+
syslog (LOG_DEBUG, "%s: %s",string, err);
127+
closelog();
128+
close(0);
129+
#endif
130+
exit (-1);
131+
}

‎src/errs.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef APG_ERRS_H
31+
#define APG_ERRS_H 1
32+
33+
#include <errno.h>
34+
35+
extern void err_sys(const char *string);
36+
extern void err_sys_fatal(const char *string);
37+
extern void err_app(const char *string, const char *err);
38+
extern void err_app_fatal(const char *string, const char *err);
39+
40+
#endif /* APG_ERRS_H */

‎src/main.c

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#include <apg.h>
3+
4+
5+
//after installing library
6+
//compile this for simple test
7+
//gcc -I/usr/local/include/ -L/usr/local/lib -o out main.c -lapg
8+
int main(void) {
9+
test_apg();
10+
}
11+

‎src/owntypes.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef APG_OWN_TYPES_H
31+
#define APG_OWN_TYPES_H 1
32+
33+
typedef unsigned int UINT;
34+
typedef unsigned short USHORT;
35+
typedef short int SHORT;
36+
typedef int boolean;
37+
typedef unsigned long int UINT32;
38+
39+
#define TRUE 1
40+
#define FALSE 0
41+
42+
#define APG_MAX_PASSWORD_LENGTH 255
43+
44+
#endif /* APG_OWN_TYPES_H */

‎src/pronpass.c

+2,302
Large diffs are not rendered by default.

‎src/pronpass.h

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
** This module uses code from the NIST implementation of FIPS-181,
3+
** but the algorythm is CHANGED and I think that I CAN
4+
** copyright it. See copiright notes below.
5+
*/
6+
7+
/*
8+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
9+
** Adel I. Mirzazhanov. All rights reserved
10+
**
11+
** Redistribution and use in source and binary forms, with or without
12+
** modification, are permitted provided that the following conditions
13+
** are met:
14+
**
15+
** 1.Redistributions of source code must retain the above copyright notice,
16+
** this list of conditions and the following disclaimer.
17+
** 2.Redistributions in binary form must reproduce the above copyright
18+
** notice, this list of conditions and the following disclaimer in the
19+
** documentation and/or other materials provided with the distribution.
20+
** 3.The name of the author may not be used to endorse or promote products
21+
** derived from this software without specific prior written permission.
22+
**
23+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
24+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
27+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
36+
37+
#ifndef APG_PRONPASS_H
38+
#define APG_PRONPASS_H 1
39+
40+
#ifndef APG_OWN_TYPES_H
41+
#include "owntypes.h"
42+
#endif /* APG_OWN_TYPES_H */
43+
44+
#ifndef APG_RND_H
45+
#include "rnd.h"
46+
#endif /* APG_RND_H */
47+
48+
#define RULE_SIZE (sizeof(rules)/sizeof(struct unit))
49+
#define ALLOWED(flag) (digram[units_in_syllable[current_unit -1]][unit] & (flag))
50+
51+
#define MAX_UNACCEPTABLE 20
52+
#define MAX_RETRIES (4 * (int) pwlen + RULE_SIZE)
53+
54+
#define NOT_BEGIN_SYLLABLE 010
55+
#define NO_FINAL_SPLIT 04
56+
#define VOWEL 02
57+
#define ALTERNATE_VOWEL 01
58+
#define NO_SPECIAL_RULE 0
59+
60+
#define BEGIN 0200
61+
#define NOT_BEGIN 0100
62+
#define BREAK 040
63+
#define PREFIX 020
64+
#define ILLEGAL_PAIR 010
65+
#define SUFFIX 04
66+
#define END 02
67+
#define NOT_END 01
68+
#define ANY_COMBINATION 0
69+
70+
extern int gen_pron_pass (char *word, char *hyphenated_word, USHORT minlen,
71+
USHORT maxlen, unsigned int pass_mode);
72+
73+
USHORT random_unit (USHORT type);
74+
USHORT get_random (USHORT minlen, USHORT maxlen);
75+
boolean have_initial_y (USHORT *units, USHORT unit_size);
76+
boolean illegal_placement (USHORT *units, USHORT pwlen);
77+
boolean improper_word (USHORT *units, USHORT word_size);
78+
boolean have_final_split (USHORT *units, USHORT unit_size);
79+
int gen_word (char *word, char *hyphenated_word, USHORT pwlen,
80+
unsigned int pass_mode);
81+
char *gen_syllable(char *syllable, USHORT pwlen, USHORT *units_in_syllable,
82+
USHORT *syllable_length);
83+
84+
#endif /* APG_PRONPASS_H */

‎src/randpass.c

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
/*
31+
** randpass.c - Random password generation module of PWGEN program
32+
*/
33+
34+
#include <stdio.h>
35+
#include <stdlib.h>
36+
#include <time.h>
37+
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
38+
#include <pwd.h>
39+
#endif
40+
#include <unistd.h>
41+
#include "randpass.h"
42+
43+
#include "owntypes.h"
44+
#include "smbl.h"
45+
46+
/*
47+
** gen_rand_pass - generates random password of specified type
48+
** INPUT:
49+
** char * - password string.
50+
** int - minimum password length.
51+
** int - maximum password length.
52+
** unsigned int - password generation mode.
53+
** OUTPUT:
54+
** int - password length or -1 on error.
55+
** NOTES:
56+
** none.
57+
*/
58+
int
59+
gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode)
60+
{
61+
int i = 0;
62+
int j = 0;
63+
int length = 0;
64+
char *str_pointer;
65+
int random_weight[94];
66+
int max_weight = 0;
67+
int max_weight_element_number = 0;
68+
69+
if (minl > APG_MAX_PASSWORD_LENGTH || maxl > APG_MAX_PASSWORD_LENGTH ||
70+
minl < 1 || maxl < 1 || minl > maxl)
71+
return (-1);
72+
for (i = 0; i <= 93; i++) random_weight[i] = 0;
73+
length = minl + randint(maxl-minl+1);
74+
str_pointer = password_string;
75+
76+
for (i = 0; i < length; i++)
77+
{
78+
/* Asign random weight in weight array if mode is present*/
79+
for (j = 0; j <= 93 ; j++)
80+
if ( ( (pass_mode & smbl[j].type) > 0) &&
81+
!( (S_RS & smbl[j].type) > 0))
82+
random_weight[j] = 1 + randint(20000);
83+
j = 0;
84+
/* Find an element with maximum weight */
85+
for (j = 0; j <= 93; j++)
86+
if (random_weight[j] > max_weight)
87+
{
88+
max_weight = random_weight[j];
89+
max_weight_element_number = j;
90+
}
91+
/* Get password symbol */
92+
*str_pointer = smbl[max_weight_element_number].ch;
93+
str_pointer++;
94+
max_weight = 0;
95+
max_weight_element_number = 0;
96+
for (j = 0; j <= 93; j++) random_weight[j] = 0;
97+
}
98+
*str_pointer = 0;
99+
return (length);
100+
}
101+
102+
/*
103+
** gen_rand_symbol - generates random password of specified type
104+
** INPUT:
105+
** char * - symbol.
106+
** unsigned int - symbol type.
107+
** OUTPUT:
108+
** int - password length or -1 on error.
109+
** NOTES:
110+
** none.
111+
*/
112+
int
113+
gen_rand_symbol (char *symbol, unsigned int mode)
114+
{
115+
int j = 0;
116+
char *str_pointer;
117+
int random_weight[94];
118+
int max_weight = 0;
119+
int max_weight_element_number = 0;
120+
121+
for (j = 0; j <= 93; j++) random_weight[j] = 0;
122+
str_pointer = symbol;
123+
j = 0;
124+
/* Asign random weight in weight array if mode is present*/
125+
for (j = 0; j <= 93 ; j++)
126+
if ( ( (mode & smbl[j].type) > 0) &&
127+
!( (S_RS & smbl[j].type) > 0))
128+
random_weight[j] = 1 + randint(20000);
129+
j = 0;
130+
/* Find an element with maximum weight */
131+
for (j = 0; j <= 93; j++)
132+
if (random_weight[j] > max_weight)
133+
{
134+
max_weight = random_weight[j];
135+
max_weight_element_number = j;
136+
}
137+
/* Get password symbol */
138+
*str_pointer = smbl[max_weight_element_number].ch;
139+
max_weight = 0;
140+
max_weight_element_number = 0;
141+
return (0);
142+
}
143+
144+
/*
145+
** is_restricted_symbol - detcts if symbol is restricted rigt now
146+
** INPUT:
147+
** char - symbol.
148+
** OUTPUT:
149+
** int - 0 - not restricted
150+
** 1 - restricted
151+
** NOTES:
152+
** none.
153+
*/
154+
int
155+
is_restricted_symbol (char symbol)
156+
{
157+
int j = 0;
158+
for (j = 0; j <= 93 ; j++)
159+
if (symbol == smbl[j].ch)
160+
if ((S_RS & smbl[j].type) > 0)
161+
return(1);
162+
return(0);
163+
}

‎src/randpass.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
/*
31+
** randpass.h
32+
*/
33+
#ifndef APG_RANDPASS_H
34+
#define APG_RANDPASS_H 1
35+
36+
#ifndef APG_RND_H
37+
#include "rnd.h"
38+
#endif
39+
40+
#ifndef APG_OWN_TYPES_H
41+
#include "owntypes.h"
42+
#endif
43+
44+
#define S_NB 0x01 /* Numeric */
45+
#define S_SS 0x02 /* Special */
46+
#define S_CL 0x04 /* Capital */
47+
#define S_SL 0x08 /* Small */
48+
#define S_RS 0x10 /* Restricted Symbol*/
49+
50+
struct sym
51+
{
52+
char ch;
53+
USHORT type;
54+
};
55+
56+
/* char gen_symbol(unsigned short int symbol_class); */
57+
extern int gen_rand_pass(char* password_string, int minl,
58+
int maxl, unsigned int pass_mode);
59+
extern int gen_rand_symbol (char *symbol, unsigned int mode);
60+
extern int is_restricted_symbol (char symbol);
61+
62+
#endif /* RANDPASS_H */

‎src/restrict.c

+273
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
/*
31+
** restrict.c
32+
*/
33+
#include <stdio.h>
34+
#include <stdlib.h>
35+
#include <string.h>
36+
#include "restrict.h"
37+
extern struct sym smbl[94];
38+
/*
39+
** check_pass() - routine that checks if password exist in dictionary
40+
** INPUT:
41+
** char * - password to check.
42+
** char * - dictionary filename.
43+
** OUTPUT:
44+
** int
45+
** -1 - error
46+
** 1 - password exist in dictionary
47+
** 0 - password does not exist in dictionary
48+
** NOTES:
49+
** none.
50+
*/
51+
int
52+
check_pass(char *pass, char *dict)
53+
{
54+
FILE *dct;
55+
char *string;
56+
char *tmp;
57+
if( (string = (char *) calloc(1,MAX_DICT_STRING_SIZE)) == NULL)
58+
return(-1);
59+
60+
#ifdef APG_DEBUG
61+
fprintf (stdout, "DEBUG> check_pass: ck pass: %s\n", pass);
62+
fflush (stdout);
63+
#endif /* APG_DEBUG */
64+
/*
65+
** Open dict file an report of error
66+
*/
67+
if ( (dct = fopen(dict,"r")) == NULL)
68+
return(-1);
69+
70+
while ((fgets(string, MAX_DICT_STRING_SIZE, dct) != NULL))
71+
{
72+
tmp = strtok (string," \t\n\0");
73+
if( tmp != NULL)
74+
string = tmp;
75+
else
76+
continue;
77+
if(strlen(string) != strlen(pass)) continue;
78+
else if (strncmp(string, pass, strlen(pass)) == 0)
79+
{
80+
free ( (void *)string);
81+
fclose (dct);
82+
#ifdef APG_DEBUG
83+
fprintf (stdout, "DEBUG> check_pass: password found in dictionary: %s\n", pass);
84+
fflush (stdout);
85+
#endif /* APG_DEBUG */
86+
return (1);
87+
}
88+
}
89+
free ( (void *)string);
90+
fclose (dct);
91+
return (0);
92+
}
93+
94+
/*
95+
** bloom_check_pass() - routine that checks if password exist in dictionary
96+
** using Bloom filter.
97+
** INPUT:
98+
** char * - password to check.
99+
** char * - bloom-filter filename.
100+
** OUTPUT:
101+
** int
102+
** -1 - error
103+
** 1 - password exist in dictionary
104+
** 0 - password does not exist in dictionary
105+
** NOTES:
106+
** none.
107+
*/
108+
int
109+
bloom_check_pass (char *word, char *filter)
110+
{
111+
int ret = 0;
112+
FILE *f_filter;
113+
h_val filter_size = 0L;
114+
f_mode flt_mode = 0x00;
115+
if ( (f_filter = open_filter(filter,"r")) == NULL)
116+
return(-1);
117+
filter_size = get_filtersize(f_filter);
118+
flt_mode = get_filtermode(f_filter);
119+
ret = check_word (word, f_filter, filter_size, flt_mode);
120+
close_filter(f_filter);
121+
return(ret);
122+
}
123+
124+
/*
125+
** paranoid_bloom_check_pass() - routine that checks if password or any
126+
** substring of the password exist in dictionary using Bloom filter.
127+
** INPUT:
128+
** char * - password to check.
129+
** char * - bloom-filter filename.
130+
** USHORT - minimum substring length
131+
** OUTPUT:
132+
** int
133+
** -1 - error
134+
** 1 - password exist in dictionary
135+
** 0 - password does not exist in dictionary
136+
** NOTES:
137+
** none.
138+
*/
139+
int
140+
paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len)
141+
{
142+
char * substring;
143+
int len = strlen(password); /* string length */
144+
int c_substr_start_pos = 0; /* current start position */
145+
int substr_len = 0; /* substring length (LEN-I >= substr_len >= 2) */
146+
int k = 0; /* counter */
147+
int c = 0; /* counter */
148+
int ret = 0;
149+
if (s_len < 2) s_len = 2;
150+
if (s_len > len) return (bloom_check_pass(password, filter));
151+
152+
#ifdef APG_DEBUG
153+
fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: ck pass: %s\n", password);
154+
fflush (stdout);
155+
#endif /* APG_DEBUG */
156+
157+
if ((substring = (char *)calloc(1, (size_t)len))==NULL)
158+
return (-1);
159+
160+
for (c_substr_start_pos = 0; c_substr_start_pos <= len-s_len; c_substr_start_pos++)
161+
for (substr_len = s_len; substr_len <= len-c_substr_start_pos; substr_len++)
162+
{
163+
c = 0;
164+
for (k = c_substr_start_pos; k <= c_substr_start_pos + substr_len-1; k++)
165+
{
166+
substring[c]=password[k];
167+
c++;
168+
}
169+
#ifdef APG_DEBUG
170+
fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: ck substr: %s\n", substring);
171+
fflush (stdout);
172+
#endif /* APG_DEBUG */
173+
if((ret = bloom_check_pass(substring, filter)) == 1)
174+
{
175+
#ifdef APG_DEBUG
176+
fprintf (stdout, "DEBUG> paranoid_bloom_check_pass: substr found in filter: %s\n", substring);
177+
fflush (stdout);
178+
#endif /* APG_DEBUG */
179+
return(1);
180+
}
181+
else if (ret == -1) return(-1);
182+
(void)memset(substring,0,(size_t)len);
183+
}
184+
return(0);
185+
}
186+
187+
/*
188+
** filter_check_pass() - routine that checks password against filter string
189+
**
190+
** INPUT:
191+
** char * - password to check.
192+
** char * - bloom-filter filename.
193+
** OUTPUT:
194+
** int
195+
** -1 - error
196+
** 1 - password do not pass the filter
197+
** 0 - password pass the filter
198+
** NOTES:
199+
** none.
200+
*/
201+
202+
int
203+
filter_check_pass(const char * word, unsigned int cond)
204+
{
205+
int i = 0;
206+
int sl_ret = 0;
207+
int cl_ret = 0;
208+
int nb_ret = 0;
209+
int ss_ret = 0;
210+
211+
#ifdef APG_DEBUG
212+
fprintf (stdout, "DEBUG> filter_check_pass: ck pass: %s\n", word);
213+
fflush (stdout);
214+
#endif /* APG_DEBUG */
215+
216+
if ((cond & S_SS) > 0)
217+
for (i=0; i < 94; i++)
218+
if ((smbl[i].type & S_SS) > 0)
219+
if ((strchr(word,smbl[i].ch)) != NULL)
220+
ss_ret = 1;
221+
i = 0;
222+
if ((cond & S_SL) > 0)
223+
for (i=0; i < 94; i++)
224+
if ((smbl[i].type & S_SL) > 0)
225+
if ((strchr(word,smbl[i].ch)) != NULL)
226+
sl_ret = 1;
227+
i = 0;
228+
if ((cond & S_CL) > 0)
229+
for (i=0; i < 94; i++)
230+
if ((smbl[i].type & S_CL) > 0)
231+
if ((strchr(word,smbl[i].ch)) != NULL)
232+
cl_ret = 1;
233+
i = 0;
234+
if ((cond & S_NB) > 0)
235+
for (i=0; i < 94; i++)
236+
if ((smbl[i].type & S_NB) > 0)
237+
if ((strchr(word,smbl[i].ch)) != NULL)
238+
nb_ret = 1;
239+
if (((cond & S_SS) > 0) &&(ss_ret != 1)) return (1);
240+
if (((cond & S_SL) > 0) &&(sl_ret != 1)) return (1);
241+
if (((cond & S_CL) > 0) &&(cl_ret != 1)) return (1);
242+
if (((cond & S_NB) > 0) &&(nb_ret != 1)) return (1);
243+
244+
#ifdef APG_DEBUG
245+
fprintf (stdout, "DEBUG> filter_check_pass: password %s pass the filter\n", word);
246+
fflush (stdout);
247+
#endif /* APG_DEBUG */
248+
return(0);
249+
}
250+
251+
/*
252+
** set_exclude_list() - set up character list that should
253+
** be excluded from password generation process
254+
**
255+
** INPUT:
256+
** char * - string of characters.
257+
** OUTPUT:
258+
** int - return code
259+
** 0 - OK
260+
** -1 - char_string is too long (max 93)
261+
** NOTES:
262+
** none.
263+
*/
264+
int set_exclude_list(const char * char_string)
265+
{
266+
int i = 0;
267+
if (strlen(char_string) > 93)
268+
return(-1);
269+
for(i=0; i < 94; i++)
270+
if ((strchr(char_string, smbl[i].ch)) != NULL)
271+
smbl[i].type = smbl[i].type | S_RS;
272+
return(0);
273+
}

‎src/restrict.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
/*
31+
** restrict.h
32+
*/
33+
#ifndef APG_RESTRICT_H
34+
#define APG_RESTRICT_H 1
35+
36+
#include "bloom.h"
37+
#include "randpass.h"
38+
#define MAX_DICT_STRING_SIZE 255
39+
int check_pass(char * pass, char *dict);
40+
int bloom_check_pass (char *word, char *filter);
41+
int paranoid_bloom_check_pass (char * password, char *filter, USHORT s_len);
42+
int filter_check_pass(const char * word, unsigned int cond);
43+
int set_exclude_list(const char * char_string);
44+
45+
#endif /* APG_RESTRICT_H */

‎src/rnd.c

+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#include <stdio.h>
31+
#include <stdlib.h>
32+
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
33+
#include <strings.h>
34+
#endif
35+
#include <string.h>
36+
#include <unistd.h>
37+
#include <sys/types.h>
38+
#include <sys/time.h>
39+
#include "rnd.h"
40+
41+
#ifndef APG_USE_SHA
42+
# include "./cast/cast.h"
43+
#else /* APG_USE_SHA */
44+
# include "./sha/sha.h"
45+
#endif /* APG_USE_SHA */
46+
47+
UINT32 __rnd_seed[2]; /* Random Seed 2*32=64 */
48+
49+
/*
50+
** randint(int n) - Produces a Random number from 0 to n-1.
51+
** INPUT:
52+
** int - limit
53+
** OUTPUT:
54+
** UINT - pandom number.
55+
** NOTES:
56+
** none.
57+
*/
58+
UINT
59+
randint(int n)
60+
{
61+
#ifndef APG_USE_SHA
62+
return ( (UINT)( x917cast_rnd() % (UINT32)n ) );
63+
#else /* APG_USE_SHA */
64+
return ( (UINT)( x917sha1_rnd() % (UINT32)n ) );
65+
#endif /* APG_USE_SHA */
66+
}
67+
68+
#ifndef APG_USE_SHA
69+
/*
70+
** ANSI X9.17 pseudorandom generator that uses CAST algorithm instead of DES
71+
** m = 1
72+
** INPUT:
73+
** none.
74+
** OUTPUT:
75+
** UINT32 - random number.
76+
** NOTES:
77+
** none.
78+
*/
79+
UINT32
80+
x917cast_rnd (void)
81+
{
82+
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
83+
struct timeval local_time;
84+
#else
85+
clock_t local_time[2]; /* clock ticks for win32 */
86+
#endif
87+
UINT32 I[2] = {0L,0L};
88+
UINT32 I_plus_s[2] = {0L,0L};
89+
UINT32 Xi[2] = {0L,0L};
90+
UINT32 Xi_plus_I[2] = {0L,0L};
91+
cast_key ky;
92+
93+
/**********************************************************************
94+
* ENCRYPTION KEY HEX : 0x000102030405060708090A0B0C0D0E0F (128-bit) *
95+
* YOU CAN CHANGE IT IF YOU WANT *
96+
**********************************************************************/
97+
u8 ro_key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
98+
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
99+
/**********************************************************************
100+
* ENCRYPTION KEY HEX : 0x000102030405060708090A0B0C0D0E0F (128-bit) *
101+
* YOU CAN CHANGE IT IF YOU WANT *
102+
**********************************************************************/
103+
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
104+
(void) gettimeofday (&local_time, 0);
105+
#else
106+
local_time[0] = clock();
107+
local_time[1] = clock();
108+
#endif
109+
cast_setkey(&ky, (u8*)&ro_key[0], 16);
110+
cast_encrypt (&ky, (u8 *)&local_time, (u8*)&I[0]); /* I=Ek(D), D-time */
111+
I_plus_s[0] = I[0] ^ __rnd_seed[0]; /* I0 (+) s0 */
112+
I_plus_s[1] = I[1] ^ __rnd_seed[1]; /* I1 (+) s1 */
113+
cast_encrypt (&ky, (u8 *)&I_plus_s[0], (u8*)&Xi[0]); /* Xi=Ek( I (+) s ) */
114+
Xi_plus_I[0] = Xi[0] ^ I[0]; /* Xi0 (+) I0 */
115+
Xi_plus_I[1] = Xi[1] ^ I[1]; /* Xi1 (+) I1 */
116+
cast_encrypt (&ky, (u8 *)&Xi_plus_I[0], (u8*)&__rnd_seed[0]); /* s=Ek( Xi (+) I ) */
117+
return (Xi[0]);
118+
}
119+
#else /* APG_USE_SHA */
120+
/*
121+
** ANSI X9.17 pseudorandom generator that uses SHA1 algorithm instead of DES
122+
** m=1
123+
** INPUT:
124+
** none.
125+
** OUTPUT:
126+
** UINT32 - random number.
127+
** NOTES:
128+
** none.
129+
*/
130+
UINT32
131+
x917sha1_rnd (void)
132+
{
133+
struct timeval local_time;
134+
UINT32 I[2] = {0L,0L};
135+
UINT32 I_plus_s[2] = {0L,0L};
136+
UINT32 Xi[2] = {0L,0L};
137+
UINT32 Xi_plus_I[2] = {0L,0L};
138+
139+
BYTE hash [SHA_DIGESTSIZE];
140+
apg_SHA_INFO shaInfo;
141+
142+
(void) gettimeofday (&local_time, 0);
143+
apg_shaInit ( &shaInfo );
144+
apg_shaUpdate ( &shaInfo, (BYTE *)&local_time, 8);
145+
apg_shaFinal ( &shaInfo, hash );
146+
(void)memcpy ( (void *)&I[0], (void *)&hash[0], sizeof(I));
147+
I_plus_s[0] = I[0] ^ __rnd_seed[0]; /* I0 (+) s0 */
148+
I_plus_s[1] = I[1] ^ __rnd_seed[1]; /* I1 (+) s1 */
149+
150+
apg_shaInit(&shaInfo);
151+
apg_shaUpdate( &shaInfo, (BYTE *)&I_plus_s, 8);
152+
apg_shaFinal( &shaInfo, hash );
153+
(void)memcpy ( (void *)&Xi[0], (void *)&hash[0], sizeof(Xi)); /* Xi=Ek( I (+) s ) */
154+
155+
Xi_plus_I[0] = Xi[0] ^ I[0]; /* Xi0 (+) I0 */
156+
Xi_plus_I[1] = Xi[1] ^ I[1]; /* Xi1 (+) I1 */
157+
158+
apg_shaInit(&shaInfo);
159+
apg_shaUpdate( &shaInfo, (BYTE *)&Xi_plus_I, 8);
160+
apg_shaFinal(&shaInfo, hash);
161+
(void)memcpy ( (void *)&__rnd_seed[0], (void *)&hash[0],
162+
sizeof(__rnd_seed)); /* s=Ek( Xi (+) I ) */
163+
return (Xi[0]);
164+
}
165+
#endif /* APG_USE_SHA */
166+
/*
167+
** x917_setseed (UINT32 seed) - Initializes seed
168+
** INPUT:
169+
** UINT32 - seed value
170+
** int - quiet mode flag
171+
** OUTPUT:
172+
** none.
173+
** NOTES:
174+
** none.
175+
*/
176+
void
177+
x917_setseed (UINT32 seed, int quiet)
178+
{
179+
FILE * dr;
180+
UINT32 drs[2];
181+
UINT32 pid = 0;
182+
183+
pid = (UINT32)getpid();
184+
185+
if ( (dr = fopen(APG_DEVRANDOM, "r")) != NULL)
186+
{
187+
(void)fread( (void *)&drs[0], 8, 1, dr);
188+
__rnd_seed[0] = seed ^ drs[0];
189+
__rnd_seed[1] = seed ^ drs[1];
190+
(void) fclose(dr);
191+
}
192+
else if ( (dr = fopen(APG_DEVURANDOM, "r")) != NULL)
193+
{
194+
(void)fread( (void *)&drs[0], 8, 1, dr);
195+
__rnd_seed[0] = seed ^ drs[0];
196+
__rnd_seed[1] = seed ^ drs[1];
197+
(void) fclose(dr);
198+
}
199+
else
200+
{
201+
#ifndef CLISERV
202+
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
203+
if (quiet != TRUE)
204+
{
205+
fprintf(stderr,"CAN NOT USE RANDOM DEVICE TO GENERATE RANDOM SEED\n");
206+
fprintf(stderr,"USING LOCAL TIME AND PID FOR SEED GENERATION !!!\n");
207+
fflush(stderr);
208+
}
209+
#endif /* WIN32 */
210+
#endif /* CLISERV */
211+
__rnd_seed[0] = seed ^ pid;
212+
__rnd_seed[1] = seed ^ pid;
213+
}
214+
}

‎src/rnd.h

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef APG_RND_H
31+
#define APG_RND_H 1
32+
33+
#ifndef APG_OWN_TYPES_H
34+
#include "owntypes.h"
35+
#endif /* OWN_TYPES_H */
36+
37+
extern UINT32 __rnd_seed[2];
38+
39+
#define RND_MX 0x7FFFFFFF
40+
#ifdef __OpenBSD__
41+
#define APG_DEVRANDOM "/dev/arandom"
42+
#else
43+
#define APG_DEVRANDOM "/dev/random"
44+
#endif /* __OpenBSD__ */
45+
#define APG_DEVURANDOM "/dev/urandom"
46+
47+
extern void x917_setseed (UINT32 seed, int quiet);
48+
extern UINT randint (int n);
49+
#ifndef APG_USE_SHA
50+
UINT32 x917cast_rnd (void);
51+
#else /* APG_USE_SHA */
52+
UINT32 x917sha1_rnd (void);
53+
#endif /* APG_USE_SHA*/
54+
55+
#endif /* APG_RND_H */

‎src/sha/sha.c

+297
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
/***************************************************************************/
2+
/* sha.c */
3+
/* */
4+
/* Public domain SHA-1 implementation. */
5+
/* */
6+
/* Taken from the SHA implementation by Peter C. Gutmann of 9/2/1992 */
7+
/* and modified by Carl Ellison to be SHA-1. */
8+
/***************************************************************************/
9+
10+
/*
11+
** Note regarding apg_* namespace: this avoids potential conflicts
12+
** with libraries.
13+
*/
14+
15+
#include <string.h>
16+
#include "sha.h"
17+
18+
/* The SHA f()-functions */
19+
20+
#define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) /* Rounds 0-19 */
21+
#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
22+
#define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) /* Rounds 40-59 */
23+
#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
24+
25+
/* The SHA Mysterious Constants */
26+
27+
#define K1 0x5A827999L /* Rounds 0-19 */
28+
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
29+
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
30+
#define K4 0xCA62C1D6L /* Rounds 60-79 */
31+
32+
/* SHA initial values */
33+
34+
#define h0init 0x67452301L
35+
#define h1init 0xEFCDAB89L
36+
#define h2init 0x98BADCFEL
37+
#define h3init 0x10325476L
38+
#define h4init 0xC3D2E1F0L
39+
40+
/* 32-bit rotate - kludged with shifts */
41+
42+
typedef unsigned long UL ; /* to save space */
43+
44+
#define S(n,X) ( ( ((UL)X) << n ) | ( ((UL)X) >> ( 32 - n ) ) )
45+
46+
/* The initial expanding function */
47+
48+
#define expand(count) W[ count ] = S(1,(W[ count - 3 ] ^ W[ count - 8 ] ^ W[ count - 14 ] ^ W[ count - 16 ])) /* to make this SHA-1 */
49+
50+
/* The four SHA sub-rounds */
51+
52+
#define subRound1(count) \
53+
{ \
54+
temp = S( 5, A ) + f1( B, C, D ) + E + W[ count ] + K1; \
55+
E = D; \
56+
D = C; \
57+
C = S( 30, B ); \
58+
B = A; \
59+
A = temp; \
60+
}
61+
62+
#define subRound2(count) \
63+
{ \
64+
temp = S( 5, A ) + f2( B, C, D ) + E + W[ count ] + K2; \
65+
E = D; \
66+
D = C; \
67+
C = S( 30, B ); \
68+
B = A; \
69+
A = temp; \
70+
}
71+
72+
#define subRound3(count) \
73+
{ \
74+
temp = S( 5, A ) + f3( B, C, D ) + E + W[ count ] + K3; \
75+
E = D; \
76+
D = C; \
77+
C = S( 30, B ); \
78+
B = A; \
79+
A = temp; \
80+
}
81+
82+
#define subRound4(count) \
83+
{ \
84+
temp = S( 5, A ) + f4( B, C, D ) + E + W[ count ] + K4; \
85+
E = D; \
86+
D = C; \
87+
C = S( 30, B ); \
88+
B = A; \
89+
A = temp; \
90+
}
91+
92+
/* The two buffers of 5 32-bit words */
93+
94+
LONG h0, h1, h2, h3, h4;
95+
LONG A, B, C, D, E;
96+
97+
/***************************************************************************/
98+
/* apg_shaInit */
99+
/* */
100+
/* Initialize the SHA values */
101+
/***************************************************************************/
102+
103+
void apg_shaInit( apg_SHA_INFO *shaInfo )
104+
{
105+
/* Set the h-vars to their initial values */
106+
shaInfo->digest[ 0 ] = h0init;
107+
shaInfo->digest[ 1 ] = h1init;
108+
shaInfo->digest[ 2 ] = h2init;
109+
shaInfo->digest[ 3 ] = h3init;
110+
shaInfo->digest[ 4 ] = h4init;
111+
112+
/* Initialise bit count */
113+
shaInfo->countLo = shaInfo->countHi = 0L;
114+
shaInfo->slop = 0 ; /* no data saved yet in data[] */
115+
} /* apg_shaInit */
116+
117+
/***************************************************************************/
118+
/* shaTransform */
119+
/* */
120+
/* Perform the SHA transformation over one input block. */
121+
/***************************************************************************/
122+
123+
static void shaTransform( apg_SHA_INFO *shaInfo )
124+
{
125+
LONG W[ 80 ], temp;
126+
int i;
127+
128+
/* Step A. Copy the data buffer into the local work buffer */
129+
for( i = 0; i < 16; i++ )
130+
W[ i ] = shaInfo->data[ i ];
131+
132+
/* Step B. Expand the 16 words into 64 temporary data words */
133+
expand( 16 ); expand( 17 ); expand( 18 ); expand( 19 ); expand( 20 );
134+
expand( 21 ); expand( 22 ); expand( 23 ); expand( 24 ); expand( 25 );
135+
expand( 26 ); expand( 27 ); expand( 28 ); expand( 29 ); expand( 30 );
136+
expand( 31 ); expand( 32 ); expand( 33 ); expand( 34 ); expand( 35 );
137+
expand( 36 ); expand( 37 ); expand( 38 ); expand( 39 ); expand( 40 );
138+
expand( 41 ); expand( 42 ); expand( 43 ); expand( 44 ); expand( 45 );
139+
expand( 46 ); expand( 47 ); expand( 48 ); expand( 49 ); expand( 50 );
140+
expand( 51 ); expand( 52 ); expand( 53 ); expand( 54 ); expand( 55 );
141+
expand( 56 ); expand( 57 ); expand( 58 ); expand( 59 ); expand( 60 );
142+
expand( 61 ); expand( 62 ); expand( 63 ); expand( 64 ); expand( 65 );
143+
expand( 66 ); expand( 67 ); expand( 68 ); expand( 69 ); expand( 70 );
144+
expand( 71 ); expand( 72 ); expand( 73 ); expand( 74 ); expand( 75 );
145+
expand( 76 ); expand( 77 ); expand( 78 ); expand( 79 );
146+
147+
/* Step C. Set up first buffer */
148+
A = shaInfo->digest[ 0 ];
149+
B = shaInfo->digest[ 1 ];
150+
C = shaInfo->digest[ 2 ];
151+
D = shaInfo->digest[ 3 ];
152+
E = shaInfo->digest[ 4 ];
153+
154+
/* Step D. Serious mangling, divided into four sub-rounds */
155+
subRound1( 0 ); subRound1( 1 ); subRound1( 2 ); subRound1( 3 );
156+
subRound1( 4 ); subRound1( 5 ); subRound1( 6 ); subRound1( 7 );
157+
subRound1( 8 ); subRound1( 9 ); subRound1( 10 ); subRound1( 11 );
158+
subRound1( 12 ); subRound1( 13 ); subRound1( 14 ); subRound1( 15 );
159+
subRound1( 16 ); subRound1( 17 ); subRound1( 18 ); subRound1( 19 );
160+
subRound2( 20 ); subRound2( 21 ); subRound2( 22 ); subRound2( 23 );
161+
subRound2( 24 ); subRound2( 25 ); subRound2( 26 ); subRound2( 27 );
162+
subRound2( 28 ); subRound2( 29 ); subRound2( 30 ); subRound2( 31 );
163+
subRound2( 32 ); subRound2( 33 ); subRound2( 34 ); subRound2( 35 );
164+
subRound2( 36 ); subRound2( 37 ); subRound2( 38 ); subRound2( 39 );
165+
subRound3( 40 ); subRound3( 41 ); subRound3( 42 ); subRound3( 43 );
166+
subRound3( 44 ); subRound3( 45 ); subRound3( 46 ); subRound3( 47 );
167+
subRound3( 48 ); subRound3( 49 ); subRound3( 50 ); subRound3( 51 );
168+
subRound3( 52 ); subRound3( 53 ); subRound3( 54 ); subRound3( 55 );
169+
subRound3( 56 ); subRound3( 57 ); subRound3( 58 ); subRound3( 59 );
170+
subRound4( 60 ); subRound4( 61 ); subRound4( 62 ); subRound4( 63 );
171+
subRound4( 64 ); subRound4( 65 ); subRound4( 66 ); subRound4( 67 );
172+
subRound4( 68 ); subRound4( 69 ); subRound4( 70 ); subRound4( 71 );
173+
subRound4( 72 ); subRound4( 73 ); subRound4( 74 ); subRound4( 75 );
174+
subRound4( 76 ); subRound4( 77 ); subRound4( 78 ); subRound4( 79 );
175+
176+
/* Step E. Build message digest */
177+
shaInfo->digest[ 0 ] += A;
178+
shaInfo->digest[ 1 ] += B;
179+
shaInfo->digest[ 2 ] += C;
180+
shaInfo->digest[ 3 ] += D;
181+
shaInfo->digest[ 4 ] += E;
182+
} /* shaTransform */
183+
184+
#ifdef APG_LITTLE_ENDIAN
185+
186+
/***************************************************************************/
187+
/* byteReverse */
188+
/* */
189+
/* When run on a little-endian CPU we need to perform byte reversal on an */
190+
/* array of longwords. It is possible to make the code endianness- */
191+
/* independant by fiddling around with data at the byte level, but this */
192+
/* makes for very slow code, so we rely on the user to sort out endianness */
193+
/* at compile time. */
194+
/***************************************************************************/
195+
196+
static void byteReverse( LONG *buffer, int byteCount )
197+
{
198+
LONG value;
199+
int count;
200+
201+
byteCount /= sizeof( LONG );
202+
for( count = 0; count < byteCount; count++ )
203+
{
204+
value = ( buffer[ count ] << 16 ) | ( buffer[ count ] >> 16 );
205+
buffer[ count ] = ( ( value & 0xFF00FF00L ) >> 8 ) | ( ( value & 0x00FF00FFL ) << 8 );
206+
} /* for */
207+
} /* byteReverse */
208+
#endif /* APG_LITTLE_ENDIAN */
209+
210+
/***************************************************************************/
211+
/* apg_shaUpdate */
212+
/* */
213+
/* Update SHA for a block of data. */
214+
/* Use any data already in the SHA_INFO structure and leave any partial */
215+
/* data block there. */
216+
/***************************************************************************/
217+
218+
void apg_shaUpdate( apg_SHA_INFO *shaInfo, BYTE *buffer, int count )
219+
{
220+
BYTE *db ;
221+
222+
db = (BYTE *) &(shaInfo->data[0]) ;
223+
224+
/* Update bitcount */
225+
if( ( shaInfo->countLo + ( ( LONG ) count << 3 ) ) < shaInfo->countLo )
226+
shaInfo->countHi++; /* Carry from low to high bitCount */
227+
shaInfo->countLo += ( ( LONG ) count << 3 );
228+
shaInfo->countHi += ( ( LONG ) count >> 29 );
229+
230+
/* Process data in SHA_BLOCKSIZE chunks */
231+
while ( count-- > 0 )
232+
{
233+
db[ shaInfo->slop++ ] = *(buffer++) ;
234+
if (shaInfo->slop == SHA_BLOCKSIZE)
235+
{ /* transform this one block */
236+
#ifdef APG_LITTLE_ENDIAN
237+
byteReverse( shaInfo->data, SHA_BLOCKSIZE );
238+
#endif /* APG_LITTLE_ENDIAN */
239+
shaTransform( shaInfo );
240+
shaInfo->slop = 0 ; /* no slop left */
241+
} /* if */
242+
} /* while */
243+
} /* apg_shaUpdate */
244+
245+
/***************************************************************************/
246+
/* apg_shaFinal */
247+
/* */
248+
/* Handle the last piece of data -- if any is left over in the data */
249+
/* buffer -- and append padding and a bit count for the last block */
250+
/* to process. Having transformed that block, pull the digest out */
251+
/* as a byte array. */
252+
/***************************************************************************/
253+
254+
void apg_shaFinal( apg_SHA_INFO *shaInfo, BYTE hash[SHA_DIGESTSIZE] )
255+
{
256+
int count;
257+
LONG lowBitcount = shaInfo->countLo, highBitcount = shaInfo->countHi;
258+
259+
/* Compute number of bytes mod 64 */
260+
count = ( int ) ( ( shaInfo->countLo >> 3 ) & 0x3F );
261+
262+
/* Set the first char of padding to 0x80. This is safe since there is
263+
always at least one byte free */
264+
( ( BYTE * ) shaInfo->data )[ count++ ] = 0x80;
265+
266+
/* Pad out to 56 mod 64 */
267+
if( count > 56 )
268+
{
269+
/* Two lots of padding: Pad the first block to 64 bytes */
270+
memset( ( BYTE * ) &shaInfo->data + count, 0, 64 - count );
271+
#ifdef APG_LITTLE_ENDIAN
272+
byteReverse( shaInfo->data, SHA_BLOCKSIZE );
273+
#endif /* APG_LITTLE_ENDIAN */
274+
shaTransform( shaInfo );
275+
276+
/* Now fill the next block with 56 bytes */
277+
memset( &shaInfo->data, 0, 56 );
278+
}
279+
else
280+
/* Pad block to 56 bytes */
281+
memset( ( BYTE * ) &shaInfo->data + count, 0, 56 - count );
282+
#ifdef APG_LITTLE_ENDIAN
283+
byteReverse( shaInfo->data, SHA_BLOCKSIZE );
284+
#endif /* APG_LITTLE_ENDIAN */
285+
286+
/* Append length in bits and transform */
287+
shaInfo->data[ 14 ] = highBitcount;
288+
shaInfo->data[ 15 ] = lowBitcount;
289+
290+
shaTransform( shaInfo );
291+
#ifdef APG_LITTLE_ENDIAN
292+
byteReverse( shaInfo->data, SHA_DIGESTSIZE );
293+
#endif /* APG_LITTLE_ENDIAN */
294+
295+
for (count=0; count<SHA_DIGESTSIZE; count++)
296+
hash[count] = (BYTE) ((shaInfo->digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff ;
297+
} /* apg_shaFinal */

‎src/sha/sha.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/***************************************************************************/
2+
/* sha.h */
3+
/* */
4+
/* SHA-1 code header file. */
5+
/* Taken from the public domain implementation by Peter C. Gutmann */
6+
/* on 2 Sep 1992, modified by Carl Ellison to be SHA-1. */
7+
/***************************************************************************/
8+
9+
#ifndef _SHA_H_
10+
#define _SHA_H_
11+
12+
/* Define APG_LITTLE_ENDIAN if the machine is little-endian */
13+
14+
#define APG_LITTLE_ENDIAN
15+
16+
/* Useful defines/typedefs */
17+
18+
typedef unsigned char BYTE ;
19+
typedef unsigned long LONG ;
20+
21+
/* The SHA block size and message digest sizes, in bytes */
22+
23+
#define SHA_BLOCKSIZE 64
24+
#define SHA_DIGESTSIZE 20
25+
26+
/* The structure for storing SHA info */
27+
28+
typedef struct {
29+
LONG digest[ 5 ] ; /* Message digest */
30+
LONG countLo, countHi ; /* 64-bit bit count */
31+
LONG data[ 16 ] ; /* SHA data buffer */
32+
LONG slop ; /* # of bytes saved in data[] */
33+
} apg_SHA_INFO ;
34+
35+
void apg_shaInit( apg_SHA_INFO *shaInfo ) ;
36+
void apg_shaUpdate( apg_SHA_INFO *shaInfo, BYTE *buffer, int count ) ;
37+
void apg_shaFinal( apg_SHA_INFO *shaInfo, BYTE hash[SHA_DIGESTSIZE] ) ;
38+
39+
#endif /* _SHA_H_ */

‎src/smbl.h

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
** Copyright (c) 1999, 2000, 2001, 2002, 2003
3+
** Adel I. Mirzazhanov. All rights reserved
4+
**
5+
** Redistribution and use in source and binary forms, with or without
6+
** modification, are permitted provided that the following conditions
7+
** are met:
8+
**
9+
** 1.Redistributions of source code must retain the above copyright notice,
10+
** this list of conditions and the following disclaimer.
11+
** 2.Redistributions in binary form must reproduce the above copyright
12+
** notice, this list of conditions and the following disclaimer in the
13+
** documentation and/or other materials provided with the distribution.
14+
** 3.The name of the author may not be used to endorse or promote products
15+
** derived from this software without specific prior written permission.
16+
**
17+
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18+
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21+
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
#ifndef APG_SMBL_H
30+
#define APG_SMBL_H 1
31+
struct sym smbl[94] =
32+
{
33+
{'a', S_SL}, {'b', S_SL}, {'c', S_SL}, {'d', S_SL}, {'e', S_SL}, {'f', S_SL},
34+
{'g', S_SL}, {'h', S_SL}, {'i', S_SL}, {'j', S_SL}, {'k', S_SL}, {'l', S_SL},
35+
{'m', S_SL}, {'n', S_SL}, {'o', S_SL}, {'p', S_SL}, {'q', S_SL}, {'r', S_SL},
36+
{'s', S_SL}, {'t', S_SL}, {'u', S_SL}, {'v', S_SL}, {'w', S_SL}, {'x', S_SL},
37+
{'y', S_SL}, {'z', S_SL}, {'A', S_CL}, {'B', S_CL}, {'C', S_CL}, {'D', S_CL},
38+
{'E', S_CL}, {'F', S_CL}, {'G', S_CL}, {'H', S_CL}, {'I', S_CL}, {'J', S_CL},
39+
{'K', S_CL}, {'L', S_CL}, {'M', S_CL}, {'N', S_CL}, {'O', S_CL}, {'P', S_CL},
40+
{'Q', S_CL}, {'R', S_CL}, {'S', S_CL}, {'T', S_CL}, {'U', S_CL}, {'V', S_CL},
41+
{'W', S_CL}, {'X', S_CL}, {'Y', S_CL}, {'Z', S_CL}, {'1', S_NB}, {'2', S_NB},
42+
{'3', S_NB}, {'4', S_NB}, {'5', S_NB}, {'6', S_NB}, {'7', S_NB}, {'8', S_NB},
43+
{'9', S_NB}, {'0', S_NB}, {33 , S_SS}, {34 , S_SS}, {35 , S_SS}, {36 , S_SS},
44+
{37 , S_SS}, {38 , S_SS}, {39 , S_SS}, {40 , S_SS}, {41 , S_SS}, {42 , S_SS},
45+
{43 , S_SS}, {44 , S_SS}, {45 , S_SS}, {46 , S_SS}, {47 , S_SS}, {58 , S_SS},
46+
{59 , S_SS}, {60 , S_SS}, {61 , S_SS}, {62 , S_SS}, {63 , S_SS}, {64 , S_SS},
47+
{91 , S_SS}, {92 , S_SS}, {93 , S_SS}, {94 , S_SS}, {95 , S_SS}, {96 , S_SS},
48+
{123, S_SS}, {124, S_SS}, {125, S_SS}, {126, S_SS}
49+
};
50+
51+
#endif /* APG_SMBL_H */

0 commit comments

Comments
 (0)
Please sign in to comment.