32#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
37static int decrypt_byte(
unsigned long* pkeys,
const unsigned long* pcrc_32_tab)
43 temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
44 return (
int)(((temp * (temp ^ 1)) >> 8) & 0xff);
50static int update_keys(
unsigned long* pkeys,
const unsigned long* pcrc_32_tab,
int c)
52 (*(pkeys+0)) =
CRC32((*(pkeys+0)), c);
53 (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
54 (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
56 int keyshift = (int)((*(pkeys+1)) >> 24);
57 (*(pkeys+2)) =
CRC32((*(pkeys+2)), keyshift);
67static void init_keys(
const char* passwd,
unsigned long* pkeys,
const unsigned long* pcrc_32_tab)
69 *(pkeys+0) = 305419896L;
70 *(pkeys+1) = 591751049L;
71 *(pkeys+2) = 878082192L;
72 while (*passwd !=
'\0') {
78#define zdecode(pkeys,pcrc_32_tab,c) \
79 (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
81#define zencode(pkeys,pcrc_32_tab,c,t) \
82 (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
84#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
86#define RAND_HEAD_LEN 12
89# define ZCR_SEED2 3141592654UL
92static int crypthead(
const char* passwd,
96 const unsigned long* pcrc_32_tab,
97 unsigned long crcForCrypting)
102 unsigned char header[RAND_HEAD_LEN-2];
103 static unsigned calls = 0;
105 if (bufSize<RAND_HEAD_LEN)
114 srand((
unsigned)(time(NULL) ^ ZCR_SEED2));
117 for (n = 0; n < RAND_HEAD_LEN-2; n++)
119 c = (rand() >> 7) & 0xff;
120 header[n] = (
unsigned char)
zencode(pkeys, pcrc_32_tab, c, t);
124 for (n = 0; n < RAND_HEAD_LEN-2; n++)
126 buf[n] = (
unsigned char)
zencode(pkeys, pcrc_32_tab, header[n], t);
128 buf[n++] = (
unsigned char)
zencode(pkeys, pcrc_32_tab, (
int)(crcForCrypting >> 16) & 0xff, t);
129 buf[n++] = (
unsigned char)
zencode(pkeys, pcrc_32_tab, (
int)(crcForCrypting >> 24) & 0xff, t);
static int update_keys(unsigned long *pkeys, const unsigned long *pcrc_32_tab, int c)
static int decrypt_byte(unsigned long *pkeys, const unsigned long *pcrc_32_tab)
static void init_keys(const char *passwd, unsigned long *pkeys, const unsigned long *pcrc_32_tab)
#define zencode(pkeys, pcrc_32_tab, c, t)