[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
this looked like it might be interesting
- To: [email protected]
- Subject: this looked like it might be interesting
- From: [email protected] (Anonymous)
- Date: Wed, 9 Aug 1995 20:52:10 +0200
- Comments: Hack-Tic may or may not approve of the content of this posting
- Comments: Please report misuse of this automated remailing service to <[email protected]>
- Organization: Hack-Tic International, Inc.
- Sender: [email protected]
it was on a floppy i got in the mail last week:
/* TOP SECRET */
/* See label file for codeword restrictions */
/*****************************************************************/
/* TOP SECRET */
/* See label file for codeword restrictions */
/* */
/* S-1 CIPHER ALGORITHM software chip simulator */
/* */
/* NOT INTENDED FOR EXTERNAL, PRODUCTION, OR CONTRACTOR USE OR */
/* DISCLOSURE. */
/* NOT CERTIFIED OR APPROVED FOR USE AS REFERENCE. */
/* FOR SECONDARY ANALYTIC USE ONLY. */
/* */
/* Basic chip functions. Block encryption methods are not */
/* implemented. */
/* */
/* SOFTWARE HISTORY: */
/* 1 FEBRUARY 1989 --- Submitted to source control. */
/* 31 JULY 1991 --- Moved UFV support into basic functions. */
/* */
/* TOP SECRET */
/* See label file for codeword restrictions */
/*****************************************************************/
/* local declarations are for ANSI C */
#include <stdio.h>
#include <sys/types.h>
/* S-1 F table - these differ in the S-2 version */
static u_char F[4][256];
/* S-1 F selection (G) table */
static u_char G[2][256];
/* exported interface */
int S1_self_check(void);
int S1_zeroize(void);
int S1_load_key(int, u_char *);
int S1_encrypt_block(int, u_char *);
int S1_decrypt_block(int, u_char *);
int S1_create_key(u_char *, u_char *);
/* local functions */
static void f_initialize(void);
static void rotatekey(int, u_char *);
static u_char f(int,int);
static u_char g(int,int);
/* CHIP PARAMETERS */
#define KEYGEN_CHIP 1 /* delete this to simulate operational chipsets */
#define KEY_REGISTERS 4
#define INTEGRITY KEY_REGISTERS
/* user family vectors (UFV) */
static u_char clear_family[8] = {129,3,5,7,2,4,6,131};
static u_char cipher_family[8] = {1,254,253,252,128,129,130,8};
static u_char key_integrity_key[10] = {0,0,0,0,0,0,0,0,0,0};
static u_char key[KEY_REGISTERS+1][10];
static u_char fullkey[KEY_REGISTERS+1][32][6]; /* SOFTWARE ONLY */
static int initialized=0;
/* EXPORTED SIMULATED CHIP INTERFACE */
/* SEE NOTES FOR INTERFACE DESCRIPTIONS */
int S1_self_check()
{
f_initialize();
rotatekey(INTEGRITY,key_integrity_key);
initialized=1;
return 0;
}
int S1_zeroize()
{
int i, j, k;
i=0;
while (i<KEY_REGISTERS+1) {
j=0;
while (j<10) {
key[i][j] = 0;
j=j+1;
}
j=0;
while (j<32) {
k=0;
while (k<6) {
fullkey[i][j][k] = 0;
k++;
}
j=j+1;
}
i=i+1;
}
i=0;
while (i<4) {
j=0;
while (j<256) {
F[i][j] = 0;
j++;
}
i++;
}
return 0;
}
int S1_load_key(int key_register, u_char *key_vector)
{
u_char key_buffer[12];
if (initialized == 0)
return 1;
if ((key_register < 0) || (key_register >= KEY_REGISTERS))
return 9;
memcpy(key_buffer,key_vector,12);
S1_decrypt_block(INTEGRITY,key_buffer);
S1_decrypt_block(INTEGRITY,key_buffer+4);
if ((key_buffer[10] != 0) || (key_buffer[11] != 0))
return 2;
rotatekey(key_register,key_buffer);
memcpy(key[key_register],key_buffer,10);
return 0;
}
int S1_encrypt_block(int key_register, u_char *block)
{
int r, startf, i;
if (initialized == 0)
return 1;
i=0;
while (i<8) {
block[i] = block[i] ^ clear_family[i];
i=i+1;
}
i=0;
while (i<32) {
r=i*2;
startf = g(0,fullkey[key_register][r][0] ^ block[(r+4) % 8])
+ g(1,fullkey[key_register][r][1] ^ block[(r+5) % 8])*2;
block[(r+6) % 8] = block[(r+6) % 8]
^ f(((startf+0) % 4),
fullkey[key_register][r][2]
^ block[(r+2) % 8]);
block[(r+6) % 8] = block[(r+6) % 8]
^ (f(((startf+1) % 4),
fullkey[key_register][r][3]
^ block[(r+3) % 8]) << 4);
block[(r+7) % 8] = block[(r+7) % 8]
^ f(((startf+2) % 4),
fullkey[key_register][r][4]
^ block[(r+0) % 8]);
block[(r+7) % 8] = block[(r+7) % 8]
^ (f(((startf+3) % 4),
fullkey[key_register][r][5]
^ block[(r+1) % 8]) << 4);
i = i+1;
}
i=0;
while (i<8) {
block[i] = block[i] ^ cipher_family[i];
i=i+1;
}
return 0;
}
int S1_decrypt_block(int key_register, u_char *block)
{
int r, startf, i;
if (initialized == 0)
return 1;
i=0;
while (i<8) {
block[i] = block[i] ^ cipher_family[i];
i=i+1;
}
i=32;
while (i>0) {
i = i-1;
r=i*2;
startf = g(0,fullkey[key_register][r][0] ^ block[(r+4) % 8])
+ g(1,fullkey[key_register][r][1] ^ block[(r+5) % 8])*2;
block[(r+6) % 8] = block[(r+6) % 8]
^ f(((startf+0) % 4),
fullkey[key_register][r][2]
^ block[(r+2) % 8]);
block[(r+6) % 8] = block[(r+6) % 8]
^ (f(((startf+1) % 4),
fullkey[key_register][r][3]
^ block[(r+3) % 8]) << 4);
block[(r+7) % 8] = block[(r+7) % 8]
^ f(((startf+2) % 4),
fullkey[key_register][r][4]
^ block[(r+0) % 8]);
block[(r+7) % 8] = block[(r+7) % 8]
^ (f(((startf+3) % 4),
fullkey[key_register][r][5]
^ block[(r+1) % 8]) << 4);
}
i=0;
while (i<8) {
block[i] = block[i] ^ clear_family[i];
i=i+1;
}
return 0;
}
#ifdef KEYGEN_CHIP
/* WARNING: this feature is not implemented on all chip sets */
int S1_create_key(u_char *key_value, u_char *key_vector)
{
if (initialized == 0)
return 1;
memcpy(key_vector,key_value,10);
key_vector[10] = 0;
key_vector[11] = 0;
S1_encrypt_block(INTEGRITY,key_vector+4);
S1_encrypt_block(INTEGRITY,key_vector);
return 0;
}
#else
int S1_create_key(u_char *key_value, u_char *key_vector)
{
return 7;
}
#endif
/* SUPPORT FUNCTIONS */
static void
rotatekey(int key_register, u_char *key_value)
{
int i, j;
int jshift[6] = {5, 8, 3, 1, 4, 0};
key_register = key_register % KEY_REGISTERS;
i=0;
while (i<32) {
j=0;
while (j<6) {
fullkey[key_register][i][j] =
f(0,(key_value[(i*6+j+jshift[j]) % 10]))
^ f(1,(key_value[(i*6+j+jshift[(j+1)%6]) % 10]))
^ (f(2,(key_value[(i*6+j+jshift[(j+2)%6]) % 10]))<<4)
^ (f(3,(key_value[(i*6+j+jshift[(j+3)%6]) % 10]))<<4);
j=j+1;
}
i=i+1;
}
}
static void f_initialize() {
/* NON-LINEAR (F0, F1, F2, F3) */
F[0][0] = 07;
F[0][1] = 02;
F[0][2] = 011;
F[0][3] = 014;
F[0][4] = 010;
F[0][5] = 016;
F[0][6] = 01;
F[0][7] = 06;
F[0][8] = 015;
F[0][9] = 02;
F[0][10] = 00;
F[0][11] = 04;
F[0][12] = 017;
F[0][13] = 07;
F[0][14] = 03;
F[0][15] = 017;
F[0][16] = 010;
F[0][17] = 017;
F[0][18] = 012;
F[0][19] = 05;
F[0][20] = 013;
F[0][21] = 00;
F[0][22] = 017;
F[0][23] = 02;
F[0][24] = 05;
F[0][25] = 015;
F[0][26] = 017;
F[0][27] = 017;
F[0][28] = 011;
F[0][29] = 011;
F[0][30] = 06;
F[0][31] = 014;
F[0][32] = 07;
F[0][33] = 017;
F[0][34] = 012;
F[0][35] = 016;
F[0][36] = 012;
F[0][37] = 06;
F[0][38] = 04;
F[0][39] = 04;
F[0][40] = 014;
F[0][41] = 04;
F[0][42] = 017;
F[0][43] = 013;
F[0][44] = 03;
F[0][45] = 014;
F[0][46] = 014;
F[0][47] = 06;
F[0][48] = 06;
F[0][49] = 00;
F[0][50] = 02;
F[0][51] = 010;
F[0][52] = 012;
F[0][53] = 012;
F[0][54] = 03;
F[0][55] = 015;
F[0][56] = 013;
F[0][57] = 014;
F[0][58] = 017;
F[0][59] = 05;
F[0][60] = 05;
F[0][61] = 00;
F[0][62] = 07;
F[0][63] = 014;
F[0][64] = 016;
F[0][65] = 011;
F[0][66] = 03;
F[0][67] = 011;
F[0][68] = 010;
F[0][69] = 014;
F[0][70] = 012;
F[0][71] = 014;
F[0][72] = 017;
F[0][73] = 05;
F[0][74] = 07;
F[0][75] = 05;
F[0][76] = 07;
F[0][77] = 016;
F[0][78] = 03;
F[0][79] = 02;
F[0][80] = 011;
F[0][81] = 014;
F[0][82] = 04;
F[0][83] = 00;
F[0][84] = 010;
F[0][85] = 016;
F[0][86] = 02;
F[0][87] = 03;
F[0][88] = 02;
F[0][89] = 016;
F[0][90] = 013;
F[0][91] = 04;
F[0][92] = 010;
F[0][93] = 01;
F[0][94] = 06;
F[0][95] = 013;
F[0][96] = 016;
F[0][97] = 010;
F[0][98] = 017;
F[0][99] = 014;
F[0][100] = 00;
F[0][101] = 02;
F[0][102] = 00;
F[0][103] = 01;
F[0][104] = 01;
F[0][105] = 013;
F[0][106] = 016;
F[0][107] = 00;
F[0][108] = 02;
F[0][109] = 013;
F[0][110] = 017;
F[0][111] = 013;
F[0][112] = 016;
F[0][113] = 016;
F[0][114] = 02;
F[0][115] = 05;
F[0][116] = 02;
F[0][117] = 00;
F[0][118] = 016;
F[0][119] = 01;
F[0][120] = 010;
F[0][121] = 013;
F[0][122] = 011;
F[0][123] = 06;
F[0][124] = 01;
F[0][125] = 05;
F[0][126] = 07;
F[0][127] = 07;
F[0][128] = 016;
F[0][129] = 014;
F[0][130] = 012;
F[0][131] = 011;
F[0][132] = 011;
F[0][133] = 016;
F[0][134] = 07;
F[0][135] = 014;
F[0][136] = 011;
F[0][137] = 015;
F[0][138] = 012;
F[0][139] = 00;
F[0][140] = 010;
F[0][141] = 00;
F[0][142] = 07;
F[0][143] = 012;
F[0][144] = 015;
F[0][145] = 013;
F[0][146] = 00;
F[0][147] = 012;
F[0][148] = 04;
F[0][149] = 017;
F[0][150] = 05;
F[0][151] = 00;
F[0][152] = 015;
F[0][153] = 02;
F[0][154] = 016;
F[0][155] = 03;
F[0][156] = 03;
F[0][157] = 013;
F[0][158] = 06;
F[0][159] = 011;
F[0][160] = 014;
F[0][161] = 03;
F[0][162] = 017;
F[0][163] = 014;
F[0][164] = 00;
F[0][165] = 013;
F[0][166] = 06;
F[0][167] = 017;
F[0][168] = 010;
F[0][169] = 015;
F[0][170] = 01;
F[0][171] = 012;
F[0][172] = 05;
F[0][173] = 010;
F[0][174] = 06;
F[0][175] = 07;
F[0][176] = 06;
F[0][177] = 03;
F[0][178] = 017;
F[0][179] = 06;
F[0][180] = 015;
F[0][181] = 015;
F[0][182] = 01;
F[0][183] = 013;
F[0][184] = 04;
F[0][185] = 012;
F[0][186] = 03;
F[0][187] = 00;
F[0][188] = 06;
F[0][189] = 011;
F[0][190] = 011;
F[0][191] = 015;
F[0][192] = 012;
F[0][193] = 017;
F[0][194] = 016;
F[0][195] = 01;
F[0][196] = 015;
F[0][197] = 016;
F[0][198] = 017;
F[0][199] = 04;
F[0][200] = 015;
F[0][201] = 06;
F[0][202] = 07;
F[0][203] = 04;
F[0][204] = 00;
F[0][205] = 017;
F[0][206] = 016;
F[0][207] = 017;
F[0][208] = 010;
F[0][209] = 02;
F[0][210] = 04;
F[0][211] = 012;
F[0][212] = 01;
F[0][213] = 02;
F[0][214] = 011;
F[0][215] = 07;
F[0][216] = 010;
F[0][217] = 010;
F[0][218] = 02;
F[0][219] = 02;
F[0][220] = 07;
F[0][221] = 010;
F[0][222] = 010;
F[0][223] = 013;
F[0][224] = 03;
F[0][225] = 016;
F[0][226] = 017;
F[0][227] = 011;
F[0][228] = 06;
F[0][229] = 011;
F[0][230] = 00;
F[0][231] = 017;
F[0][232] = 014;
F[0][233] = 06;
F[0][234] = 04;
F[0][235] = 02;
F[0][236] = 03;
F[0][237] = 00;
F[0][238] = 011;
F[0][239] = 013;
F[0][240] = 014;
F[0][241] = 05;
F[0][242] = 03;
F[0][243] = 016;
F[0][244] = 013;
F[0][245] = 017;
F[0][246] = 04;
F[0][247] = 05;
F[0][248] = 017;
F[0][249] = 011;
F[0][250] = 03;
F[0][251] = 06;
F[0][252] = 010;
F[0][253] = 013;
F[0][254] = 014;
F[0][255] = 06;
F[1][0] = 017;
F[1][1] = 06;
F[1][2] = 016;
F[1][3] = 015;
F[1][4] = 012;
F[1][5] = 07;
F[1][6] = 07;
F[1][7] = 03;
F[1][8] = 03;
F[1][9] = 01;
F[1][10] = 017;
F[1][11] = 00;
F[1][12] = 013;
F[1][13] = 07;
F[1][14] = 02;
F[1][15] = 010;
F[1][16] = 01;
F[1][17] = 014;
F[1][18] = 012;
F[1][19] = 01;
F[1][20] = 07;
F[1][21] = 03;
F[1][22] = 01;
F[1][23] = 016;
F[1][24] = 014;
F[1][25] = 011;
F[1][26] = 00;
F[1][27] = 01;
F[1][28] = 06;
F[1][29] = 02;
F[1][30] = 011;
F[1][31] = 013;
F[1][32] = 014;
F[1][33] = 011;
F[1][34] = 07;
F[1][35] = 012;
F[1][36] = 03;
F[1][37] = 03;
F[1][38] = 010;
F[1][39] = 00;
F[1][40] = 00;
F[1][41] = 012;
F[1][42] = 04;
F[1][43] = 00;
F[1][44] = 02;
F[1][45] = 017;
F[1][46] = 015;
F[1][47] = 013;
F[1][48] = 02;
F[1][49] = 017;
F[1][50] = 05;
F[1][51] = 04;
F[1][52] = 03;
F[1][53] = 013;
F[1][54] = 017;
F[1][55] = 03;
F[1][56] = 011;
F[1][57] = 012;
F[1][58] = 01;
F[1][59] = 011;
F[1][60] = 07;
F[1][61] = 011;
F[1][62] = 011;
F[1][63] = 010;
F[1][64] = 01;
F[1][65] = 05;
F[1][66] = 02;
F[1][67] = 03;
F[1][68] = 010;
F[1][69] = 017;
F[1][70] = 07;
F[1][71] = 012;
F[1][72] = 015;
F[1][73] = 011;
F[1][74] = 010;
F[1][75] = 017;
F[1][76] = 03;
F[1][77] = 016;
F[1][78] = 03;
F[1][79] = 015;
F[1][80] = 011;
F[1][81] = 013;
F[1][82] = 05;
F[1][83] = 07;
F[1][84] = 017;
F[1][85] = 012;
F[1][86] = 012;
F[1][87] = 07;
F[1][88] = 017;
F[1][89] = 05;
F[1][90] = 07;
F[1][91] = 00;
F[1][92] = 04;
F[1][93] = 04;
F[1][94] = 04;
F[1][95] = 06;
F[1][96] = 011;
F[1][97] = 04;
F[1][98] = 07;
F[1][99] = 010;
F[1][100] = 010;
F[1][101] = 015;
F[1][102] = 017;
F[1][103] = 00;
F[1][104] = 012;
F[1][105] = 02;
F[1][106] = 01;
F[1][107] = 016;
F[1][108] = 00;
F[1][109] = 05;
F[1][110] = 03;
F[1][111] = 011;
F[1][112] = 05;
F[1][113] = 014;
F[1][114] = 011;
F[1][115] = 00;
F[1][116] = 011;
F[1][117] = 00;
F[1][118] = 013;
F[1][119] = 010;
F[1][120] = 016;
F[1][121] = 014;
F[1][122] = 04;
F[1][123] = 03;
F[1][124] = 015;
F[1][125] = 016;
F[1][126] = 02;
F[1][127] = 03;
F[1][128] = 012;
F[1][129] = 06;
F[1][130] = 017;
F[1][131] = 00;
F[1][132] = 011;
F[1][133] = 011;
F[1][134] = 02;
F[1][135] = 017;
F[1][136] = 013;
F[1][137] = 04;
F[1][138] = 07;
F[1][139] = 02;
F[1][140] = 02;
F[1][141] = 014;
F[1][142] = 04;
F[1][143] = 07;
F[1][144] = 014;
F[1][145] = 01;
F[1][146] = 00;
F[1][147] = 03;
F[1][148] = 01;
F[1][149] = 010;
F[1][150] = 01;
F[1][151] = 07;
F[1][152] = 012;
F[1][153] = 00;
F[1][154] = 015;
F[1][155] = 04;
F[1][156] = 00;
F[1][157] = 017;
F[1][158] = 04;
F[1][159] = 00;
F[1][160] = 017;
F[1][161] = 014;
F[1][162] = 04;
F[1][163] = 07;
F[1][164] = 013;
F[1][165] = 011;
F[1][166] = 012;
F[1][167] = 017;
F[1][168] = 017;
F[1][169] = 03;
F[1][170] = 07;
F[1][171] = 00;
F[1][172] = 04;
F[1][173] = 07;
F[1][174] = 07;
F[1][175] = 03;
F[1][176] = 05;
F[1][177] = 06;
F[1][178] = 017;
F[1][179] = 03;
F[1][180] = 017;
F[1][181] = 02;
F[1][182] = 04;
F[1][183] = 017;
F[1][184] = 00;
F[1][185] = 014;
F[1][186] = 017;
F[1][187] = 04;
F[1][188] = 05;
F[1][189] = 016;
F[1][190] = 015;
F[1][191] = 04;
F[1][192] = 012;
F[1][193] = 013;
F[1][194] = 00;
F[1][195] = 04;
F[1][196] = 017;
F[1][197] = 07;
F[1][198] = 013;
F[1][199] = 04;
F[1][200] = 010;
F[1][201] = 05;
F[1][202] = 07;
F[1][203] = 04;
F[1][204] = 013;
F[1][205] = 05;
F[1][206] = 016;
F[1][207] = 010;
F[1][208] = 015;
F[1][209] = 00;
F[1][210] = 04;
F[1][211] = 04;
F[1][212] = 017;
F[1][213] = 010;
F[1][214] = 05;
F[1][215] = 015;
F[1][216] = 011;
F[1][217] = 01;
F[1][218] = 012;
F[1][219] = 013;
F[1][220] = 015;
F[1][221] = 03;
F[1][222] = 010;
F[1][223] = 05;
F[1][224] = 07;
F[1][225] = 06;
F[1][226] = 00;
F[1][227] = 02;
F[1][228] = 011;
F[1][229] = 06;
F[1][230] = 00;
F[1][231] = 017;
F[1][232] = 01;
F[1][233] = 010;
F[1][234] = 03;
F[1][235] = 06;
F[1][236] = 05;
F[1][237] = 010;
F[1][238] = 010;
F[1][239] = 012;
F[1][240] = 014;
F[1][241] = 02;
F[1][242] = 02;
F[1][243] = 02;
F[1][244] = 010;
F[1][245] = 04;
F[1][246] = 013;
F[1][247] = 07;
F[1][248] = 016;
F[1][249] = 015;
F[1][250] = 05;
F[1][251] = 017;
F[1][252] = 05;
F[1][253] = 03;
F[1][254] = 010;
F[1][255] = 010;
F[2][0] = 013;
F[2][1] = 011;
F[2][2] = 017;
F[2][3] = 07;
F[2][4] = 01;
F[2][5] = 012;
F[2][6] = 00;
F[2][7] = 011;
F[2][8] = 06;
F[2][9] = 010;
F[2][10] = 012;
F[2][11] = 014;
F[2][12] = 00;
F[2][13] = 012;
F[2][14] = 01;
F[2][15] = 012;
F[2][16] = 011;
F[2][17] = 014;
F[2][18] = 05;
F[2][19] = 05;
F[2][20] = 07;
F[2][21] = 04;
F[2][22] = 013;
F[2][23] = 015;
F[2][24] = 04;
F[2][25] = 00;
F[2][26] = 01;
F[2][27] = 010;
F[2][28] = 017;
F[2][29] = 02;
F[2][30] = 015;
F[2][31] = 012;
F[2][32] = 06;
F[2][33] = 00;
F[2][34] = 07;
F[2][35] = 017;
F[2][36] = 014;
F[2][37] = 013;
F[2][38] = 011;
F[2][39] = 03;
F[2][40] = 07;
F[2][41] = 013;
F[2][42] = 06;
F[2][43] = 05;
F[2][44] = 011;
F[2][45] = 010;
F[2][46] = 00;
F[2][47] = 02;
F[2][48] = 07;
F[2][49] = 011;
F[2][50] = 016;
F[2][51] = 01;
F[2][52] = 012;
F[2][53] = 014;
F[2][54] = 012;
F[2][55] = 06;
F[2][56] = 011;
F[2][57] = 016;
F[2][58] = 015;
F[2][59] = 06;
F[2][60] = 07;
F[2][61] = 05;
F[2][62] = 014;
F[2][63] = 07;
F[2][64] = 01;
F[2][65] = 06;
F[2][66] = 012;
F[2][67] = 06;
F[2][68] = 05;
F[2][69] = 04;
F[2][70] = 03;
F[2][71] = 011;
F[2][72] = 04;
F[2][73] = 014;
F[2][74] = 013;
F[2][75] = 00;
F[2][76] = 010;
F[2][77] = 016;
F[2][78] = 03;
F[2][79] = 06;
F[2][80] = 00;
F[2][81] = 017;
F[2][82] = 02;
F[2][83] = 010;
F[2][84] = 010;
F[2][85] = 012;
F[2][86] = 012;
F[2][87] = 017;
F[2][88] = 07;
F[2][89] = 03;
F[2][90] = 012;
F[2][91] = 012;
F[2][92] = 013;
F[2][93] = 014;
F[2][94] = 013;
F[2][95] = 03;
F[2][96] = 011;
F[2][97] = 012;
F[2][98] = 06;
F[2][99] = 02;
F[2][100] = 02;
F[2][101] = 02;
F[2][102] = 011;
F[2][103] = 04;
F[2][104] = 06;
F[2][105] = 010;
F[2][106] = 05;
F[2][107] = 01;
F[2][108] = 016;
F[2][109] = 07;
F[2][110] = 017;
F[2][111] = 00;
F[2][112] = 013;
F[2][113] = 012;
F[2][114] = 016;
F[2][115] = 07;
F[2][116] = 016;
F[2][117] = 01;
F[2][118] = 04;
F[2][119] = 015;
F[2][120] = 07;
F[2][121] = 014;
F[2][122] = 00;
F[2][123] = 04;
F[2][124] = 06;
F[2][125] = 016;
F[2][126] = 011;
F[2][127] = 014;
F[2][128] = 06;
F[2][129] = 011;
F[2][130] = 012;
F[2][131] = 02;
F[2][132] = 012;
F[2][133] = 016;
F[2][134] = 013;
F[2][135] = 00;
F[2][136] = 00;
F[2][137] = 03;
F[2][138] = 03;
F[2][139] = 015;
F[2][140] = 07;
F[2][141] = 012;
F[2][142] = 00;
F[2][143] = 012;
F[2][144] = 017;
F[2][145] = 011;
F[2][146] = 05;
F[2][147] = 05;
F[2][148] = 010;
F[2][149] = 04;
F[2][150] = 04;
F[2][151] = 05;
F[2][152] = 014;
F[2][153] = 012;
F[2][154] = 011;
F[2][155] = 015;
F[2][156] = 015;
F[2][157] = 013;
F[2][158] = 017;
F[2][159] = 014;
F[2][160] = 011;
F[2][161] = 07;
F[2][162] = 013;
F[2][163] = 01;
F[2][164] = 00;
F[2][165] = 015;
F[2][166] = 011;
F[2][167] = 05;
F[2][168] = 015;
F[2][169] = 016;
F[2][170] = 012;
F[2][171] = 017;
F[2][172] = 01;
F[2][173] = 015;
F[2][174] = 07;
F[2][175] = 012;
F[2][176] = 010;
F[2][177] = 017;
F[2][178] = 07;
F[2][179] = 04;
F[2][180] = 011;
F[2][181] = 013;
F[2][182] = 01;
F[2][183] = 010;
F[2][184] = 06;
F[2][185] = 03;
F[2][186] = 010;
F[2][187] = 02;
F[2][188] = 05;
F[2][189] = 010;
F[2][190] = 011;
F[2][191] = 02;
F[2][192] = 04;
F[2][193] = 017;
F[2][194] = 012;
F[2][195] = 06;
F[2][196] = 05;
F[2][197] = 05;
F[2][198] = 015;
F[2][199] = 012;
F[2][200] = 00;
F[2][201] = 03;
F[2][202] = 04;
F[2][203] = 015;
F[2][204] = 016;
F[2][205] = 015;
F[2][206] = 015;
F[2][207] = 011;
F[2][208] = 03;
F[2][209] = 05;
F[2][210] = 013;
F[2][211] = 016;
F[2][212] = 02;
F[2][213] = 017;
F[2][214] = 013;
F[2][215] = 00;
F[2][216] = 03;
F[2][217] = 012;
F[2][218] = 02;
F[2][219] = 07;
F[2][220] = 03;
F[2][221] = 010;
F[2][222] = 011;
F[2][223] = 01;
F[2][224] = 06;
F[2][225] = 02;
F[2][226] = 014;
F[2][227] = 01;
F[2][228] = 012;
F[2][229] = 010;
F[2][230] = 02;
F[2][231] = 012;
F[2][232] = 013;
F[2][233] = 017;
F[2][234] = 013;
F[2][235] = 014;
F[2][236] = 05;
F[2][237] = 02;
F[2][238] = 02;
F[2][239] = 013;
F[2][240] = 011;
F[2][241] = 013;
F[2][242] = 02;
F[2][243] = 05;
F[2][244] = 014;
F[2][245] = 017;
F[2][246] = 06;
F[2][247] = 015;
F[2][248] = 01;
F[2][249] = 011;
F[2][250] = 012;
F[2][251] = 00;
F[2][252] = 013;
F[2][253] = 05;
F[2][254] = 03;
F[2][255] = 015;
F[3][0] = 013;
F[3][1] = 07;
F[3][2] = 04;
F[3][3] = 01;
F[3][4] = 03;
F[3][5] = 017;
F[3][6] = 07;
F[3][7] = 05;
F[3][8] = 014;
F[3][9] = 02;
F[3][10] = 05;
F[3][11] = 016;
F[3][12] = 013;
F[3][13] = 04;
F[3][14] = 013;
F[3][15] = 01;
F[3][16] = 015;
F[3][17] = 015;
F[3][18] = 014;
F[3][19] = 015;
F[3][20] = 01;
F[3][21] = 010;
F[3][22] = 04;
F[3][23] = 02;
F[3][24] = 07;
F[3][25] = 015;
F[3][26] = 016;
F[3][27] = 016;
F[3][28] = 01;
F[3][29] = 03;
F[3][30] = 011;
F[3][31] = 011;
F[3][32] = 010;
F[3][33] = 017;
F[3][34] = 06;
F[3][35] = 04;
F[3][36] = 013;
F[3][37] = 010;
F[3][38] = 014;
F[3][39] = 013;
F[3][40] = 03;
F[3][41] = 010;
F[3][42] = 015;
F[3][43] = 07;
F[3][44] = 07;
F[3][45] = 00;
F[3][46] = 05;
F[3][47] = 01;
F[3][48] = 03;
F[3][49] = 013;
F[3][50] = 015;
F[3][51] = 04;
F[3][52] = 017;
F[3][53] = 015;
F[3][54] = 03;
F[3][55] = 017;
F[3][56] = 013;
F[3][57] = 03;
F[3][58] = 013;
F[3][59] = 011;
F[3][60] = 00;
F[3][61] = 010;
F[3][62] = 01;
F[3][63] = 07;
F[3][64] = 03;
F[3][65] = 04;
F[3][66] = 04;
F[3][67] = 03;
F[3][68] = 03;
F[3][69] = 010;
F[3][70] = 016;
F[3][71] = 00;
F[3][72] = 01;
F[3][73] = 011;
F[3][74] = 015;
F[3][75] = 02;
F[3][76] = 013;
F[3][77] = 03;
F[3][78] = 07;
F[3][79] = 010;
F[3][80] = 010;
F[3][81] = 07;
F[3][82] = 014;
F[3][83] = 015;
F[3][84] = 013;
F[3][85] = 05;
F[3][86] = 00;
F[3][87] = 012;
F[3][88] = 012;
F[3][89] = 016;
F[3][90] = 07;
F[3][91] = 02;
F[3][92] = 017;
F[3][93] = 06;
F[3][94] = 017;
F[3][95] = 015;
F[3][96] = 013;
F[3][97] = 02;
F[3][98] = 03;
F[3][99] = 013;
F[3][100] = 01;
F[3][101] = 02;
F[3][102] = 017;
F[3][103] = 06;
F[3][104] = 04;
F[3][105] = 07;
F[3][106] = 04;
F[3][107] = 017;
F[3][108] = 03;
F[3][109] = 03;
F[3][110] = 02;
F[3][111] = 00;
F[3][112] = 05;
F[3][113] = 01;
F[3][114] = 00;
F[3][115] = 016;
F[3][116] = 014;
F[3][117] = 05;
F[3][118] = 02;
F[3][119] = 04;
F[3][120] = 07;
F[3][121] = 014;
F[3][122] = 07;
F[3][123] = 012;
F[3][124] = 05;
F[3][125] = 017;
F[3][126] = 011;
F[3][127] = 01;
F[3][128] = 06;
F[3][129] = 00;
F[3][130] = 015;
F[3][131] = 014;
F[3][132] = 017;
F[3][133] = 01;
F[3][134] = 00;
F[3][135] = 04;
F[3][136] = 00;
F[3][137] = 00;
F[3][138] = 011;
F[3][139] = 04;
F[3][140] = 013;
F[3][141] = 012;
F[3][142] = 03;
F[3][143] = 015;
F[3][144] = 01;
F[3][145] = 05;
F[3][146] = 04;
F[3][147] = 02;
F[3][148] = 011;
F[3][149] = 07;
F[3][150] = 00;
F[3][151] = 011;
F[3][152] = 015;
F[3][153] = 011;
F[3][154] = 00;
F[3][155] = 05;
F[3][156] = 07;
F[3][157] = 016;
F[3][158] = 017;
F[3][159] = 02;
F[3][160] = 05;
F[3][161] = 013;
F[3][162] = 06;
F[3][163] = 04;
F[3][164] = 06;
F[3][165] = 01;
F[3][166] = 013;
F[3][167] = 04;
F[3][168] = 06;
F[3][169] = 015;
F[3][170] = 010;
F[3][171] = 012;
F[3][172] = 03;
F[3][173] = 010;
F[3][174] = 017;
F[3][175] = 013;
F[3][176] = 011;
F[3][177] = 010;
F[3][178] = 07;
F[3][179] = 00;
F[3][180] = 014;
F[3][181] = 03;
F[3][182] = 05;
F[3][183] = 00;
F[3][184] = 013;
F[3][185] = 016;
F[3][186] = 013;
F[3][187] = 014;
F[3][188] = 01;
F[3][189] = 02;
F[3][190] = 016;
F[3][191] = 06;
F[3][192] = 012;
F[3][193] = 016;
F[3][194] = 014;
F[3][195] = 03;
F[3][196] = 04;
F[3][197] = 06;
F[3][198] = 00;
F[3][199] = 017;
F[3][200] = 00;
F[3][201] = 014;
F[3][202] = 05;
F[3][203] = 016;
F[3][204] = 01;
F[3][205] = 01;
F[3][206] = 04;
F[3][207] = 03;
F[3][208] = 01;
F[3][209] = 010;
F[3][210] = 00;
F[3][211] = 013;
F[3][212] = 010;
F[3][213] = 03;
F[3][214] = 015;
F[3][215] = 03;
F[3][216] = 07;
F[3][217] = 017;
F[3][218] = 014;
F[3][219] = 012;
F[3][220] = 06;
F[3][221] = 01;
F[3][222] = 01;
F[3][223] = 03;
F[3][224] = 00;
F[3][225] = 06;
F[3][226] = 012;
F[3][227] = 05;
F[3][228] = 05;
F[3][229] = 06;
F[3][230] = 07;
F[3][231] = 010;
F[3][232] = 017;
F[3][233] = 016;
F[3][234] = 01;
F[3][235] = 05;
F[3][236] = 00;
F[3][237] = 016;
F[3][238] = 00;
F[3][239] = 00;
F[3][240] = 014;
F[3][241] = 017;
F[3][242] = 010;
F[3][243] = 00;
F[3][244] = 06;
F[3][245] = 012;
F[3][246] = 011;
F[3][247] = 016;
F[3][248] = 017;
F[3][249] = 017;
F[3][250] = 03;
F[3][251] = 03;
F[3][252] = 014;
F[3][253] = 00;
F[3][254] = 015;
F[3][255] = 017;
/* PSEUDO-LINEAR (G0, G1) */
G[0][0] = 00;
G[0][1] = 00;
G[0][2] = 01;
G[0][3] = 01;
G[0][4] = 00;
G[0][5] = 01;
G[0][6] = 01;
G[0][7] = 00;
G[0][8] = 00;
G[0][9] = 01;
G[0][10] = 00;
G[0][11] = 00;
G[0][12] = 01;
G[0][13] = 01;
G[0][14] = 00;
G[0][15] = 01;
G[0][16] = 01;
G[0][17] = 00;
G[0][18] = 00;
G[0][19] = 01;
G[0][20] = 00;
G[0][21] = 00;
G[0][22] = 01;
G[0][23] = 01;
G[0][24] = 00;
G[0][25] = 01;
G[0][26] = 01;
G[0][27] = 00;
G[0][28] = 00;
G[0][29] = 01;
G[0][30] = 00;
G[0][31] = 00;
G[0][32] = 01;
G[0][33] = 01;
G[0][34] = 00;
G[0][35] = 01;
G[0][36] = 01;
G[0][37] = 00;
G[0][38] = 00;
G[0][39] = 01;
G[0][40] = 00;
G[0][41] = 00;
G[0][42] = 01;
G[0][43] = 01;
G[0][44] = 00;
G[0][45] = 01;
G[0][46] = 01;
G[0][47] = 00;
G[0][48] = 00;
G[0][49] = 01;
G[0][50] = 00;
G[0][51] = 00;
G[0][52] = 01;
G[0][53] = 01;
G[0][54] = 00;
G[0][55] = 01;
G[0][56] = 01;
G[0][57] = 00;
G[0][58] = 00;
G[0][59] = 01;
G[0][60] = 00;
G[0][61] = 00;
G[0][62] = 01;
G[0][63] = 01;
G[0][64] = 00;
G[0][65] = 01;
G[0][66] = 01;
G[0][67] = 00;
G[0][68] = 00;
G[0][69] = 01;
G[0][70] = 00;
G[0][71] = 00;
G[0][72] = 01;
G[0][73] = 01;
G[0][74] = 00;
G[0][75] = 01;
G[0][76] = 01;
G[0][77] = 00;
G[0][78] = 00;
G[0][79] = 01;
G[0][80] = 00;
G[0][81] = 00;
G[0][82] = 01;
G[0][83] = 01;
G[0][84] = 00;
G[0][85] = 01;
G[0][86] = 01;
G[0][87] = 00;
G[0][88] = 00;
G[0][89] = 01;
G[0][90] = 00;
G[0][91] = 00;
G[0][92] = 01;
G[0][93] = 01;
G[0][94] = 00;
G[0][95] = 01;
G[0][96] = 01;
G[0][97] = 00;
G[0][98] = 00;
G[0][99] = 01;
G[0][100] = 00;
G[0][101] = 00;
G[0][102] = 01;
G[0][103] = 01;
G[0][104] = 00;
G[0][105] = 01;
G[0][106] = 01;
G[0][107] = 00;
G[0][108] = 00;
G[0][109] = 01;
G[0][110] = 00;
G[0][111] = 00;
G[0][112] = 01;
G[0][113] = 01;
G[0][114] = 00;
G[0][115] = 01;
G[0][116] = 01;
G[0][117] = 00;
G[0][118] = 00;
G[0][119] = 01;
G[0][120] = 00;
G[0][121] = 00;
G[0][122] = 01;
G[0][123] = 01;
G[0][124] = 00;
G[0][125] = 01;
G[0][126] = 01;
G[0][127] = 00;
G[0][128] = 00;
G[0][129] = 01;
G[0][130] = 00;
G[0][131] = 00;
G[0][132] = 01;
G[0][133] = 01;
G[0][134] = 00;
G[0][135] = 01;
G[0][136] = 01;
G[0][137] = 00;
G[0][138] = 00;
G[0][139] = 01;
G[0][140] = 00;
G[0][141] = 00;
G[0][142] = 01;
G[0][143] = 01;
G[0][144] = 00;
G[0][145] = 01;
G[0][146] = 01;
G[0][147] = 00;
G[0][148] = 00;
G[0][149] = 01;
G[0][150] = 00;
G[0][151] = 00;
G[0][152] = 01;
G[0][153] = 01;
G[0][154] = 00;
G[0][155] = 01;
G[0][156] = 01;
G[0][157] = 00;
G[0][158] = 00;
G[0][159] = 01;
G[0][160] = 00;
G[0][161] = 00;
G[0][162] = 01;
G[0][163] = 01;
G[0][164] = 00;
G[0][165] = 01;
G[0][166] = 01;
G[0][167] = 00;
G[0][168] = 00;
G[0][169] = 01;
G[0][170] = 00;
G[0][171] = 00;
G[0][172] = 01;
G[0][173] = 01;
G[0][174] = 00;
G[0][175] = 01;
G[0][176] = 01;
G[0][177] = 00;
G[0][178] = 00;
G[0][179] = 01;
G[0][180] = 00;
G[0][181] = 00;
G[0][182] = 01;
G[0][183] = 01;
G[0][184] = 00;
G[0][185] = 01;
G[0][186] = 01;
G[0][187] = 00;
G[0][188] = 00;
G[0][189] = 01;
G[0][190] = 00;
G[0][191] = 00;
G[0][192] = 01;
G[0][193] = 01;
G[0][194] = 00;
G[0][195] = 01;
G[0][196] = 01;
G[0][197] = 00;
G[0][198] = 00;
G[0][199] = 01;
G[0][200] = 00;
G[0][201] = 00;
G[0][202] = 01;
G[0][203] = 01;
G[0][204] = 00;
G[0][205] = 01;
G[0][206] = 01;
G[0][207] = 00;
G[0][208] = 00;
G[0][209] = 01;
G[0][210] = 00;
G[0][211] = 00;
G[0][212] = 01;
G[0][213] = 01;
G[0][214] = 00;
G[0][215] = 01;
G[0][216] = 01;
G[0][217] = 00;
G[0][218] = 00;
G[0][219] = 01;
G[0][220] = 00;
G[0][221] = 00;
G[0][222] = 01;
G[0][223] = 01;
G[0][224] = 00;
G[0][225] = 01;
G[0][226] = 01;
G[0][227] = 00;
G[0][228] = 00;
G[0][229] = 01;
G[0][230] = 00;
G[0][231] = 00;
G[0][232] = 01;
G[0][233] = 01;
G[0][234] = 00;
G[0][235] = 01;
G[0][236] = 01;
G[0][237] = 00;
G[0][238] = 00;
G[0][239] = 01;
G[0][240] = 00;
G[0][241] = 00;
G[0][242] = 01;
G[0][243] = 01;
G[0][244] = 00;
G[0][245] = 01;
G[0][246] = 01;
G[0][247] = 00;
G[0][248] = 00;
G[0][249] = 01;
G[0][250] = 00;
G[0][251] = 00;
G[0][252] = 01;
G[0][253] = 01;
G[0][254] = 00;
G[0][255] = 01;
G[1][0] = 00;
G[1][1] = 01;
G[1][2] = 01;
G[1][3] = 00;
G[1][4] = 01;
G[1][5] = 00;
G[1][6] = 00;
G[1][7] = 01;
G[1][8] = 00;
G[1][9] = 01;
G[1][10] = 01;
G[1][11] = 00;
G[1][12] = 01;
G[1][13] = 00;
G[1][14] = 00;
G[1][15] = 01;
G[1][16] = 01;
G[1][17] = 00;
G[1][18] = 00;
G[1][19] = 01;
G[1][20] = 00;
G[1][21] = 01;
G[1][22] = 01;
G[1][23] = 00;
G[1][24] = 01;
G[1][25] = 00;
G[1][26] = 00;
G[1][27] = 01;
G[1][28] = 00;
G[1][29] = 01;
G[1][30] = 01;
G[1][31] = 00;
G[1][32] = 00;
G[1][33] = 01;
G[1][34] = 01;
G[1][35] = 00;
G[1][36] = 01;
G[1][37] = 00;
G[1][38] = 00;
G[1][39] = 01;
G[1][40] = 00;
G[1][41] = 01;
G[1][42] = 01;
G[1][43] = 00;
G[1][44] = 01;
G[1][45] = 00;
G[1][46] = 00;
G[1][47] = 01;
G[1][48] = 01;
G[1][49] = 00;
G[1][50] = 00;
G[1][51] = 01;
G[1][52] = 00;
G[1][53] = 01;
G[1][54] = 01;
G[1][55] = 00;
G[1][56] = 01;
G[1][57] = 00;
G[1][58] = 00;
G[1][59] = 01;
G[1][60] = 00;
G[1][61] = 01;
G[1][62] = 01;
G[1][63] = 00;
G[1][64] = 00;
G[1][65] = 01;
G[1][66] = 01;
G[1][67] = 00;
G[1][68] = 01;
G[1][69] = 00;
G[1][70] = 00;
G[1][71] = 01;
G[1][72] = 00;
G[1][73] = 01;
G[1][74] = 01;
G[1][75] = 00;
G[1][76] = 01;
G[1][77] = 00;
G[1][78] = 00;
G[1][79] = 01;
G[1][80] = 01;
G[1][81] = 00;
G[1][82] = 00;
G[1][83] = 01;
G[1][84] = 00;
G[1][85] = 01;
G[1][86] = 01;
G[1][87] = 00;
G[1][88] = 01;
G[1][89] = 00;
G[1][90] = 00;
G[1][91] = 01;
G[1][92] = 00;
G[1][93] = 01;
G[1][94] = 01;
G[1][95] = 00;
G[1][96] = 00;
G[1][97] = 01;
G[1][98] = 01;
G[1][99] = 00;
G[1][100] = 01;
G[1][101] = 00;
G[1][102] = 00;
G[1][103] = 01;
G[1][104] = 00;
G[1][105] = 01;
G[1][106] = 01;
G[1][107] = 00;
G[1][108] = 01;
G[1][109] = 00;
G[1][110] = 00;
G[1][111] = 01;
G[1][112] = 01;
G[1][113] = 00;
G[1][114] = 00;
G[1][115] = 01;
G[1][116] = 00;
G[1][117] = 01;
G[1][118] = 01;
G[1][119] = 00;
G[1][120] = 01;
G[1][121] = 00;
G[1][122] = 00;
G[1][123] = 01;
G[1][124] = 00;
G[1][125] = 01;
G[1][126] = 01;
G[1][127] = 00;
G[1][128] = 00;
G[1][129] = 01;
G[1][130] = 01;
G[1][131] = 00;
G[1][132] = 01;
G[1][133] = 00;
G[1][134] = 00;
G[1][135] = 01;
G[1][136] = 00;
G[1][137] = 01;
G[1][138] = 01;
G[1][139] = 00;
G[1][140] = 01;
G[1][141] = 00;
G[1][142] = 00;
G[1][143] = 01;
G[1][144] = 01;
G[1][145] = 00;
G[1][146] = 00;
G[1][147] = 01;
G[1][148] = 00;
G[1][149] = 01;
G[1][150] = 01;
G[1][151] = 00;
G[1][152] = 01;
G[1][153] = 00;
G[1][154] = 00;
G[1][155] = 01;
G[1][156] = 00;
G[1][157] = 01;
G[1][158] = 01;
G[1][159] = 00;
G[1][160] = 00;
G[1][161] = 01;
G[1][162] = 01;
G[1][163] = 00;
G[1][164] = 01;
G[1][165] = 00;
G[1][166] = 00;
G[1][167] = 01;
G[1][168] = 00;
G[1][169] = 01;
G[1][170] = 01;
G[1][171] = 00;
G[1][172] = 01;
G[1][173] = 00;
G[1][174] = 00;
G[1][175] = 01;
G[1][176] = 01;
G[1][177] = 00;
G[1][178] = 00;
G[1][179] = 01;
G[1][180] = 00;
G[1][181] = 01;
G[1][182] = 01;
G[1][183] = 00;
G[1][184] = 01;
G[1][185] = 00;
G[1][186] = 00;
G[1][187] = 01;
G[1][188] = 00;
G[1][189] = 01;
G[1][190] = 01;
G[1][191] = 00;
G[1][192] = 00;
G[1][193] = 01;
G[1][194] = 01;
G[1][195] = 00;
G[1][196] = 01;
G[1][197] = 00;
G[1][198] = 00;
G[1][199] = 01;
G[1][200] = 00;
G[1][201] = 01;
G[1][202] = 01;
G[1][203] = 00;
G[1][204] = 01;
G[1][205] = 00;
G[1][206] = 00;
G[1][207] = 01;
G[1][208] = 01;
G[1][209] = 00;
G[1][210] = 00;
G[1][211] = 01;
G[1][212] = 00;
G[1][213] = 01;
G[1][214] = 01;
G[1][215] = 00;
G[1][216] = 01;
G[1][217] = 00;
G[1][218] = 00;
G[1][219] = 01;
G[1][220] = 00;
G[1][221] = 01;
G[1][222] = 01;
G[1][223] = 00;
G[1][224] = 00;
G[1][225] = 01;
G[1][226] = 01;
G[1][227] = 00;
G[1][228] = 01;
G[1][229] = 00;
G[1][230] = 00;
G[1][231] = 01;
G[1][232] = 00;
G[1][233] = 01;
G[1][234] = 01;
G[1][235] = 00;
G[1][236] = 01;
G[1][237] = 00;
G[1][238] = 00;
G[1][239] = 01;
G[1][240] = 01;
G[1][241] = 00;
G[1][242] = 00;
G[1][243] = 01;
G[1][244] = 00;
G[1][245] = 01;
G[1][246] = 01;
G[1][247] = 00;
G[1][248] = 01;
G[1][249] = 00;
G[1][250] = 00;
G[1][251] = 01;
G[1][252] = 00;
G[1][253] = 01;
G[1][254] = 01;
G[1][255] = 00;
}
static u_char f(int table, int value)
{
if ((table<0) || (table>3) || (value<0) || (value>255)) {
fprintf(stderr,"\n\nF TABLE EXCEPTION %x %x\n\n",table,value);
exit(1001);
}
return F[table][value];
}
static u_char g(int table, int value)
{
if ((table<0) || (table>2) || (value<0) || (value>255)) {
fprintf(stderr,"\n\nG TABLE EXCEPTION %x %x\n\n",table,value);
exit(1001);
}
return G[table][value];
}
/* TOP SECRET */
/* See label file for codeword restrictions */