ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
crypt.h File Reference
#include "quazip_global.h"
+ Include dependency graph for crypt.h:
+ This graph shows which files directly or indirectly include this file:

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), t^(c))
 

Functions

static int decrypt_byte (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)
 
static void init_keys (const char *passwd, unsigned long *pkeys, const z_crc_t FAR *pcrc_32_tab)
 

Macro Definition Documentation

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

Definition at line 32 of file crypt.h.

Referenced by update_keys().

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

Definition at line 79 of file crypt.h.

Referenced by unzOpenCurrentFile3(), and unzReadCurrentFile().

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

Definition at line 82 of file crypt.h.

Referenced by zip64FlushWriteBuffer().

Function Documentation

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

Definition at line 37 of file crypt.h.

38 {
39  //(void) pcrc_32_tab; /* avoid "unused parameter" warning */
40  unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
41  * unpredictable manner on 16-bit systems; not a problem
42  * with any known compiler so far, though */
43 
44  temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
45  return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
46 }
static void init_keys ( const char *  passwd,
unsigned long *  pkeys,
const z_crc_t FAR *  pcrc_32_tab 
)
static

Definition at line 68 of file crypt.h.

References update_keys().

Referenced by unzOpenCurrentFile3().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 51 of file crypt.h.

References CRC32.

Referenced by init_keys().

52 {
53  (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
54  (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
55  (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
56  {
57  register int keyshift = (int)((*(pkeys+1)) >> 24);
58  (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
59  }
60  return c;
61 }
#define CRC32(c, b)
Definition: crypt.h:32

+ Here is the caller graph for this function: