32 #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
44 temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
45 return (
int)(((temp * (temp ^ 1)) >> 8) & 0xff);
53 (*(pkeys+0)) =
CRC32((*(pkeys+0)), c);
54 (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
55 (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
57 register int keyshift = (int)((*(pkeys+1)) >> 24);
58 (*(pkeys+2)) =
CRC32((*(pkeys+2)), keyshift);
68 static void init_keys(
const char* passwd,
unsigned long* pkeys,
const z_crc_t FAR * pcrc_32_tab)
70 *(pkeys+0) = 305419896L;
71 *(pkeys+1) = 591751049L;
72 *(pkeys+2) = 878082192L;
73 while (*passwd !=
'\0') {
79 #define zdecode(pkeys,pcrc_32_tab,c) \
80 (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
82 #define zencode(pkeys,pcrc_32_tab,c,t) \
83 (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
85 #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
87 #define RAND_HEAD_LEN 12
90 # define ZCR_SEED2 3141592654UL
93 static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
98 const
z_crc_t FAR * pcrc_32_tab;
99 unsigned long crcForCrypting;
104 unsigned char header[RAND_HEAD_LEN-2];
105 static unsigned calls = 0;
107 if (bufSize<RAND_HEAD_LEN)
116 srand((
unsigned)(time(NULL) ^ ZCR_SEED2));
119 for (n = 0; n < RAND_HEAD_LEN-2; n++)
121 c = (rand() >> 7) & 0xff;
122 header[n] = (
unsigned char)
zencode(pkeys, pcrc_32_tab, c, t);
126 for (n = 0; n < RAND_HEAD_LEN-2; n++)
128 buf[n] = (
unsigned char)
zencode(pkeys, pcrc_32_tab, header[n], t);
130 buf[n++] =
zencode(pkeys, pcrc_32_tab, (
int)(crcForCrypting >> 16) & 0xff, t);
131 buf[n++] =
zencode(pkeys, pcrc_32_tab, (
int)(crcForCrypting >> 24) & 0xff, t);
static int decrypt_byte(unsigned long *pkeys, const z_crc_t FAR *pcrc_32_tab)
static void init_keys(const char *passwd, unsigned long *pkeys, const z_crc_t FAR *pcrc_32_tab)
static int update_keys(unsigned long *pkeys, const z_crc_t FAR *pcrc_32_tab, int c)
#define zencode(pkeys, pcrc_32_tab, c, t)