Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
4.6KB

  1. /*
  2. Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2005-Feb-10 or later
  4. (the contents of which are also included in (un)zip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  7. */
  8. /*
  9. crypt.h (full version) by Info-ZIP. Last revised: [see CR_VERSION_DATE]
  10. The main encryption/decryption source code for Info-Zip software was
  11. originally written in Europe. To the best of our knowledge, it can
  12. be freely distributed in both source and object forms from any country,
  13. including the USA under License Exception TSU of the U.S. Export
  14. Administration Regulations (section 740.13(e)) of 6 June 2002.
  15. NOTE on copyright history:
  16. Previous versions of this source package (up to version 2.8) were
  17. not copyrighted and put in the public domain. If you cannot comply
  18. with the Info-Zip LICENSE, you may want to look for one of those
  19. public domain versions.
  20. */
  21. #ifndef __crypt_h /* don't include more than once */
  22. #define __crypt_h
  23. #ifdef CRYPT
  24. # undef CRYPT
  25. #endif
  26. /*
  27. Logic of selecting "full crypt" code:
  28. a) default behaviour:
  29. - dummy crypt code when compiling UnZipSFX stub, to minimize size
  30. - full crypt code when used to compile Zip, UnZip and fUnZip
  31. b) USE_CRYPT defined:
  32. - always full crypt code
  33. c) NO_CRYPT defined:
  34. - never full crypt code
  35. NO_CRYPT takes precedence over USE_CRYPT
  36. */
  37. #if defined(NO_CRYPT)
  38. # define CRYPT 0 /* dummy version */
  39. #else
  40. #if defined(USE_CRYPT)
  41. # define CRYPT 1 /* full version */
  42. #else
  43. #if !defined(SFX)
  44. # define CRYPT 1 /* full version for zip and main unzip */
  45. #else
  46. # define CRYPT 0 /* dummy version for unzip sfx */
  47. #endif
  48. #endif /* ?USE_CRYPT */
  49. #endif /* ?NO_CRYPT */
  50. #if CRYPT
  51. /* full version */
  52. #ifdef CR_BETA
  53. # undef CR_BETA /* this is not a beta release */
  54. #endif
  55. #define CR_MAJORVER 2
  56. #define CR_MINORVER 11
  57. #ifdef CR_BETA
  58. # define CR_BETA_VER "c BETA"
  59. # define CR_VERSION_DATE "05 Jan 2007" /* last real code change */
  60. #else
  61. # define CR_BETA_VER ""
  62. # define CR_VERSION_DATE "05 Jan 2007" /* last public release date */
  63. # define CR_RELEASE
  64. #endif
  65. #ifndef __G /* UnZip only, for now (DLL stuff) */
  66. # define __G
  67. # define __G__
  68. # define __GDEF
  69. # define __GPRO void
  70. # define __GPRO__
  71. #endif
  72. #if defined(MSDOS) || defined(OS2) || defined(WIN32)
  73. # ifndef DOS_OS2_W32
  74. # define DOS_OS2_W32
  75. # endif
  76. #endif
  77. #if defined(DOS_OS2_W32) || defined(__human68k__)
  78. # ifndef DOS_H68_OS2_W32
  79. # define DOS_H68_OS2_W32
  80. # endif
  81. #endif
  82. #if defined(VM_CMS) || defined(MVS)
  83. # ifndef CMS_MVS
  84. # define CMS_MVS
  85. # endif
  86. #endif
  87. /* To allow combining of Zip and UnZip static libraries in a single binary,
  88. * the Zip and UnZip versions of the crypt core functions have to be named
  89. * differently.
  90. */
  91. #ifdef ZIP
  92. # ifdef REALLY_SHORT_SYMS
  93. # define decrypt_byte zdcrby
  94. # else
  95. # define decrypt_byte zp_decrypt_byte
  96. # endif
  97. # define update_keys zp_update_keys
  98. # define init_keys zp_init_keys
  99. #else /* !ZIP */
  100. # ifdef REALLY_SHORT_SYMS
  101. # define decrypt_byte dcrbyt
  102. # endif
  103. #endif /* ?ZIP */
  104. #define IZ_PWLEN 80 /* input buffer size for reading encryption key */
  105. #ifndef PWLEN /* for compatibility with previous zcrypt release... */
  106. # define PWLEN IZ_PWLEN
  107. #endif
  108. #define RAND_HEAD_LEN 12 /* length of encryption random header */
  109. /* the crc_32_tab array has to be provided externally for the crypt calculus */
  110. /* encode byte c, using temp t. Warning: c must not have side effects. */
  111. #define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c))
  112. /* decode byte c in place */
  113. #define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G))
  114. int decrypt_byte OF((__GPRO));
  115. int update_keys OF((__GPRO__ int c));
  116. void init_keys OF((__GPRO__ ZCONST char *passwd));
  117. #ifdef ZIP
  118. void crypthead OF((ZCONST char *, ulg, FILE *));
  119. # ifdef UTIL
  120. int zipcloak OF((struct zlist far *, FILE *, FILE *, ZCONST char *));
  121. int zipbare OF((struct zlist far *, FILE *, FILE *, ZCONST char *));
  122. # else
  123. unsigned zfwrite OF((zvoid *, extent, extent, FILE *));
  124. extern char *key;
  125. # endif
  126. #endif /* ZIP */
  127. #if (defined(UNZIP) && !defined(FUNZIP))
  128. int decrypt OF((__GPRO__ ZCONST char *passwrd));
  129. #endif
  130. #ifdef FUNZIP
  131. extern int encrypted;
  132. # ifdef NEXTBYTE
  133. # undef NEXTBYTE
  134. # endif
  135. # define NEXTBYTE \
  136. (encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in))
  137. #endif /* FUNZIP */
  138. #else /* !CRYPT */
  139. /* dummy version */
  140. #define zencode
  141. #define zdecode
  142. #define zfwrite fwrite
  143. #endif /* ?CRYPT */
  144. #endif /* !__crypt_h */