Rizin
unix-like reverse engineering framework and cli tools
crypt.h File Reference

Go to the source code of this file.

Macros

#define CRC32(c, b)   ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
 
#define zdecode(pkeys, pcrc_32_tab, c)    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
 
#define zencode(pkeys, pcrc_32_tab, c, t)    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
 

Functions

static int decrypt_byte (unsigned long *pkeys, const z_crc_t *pcrc_32_tab)
 
static int update_keys (unsigned long *pkeys, const z_crc_t *pcrc_32_tab, int c)
 
static void init_keys (const char *passwd, unsigned long *pkeys, const z_crc_t *pcrc_32_tab)
 

Macro Definition Documentation

◆ CRC32

#define CRC32 (   c,
  b 
)    ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))

Definition at line 30 of file crypt.h.

◆ zdecode

#define zdecode (   pkeys,
  pcrc_32_tab,
  c 
)     (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))

Definition at line 77 of file crypt.h.

◆ zencode

#define zencode (   pkeys,
  pcrc_32_tab,
  c,
 
)     (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))

Definition at line 80 of file crypt.h.

Function Documentation

◆ decrypt_byte()

static int decrypt_byte ( unsigned long pkeys,
const z_crc_t pcrc_32_tab 
)
static

Definition at line 35 of file crypt.h.

36 {
37  unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
38  * unpredictable manner on 16-bit systems; not a problem
39  * with any known compiler so far, though */
40 
41  (void)pcrc_32_tab;
42  temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
43  return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
44 }
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
Definition: sflib.h:97

References unsigned.

◆ init_keys()

static void init_keys ( const char *  passwd,
unsigned long pkeys,
const z_crc_t pcrc_32_tab 
)
static

Definition at line 66 of file crypt.h.

67 {
68  *(pkeys+0) = 305419896L;
69  *(pkeys+1) = 591751049L;
70  *(pkeys+2) = 878082192L;
71  while (*passwd != '\0') {
72  update_keys(pkeys,pcrc_32_tab,(int)*passwd);
73  passwd++;
74  }
75 }
static int update_keys(unsigned long *pkeys, const z_crc_t *pcrc_32_tab, int c)
Definition: crypt.h:49

References update_keys().

Referenced by unzOpenCurrentFile3().

◆ update_keys()

static int update_keys ( unsigned long pkeys,
const z_crc_t pcrc_32_tab,
int  c 
)
static

Definition at line 49 of file crypt.h.

50 {
51  (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
52  (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
53  (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
54  {
55  register int keyshift = (int)((*(pkeys+1)) >> 24);
56  (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
57  }
58  return c;
59 }
#define CRC32(c, b)
Definition: crypt.h:30
static int
Definition: sfsocketcall.h:114
#define c(i)
Definition: sha256.c:43

References c, CRC32, and int.

Referenced by init_keys().