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