Skip to content

Instantly share code, notes, and snippets.

@tcoram
Created July 30, 2014 19:51
Show Gist options
  • Save tcoram/61d47b145cb754c59497 to your computer and use it in GitHub Desktop.
Save tcoram/61d47b145cb754c59497 to your computer and use it in GitHub Desktop.
Blowfish crypto in sh and gawk
#!/bin/sh
#
# Blowfish - A pure posix shell and gawk implementation of the
# Blowfish algorithm.
# By Todd Coram (todd at maplefish dot com)
#
# This file is in the public domain. You are free to use it for any purpose.
#
# Be warned: This is a naive CBC implementation and is only meant for
# demonstrations and playing around with crytpo.
#
# Based on Paul Kocher's C implementation of the blowfish algorithm.
#
#
# This blowfish implementation reads and writes files formatted as follows:
#
# byte_length_of_data\n
# left_hex_long_word right_hex_long_word \n
# ..
#
# As a convenience, a special function "to_lr" will put the standard input
# stream in this form (for encryption) and convert decrypted data from this
# intermediate form.
#
# version 1.1 07/30/2014 - fixed a long standing byte count bug.
# version 1.0 9/6/2006
#
ENCRYPT=1
PASSWORD=""
die() {
status=$?
stty </dev/tty echo
exit $status
}
trap die 0 1 2 3 6 8 13 15
type gawk >/dev/null 2>&1
if [ ! $? = 0 ]; then
echo "GNU Awk is required! Sorry."
exit 1
fi
while test $# -gt 0
do
case $1 in
-d | --decrypt )
ENCRYPT=0
;;
-h | --help )
echo "Usage: $0 [--decrypt | -d] [password]" >&2
exit 0
;;
-* )
echo "Unrecognized option: $1" >&2
exit 1
;;
* )
PASSWORD="$1"
;;
esac
shift
done
if [ "$PASSWORD" = "" ]; then
echo -n "Enter Password: " >/dev/tty
stty </dev/tty -echo && read PASSWORD </dev/tty
stty </dev/tty echo
fi
##########################################################################
# Blowfish functions
##########################################################################
# Convert stream from left-right numeric pairs (from blowfish) to data
#
from_lr() {
gawk '
NF == 1 {
len = strtonum($1);
}
NF == 2 {
l = strtonum($1);
r = strtonum($2);
for (b=3; b >=0 && bcnt < len; b--) {
printf("%c", and(rshift(l,b*8),0xff));
bcnt++;
}
for (b=3; b >=0 && bcnt < len; b--) {
printf("%c", and(rshift(r,b*8),0xff));
bcnt++;
}
}'
}
# Convert stream from data to left-right numeric pairs (for blowfish)
#
to_lr() {
gawk '
BEGIN {
for (i=0; i < 256; i++) {
t = sprintf("%c", i);
ORD[t] = i;
}
ORS="";
RS="UdeadbeefY" PROCINFO["pid"];
while ((getline ln ) > 0) {
buf=buf ln;
if (RT != "") buf=buf RT;
}
}
END {
len = length(buf);
printf("0x%08x\n", len);
while ((len % 8) != 0) { buf=buf"\0"; len++; }
for(i=1; i <= len; i+=8) {
lr_s=substr(buf,i,8);
split(lr_s,lr,"");
l = 0; r = 0;
for(ii=1; ii <= 4; ii++) {
l = lshift(l,8) + ORD[lr[ii]];
r = lshift(r,8) + ORD[lr[4+ii]];
}
printf("0x%08x 0x%08x\n", l, r);
}
}'
}
# Blowfish algorithm
#
blowfish() {
gawk -v ENCRYPT=$1 -v PASSWORD=$2 '
BEGIN {
uid = 0;
ORIG_P[0]=0x243F6A88; ORIG_P[1]=0x85A308D3; ORIG_P[2]=0x13198A2E;
ORIG_P[3]=0x03707344; ORIG_P[4]=0xA4093822; ORIG_P[5]=0x299F31D0;
ORIG_P[6]=0x082EFA98; ORIG_P[7]=0xEC4E6C89; ORIG_P[8]=0x452821E6;
ORIG_P[9]=0x38D01377; ORIG_P[10]=0xBE5466CF; ORIG_P[11]=0x34E90C6C;
ORIG_P[12]=0xC0AC29B7; ORIG_P[13]=0xC97C50DD; ORIG_P[14]=0x3F84D5B5;
ORIG_P[15]=0xB5470917; ORIG_P[16]=0x9216D5D9; ORIG_P[17]=0x8979FB1B;
ORIG_S[0]=0xD1310BA6; ORIG_S[1]=0x98DFB5AC; ORIG_S[2]=0x2FFD72DB;
ORIG_S[3]=0xD01ADFB7; ORIG_S[4]=0xB8E1AFED; ORIG_S[5]=0x6A267E96;
ORIG_S[6]=0xBA7C9045; ORIG_S[7]=0xF12C7F99; ORIG_S[8]=0x24A19947;
ORIG_S[9]=0xB3916CF7; ORIG_S[10]=0x0801F2E2; ORIG_S[11]=0x858EFC16;
ORIG_S[12]=0x636920D8; ORIG_S[13]=0x71574E69; ORIG_S[14]=0xA458FEA3;
ORIG_S[15]=0xF4933D7E; ORIG_S[16]=0x0D95748F; ORIG_S[17]=0x728EB658;
ORIG_S[18]=0x718BCD58; ORIG_S[19]=0x82154AEE; ORIG_S[20]=0x7B54A41D;
ORIG_S[21]=0xC25A59B5; ORIG_S[22]=0x9C30D539; ORIG_S[23]=0x2AF26013;
ORIG_S[24]=0xC5D1B023; ORIG_S[25]=0x286085F0; ORIG_S[26]=0xCA417918;
ORIG_S[27]=0xB8DB38EF; ORIG_S[28]=0x8E79DCB0; ORIG_S[29]=0x603A180E;
ORIG_S[30]=0x6C9E0E8B; ORIG_S[31]=0xB01E8A3E; ORIG_S[32]=0xD71577C1;
ORIG_S[33]=0xBD314B27; ORIG_S[34]=0x78AF2FDA; ORIG_S[35]=0x55605C60;
ORIG_S[36]=0xE65525F3; ORIG_S[37]=0xAA55AB94; ORIG_S[38]=0x57489862;
ORIG_S[39]=0x63E81440; ORIG_S[40]=0x55CA396A; ORIG_S[41]=0x2AAB10B6;
ORIG_S[42]=0xB4CC5C34; ORIG_S[43]=0x1141E8CE; ORIG_S[44]=0xA15486AF;
ORIG_S[45]=0x7C72E993; ORIG_S[46]=0xB3EE1411; ORIG_S[47]=0x636FBC2A;
ORIG_S[48]=0x2BA9C55D; ORIG_S[49]=0x741831F6; ORIG_S[50]=0xCE5C3E16;
ORIG_S[51]=0x9B87931E; ORIG_S[52]=0xAFD6BA33; ORIG_S[53]=0x6C24CF5C;
ORIG_S[54]=0x7A325381; ORIG_S[55]=0x28958677; ORIG_S[56]=0x3B8F4898;
ORIG_S[57]=0x6B4BB9AF; ORIG_S[58]=0xC4BFE81B; ORIG_S[59]=0x66282193;
ORIG_S[60]=0x61D809CC; ORIG_S[61]=0xFB21A991; ORIG_S[62]=0x487CAC60;
ORIG_S[63]=0x5DEC8032; ORIG_S[64]=0xEF845D5D; ORIG_S[65]=0xE98575B1;
ORIG_S[66]=0xDC262302; ORIG_S[67]=0xEB651B88; ORIG_S[68]=0x23893E81;
ORIG_S[69]=0xD396ACC5; ORIG_S[70]=0x0F6D6FF3; ORIG_S[71]=0x83F44239;
ORIG_S[72]=0x2E0B4482; ORIG_S[73]=0xA4842004; ORIG_S[74]=0x69C8F04A;
ORIG_S[75]=0x9E1F9B5E; ORIG_S[76]=0x21C66842; ORIG_S[77]=0xF6E96C9A;
ORIG_S[78]=0x670C9C61; ORIG_S[79]=0xABD388F0; ORIG_S[80]=0x6A51A0D2;
ORIG_S[81]=0xD8542F68; ORIG_S[82]=0x960FA728; ORIG_S[83]=0xAB5133A3;
ORIG_S[84]=0x6EEF0B6C; ORIG_S[85]=0x137A3BE4; ORIG_S[86]=0xBA3BF050;
ORIG_S[87]=0x7EFB2A98; ORIG_S[88]=0xA1F1651D; ORIG_S[89]=0x39AF0176;
ORIG_S[90]=0x66CA593E; ORIG_S[91]=0x82430E88; ORIG_S[92]=0x8CEE8619;
ORIG_S[93]=0x456F9FB4; ORIG_S[94]=0x7D84A5C3; ORIG_S[95]=0x3B8B5EBE;
ORIG_S[96]=0xE06F75D8; ORIG_S[97]=0x85C12073; ORIG_S[98]=0x401A449F;
ORIG_S[99]=0x56C16AA6; ORIG_S[100]=0x4ED3AA62; ORIG_S[101]=0x363F7706;
ORIG_S[102]=0x1BFEDF72; ORIG_S[103]=0x429B023D; ORIG_S[104]=0x37D0D724;
ORIG_S[105]=0xD00A1248; ORIG_S[106]=0xDB0FEAD3; ORIG_S[107]=0x49F1C09B;
ORIG_S[108]=0x075372C9; ORIG_S[109]=0x80991B7B; ORIG_S[110]=0x25D479D8;
ORIG_S[111]=0xF6E8DEF7; ORIG_S[112]=0xE3FE501A; ORIG_S[113]=0xB6794C3B;
ORIG_S[114]=0x976CE0BD; ORIG_S[115]=0x04C006BA; ORIG_S[116]=0xC1A94FB6;
ORIG_S[117]=0x409F60C4; ORIG_S[118]=0x5E5C9EC2; ORIG_S[119]=0x196A2463;
ORIG_S[120]=0x68FB6FAF; ORIG_S[121]=0x3E6C53B5; ORIG_S[122]=0x1339B2EB;
ORIG_S[123]=0x3B52EC6F; ORIG_S[124]=0x6DFC511F; ORIG_S[125]=0x9B30952C;
ORIG_S[126]=0xCC814544; ORIG_S[127]=0xAF5EBD09; ORIG_S[128]=0xBEE3D004;
ORIG_S[129]=0xDE334AFD; ORIG_S[130]=0x660F2807; ORIG_S[131]=0x192E4BB3;
ORIG_S[132]=0xC0CBA857; ORIG_S[133]=0x45C8740F; ORIG_S[134]=0xD20B5F39;
ORIG_S[135]=0xB9D3FBDB; ORIG_S[136]=0x5579C0BD; ORIG_S[137]=0x1A60320A;
ORIG_S[138]=0xD6A100C6; ORIG_S[139]=0x402C7279; ORIG_S[140]=0x679F25FE;
ORIG_S[141]=0xFB1FA3CC; ORIG_S[142]=0x8EA5E9F8; ORIG_S[143]=0xDB3222F8;
ORIG_S[144]=0x3C7516DF; ORIG_S[145]=0xFD616B15; ORIG_S[146]=0x2F501EC8;
ORIG_S[147]=0xAD0552AB; ORIG_S[148]=0x323DB5FA; ORIG_S[149]=0xFD238760;
ORIG_S[150]=0x53317B48; ORIG_S[151]=0x3E00DF82; ORIG_S[152]=0x9E5C57BB;
ORIG_S[153]=0xCA6F8CA0; ORIG_S[154]=0x1A87562E; ORIG_S[155]=0xDF1769DB;
ORIG_S[156]=0xD542A8F6; ORIG_S[157]=0x287EFFC3; ORIG_S[158]=0xAC6732C6;
ORIG_S[159]=0x8C4F5573; ORIG_S[160]=0x695B27B0; ORIG_S[161]=0xBBCA58C8;
ORIG_S[162]=0xE1FFA35D; ORIG_S[163]=0xB8F011A0; ORIG_S[164]=0x10FA3D98;
ORIG_S[165]=0xFD2183B8; ORIG_S[166]=0x4AFCB56C; ORIG_S[167]=0x2DD1D35B;
ORIG_S[168]=0x9A53E479; ORIG_S[169]=0xB6F84565; ORIG_S[170]=0xD28E49BC;
ORIG_S[171]=0x4BFB9790; ORIG_S[172]=0xE1DDF2DA; ORIG_S[173]=0xA4CB7E33;
ORIG_S[174]=0x62FB1341; ORIG_S[175]=0xCEE4C6E8; ORIG_S[176]=0xEF20CADA;
ORIG_S[177]=0x36774C01; ORIG_S[178]=0xD07E9EFE; ORIG_S[179]=0x2BF11FB4;
ORIG_S[180]=0x95DBDA4D; ORIG_S[181]=0xAE909198; ORIG_S[182]=0xEAAD8E71;
ORIG_S[183]=0x6B93D5A0; ORIG_S[184]=0xD08ED1D0; ORIG_S[185]=0xAFC725E0;
ORIG_S[186]=0x8E3C5B2F; ORIG_S[187]=0x8E7594B7; ORIG_S[188]=0x8FF6E2FB;
ORIG_S[189]=0xF2122B64; ORIG_S[190]=0x8888B812; ORIG_S[191]=0x900DF01C;
ORIG_S[192]=0x4FAD5EA0; ORIG_S[193]=0x688FC31C; ORIG_S[194]=0xD1CFF191;
ORIG_S[195]=0xB3A8C1AD; ORIG_S[196]=0x2F2F2218; ORIG_S[197]=0xBE0E1777;
ORIG_S[198]=0xEA752DFE; ORIG_S[199]=0x8B021FA1; ORIG_S[200]=0xE5A0CC0F;
ORIG_S[201]=0xB56F74E8; ORIG_S[202]=0x18ACF3D6; ORIG_S[203]=0xCE89E299;
ORIG_S[204]=0xB4A84FE0; ORIG_S[205]=0xFD13E0B7; ORIG_S[206]=0x7CC43B81;
ORIG_S[207]=0xD2ADA8D9; ORIG_S[208]=0x165FA266; ORIG_S[209]=0x80957705;
ORIG_S[210]=0x93CC7314; ORIG_S[211]=0x211A1477; ORIG_S[212]=0xE6AD2065;
ORIG_S[213]=0x77B5FA86; ORIG_S[214]=0xC75442F5; ORIG_S[215]=0xFB9D35CF;
ORIG_S[216]=0xEBCDAF0C; ORIG_S[217]=0x7B3E89A0; ORIG_S[218]=0xD6411BD3;
ORIG_S[219]=0xAE1E7E49; ORIG_S[220]=0x00250E2D; ORIG_S[221]=0x2071B35E;
ORIG_S[222]=0x226800BB; ORIG_S[223]=0x57B8E0AF; ORIG_S[224]=0x2464369B;
ORIG_S[225]=0xF009B91E; ORIG_S[226]=0x5563911D; ORIG_S[227]=0x59DFA6AA;
ORIG_S[228]=0x78C14389; ORIG_S[229]=0xD95A537F; ORIG_S[230]=0x207D5BA2;
ORIG_S[231]=0x02E5B9C5; ORIG_S[232]=0x83260376; ORIG_S[233]=0x6295CFA9;
ORIG_S[234]=0x11C81968; ORIG_S[235]=0x4E734A41; ORIG_S[236]=0xB3472DCA;
ORIG_S[237]=0x7B14A94A; ORIG_S[238]=0x1B510052; ORIG_S[239]=0x9A532915;
ORIG_S[240]=0xD60F573F; ORIG_S[241]=0xBC9BC6E4; ORIG_S[242]=0x2B60A476;
ORIG_S[243]=0x81E67400; ORIG_S[244]=0x08BA6FB5; ORIG_S[245]=0x571BE91F;
ORIG_S[246]=0xF296EC6B; ORIG_S[247]=0x2A0DD915; ORIG_S[248]=0xB6636521;
ORIG_S[249]=0xE7B9F9B6; ORIG_S[250]=0xFF34052E; ORIG_S[251]=0xC5855664;
ORIG_S[252]=0x53B02D5D; ORIG_S[253]=0xA99F8FA1; ORIG_S[254]=0x08BA4799;
ORIG_S[255]=0x6E85076A; ORIG_S[256]=0x4B7A70E9; ORIG_S[257]=0xB5B32944;
ORIG_S[258]=0xDB75092E; ORIG_S[259]=0xC4192623; ORIG_S[260]=0xAD6EA6B0;
ORIG_S[261]=0x49A7DF7D; ORIG_S[262]=0x9CEE60B8; ORIG_S[263]=0x8FEDB266;
ORIG_S[264]=0xECAA8C71; ORIG_S[265]=0x699A17FF; ORIG_S[266]=0x5664526C;
ORIG_S[267]=0xC2B19EE1; ORIG_S[268]=0x193602A5; ORIG_S[269]=0x75094C29;
ORIG_S[270]=0xA0591340; ORIG_S[271]=0xE4183A3E; ORIG_S[272]=0x3F54989A;
ORIG_S[273]=0x5B429D65; ORIG_S[274]=0x6B8FE4D6; ORIG_S[275]=0x99F73FD6;
ORIG_S[276]=0xA1D29C07; ORIG_S[277]=0xEFE830F5; ORIG_S[278]=0x4D2D38E6;
ORIG_S[279]=0xF0255DC1; ORIG_S[280]=0x4CDD2086; ORIG_S[281]=0x8470EB26;
ORIG_S[282]=0x6382E9C6; ORIG_S[283]=0x021ECC5E; ORIG_S[284]=0x09686B3F;
ORIG_S[285]=0x3EBAEFC9; ORIG_S[286]=0x3C971814; ORIG_S[287]=0x6B6A70A1;
ORIG_S[288]=0x687F3584; ORIG_S[289]=0x52A0E286; ORIG_S[290]=0xB79C5305;
ORIG_S[291]=0xAA500737; ORIG_S[292]=0x3E07841C; ORIG_S[293]=0x7FDEAE5C;
ORIG_S[294]=0x8E7D44EC; ORIG_S[295]=0x5716F2B8; ORIG_S[296]=0xB03ADA37;
ORIG_S[297]=0xF0500C0D; ORIG_S[298]=0xF01C1F04; ORIG_S[299]=0x0200B3FF;
ORIG_S[300]=0xAE0CF51A; ORIG_S[301]=0x3CB574B2; ORIG_S[302]=0x25837A58;
ORIG_S[303]=0xDC0921BD; ORIG_S[304]=0xD19113F9; ORIG_S[305]=0x7CA92FF6;
ORIG_S[306]=0x94324773; ORIG_S[307]=0x22F54701; ORIG_S[308]=0x3AE5E581;
ORIG_S[309]=0x37C2DADC; ORIG_S[310]=0xC8B57634; ORIG_S[311]=0x9AF3DDA7;
ORIG_S[312]=0xA9446146; ORIG_S[313]=0x0FD0030E; ORIG_S[314]=0xECC8C73E;
ORIG_S[315]=0xA4751E41; ORIG_S[316]=0xE238CD99; ORIG_S[317]=0x3BEA0E2F;
ORIG_S[318]=0x3280BBA1; ORIG_S[319]=0x183EB331; ORIG_S[320]=0x4E548B38;
ORIG_S[321]=0x4F6DB908; ORIG_S[322]=0x6F420D03; ORIG_S[323]=0xF60A04BF;
ORIG_S[324]=0x2CB81290; ORIG_S[325]=0x24977C79; ORIG_S[326]=0x5679B072;
ORIG_S[327]=0xBCAF89AF; ORIG_S[328]=0xDE9A771F; ORIG_S[329]=0xD9930810;
ORIG_S[330]=0xB38BAE12; ORIG_S[331]=0xDCCF3F2E; ORIG_S[332]=0x5512721F;
ORIG_S[333]=0x2E6B7124; ORIG_S[334]=0x501ADDE6; ORIG_S[335]=0x9F84CD87;
ORIG_S[336]=0x7A584718; ORIG_S[337]=0x7408DA17; ORIG_S[338]=0xBC9F9ABC;
ORIG_S[339]=0xE94B7D8C; ORIG_S[340]=0xEC7AEC3A; ORIG_S[341]=0xDB851DFA;
ORIG_S[342]=0x63094366; ORIG_S[343]=0xC464C3D2; ORIG_S[344]=0xEF1C1847;
ORIG_S[345]=0x3215D908; ORIG_S[346]=0xDD433B37; ORIG_S[347]=0x24C2BA16;
ORIG_S[348]=0x12A14D43; ORIG_S[349]=0x2A65C451; ORIG_S[350]=0x50940002;
ORIG_S[351]=0x133AE4DD; ORIG_S[352]=0x71DFF89E; ORIG_S[353]=0x10314E55;
ORIG_S[354]=0x81AC77D6; ORIG_S[355]=0x5F11199B; ORIG_S[356]=0x043556F1;
ORIG_S[357]=0xD7A3C76B; ORIG_S[358]=0x3C11183B; ORIG_S[359]=0x5924A509;
ORIG_S[360]=0xF28FE6ED; ORIG_S[361]=0x97F1FBFA; ORIG_S[362]=0x9EBABF2C;
ORIG_S[363]=0x1E153C6E; ORIG_S[364]=0x86E34570; ORIG_S[365]=0xEAE96FB1;
ORIG_S[366]=0x860E5E0A; ORIG_S[367]=0x5A3E2AB3; ORIG_S[368]=0x771FE71C;
ORIG_S[369]=0x4E3D06FA; ORIG_S[370]=0x2965DCB9; ORIG_S[371]=0x99E71D0F;
ORIG_S[372]=0x803E89D6; ORIG_S[373]=0x5266C825; ORIG_S[374]=0x2E4CC978;
ORIG_S[375]=0x9C10B36A; ORIG_S[376]=0xC6150EBA; ORIG_S[377]=0x94E2EA78;
ORIG_S[378]=0xA5FC3C53; ORIG_S[379]=0x1E0A2DF4; ORIG_S[380]=0xF2F74EA7;
ORIG_S[381]=0x361D2B3D; ORIG_S[382]=0x1939260F; ORIG_S[383]=0x19C27960;
ORIG_S[384]=0x5223A708; ORIG_S[385]=0xF71312B6; ORIG_S[386]=0xEBADFE6E;
ORIG_S[387]=0xEAC31F66; ORIG_S[388]=0xE3BC4595; ORIG_S[389]=0xA67BC883;
ORIG_S[390]=0xB17F37D1; ORIG_S[391]=0x018CFF28; ORIG_S[392]=0xC332DDEF;
ORIG_S[393]=0xBE6C5AA5; ORIG_S[394]=0x65582185; ORIG_S[395]=0x68AB9802;
ORIG_S[396]=0xEECEA50F; ORIG_S[397]=0xDB2F953B; ORIG_S[398]=0x2AEF7DAD;
ORIG_S[399]=0x5B6E2F84; ORIG_S[400]=0x1521B628; ORIG_S[401]=0x29076170;
ORIG_S[402]=0xECDD4775; ORIG_S[403]=0x619F1510; ORIG_S[404]=0x13CCA830;
ORIG_S[405]=0xEB61BD96; ORIG_S[406]=0x0334FE1E; ORIG_S[407]=0xAA0363CF;
ORIG_S[408]=0xB5735C90; ORIG_S[409]=0x4C70A239; ORIG_S[410]=0xD59E9E0B;
ORIG_S[411]=0xCBAADE14; ORIG_S[412]=0xEECC86BC; ORIG_S[413]=0x60622CA7;
ORIG_S[414]=0x9CAB5CAB; ORIG_S[415]=0xB2F3846E; ORIG_S[416]=0x648B1EAF;
ORIG_S[417]=0x19BDF0CA; ORIG_S[418]=0xA02369B9; ORIG_S[419]=0x655ABB50;
ORIG_S[420]=0x40685A32; ORIG_S[421]=0x3C2AB4B3; ORIG_S[422]=0x319EE9D5;
ORIG_S[423]=0xC021B8F7; ORIG_S[424]=0x9B540B19; ORIG_S[425]=0x875FA099;
ORIG_S[426]=0x95F7997E; ORIG_S[427]=0x623D7DA8; ORIG_S[428]=0xF837889A;
ORIG_S[429]=0x97E32D77; ORIG_S[430]=0x11ED935F; ORIG_S[431]=0x16681281;
ORIG_S[432]=0x0E358829; ORIG_S[433]=0xC7E61FD6; ORIG_S[434]=0x96DEDFA1;
ORIG_S[435]=0x7858BA99; ORIG_S[436]=0x57F584A5; ORIG_S[437]=0x1B227263;
ORIG_S[438]=0x9B83C3FF; ORIG_S[439]=0x1AC24696; ORIG_S[440]=0xCDB30AEB;
ORIG_S[441]=0x532E3054; ORIG_S[442]=0x8FD948E4; ORIG_S[443]=0x6DBC3128;
ORIG_S[444]=0x58EBF2EF; ORIG_S[445]=0x34C6FFEA; ORIG_S[446]=0xFE28ED61;
ORIG_S[447]=0xEE7C3C73; ORIG_S[448]=0x5D4A14D9; ORIG_S[449]=0xE864B7E3;
ORIG_S[450]=0x42105D14; ORIG_S[451]=0x203E13E0; ORIG_S[452]=0x45EEE2B6;
ORIG_S[453]=0xA3AAABEA; ORIG_S[454]=0xDB6C4F15; ORIG_S[455]=0xFACB4FD0;
ORIG_S[456]=0xC742F442; ORIG_S[457]=0xEF6ABBB5; ORIG_S[458]=0x654F3B1D;
ORIG_S[459]=0x41CD2105; ORIG_S[460]=0xD81E799E; ORIG_S[461]=0x86854DC7;
ORIG_S[462]=0xE44B476A; ORIG_S[463]=0x3D816250; ORIG_S[464]=0xCF62A1F2;
ORIG_S[465]=0x5B8D2646; ORIG_S[466]=0xFC8883A0; ORIG_S[467]=0xC1C7B6A3;
ORIG_S[468]=0x7F1524C3; ORIG_S[469]=0x69CB7492; ORIG_S[470]=0x47848A0B;
ORIG_S[471]=0x5692B285; ORIG_S[472]=0x095BBF00; ORIG_S[473]=0xAD19489D;
ORIG_S[474]=0x1462B174; ORIG_S[475]=0x23820E00; ORIG_S[476]=0x58428D2A;
ORIG_S[477]=0x0C55F5EA; ORIG_S[478]=0x1DADF43E; ORIG_S[479]=0x233F7061;
ORIG_S[480]=0x3372F092; ORIG_S[481]=0x8D937E41; ORIG_S[482]=0xD65FECF1;
ORIG_S[483]=0x6C223BDB; ORIG_S[484]=0x7CDE3759; ORIG_S[485]=0xCBEE7460;
ORIG_S[486]=0x4085F2A7; ORIG_S[487]=0xCE77326E; ORIG_S[488]=0xA6078084;
ORIG_S[489]=0x19F8509E; ORIG_S[490]=0xE8EFD855; ORIG_S[491]=0x61D99735;
ORIG_S[492]=0xA969A7AA; ORIG_S[493]=0xC50C06C2; ORIG_S[494]=0x5A04ABFC;
ORIG_S[495]=0x800BCADC; ORIG_S[496]=0x9E447A2E; ORIG_S[497]=0xC3453484;
ORIG_S[498]=0xFDD56705; ORIG_S[499]=0x0E1E9EC9; ORIG_S[500]=0xDB73DBD3;
ORIG_S[501]=0x105588CD; ORIG_S[502]=0x675FDA79; ORIG_S[503]=0xE3674340;
ORIG_S[504]=0xC5C43465; ORIG_S[505]=0x713E38D8; ORIG_S[506]=0x3D28F89E;
ORIG_S[507]=0xF16DFF20; ORIG_S[508]=0x153E21E7; ORIG_S[509]=0x8FB03D4A;
ORIG_S[510]=0xE6E39F2B; ORIG_S[511]=0xDB83ADF7; ORIG_S[512]=0xE93D5A68;
ORIG_S[513]=0x948140F7; ORIG_S[514]=0xF64C261C; ORIG_S[515]=0x94692934;
ORIG_S[516]=0x411520F7; ORIG_S[517]=0x7602D4F7; ORIG_S[518]=0xBCF46B2E;
ORIG_S[519]=0xD4A20068; ORIG_S[520]=0xD4082471; ORIG_S[521]=0x3320F46A;
ORIG_S[522]=0x43B7D4B7; ORIG_S[523]=0x500061AF; ORIG_S[524]=0x1E39F62E;
ORIG_S[525]=0x97244546; ORIG_S[526]=0x14214F74; ORIG_S[527]=0xBF8B8840;
ORIG_S[528]=0x4D95FC1D; ORIG_S[529]=0x96B591AF; ORIG_S[530]=0x70F4DDD3;
ORIG_S[531]=0x66A02F45; ORIG_S[532]=0xBFBC09EC; ORIG_S[533]=0x03BD9785;
ORIG_S[534]=0x7FAC6DD0; ORIG_S[535]=0x31CB8504; ORIG_S[536]=0x96EB27B3;
ORIG_S[537]=0x55FD3941; ORIG_S[538]=0xDA2547E6; ORIG_S[539]=0xABCA0A9A;
ORIG_S[540]=0x28507825; ORIG_S[541]=0x530429F4; ORIG_S[542]=0x0A2C86DA;
ORIG_S[543]=0xE9B66DFB; ORIG_S[544]=0x68DC1462; ORIG_S[545]=0xD7486900;
ORIG_S[546]=0x680EC0A4; ORIG_S[547]=0x27A18DEE; ORIG_S[548]=0x4F3FFEA2;
ORIG_S[549]=0xE887AD8C; ORIG_S[550]=0xB58CE006; ORIG_S[551]=0x7AF4D6B6;
ORIG_S[552]=0xAACE1E7C; ORIG_S[553]=0xD3375FEC; ORIG_S[554]=0xCE78A399;
ORIG_S[555]=0x406B2A42; ORIG_S[556]=0x20FE9E35; ORIG_S[557]=0xD9F385B9;
ORIG_S[558]=0xEE39D7AB; ORIG_S[559]=0x3B124E8B; ORIG_S[560]=0x1DC9FAF7;
ORIG_S[561]=0x4B6D1856; ORIG_S[562]=0x26A36631; ORIG_S[563]=0xEAE397B2;
ORIG_S[564]=0x3A6EFA74; ORIG_S[565]=0xDD5B4332; ORIG_S[566]=0x6841E7F7;
ORIG_S[567]=0xCA7820FB; ORIG_S[568]=0xFB0AF54E; ORIG_S[569]=0xD8FEB397;
ORIG_S[570]=0x454056AC; ORIG_S[571]=0xBA489527; ORIG_S[572]=0x55533A3A;
ORIG_S[573]=0x20838D87; ORIG_S[574]=0xFE6BA9B7; ORIG_S[575]=0xD096954B;
ORIG_S[576]=0x55A867BC; ORIG_S[577]=0xA1159A58; ORIG_S[578]=0xCCA92963;
ORIG_S[579]=0x99E1DB33; ORIG_S[580]=0xA62A4A56; ORIG_S[581]=0x3F3125F9;
ORIG_S[582]=0x5EF47E1C; ORIG_S[583]=0x9029317C; ORIG_S[584]=0xFDF8E802;
ORIG_S[585]=0x04272F70; ORIG_S[586]=0x80BB155C; ORIG_S[587]=0x05282CE3;
ORIG_S[588]=0x95C11548; ORIG_S[589]=0xE4C66D22; ORIG_S[590]=0x48C1133F;
ORIG_S[591]=0xC70F86DC; ORIG_S[592]=0x07F9C9EE; ORIG_S[593]=0x41041F0F;
ORIG_S[594]=0x404779A4; ORIG_S[595]=0x5D886E17; ORIG_S[596]=0x325F51EB;
ORIG_S[597]=0xD59BC0D1; ORIG_S[598]=0xF2BCC18F; ORIG_S[599]=0x41113564;
ORIG_S[600]=0x257B7834; ORIG_S[601]=0x602A9C60; ORIG_S[602]=0xDFF8E8A3;
ORIG_S[603]=0x1F636C1B; ORIG_S[604]=0x0E12B4C2; ORIG_S[605]=0x02E1329E;
ORIG_S[606]=0xAF664FD1; ORIG_S[607]=0xCAD18115; ORIG_S[608]=0x6B2395E0;
ORIG_S[609]=0x333E92E1; ORIG_S[610]=0x3B240B62; ORIG_S[611]=0xEEBEB922;
ORIG_S[612]=0x85B2A20E; ORIG_S[613]=0xE6BA0D99; ORIG_S[614]=0xDE720C8C;
ORIG_S[615]=0x2DA2F728; ORIG_S[616]=0xD0127845; ORIG_S[617]=0x95B794FD;
ORIG_S[618]=0x647D0862; ORIG_S[619]=0xE7CCF5F0; ORIG_S[620]=0x5449A36F;
ORIG_S[621]=0x877D48FA; ORIG_S[622]=0xC39DFD27; ORIG_S[623]=0xF33E8D1E;
ORIG_S[624]=0x0A476341; ORIG_S[625]=0x992EFF74; ORIG_S[626]=0x3A6F6EAB;
ORIG_S[627]=0xF4F8FD37; ORIG_S[628]=0xA812DC60; ORIG_S[629]=0xA1EBDDF8;
ORIG_S[630]=0x991BE14C; ORIG_S[631]=0xDB6E6B0D; ORIG_S[632]=0xC67B5510;
ORIG_S[633]=0x6D672C37; ORIG_S[634]=0x2765D43B; ORIG_S[635]=0xDCD0E804;
ORIG_S[636]=0xF1290DC7; ORIG_S[637]=0xCC00FFA3; ORIG_S[638]=0xB5390F92;
ORIG_S[639]=0x690FED0B; ORIG_S[640]=0x667B9FFB; ORIG_S[641]=0xCEDB7D9C;
ORIG_S[642]=0xA091CF0B; ORIG_S[643]=0xD9155EA3; ORIG_S[644]=0xBB132F88;
ORIG_S[645]=0x515BAD24; ORIG_S[646]=0x7B9479BF; ORIG_S[647]=0x763BD6EB;
ORIG_S[648]=0x37392EB3; ORIG_S[649]=0xCC115979; ORIG_S[650]=0x8026E297;
ORIG_S[651]=0xF42E312D; ORIG_S[652]=0x6842ADA7; ORIG_S[653]=0xC66A2B3B;
ORIG_S[654]=0x12754CCC; ORIG_S[655]=0x782EF11C; ORIG_S[656]=0x6A124237;
ORIG_S[657]=0xB79251E7; ORIG_S[658]=0x06A1BBE6; ORIG_S[659]=0x4BFB6350;
ORIG_S[660]=0x1A6B1018; ORIG_S[661]=0x11CAEDFA; ORIG_S[662]=0x3D25BDD8;
ORIG_S[663]=0xE2E1C3C9; ORIG_S[664]=0x44421659; ORIG_S[665]=0x0A121386;
ORIG_S[666]=0xD90CEC6E; ORIG_S[667]=0xD5ABEA2A; ORIG_S[668]=0x64AF674E;
ORIG_S[669]=0xDA86A85F; ORIG_S[670]=0xBEBFE988; ORIG_S[671]=0x64E4C3FE;
ORIG_S[672]=0x9DBC8057; ORIG_S[673]=0xF0F7C086; ORIG_S[674]=0x60787BF8;
ORIG_S[675]=0x6003604D; ORIG_S[676]=0xD1FD8346; ORIG_S[677]=0xF6381FB0;
ORIG_S[678]=0x7745AE04; ORIG_S[679]=0xD736FCCC; ORIG_S[680]=0x83426B33;
ORIG_S[681]=0xF01EAB71; ORIG_S[682]=0xB0804187; ORIG_S[683]=0x3C005E5F;
ORIG_S[684]=0x77A057BE; ORIG_S[685]=0xBDE8AE24; ORIG_S[686]=0x55464299;
ORIG_S[687]=0xBF582E61; ORIG_S[688]=0x4E58F48F; ORIG_S[689]=0xF2DDFDA2;
ORIG_S[690]=0xF474EF38; ORIG_S[691]=0x8789BDC2; ORIG_S[692]=0x5366F9C3;
ORIG_S[693]=0xC8B38E74; ORIG_S[694]=0xB475F255; ORIG_S[695]=0x46FCD9B9;
ORIG_S[696]=0x7AEB2661; ORIG_S[697]=0x8B1DDF84; ORIG_S[698]=0x846A0E79;
ORIG_S[699]=0x915F95E2; ORIG_S[700]=0x466E598E; ORIG_S[701]=0x20B45770;
ORIG_S[702]=0x8CD55591; ORIG_S[703]=0xC902DE4C; ORIG_S[704]=0xB90BACE1;
ORIG_S[705]=0xBB8205D0; ORIG_S[706]=0x11A86248; ORIG_S[707]=0x7574A99E;
ORIG_S[708]=0xB77F19B6; ORIG_S[709]=0xE0A9DC09; ORIG_S[710]=0x662D09A1;
ORIG_S[711]=0xC4324633; ORIG_S[712]=0xE85A1F02; ORIG_S[713]=0x09F0BE8C;
ORIG_S[714]=0x4A99A025; ORIG_S[715]=0x1D6EFE10; ORIG_S[716]=0x1AB93D1D;
ORIG_S[717]=0x0BA5A4DF; ORIG_S[718]=0xA186F20F; ORIG_S[719]=0x2868F169;
ORIG_S[720]=0xDCB7DA83; ORIG_S[721]=0x573906FE; ORIG_S[722]=0xA1E2CE9B;
ORIG_S[723]=0x4FCD7F52; ORIG_S[724]=0x50115E01; ORIG_S[725]=0xA70683FA;
ORIG_S[726]=0xA002B5C4; ORIG_S[727]=0x0DE6D027; ORIG_S[728]=0x9AF88C27;
ORIG_S[729]=0x773F8641; ORIG_S[730]=0xC3604C06; ORIG_S[731]=0x61A806B5;
ORIG_S[732]=0xF0177A28; ORIG_S[733]=0xC0F586E0; ORIG_S[734]=0x006058AA;
ORIG_S[735]=0x30DC7D62; ORIG_S[736]=0x11E69ED7; ORIG_S[737]=0x2338EA63;
ORIG_S[738]=0x53C2DD94; ORIG_S[739]=0xC2C21634; ORIG_S[740]=0xBBCBEE56;
ORIG_S[741]=0x90BCB6DE; ORIG_S[742]=0xEBFC7DA1; ORIG_S[743]=0xCE591D76;
ORIG_S[744]=0x6F05E409; ORIG_S[745]=0x4B7C0188; ORIG_S[746]=0x39720A3D;
ORIG_S[747]=0x7C927C24; ORIG_S[748]=0x86E3725F; ORIG_S[749]=0x724D9DB9;
ORIG_S[750]=0x1AC15BB4; ORIG_S[751]=0xD39EB8FC; ORIG_S[752]=0xED545578;
ORIG_S[753]=0x08FCA5B5; ORIG_S[754]=0xD83D7CD3; ORIG_S[755]=0x4DAD0FC4;
ORIG_S[756]=0x1E50EF5E; ORIG_S[757]=0xB161E6F8; ORIG_S[758]=0xA28514D9;
ORIG_S[759]=0x6C51133C; ORIG_S[760]=0x6FD5C7E7; ORIG_S[761]=0x56E14EC4;
ORIG_S[762]=0x362ABFCE; ORIG_S[763]=0xDDC6C837; ORIG_S[764]=0xD79A3234;
ORIG_S[765]=0x92638212; ORIG_S[766]=0x670EFA8E; ORIG_S[767]=0x406000E0;
ORIG_S[768]=0x3A39CE37; ORIG_S[769]=0xD3FAF5CF; ORIG_S[770]=0xABC27737;
ORIG_S[771]=0x5AC52D1B; ORIG_S[772]=0x5CB0679E; ORIG_S[773]=0x4FA33742;
ORIG_S[774]=0xD3822740; ORIG_S[775]=0x99BC9BBE; ORIG_S[776]=0xD5118E9D;
ORIG_S[777]=0xBF0F7315; ORIG_S[778]=0xD62D1C7E; ORIG_S[779]=0xC700C47B;
ORIG_S[780]=0xB78C1B6B; ORIG_S[781]=0x21A19045; ORIG_S[782]=0xB26EB1BE;
ORIG_S[783]=0x6A366EB4; ORIG_S[784]=0x5748AB2F; ORIG_S[785]=0xBC946E79;
ORIG_S[786]=0xC6A376D2; ORIG_S[787]=0x6549C2C8; ORIG_S[788]=0x530FF8EE;
ORIG_S[789]=0x468DDE7D; ORIG_S[790]=0xD5730A1D; ORIG_S[791]=0x4CD04DC6;
ORIG_S[792]=0x2939BBDB; ORIG_S[793]=0xA9BA4650; ORIG_S[794]=0xAC9526E8;
ORIG_S[795]=0xBE5EE304; ORIG_S[796]=0xA1FAD5F0; ORIG_S[797]=0x6A2D519A;
ORIG_S[798]=0x63EF8CE2; ORIG_S[799]=0x9A86EE22; ORIG_S[800]=0xC089C2B8;
ORIG_S[801]=0x43242EF6; ORIG_S[802]=0xA51E03AA; ORIG_S[803]=0x9CF2D0A4;
ORIG_S[804]=0x83C061BA; ORIG_S[805]=0x9BE96A4D; ORIG_S[806]=0x8FE51550;
ORIG_S[807]=0xBA645BD6; ORIG_S[808]=0x2826A2F9; ORIG_S[809]=0xA73A3AE1;
ORIG_S[810]=0x4BA99586; ORIG_S[811]=0xEF5562E9; ORIG_S[812]=0xC72FEFD3;
ORIG_S[813]=0xF752F7DA; ORIG_S[814]=0x3F046F69; ORIG_S[815]=0x77FA0A59;
ORIG_S[816]=0x80E4A915; ORIG_S[817]=0x87B08601; ORIG_S[818]=0x9B09E6AD;
ORIG_S[819]=0x3B3EE593; ORIG_S[820]=0xE990FD5A; ORIG_S[821]=0x9E34D797;
ORIG_S[822]=0x2CF0B7D9; ORIG_S[823]=0x022B8B51; ORIG_S[824]=0x96D5AC3A;
ORIG_S[825]=0x017DA67D; ORIG_S[826]=0xD1CF3ED6; ORIG_S[827]=0x7C7D2D28;
ORIG_S[828]=0x1F9F25CF; ORIG_S[829]=0xADF2B89B; ORIG_S[830]=0x5AD6B472;
ORIG_S[831]=0x5A88F54C; ORIG_S[832]=0xE029AC71; ORIG_S[833]=0xE019A5E6;
ORIG_S[834]=0x47B0ACFD; ORIG_S[835]=0xED93FA9B; ORIG_S[836]=0xE8D3C48D;
ORIG_S[837]=0x283B57CC; ORIG_S[838]=0xF8D56629; ORIG_S[839]=0x79132E28;
ORIG_S[840]=0x785F0191; ORIG_S[841]=0xED756055; ORIG_S[842]=0xF7960E44;
ORIG_S[843]=0xE3D35E8C; ORIG_S[844]=0x15056DD4; ORIG_S[845]=0x88F46DBA;
ORIG_S[846]=0x03A16125; ORIG_S[847]=0x0564F0BD; ORIG_S[848]=0xC3EB9E15;
ORIG_S[849]=0x3C9057A2; ORIG_S[850]=0x97271AEC; ORIG_S[851]=0xA93A072A;
ORIG_S[852]=0x1B3F6D9B; ORIG_S[853]=0x1E6321F5; ORIG_S[854]=0xF59C66FB;
ORIG_S[855]=0x26DCF319; ORIG_S[856]=0x7533D928; ORIG_S[857]=0xB155FDF5;
ORIG_S[858]=0x03563482; ORIG_S[859]=0x8ABA3CBB; ORIG_S[860]=0x28517711;
ORIG_S[861]=0xC20AD9F8; ORIG_S[862]=0xABCC5167; ORIG_S[863]=0xCCAD925F;
ORIG_S[864]=0x4DE81751; ORIG_S[865]=0x3830DC8E; ORIG_S[866]=0x379D5862;
ORIG_S[867]=0x9320F991; ORIG_S[868]=0xEA7A90C2; ORIG_S[869]=0xFB3E7BCE;
ORIG_S[870]=0x5121CE64; ORIG_S[871]=0x774FBE32; ORIG_S[872]=0xA8B6E37E;
ORIG_S[873]=0xC3293D46; ORIG_S[874]=0x48DE5369; ORIG_S[875]=0x6413E680;
ORIG_S[876]=0xA2AE0810; ORIG_S[877]=0xDD6DB224; ORIG_S[878]=0x69852DFD;
ORIG_S[879]=0x09072166; ORIG_S[880]=0xB39A460A; ORIG_S[881]=0x6445C0DD;
ORIG_S[882]=0x586CDECF; ORIG_S[883]=0x1C20C8AE; ORIG_S[884]=0x5BBEF7DD;
ORIG_S[885]=0x1B588D40; ORIG_S[886]=0xCCD2017F; ORIG_S[887]=0x6BB4E3BB;
ORIG_S[888]=0xDDA26A7E; ORIG_S[889]=0x3A59FF45; ORIG_S[890]=0x3E350A44;
ORIG_S[891]=0xBCB4CDD5; ORIG_S[892]=0x72EACEA8; ORIG_S[893]=0xFA6484BB;
ORIG_S[894]=0x8D6612AE; ORIG_S[895]=0xBF3C6F47; ORIG_S[896]=0xD29BE463;
ORIG_S[897]=0x542F5D9E; ORIG_S[898]=0xAEC2771B; ORIG_S[899]=0xF64E6370;
ORIG_S[900]=0x740E0D8D; ORIG_S[901]=0xE75B1357; ORIG_S[902]=0xF8721671;
ORIG_S[903]=0xAF537D5D; ORIG_S[904]=0x4040CB08; ORIG_S[905]=0x4EB4E2CC;
ORIG_S[906]=0x34D2466A; ORIG_S[907]=0x0115AF84; ORIG_S[908]=0xE1B00428;
ORIG_S[909]=0x95983A1D; ORIG_S[910]=0x06B89FB4; ORIG_S[911]=0xCE6EA048;
ORIG_S[912]=0x6F3F3B82; ORIG_S[913]=0x3520AB82; ORIG_S[914]=0x011A1D4B;
ORIG_S[915]=0x277227F8; ORIG_S[916]=0x611560B1; ORIG_S[917]=0xE7933FDC;
ORIG_S[918]=0xBB3A792B; ORIG_S[919]=0x344525BD; ORIG_S[920]=0xA08839E1;
ORIG_S[921]=0x51CE794B; ORIG_S[922]=0x2F32C9B7; ORIG_S[923]=0xA01FBAC9;
ORIG_S[924]=0xE01CC87E; ORIG_S[925]=0xBCC7D1F6; ORIG_S[926]=0xCF0111C3;
ORIG_S[927]=0xA1E8AAC7; ORIG_S[928]=0x1A908749; ORIG_S[929]=0xD44FBD9A;
ORIG_S[930]=0xD0DADECB; ORIG_S[931]=0xD50ADA38; ORIG_S[932]=0x0339C32A;
ORIG_S[933]=0xC6913667; ORIG_S[934]=0x8DF9317C; ORIG_S[935]=0xE0B12B4F;
ORIG_S[936]=0xF79E59B7; ORIG_S[937]=0x43F5BB3A; ORIG_S[938]=0xF2D519FF;
ORIG_S[939]=0x27D9459C; ORIG_S[940]=0xBF97222C; ORIG_S[941]=0x15E6FC2A;
ORIG_S[942]=0x0F91FC71; ORIG_S[943]=0x9B941525; ORIG_S[944]=0xFAE59361;
ORIG_S[945]=0xCEB69CEB; ORIG_S[946]=0xC2A86459; ORIG_S[947]=0x12BAA8D1;
ORIG_S[948]=0xB6C1075E; ORIG_S[949]=0xE3056A0C; ORIG_S[950]=0x10D25065;
ORIG_S[951]=0xCB03A442; ORIG_S[952]=0xE0EC6E0E; ORIG_S[953]=0x1698DB3B;
ORIG_S[954]=0x4C98A0BE; ORIG_S[955]=0x3278E964; ORIG_S[956]=0x9F1F9532;
ORIG_S[957]=0xE0D392DF; ORIG_S[958]=0xD3A0342B; ORIG_S[959]=0x8971F21E;
ORIG_S[960]=0x1B0A7441; ORIG_S[961]=0x4BA3348C; ORIG_S[962]=0xC5BE7120;
ORIG_S[963]=0xC37632D8; ORIG_S[964]=0xDF359F8D; ORIG_S[965]=0x9B992F2E;
ORIG_S[966]=0xE60B6F47; ORIG_S[967]=0x0FE3F11D; ORIG_S[968]=0xE54CDA54;
ORIG_S[969]=0x1EDAD891; ORIG_S[970]=0xCE6279CF; ORIG_S[971]=0xCD3E7E6F;
ORIG_S[972]=0x1618B166; ORIG_S[973]=0xFD2C1D05; ORIG_S[974]=0x848FD2C5;
ORIG_S[975]=0xF6FB2299; ORIG_S[976]=0xF523F357; ORIG_S[977]=0xA6327623;
ORIG_S[978]=0x93A83531; ORIG_S[979]=0x56CCCD02; ORIG_S[980]=0xACF08162;
ORIG_S[981]=0x5A75EBB5; ORIG_S[982]=0x6E163697; ORIG_S[983]=0x88D273CC;
ORIG_S[984]=0xDE966292; ORIG_S[985]=0x81B949D0; ORIG_S[986]=0x4C50901B;
ORIG_S[987]=0x71C65614; ORIG_S[988]=0xE6C6C7BD; ORIG_S[989]=0x327A140A;
ORIG_S[990]=0x45E1D006; ORIG_S[991]=0xC3F27B9A; ORIG_S[992]=0xC9AA53FD;
ORIG_S[993]=0x62A80F00; ORIG_S[994]=0xBB25BFE2; ORIG_S[995]=0x35BDD2F6;
ORIG_S[996]=0x71126905; ORIG_S[997]=0xB2040222; ORIG_S[998]=0xB6CBCF7C;
ORIG_S[999]=0xCD769C2B; ORIG_S[1000]=0x53113EC0; ORIG_S[1001]=0x1640E3D3;
ORIG_S[1002]=0x38ABBD60; ORIG_S[1003]=0x2547ADF0; ORIG_S[1004]=0xBA38209C;
ORIG_S[1005]=0xF746CE76; ORIG_S[1006]=0x77AFA1C5; ORIG_S[1007]=0x20756060;
ORIG_S[1008]=0x85CBFE4E; ORIG_S[1009]=0x8AE88DD8; ORIG_S[1010]=0x7AAAF9B0;
ORIG_S[1011]=0x4CF9AA7E; ORIG_S[1012]=0x1948C25C; ORIG_S[1013]=0x02FB8A8C;
ORIG_S[1014]=0x01C36AE4; ORIG_S[1015]=0xD6EBE1F9; ORIG_S[1016]=0x90D4F869;
ORIG_S[1017]=0xA65CDEA0; ORIG_S[1018]=0x3F09252D; ORIG_S[1019]=0xC208E69F;
ORIG_S[1020]=0xB74E6132; ORIG_S[1021]=0xCE77E25B; ORIG_S[1022]=0x578FDFE3;
ORIG_S[1023]=0x3AC372E6;
}
function int_encrypt(P,S,D, xl,xr,i,S0a,S1b,S2c,S3d,temp) {
xl=D[0];
xr=D[1];
for (i=0; i<16; i++) {
xl = xor(xl,P[i]);
S0a = S[and(rshift(xl,24),0xff)];
S1b = S[and(rshift(xl,16),0xff)+256];
S2c = S[and(rshift(xl,8),0xff)+512];
S3d = S[and(xl,0xff)+768];
xr = xor(and(xor((S0a + S1b),S2c)+S3d,0xffffffff),xr);
temp=xl; xl=xr; xr=temp;
}
temp=xl; xl=xr; xr=temp;
D[0]=xor(xl,P[17]);
D[1]=xor(xr,P[16]);
}
function int_decrypt(P,S,D, xl,xr,i,S0a,S1b,S2c,S3d,temp) {
xl=D[0];
xr=D[1];
for (i=17; i>1; i--) {
xl = xor(xl,P[i]);
S0a = S[and(rshift(xl,24),0xff)];
S1b = S[and(rshift(xl,16),0xff)+256];
S2c = S[and(rshift(xl,8),0xff)+512];
S3d = S[and(xl,0xff)+768];
xr = xor(and(xor((S0a + S1b),S2c)+S3d,0xffffffff),xr);
temp=xl; xl=xr; xr=temp;
}
temp=xl; xl=xr; xr=temp;
D[0]=xor(xl,P[0]);
D[1]=xor(xr,P[1]);
}
function copy_array(f,t) {
for (i in f) {
t[i] = f[i];
}
}
function init(key,P,S, kc,kl,i,j,data,k,pidx,D,t) {
copy_array(ORIG_S,S);
kl=length(key);
split(key,kc,"");
j=0;
pidx=0;
for (i=0; i < 18; i++) {
data=0;
for (k=0; k < 4; k++) {
data=and(or(lshift(data,8), and(kc[j+1],0xff)),0xffffffff);
if (++j >= kl) {
j=0;
}
}
P[pidx++] = xor(ORIG_P[i],data);
}
D[0] = 0;
D[1] = 0;
for (i=0; i < 18; i+=2) {
int_encrypt(P,S,D);
P[i]=D[0];
P[i+1]=D[1];
}
for (i=0; i < 4; i++) {
for (j=0; j < 256; j+=2) {
int_encrypt(P,S,D);
t=(i*256)+j;
S[t]=D[0];
S[t+1]=D[1];
}
}
}
BEGIN {
init(PASSWORD,CTX_P,CTX_S);
}
NF == 1 {
print $1
}
NF == 2 {
#data[0]=strtonum($1);
#data[1]=strtonum($2);
if (ENCRYPT) {
data[0]=xor(strtonum($1),data[0]);
data[1]=xor(strtonum($2),data[1]);
int_encrypt(CTX_P,CTX_S,data);
} else {
data[0]=strtonum($1);
data[1]=strtonum($2);
int_decrypt(CTX_P,CTX_S,data);
data[0]=xor(data[0],old_l);
data[1]=xor(data[1],old_r);
old_l = strtonum($1);
old_r = strtonum($2);
}
printf("0x%08x 0x%08x\n", data[0], data[1]);
}'
}
##########################################################################
# Main Invocation
##########################################################################
if [ $ENCRYPT = 1 ]; then
to_lr | blowfish $ENCRYPT $PASSWORD
else
blowfish $ENCRYPT $PASSWORD | from_lr
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment