K L Decryption Routines in C: EE OQ
K L Decryption Routines in C: EE OQ
NLF
XOR
bit 7
7 6 5 4 3 2 1 0
MSB Key Register LSB
{
dword lut[32] =
{ 0,1,1,1, 0,1,0,0, 0,0,1,0, 1,1,1,0, 0,0,1,1, 1,0,1,0, 0,1,0,1, 1,1,0,0 };
/* E 2 4 7 C 5 A 3 */
dword pik,pin,bitin,keybit,keybit2;
word bitlu;
int ix;
// Load Key
pik = mpik;
pin = mpin;
bitin = getbit(csr,31);
csr<<=1;
keybit2=getbit(pin,15);
keybit=getbit(pik,31);
pik=(pik<<1)|getbit(pin,31);
pin=(pin<<1)|keybit; /* 64-bit left rotate */
bitlu = 0;
ifbit (csr, 1) setbit(bitlu,0);
ifbit (csr, 9) setbit(bitlu,1);
ifbit (csr,20) setbit(bitlu,2);
ifbit (csr,26) setbit(bitlu,3);
ifbit (csr,31) setbit(bitlu,4);
void Decrypt()
{
unsigned int i, j, key, aux; // 8bit variables
signed int p; // 7bit +sign
p = 1;
// shift in buffer
SHIFT_LEFT( Buffer, 4, BIT_TEST( aux,7));
key<<=1;
} // for j
} // decrypt
void Decrypt()
{
unsigned char i, j, key; // 8 bit unsigned
signed char p; // 8 bit signed
p = 1;
// shift in buffer
// rotate Dkey
key<<=1;
} // for i
} // for j
} // decrypt
01/30/01
All rights reserved. © 2001 Microchip Technology Incorporated. Printed in the USA. 3/01 Printed on recycled paper.
Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by
updates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is
assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual
property rights arising from such use or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with
express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, except as maybe explicitly expressed herein, under any intellec-
tual property rights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights
reserved. All other trademarks mentioned herein are the property of their respective companies.