]> granicus.if.org Git - zziplib/commitdiff
describing zzip-cryptoid handling v0.13.36
authorGuido Draheim <guidod@gmx.de>
Tue, 11 May 2004 17:25:22 +0000 (17:25 +0000)
committerGuido Draheim <guidod@gmx.de>
Tue, 11 May 2004 17:25:22 +0000 (17:25 +0000)
 ()

ChangeLog
docs/Makefile.am
docs/Makefile.in
docs/body.htm
docs/zzip-crypt.htm
docs/zzip-cryptoid.htm [new file with mode: 0644]
docs/zzip-xor.htm
zziplib.spec

index d5f2285c7b79dd34ece41f59c792de13b1fd3bae..4aa6b67d3fea31d3ade69b2e0ce7976c99b93a39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2004-05-11
+ * documenting zzip-cryptoid handling
+
 2004-05-09
  * documenting zzipmmapped and zzipfseeko parser libraries
        
index 5c7608f99f5c06b5115db78d35a141f2847ebc49..f3d9e7081f7cfa0a23a9c82f20af482f7590e46b 100644 (file)
@@ -4,7 +4,7 @@ AUTOTOOL_VERSION=autoconf-2.52 automake-1.5 libtool-1.4.2
 doc_FILES = README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB \
             zziplib.html
 htm_FILES = zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm \
-            zzip-extio.htm zzip-xor.htm zzip-crypt.htm \
+            zzip-extio.htm zzip-xor.htm zzip-crypt.htm zzip-cryptoid.htm \
             zzip-api.htm  zzip-basics.htm zzip-extras.htm zzip-parse.htm \
             64on32.htm future.htm fseeko.htm mmapped.htm \
             configs.htm sfx-make.htm \
index ab35d9b7ce71ad1202e3058b92710e836d3f7583..39566cab5066517bdafbe5a964450911a06e53b5 100644 (file)
@@ -156,9 +156,10 @@ doc_FILES = README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB \
             zziplib.html
 
 htm_FILES = zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm \
-            zzip-extio.htm zzip-xor.htm zzip-crypt.htm \
+            zzip-extio.htm zzip-xor.htm zzip-crypt.htm zzip-cryptoid.htm \
             zzip-api.htm  zzip-basics.htm zzip-extras.htm zzip-parse.htm \
-            64on32.htm future.htm configs.htm sfx-make.htm \
+            64on32.htm future.htm fseeko.htm mmapped.htm \
+            configs.htm sfx-make.htm \
             history.htm referentials.htm  copying.htm
 
 SDL_RWOPS = $(SDL)/SDL_rwops_zzcat.c \
index 110dcf0f144ecdb0f6d22a655545acf4a9001877..16210e611f7cebd86719689d2ad6a625f8d617b2 100644 (file)
@@ -34,6 +34,7 @@
 <br>-<a href="zzip-extio.html"> ext/io <small>Customization</small></a>
 <br><><a href="zzip-xor.html"> xor/io <small>Obfuscation</small></a>
 <br><><a href="zzip-crypt.html"> zip/no <small>Encryption</small></a>
+<small><a href="zzip-cryptoid.html">(2)</a></small>
 <br>-<a href="zzip-api.html"> Library API</a>
 <br><><a href="zzip-basics.html"> basics</a></u>
 <><a href="zzip-extras.html"> extras</a></u>
index 99599aaa8d5a9a6f491f44b5f852f9ebcef34a99..34151ab0d1e832f8c6efecff222316994eff3438 100644 (file)
@@ -1,4 +1,4 @@
-<h2> ZIP Encryption </h2>       Standard Zip Encryption is Weak.
+<h2> ZIP Std Encryption </h2>       Standard Zip Encryption is Weak!
 
 <!--border--> <date> 15. July 2002 </date>
 
@@ -9,23 +9,27 @@
   first of all the standard zip-encryption has not been strong enough
   for modern computers, and there are hacker tools that even a 
   half-literate computer-user can use to crack the password of a
-  zip-archive. Furthermore, adding real encryption is a heavy weight
+  zip-archive. In other words: <b> every encrypted zip file can be
+  cracked using freely downloadable helper tools </b>. That's because
+  standard zip encryption is weak regarding modern personal computer 
+  power. Furthermore, adding <em>real</em> encryption is a heavy weight
   that many people do not need, see the last argument for seeing the
   standard one is useless anyway, and adding a non-standard one 
   should not be the case of the standard zziplib either, ye know.
 </P><P>
   On the other hand, obfuscation is a means to fear off half-literates
-  just as well - there are no premade tools for the obfuscation you
+  just as well - there are no <em>premade</em> tools for the obfuscation you
   can invent from the xor examples. And a hacker that can de-obfuscate
-  such a dat-file is able to dissassemble your program as well thereby
-  going to see your decryption routine <em>and</em> the decryption key.
-  Although there is a difference, it just ranges on about times and
-  exprience, not magnitudes. Remember the old saying: you can irritate
+  such a dat-file is able to dissassemble your program as well - just to
+  remind you that the disassembly of a program will reveal the decryption
+  routine <em>and</em> the decryption key, even for a heavyweight crypt
+  algorithm. Although there is a difference, it just ranges on about times 
+  and exprience, not magnitudes. Remember the old saying: you can irritate
   some people for some time but not irritate all people for all the time.
   As for encryption of artwork and AI scripts in games and applications,
   just keep in mind that the final recipient has the decryption key on
   his system anyway, just obfuscated. So each such encryption is nothing
-  more than just a clever form of obfuscation, nothing mathemetical strong.
+  more than just a clever form of obfuscation, nothing mathematical strong.
 </P><P>
   Some other people might ask why to obfuscate anyway. Well, the reason
   is theft. Even people who write opensource free software generally
diff --git a/docs/zzip-cryptoid.htm b/docs/zzip-cryptoid.htm
new file mode 100644 (file)
index 0000000..072deac
--- /dev/null
@@ -0,0 +1,102 @@
+<h2> ZIP Ext Encryption </h2>       ext/io used for cryptoid plugins
+
+<!--border--> <date> 11. May 2004 </date>
+
+<h3> Stronger Obfuscation For ZZip </h3>
+
+<P>
+  Some people feel that a simple bytewise xor is not strong enough
+  as an obfuscation for the data. There we have the question how to
+  implant a stronger obfuscation routine to protect that data of an
+  application from artwork theft. Perhaps there is even the idea to
+  use an obfuscation in the range of a real crypt routine - in which
+  case I want to recommend strongly to read the 
+  <a href="zzip-crypt.html"> reasoning page </a> why it can not be
+  real encryption and that the resulting obfuscation has an upper 
+  limit being <em>lower</em> than the crypt routine complexity.
+</P>
+
+<P>
+ After reminding you of this fact we can go at evaluationg how to
+ implant a stronger obfusction routine to protect your data. The
+ ext/io feature uses a callback routine "read" that must read a
+ block of the given size - for the obfuscation case it will call
+ the "read()" function of the underlying operation system, and
+ the obfuscated block will be deobfuscated before returning it to
+ the caller.
+</P>
+
+<P>
+ In this mechanism there is not asseration at which file-offset
+ the ext/io-read() callback is triggered. That is the reason we
+ have shown obfuscation with bytewise xor-key example - formally
+ this is using obfuscation blocks of 8bit width being aligned
+ on 8bit boundaries in the data file, and our decryption stream
+ is stateless being the same for each obfuscation block (of 8bit
+ width). 
+</P>
+<P>
+ In order for a stronger obfuscation we have to break those 
+ limitations which are directly derived from the natural way
+ of the handling of files by a contemporary operating system.
+ This is triggered as the call synopsis of the ext/io read()
+ callback matches <em>exactly</em> the one of posix, so that
+ one can use the posix read() function reference as the default
+ for ensuring the most minimal overhead in accessing non-obfuscated 
+ zip files. 
+<br><small>And btw, the abbreviation "posix" stands for 
+   "Portable Open System in Unix".</small>
+</P>
+
+<P>
+ The trick we show here: the first argument of the ext/io read
+ callback is the file descriptor of the underlying operationg
+ system. While we can not add another argument to the ext/io
+ read call we can pick up additional information with the help
+ of that file descriptor id being globally unique even across
+ multiple threads. One solution would make the application map
+ that descriptor id to a special argument but this is often too
+ much overhead: the current file position is enough. 
+</P>
+<P>
+ The current file position is managed by the operation system
+ via the file descriptor table. There is a function call to
+ map a file descriptor to the current read position offset
+ usually named "tell(fd)". Since this call is not mandated by
+ posix, you can emulate it with the posix lseek() call which
+ returns the resulting offset after the operation was performed,
+ so we just seek by a zero offset:
+<br><code>#define tell(fd) lseek(fd,0,SEEK_CUR)
+</P>
+
+<P>
+ That file offset is measured from the start of the zip archive,
+ not per each zipped file. Remind yourself of that fact when
+ creating your own "zzobfuscate.exe" which should work on the
+ zip archive and not per file before zipping. That is a difference
+ over normal zip archives where the user can atleast recognized the
+ dat file as a zip archive and see a list of files contained in the 
+ archive, atleast their names and data start offset.
+</P>
+<P>
+ Now, let's use the file read offset to break the blocking
+ limitations of 8bit/8bit to a larger xor-key. In our example
+ we expand to a 32bit/32bit xor-key giving a search space of
+ 4<>billion keys instead of the just 256<>keys in 8bit blocking.
+ That is simply done by a static 4<>byte xor-key sequence and using
+ modulo operations for alignment. For the 2^X cases any modulo
+ operations shrink to a set of ultra-fast bitwise-and operations.
+</P>
+
+<pre>
+      static char xor_value[4] = { 0x55, 0x63, 0x27, 0x31 };
+      static zzip_ssize_t xor_read (int f, void* p, zzip_size_t l)
+      {
+          zzip_off_t  y = tell(f);
+          zzip_size_t r = read(f, p, l);
+         zzip_size_t x;  char* q = p;
+          for (x=0; x &lt; r; x++) q[x] ^= xor_value[(y+x)&amp;3];
+          return r;
+      }
+</pre>
+
index 8478455d7bfffc7274bdeeba4afbcfd8cc9c3f02..7f91a0eb7148c6f3461b6d114ba6398424b4d994 100644 (file)
@@ -23,7 +23,7 @@
       static zzip_ssize_t xor_read (int f, void* p, zzip_size_t l)
       {
           zzip_size_t r = read(f, p, l);
-         zzip_size_t i;     char* q = p;
+         zzip_size_t x;  char* q = p;
           for (x=0; x &lt; r; x++) q[x] ^= xor_value;
           return r;
       }
index 9bf4ca99920a5f9324c4ce68ad2d585f7f042285..16491a8c6b4e670387467b69cbcdac21ea151d19 100644 (file)
@@ -1,7 +1,7 @@
 %define lib   lib010
 Summary:      ZZipLib - libZ-based ZIP-access Library
 Name:         zziplib
-Version:      0.13.36
+Version:      0.13.37
 Release:      1mdk
 Serial:       1
 Copyright:    LGPL