home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zcrypt27.zip / crypt.c next >
C/C++ Source or Header  |  1997-03-30  |  19KB  |  561 lines

  1. /*
  2.    crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
  3.  
  4.    This code is not copyrighted and is put in the public domain.  The
  5.    encryption/decryption parts (as opposed to the non-echoing password
  6.    parts) were originally written in Europe; the whole file can there-
  7.    fore be freely distributed from any country except the USA.  If this
  8.    code is imported into the USA, it cannot be re-exported from from
  9.    there to another country.  (This restriction might seem curious, but
  10.    this is what US law requires.)
  11.  */
  12.  
  13. /* This encryption code is a direct transcription of the algorithm from
  14.    Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
  15.    file (appnote.txt) is distributed with the PKZIP program (even in the
  16.    version without encryption capabilities).
  17.  */
  18.  
  19. #define ZCRYPT_INTERNAL
  20. #include "zip.h"
  21. #include "crypt.h"
  22. #include "ttyio.h"
  23.  
  24. #ifndef FALSE
  25. #  define FALSE 0
  26. #endif
  27.  
  28. #ifdef ZIP
  29.    /* For the encoding task used in Zip (and ZipCloak), we want to initialize
  30.       the crypt algorithm with some reasonably unpredictable bytes, see
  31.       the crypthead() function. The standard rand() library function is
  32.       used to supply these `random' bytes, which in turn is initialized by
  33.       a srand() call. The srand() function takes an "unsigned" (at least 16bit)
  34.       seed value as argument to determine the starting point of the rand()
  35.       pseudo-random number generator.
  36.       This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with
  37.       Seed1 supplied by the current time (= "(unsigned)time()") and Seed2
  38.       as some (hopefully) nondeterministic bitmask. On many (most) systems,
  39.       we use some "process specific" number, as the PID or something similar,
  40.       but when nothing unpredictable is available, a fixed number may be
  41.       sufficient.
  42.       NOTE:
  43.       1.) This implementation requires the availability of the following
  44.           standard UNIX C runtime library functions: time(), rand(), srand().
  45.           On systems where some of them are missing, the environment that
  46.           incorporates the crypt routines must supply suitable replacement
  47.           functions.
  48.       2.) It is a very bad idea to use a second call to time() to set the
  49.           "Seed2" number! In this case, both "Seed1" and "Seed2" would be
  50.           (almost) identical, resulting in a (mostly) "zero" constant seed
  51.           number passed to srand().
  52.  
  53.       The implementation environment defined in the "zip.h" header should
  54.       supply a reasonable definition for ZCR_SEED2 (an unsigned number; for
  55.       most implementations of rand() and srand(), only the lower 16 bits are
  56.       significant!). An example that works on many systems would be
  57.            "#define ZCR_SEED2  (unsigned)getpid()".
  58.       The default definition for ZCR_SEED2 supplied below should be regarded
  59.       as a fallback to allow successful compilation in "beta state"
  60.       environments.
  61.     */
  62. #  include <time.h>     /* time() function supplies first part of crypt seed */
  63.    /* "last resort" source for second part of crypt seed pattern */
  64. #  ifndef ZCR_SEED2
  65. #    define ZCR_SEED2 (unsigned)3141592654L     /* use PI as default pattern */
  66. #  endif
  67. #  ifdef GLOBAL         /* used in Amiga system headers, maybe others too */
  68. #    undef GLOBAL
  69. #  endif
  70. #  define GLOBAL(g) g
  71. #else /* !ZIP */
  72. #  define GLOBAL(g) G.g
  73. #endif /* ?ZIP */
  74.  
  75.  
  76. #ifdef UNZIP
  77.    /* char *key = (char *)NULL; moved to globals.h */
  78. #  ifndef FUNZIP
  79.      local int testp OF((__GPRO__ uch *h));
  80.      local int testkey OF((__GPRO__ uch *h, char *key));
  81. #  endif
  82. #endif /* UNZIP */
  83.  
  84. #ifndef UNZIP             /* moved to globals.h for UnZip */
  85.    local ulg keys[3];     /* keys defining the pseudo-random sequence */
  86. #endif /* !UNZIP */
  87.  
  88. #ifndef Trace
  89. #  ifdef CRYPT_DEBUG
  90. #    define Trace(x) fprintf x
  91. #  else
  92. #    define Trace(x)
  93. #  endif
  94. #endif
  95.  
  96. #ifndef CRC_32_TAB
  97. #  define CRC_32_TAB     crc_32_tab
  98. #endif
  99.  
  100. #define CRC32(c, b) (CRC_32_TAB[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
  101.  
  102. /***********************************************************************
  103.  * Return the next byte in the pseudo-random sequence
  104.  */
  105. int decrypt_byte(__G)
  106.     __GDEF
  107. {
  108.     unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an
  109.                      * unpredictable manner on 16-bit systems; not a problem
  110.                      * with any known compiler so far, though */
  111.  
  112.     temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2;
  113.     return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
  114. }
  115.  
  116. /***********************************************************************
  117.  * Update the encryption keys with the next byte of plain text
  118.  */
  119. int update_keys(__G__ c)
  120.     __GDEF
  121.     int c;                  /* byte of plain text */
  122. {
  123.     GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c);
  124.     GLOBAL(keys[1]) += GLOBAL(keys[0]) & 0xff;
  125.     GLOBAL(keys[1]) = GLOBAL(keys[1]) * 134775813L + 1;
  126.     {
  127.       register int keyshift = (int)(GLOBAL(keys[1]) >> 24);
  128.       GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift);
  129.     }
  130.     return c;
  131. }
  132.  
  133.  
  134. /***********************************************************************
  135.  * Initialize the encryption keys and the random header according to
  136.  * the given password.
  137.  */
  138. void init_keys(__G__ passwd)
  139.     __GDEF
  140.     char *passwd;             /* password string with which to modify keys */
  141. {
  142.     GLOBAL(keys[0]) = 305419896L;
  143.     GLOBAL(keys[1]) = 591751049L;
  144.     GLOBAL(keys[2]) = 878082192L;
  145.     while (*passwd != '\0') {
  146.         update_keys(__G__ (int)*passwd);
  147.         passwd++;
  148.     }
  149. }
  150.  
  151.  
  152. #ifdef ZIP
  153.  
  154. /***********************************************************************
  155.  * Write encryption header to file zfile using the password passwd
  156.  * and the cyclic redundancy check crc.
  157.  */
  158. void crypthead(passwd, crc, zfile)
  159.     char *passwd;                /* password string */
  160.     ulg crc;                     /* crc of file being encrypted */
  161.     FILE *zfile;                 /* where to write header */
  162. {
  163.     int n;                       /* index in random header */
  164.     int t;                       /* temporary */
  165.     int c;                       /* random byte */
  166.     int ztemp;                   /* temporary for zencoded value */
  167.     uch header[RAND_HEAD_LEN-2]; /* random header */
  168.     static unsigned calls = 0;   /* ensure different random header each time */
  169.  
  170.     /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
  171.      * output of rand() to get less predictability, since rand() is
  172.      * often poorly implemented.
  173.      */
  174.     if (++calls == 1) {
  175.         srand((unsigned)time(NULL) ^ ZCR_SEED2);
  176.     }
  177.     init_keys(passwd);
  178.     for (n = 0; n < RAND_HEAD_LEN-2; n++) {
  179.         c = (rand() >> 7) & 0xff;
  180.         header[n] = (uch)zencode(c, t);
  181.     }
  182.     /* Encrypt random header (last two bytes is high word of crc) */
  183.     init_keys(passwd);
  184.     for (n = 0; n < RAND_HEAD_LEN-2; n++) {
  185.         ztemp = zencode(header[n], t);
  186.         putc(ztemp, zfile);
  187.     }
  188.     ztemp = zencode((int)(crc >> 16) & 0xff, t);
  189.     putc(ztemp, zfile);
  190.     ztemp = zencode((int)(crc >> 24) & 0xff, t);
  191.     putc(ztemp, zfile);
  192. }
  193.  
  194.  
  195. #ifdef UTIL
  196.  
  197. /***********************************************************************
  198.  * Encrypt the zip entry described by z from file source to file dest
  199.  * using the password passwd.  Return an error code in the ZE_ class.
  200.  */
  201. int zipcloak(z, source, dest, passwd)
  202.     struct zlist far *z;    /* zip entry to encrypt */
  203.     FILE *source, *dest;    /* source and destination files */
  204.     char *passwd;           /* password string */
  205. {
  206.     int c;                  /* input byte */
  207.     int res;                /* result code */
  208.     ulg n;                  /* holds offset and counts size */
  209.     ush flag;               /* previous flags */
  210.     int t;                  /* temporary */
  211.     int ztemp;              /* temporary storage for zencode value */
  212.  
  213.     /* Set encrypted bit, clear extended local header bit and write local
  214.        header to output file */
  215.     if ((n = ftell(dest)) == -1L) return ZE_TEMP;
  216.     z->off = n;
  217.     flag = z->flg;
  218.     z->flg |= 1,  z->flg &= ~8;
  219.     z->lflg |= 1, z->lflg &= ~8;
  220.     z->siz += RAND_HEAD_LEN;
  221.     if ((res = putlocal(z, dest)) != ZE_OK) return res;
  222.  
  223.     /* Initialize keys with password and write random header */
  224.     crypthead(passwd, z->crc, dest);
  225.  
  226.     /* Skip local header in input file */
  227.     if (fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext),
  228.               SEEK_CUR)) {
  229.         return ferror(source) ? ZE_READ : ZE_EOF;
  230.     }
  231.  
  232.     /* Encrypt data */
  233.     for (n = z->siz - RAND_HEAD_LEN; n; n--) {
  234.         if ((c = getc(source)) == EOF) {
  235.             return ferror(source) ? ZE_READ : ZE_EOF;
  236.         }
  237.         ztemp = zencode(c, t);
  238.         putc(ztemp, dest);
  239.     }
  240.     /* Skip extended local header in input file if there is one */
  241.     if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) {
  242.         return ferror(source) ? ZE_READ : ZE_EOF;
  243.     }
  244.     if (fflush(dest) == EOF) return ZE_TEMP;
  245.     return ZE_OK;
  246. }
  247.  
  248. /***********************************************************************
  249.  * Decrypt the zip entry described by z from file source to file dest
  250.  * using the password passwd.  Return an error code in the ZE_ class.
  251.  */
  252. int zipbare(__G__ z, source, dest, passwd)
  253.     __GDEF
  254.     struct zlist far *z;  /* zip entry to encrypt */
  255.     FILE *source, *dest;  /* source and destination files */
  256.     char *passwd;         /* password string */
  257. {
  258.     int c0, c1;           /* last two input bytes */
  259.     ulg offset;           /* used for file offsets */
  260.     ulg size;             /* size of input data */
  261.     int r;                /* size of encryption header */
  262.     int res;              /* return code */
  263.     ush flag;             /* previous flags */
  264.  
  265.     /* Save position and skip local header in input file */
  266.     if ((offset = ftell(source)) == -1L ||
  267.         fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext),
  268.               SEEK_CUR)) {
  269.         return ferror(source) ? ZE_READ : ZE_EOF;
  270.     }
  271.     /* Initialize keys with password */
  272.     init_keys(passwd);
  273.  
  274.     /* Decrypt encryption header, save last two bytes */
  275.     c1 = 0;
  276.     for (r = RAND_HEAD_LEN; r; r--) {
  277.         c0 = c1;
  278.         if ((c1 = getc(source)) == EOF) {
  279.             return ferror(source) ? ZE_READ : ZE_EOF;
  280.         }
  281.         Trace((stdout, " (%02x)", c1));
  282.         zdecode(c1);
  283.         Trace((stdout, " %02x", c1));
  284.     }
  285.     Trace((stdout, "\n"));
  286.  
  287.     /* If last two bytes of header don't match crc (or file time in the
  288.      * case of an extended local header), back up and just copy. For
  289.      * pkzip 2.0, the check has been reduced to one byte only.
  290.      */
  291. #ifdef ZIP10
  292.     if ((ush)(c0 | (c1<<8)) !=
  293.         (z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) {
  294. #else
  295.     c0++; /* avoid warning on unused variable */
  296.     if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) {
  297. #endif
  298.         if (fseek(source, offset, SEEK_SET)) {
  299.             return ferror(source) ? ZE_READ : ZE_EOF;
  300.         }
  301.         if ((res = zipcopy(z, source, dest)) != ZE_OK) return res;
  302.         return ZE_MISS;
  303.     }
  304.  
  305.     /* Clear encrypted bit and local header bit, and write local header to
  306.        output file */
  307.     if ((offset = ftell(dest)) == -1L) return ZE_TEMP;
  308.     z->off = offset;
  309.     flag = z->flg;
  310.     z->flg &= ~9;
  311.     z->lflg &= ~9;
  312.     z->siz -= RAND_HEAD_LEN;
  313.     if ((res = putlocal(z, dest)) != ZE_OK) return res;
  314.  
  315.     /* Decrypt data */
  316.     for (size = z->siz; size; size--) {
  317.         if ((c1 = getc(source)) == EOF) {
  318.             return ferror(source) ? ZE_READ : ZE_EOF;
  319.         }
  320.         zdecode(c1);
  321.         putc(c1, dest);
  322.     }
  323.     /* Skip extended local header in input file if there is one */
  324.     if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) {
  325.         return ferror(source) ? ZE_READ : ZE_EOF;
  326.     }
  327.     if (fflush(dest) == EOF) return ZE_TEMP;
  328.  
  329.     return ZE_OK;
  330. }
  331.  
  332.  
  333. #else /* !UTIL */
  334.  
  335. /***********************************************************************
  336.  * If requested, encrypt the data in buf, and in any case call fwrite()
  337.  * with the arguments to zfwrite().  Return what fwrite() returns.
  338.  */
  339. unsigned zfwrite(buf, item_size, nb, f)
  340.     zvoid *buf;                /* data buffer */
  341.     extent item_size;          /* size of each item in bytes */
  342.     extent nb;                 /* number of items */
  343.     FILE *f;                   /* file to write to */
  344. {
  345.     int t;                    /* temporary */
  346.  
  347.     if (key != (char *)NULL) { /* key is the global password pointer */
  348.         ulg size;              /* buffer size */
  349.         char *p = (char*)buf;  /* steps through buffer */
  350.  
  351.         /* Encrypt data in buffer */
  352.         for (size = item_size*(ulg)nb; size != 0; p++, size--) {
  353.             *p = (char)zencode(*p, t);
  354.         }
  355.     }
  356.     /* Write the buffer out */
  357.     return fwrite(buf, item_size, nb, f);
  358. }
  359.  
  360. #endif /* ?UTIL */
  361. #endif /* ZIP */
  362.  
  363.  
  364. #if (defined(UNZIP) && !defined(FUNZIP))
  365.  
  366. /***********************************************************************
  367.  * Get the password and set up keys for current zipfile member.  Return
  368.  * PK_ class error.
  369.  */
  370. int decrypt(__G)
  371.     __GDEF
  372. {
  373.     ush b;
  374.     int n, r;
  375.     uch h[RAND_HEAD_LEN];
  376.  
  377.     Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt)));
  378.  
  379.     /* get header once (turn off "encrypted" flag temporarily so we don't
  380.      * try to decrypt the same data twice) */
  381.     GLOBAL(pInfo->encrypted) = FALSE;
  382.     defer_leftover_input(__G);
  383.     for (n = 0; n < RAND_HEAD_LEN; n++) {
  384.         b = NEXTBYTE;
  385.         h[n] = (uch)b;
  386.         Trace((stdout, " (%02x)", h[n]));
  387.     }
  388.     undefer_input(__G);
  389.     GLOBAL(pInfo->encrypted) = TRUE;
  390.  
  391.     if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */
  392.         GLOBAL(newzip) = FALSE;
  393.         if (GLOBAL(P_flag)) {     /* user gave password on command line */
  394.             if (!GLOBAL(key)) {
  395.                 if ((GLOBAL(key) = (char *)malloc(PWLEN+1)) == (char *)NULL)
  396.                     return PK_MEM2;
  397.                 strncpy(GLOBAL(key), GLOBAL(pwdarg), PWLEN);
  398.                 GLOBAL(nopwd) = TRUE;  /* inhibit password prompting! */
  399.             }
  400.         } else if (GLOBAL(key)) { /* get rid of previous zipfile's key */
  401.             free(GLOBAL(key));
  402.             GLOBAL(key) = (char *)NULL;
  403.         }
  404.     }
  405.  
  406.     /* if have key already, test it; else allocate memory for it */
  407.     if (GLOBAL(key)) {
  408.         if (!testp(__G__ h))
  409.             return PK_COOL;   /* existing password OK (else prompt for new) */
  410.         else if (GLOBAL(nopwd))
  411.             return PK_WARN;   /* user indicated no more prompting */
  412.     } else if ((GLOBAL(key) = (char *)malloc(PWLEN+1)) == (char *)NULL)
  413.         return PK_MEM2;
  414.  
  415.     /* try a few keys */
  416.     n = 0;
  417.     do {
  418.         r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), PWLEN+1,
  419.                              GLOBAL(zipfn), GLOBAL(filename));
  420.         if (r == IZ_PW_ERROR) {         /* internal error in fetch of PW */
  421.             free (GLOBAL(key));
  422.             GLOBAL(key) = NULL;
  423.             return PK_MEM2;
  424.         }
  425.         if (r != IZ_PW_ENTERED) {       /* user replied "skip" or "skip all" */
  426.             *GLOBAL(key) = '\0';        /*   We try the NIL password, ... */
  427.             n = 0;                      /*   and cancel fetch for this item. */
  428.         }
  429.         if (!testp(__G__ h))
  430.             return PK_COOL;
  431.         if (r == IZ_PW_CANCELALL)       /* User replied "Skip all" */
  432.             GLOBAL(nopwd) = TRUE;       /*   inhibit any further PW prompt! */
  433.     } while (n > 0);
  434.  
  435.     return PK_WARN;
  436.  
  437. } /* end function decrypt() */
  438.  
  439.  
  440.  
  441. /***********************************************************************
  442.  * Test the password.  Return -1 if bad, 0 if OK.
  443.  */
  444. local int testp(__G__ h)
  445.     __GDEF
  446.     uch *h;
  447. {
  448.     int r;
  449.     char *key_translated;
  450.  
  451.     /* On systems with "obscure" native character coding (e.g., EBCDIC),
  452.      * the first test translates the password to the "main standard"
  453.      * character coding. */
  454.  
  455. #ifdef STR_TO_CP1
  456.     /* allocate buffer for translated password */
  457.     if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
  458.         return -1;
  459.     /* first try, test password translated "standard" charset */
  460.     r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key)));
  461. #else /* !STR_TO_CP1 */
  462.     /* first try, test password as supplied on the extractor's host */
  463.     r = testkey(__G__ h, GLOBAL(key));
  464. #endif /* ?STR_TO_CP1 */
  465.  
  466. #ifdef STR_TO_CP2
  467.     if (r != 0) {
  468. #ifndef STR_TO_CP1
  469.         /* now prepare for second (and maybe third) test with translated pwd */
  470.         if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
  471.             return -1;
  472. #endif
  473.         /* second try, password translated to alternate ("standard") charset */
  474.         r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key)));
  475. #ifdef STR_TO_CP3
  476.         if (r != 0)
  477.             /* third try, password translated to another "standard" charset */
  478.             r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key)));
  479. #endif
  480. #ifndef STR_TO_CP1
  481.         free(key_translated);
  482. #endif
  483.     }
  484. #endif /* STR_TO_CP2 */
  485.  
  486. #ifdef STR_TO_CP1
  487.     free(key_translated);
  488.     if (r != 0) {
  489.         /* last resort, test password as supplied on the extractor's host */
  490.         r = testkey(__G__ h, GLOBAL(key));
  491.     }
  492. #endif /* STR_TO_CP1 */
  493.  
  494.     return r;
  495.  
  496. } /* end function testp() */
  497.  
  498.  
  499. local int testkey(__G__ h, key)
  500.     __GDEF
  501.     uch *h;             /* decrypted header */
  502.     char *key;          /* decryption password to test */
  503. {
  504.     ush b;
  505. #ifdef ZIP10
  506.     ush c;
  507. #endif
  508.     int n;
  509.     uch *p;
  510.     uch hh[RAND_HEAD_LEN]; /* decrypted header */
  511.  
  512.     /* set keys and save the encrypted header */
  513.     init_keys(__G__ key);
  514.     memcpy(hh, h, RAND_HEAD_LEN);
  515.  
  516.     /* check password */
  517.     for (n = 0; n < RAND_HEAD_LEN; n++) {
  518.         zdecode(hh[n]);
  519.         Trace((stdout, " %02x", hh[n]));
  520.     }
  521.  
  522.     Trace((stdout,
  523.       "\n  lrec.crc= %08lx  crec.crc= %08lx  pInfo->ExtLocHdr= %s\n",
  524.       GLOBAL(lrec.crc32), GLOBAL(pInfo->crc),
  525.       GLOBAL(pInfo->ExtLocHdr) ? "true":"false"));
  526.     Trace((stdout, "  incnt = %d  unzip offset into zipfile = %ld\n",
  527.       GLOBAL(incnt),
  528.       GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf))));
  529.  
  530.     /* same test as in zipbare(): */
  531.  
  532. #ifdef ZIP10 /* check two bytes */
  533.     c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1];
  534.     Trace((stdout,
  535.       "  (c | (b<<8)) = %04x  (crc >> 16) = %04x  lrec.time = %04x\n",
  536.       (ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16),
  537.       GLOBAL(lrec.last_mod_file_time)));
  538.     if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ?
  539.                               GLOBAL(lrec.last_mod_file_time) :
  540.                               (ush)(GLOBAL(lrec.crc32) >> 16)))
  541.         return -1;  /* bad */
  542. #else
  543.     b = hh[RAND_HEAD_LEN-1];
  544.     Trace((stdout, "  b = %02x  (crc >> 24) = %02x  (lrec.time >> 8) = %02x\n",
  545.       b, (ush)(GLOBAL(lrec.crc32) >> 24),
  546.       (GLOBAL(lrec.last_mod_file_time) >> 8)));
  547.     if (b != (GLOBAL(pInfo->ExtLocHdr) ? GLOBAL(lrec.last_mod_file_time) >> 8 :
  548.         (ush)(GLOBAL(lrec.crc32) >> 24)))
  549.         return -1;  /* bad */
  550. #endif
  551.     /* password OK:  decrypt current buffer contents before leaving */
  552.     for (n = (long)GLOBAL(incnt) > GLOBAL(csize) ?
  553.              (int)GLOBAL(csize) : GLOBAL(incnt),
  554.          p = GLOBAL(inptr); n--; p++)
  555.         zdecode(*p);
  556.     return 0;       /* OK */
  557.  
  558. } /* end function testkey() */
  559.  
  560. #endif /* UNZIP && !FUNZIP */
  561.