📄 ltable_generation.cpp
字号:
/* The header for LTable_Generation is the same as for
3 DataKey_Generation (see Exhibit 2-46).*/
#define LTable_Generation_SOURCE_FILE
#include "cavei.h" /* see Exhibit 2-3 */
#include "oryx.h" /* see Exhibit 2-45 */
#define high(x) (unsigned char)(0xffU&(x>>24)) /* leftmost octet */
#define FA1 000460216667 /* Peterson & Weldon prim 32 */
#define FA2 001760427607 /* Peterson & Weldon prim 32 */
#define FB 020014300113 /* P&W prim 31 020004100071 times z+1 */
#define FK 030634530010 /* reverse of P&W prim 32 04200324714328 */
static
unsigned long K; /* 32-bit K register */
static
unsigned long A, B; /* 32-bit LFSRs */
unsigned char L[256]; /* look up table */
unsigned long DataKey; /* data encryption key */
static
void kstep(void);
static
unsigned char keygen(void);
void LTable_Generation(const unsigned char RAND[4])
{
int i,j;
unsigned char tempc;
K = 0;
K = (K<<8) + (unsigned long)RAND[i];
for (i=0; i<256; i++)
L[i] = (unsigned char)i;
/* use high octet of K to permute 0 through 255 */
for (i=0; i< 256; i++)
{
kstep();
tempc = L[i];
L[i] = L[j];
L[j] = tempc;
}
}
static
void kstep(void)
{
if(K==0) K = 0x31415926;
if(K&1)
{
K = (K>>1) ^ FK;
}
else
{
K = (K>>1);
}
K &= 0xffffffff;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -