home *** CD-ROM | disk | FTP | other *** search
/ PCMania 10 / Pcmania_Ep2_10_CD-01.iso / ARTICULOS / tecnologia / PUFFER.ZIP / SPECS.TX_ / SPECS.TX
Encoding:
Text File  |  1996-02-13  |  11.3 KB  |  291 lines

  1.  
  2.                           Puffer (tm) 2.0
  3.                  File Formats and Security Protocols
  4.                          (13 February 1996)
  5.  
  6.  
  7. File Formats
  8. ------------
  9.  
  10. Puffer is designed to run on personal computers using the Windows 3.1 
  11. and compatible operating systems.
  12.  
  13. Puffer supports three output formats: Binary, ASCII, and Self-
  14. Extracting.  Each type can hold up to 1000 encrypted files.  All the 
  15. files in a single archive are encrypted with the same key.  Files from 
  16. the binary and ASCII formats can be decrypted independently.
  17.  
  18. Binary Format
  19. -------------
  20.  
  21. The default file extension for a binary file is ".PUF".  Binary PUF files
  22. begin with a file header, shown here in Pascal format:
  23.  
  24. file_header: record
  25.                id: array[1..4] of char;
  26.                method: byte;
  27.              end;
  28.  
  29. The id field is always 'PUFX'.  The method field is one of these values:
  30.  
  31. method  format
  32. ------  ---------------------------------------
  33.   3     Symmetric encryption, 40-bit PC1
  34.   4     Symmetric encryption, 160-bit Blowfish
  35.  
  36. Note: Version 1.0 binary files (now obsolete) used an id of 'PUF8' and 
  37. had method numbers 1 and 2.
  38.  
  39. Method 4, using the Blowfish algorithm, is not available in the
  40. exportable versions of Puffer.
  41.  
  42. Global Header
  43. -------------
  44.  
  45. A global header follows the file header with this structure:
  46.  
  47. gheader: record
  48.            nfiles: word;
  49.            encrypt_headers: boolean;
  50.            case_sensitive_pw: boolean;
  51.            pw_salt: array[1..5] of byte;
  52.            giv: array[1..8] of byte;
  53.            pw_check: word;
  54.          end;
  55.  
  56. Note: boolean values are 1 byte in length with values of 0=false and 
  57. 1=true.  Words are 16-bit unsigned integers.  All multi-byte integers 
  58. are stored in little-endian (least significant byte first) format.
  59.  
  60. nfiles = the number of files in the archive from 1 to 1000.
  61. encrypt_headers = true if the local headers are encrypted.
  62. case_sensitive_pw = true if the case sensitive password option is set.
  63. pw_salt = 5 bytes of random password salt.
  64. giv = 8 bytes of random data for a global initialization vector (IV).
  65. pw_check = 2 bytes of ciphertext used for password confirmation.
  66.  
  67. Local Headers
  68. -------------
  69.  
  70. Immediately preceding each file in the archive is a local header.  If 
  71. encrypt_headers=true in the global header, then each local header is 
  72. preceded by a header initialization vector:
  73.  
  74. hiv: array[1..8] of byte;
  75.  
  76. hiv = 8 bytes of random data.
  77.  
  78. Next follows:
  79.  
  80. hlength: word;
  81.  
  82. hlength is the length of the local header in bytes.  This number varies 
  83. because the length of the plaintext file name can vary.
  84.  
  85. Next follows the local header in this structure:
  86.  
  87. lheader: record
  88.            id: array[1..3] of char;
  89.            compression: byte;
  90.            size: longint;
  91.            csize: longint;
  92.            time: longint;
  93.            crc32: longint;
  94.            next: longint;
  95.            ptname: string;
  96.          end;
  97.  
  98. id = 'PUF'
  99. compression = 0 for no compression, 1 for LZ77 compression.
  100. size = length of original plaintext file in bytes.
  101. csize = compressed length of plaintext file.  Will be the same as size 
  102. if compression=0.
  103. time = plaintext timestamp in MS-DOS date/time format.
  104. crc32 = 32-bit CRC value of original plaintext file.
  105. next = absolute offset in PUF file for next file header in archive.
  106. ptname = plaintext file name.  The first byte contains the length of the 
  107. string.
  108.  
  109. Following the local header is the file initialization vector:
  110.  
  111. fiv: array[1..8] of byte;
  112.  
  113. fiv is 8 bytes of random data.
  114.  
  115. Following the fiv is the encrypted (and possibly compressed) file using 
  116. either the 40-bit PC1 or the 160-bit Blowfish algorithms.  The encryption
  117. key is the user's pass-phrase, salted and hashed with SHA-1.  The file is
  118. padded with random bytes (after compression) if necessary so that its
  119. length is an even multiple of 8.
  120.  
  121. ASCII Format
  122. ------------
  123.  
  124. The default extension for an ASCII file is also ".PUF".  When ASCII PUF 
  125. files are split to facilitate e-mail delivery, the extensions are 
  126. ".P01", ".P02", ".P03", etc.  ASCII PUF files are similar to Binary PUF 
  127. files except all the binary data is xxencoded to text format so that 
  128. they can be safely mailed across the Internet.  Also, the lheader.next 
  129. field contains the data line number (1-based) of the next file in the 
  130. archive rather than its byte offset.  Each line in an ASCII PUF file is 
  131. terminated by a carriage return and line feed character (#13#10).  Some 
  132. e-mail systems will strip out the carriage returns.  Therefore, Puffer 
  133. will look for line feed characters when decrypting and will ignore 
  134. carriage returns.
  135.  
  136. ASCII files begin with a file header line of:
  137.  
  138. Begin PUFXnn
  139.  
  140. where nn is the encryption method:
  141.  
  142. method  format
  143. ------  ---------------------------------------
  144.   03     Symmetric encryption, 40-bit PC1
  145.   04     Symmetric encryption, 160-bit Blowfish
  146.  
  147. Any text before the file header line is ignored during the decryption 
  148. process.  The header line must appear in the first 100 lines, however.
  149.  
  150. Following the file header line is the same data that follows the file 
  151. header in Binary PUF files except the data is encoded in the following 
  152. manner:
  153.  
  154. Every three binary bytes are converted to four text bytes by splitting 
  155. the original 24 bits into four pieces of 6 bits each.  These 6-bit 
  156. values correspond to an offset into this array:
  157.  
  158. const
  159.   xxcode: array[0..63] of char='+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'+
  160.                                            'abcdefghijklmnopqrstuvwxyz';
  161.  
  162. Each data line in the ASCII file contains 64 characters plus a cr/lf 
  163. representing 48 bytes of ciphertext.
  164.  
  165. The output lines are flushed at certain points of the file.  Flushing 
  166. the line means appending random data until a complete 64-character line 
  167. is ready for output.  Flushing occurs once after all the global header 
  168. information is output.  It also occurs after the local header is output 
  169. for each file and after the last byte of ciphertext for each file is 
  170. output.
  171.  
  172. Before the file is closed, a footer line is appended to the file:
  173.  
  174. End Puf
  175.  
  176. Any data past the footer line is ignored during decryption.  When ASCII 
  177. files are split, each split file also contains a header and footer line 
  178. except the "Xnn" suffix is only placed in the first ".P01" split file.
  179.  
  180. Self-Extracting Format
  181. ----------------------
  182.  
  183. Self-Extracting files are DOS executables with an extension of ".EXE".  
  184. They are identical to Binary PUF files except they contain header code 
  185. that prompts the user for a password and then decrypts the data stored 
  186. past the header code.
  187.  
  188. Blowfish Algorithm
  189. ------------------
  190.  
  191. Due to U.S. export restrictions, the Blowfish option is not available in 
  192. the shareware or the international versions of Puffer.
  193.  
  194. Blowfish is a fast, unpatented variable size-key block encryption 
  195. algorithm invented by Bruce Schneier, security consultant and author of 
  196. "Applied Cryptography" (Wiley, ISBN 0-471-11709-9).  
  197.  
  198. The Blowfish algorithm used in Puffer follows the original specification 
  199. as described in the April 1994 edition of Dr. Dobb's Journal and the 
  200. second edition of "Applied Cryptography" with two exceptions:
  201.  
  202. 1. The data blocks are processed in little-endian (least significant 
  203. byte first) format, the natural state for Intel-based processors.
  204.  
  205. 2. The p-array and s-boxes are initialized with the output of a linear 
  206. congruential random number generator (RNG) instead of the hexadecimal 
  207. digits of pi.  The RNG used is based on the formula: rng(i) = rng(i-1) * 
  208. 134775813 + 1, where rng is a 32-bit integer with an initial value of 
  209. ffffffff hex.
  210.  
  211. Puffer runs Blowfish with a 160-bit key in Cipher Block Chaining (CBC) 
  212. mode.  An 8-byte initialization vector (IV) is generated from the 
  213. compiler's (Borland Delphi) pseudo random number generator (PRNG).  The 
  214. PRNG is seeded with data from the system clock at startup to ensure a 
  215. unique IV for each file.
  216.  
  217. Puffer Cipher 1 (PC1) Algorithm
  218. -------------------------------
  219.  
  220. PC1 is a very fast, unpatented variable size-key stream cipher that 
  221. produces an identical key stream as RSA Data Security Inc's RC4 
  222. algorithm.  The algorithm follows the RC4 specification as described by 
  223. Schneier in "Applied Cryptography".
  224.  
  225. Puffer runs PC1 with an 80-bit key consisting of 40 bits of secret key 
  226. material and 40 bits of salt provided by the compiler's PRNG.
  227.  
  228. Key Generation
  229. --------------
  230.  
  231. Encryption keys are generated from the user's password.  Passwords can be
  232. up to 50 characters in length using any character available from the
  233. keyboard.  The user has the option of setting a "case sensitivity" flag
  234. at run-time which is saved in the global header of the ciphertext file.
  235. If this flag is disabled, the password is converted to uppercase.
  236.  
  237. To discourage pre-computed dictionary attacks, five bytes of random salt 
  238. from the compiler's PRNG are appended to the password and then run 
  239. through the Secure Hash Algorithm (SHA-1) to produce a 160-bit hash 
  240. value.  The SHA-1 algorithm conforms to FIPS PUB 180-1 specification as 
  241. published by the National Institute of Standards and Technology (NIST).
  242. The password salt is saved in the global header of the ciphertext file.
  243.  
  244. For the Blowfish algorithm, the entire 160-bit hash is used as the 
  245. encryption key.  For the PC1 algorithm, only the 40 least significant 
  246. bits are used as the encryption key and the remaining 120 bits are 
  247. discarded.
  248.  
  249. Key Confirmation
  250. ----------------
  251.  
  252. Puffer has a key confirmation feature that will determine if the user 
  253. enters an incorrect password during decryption.  A 64-bit IV is filled 
  254. with output from the compiler's PRNG.  
  255.  
  256. For the Blowfish algorithm, the IV block is encrypted with the 
  257. encryption key and the least significant 16 bits of ciphertext output is 
  258. saved in a password check variable.  
  259.  
  260. For the PC1 algorithm, the first 40 bits of the IV are used as salt for 
  261. the key.  The other 24 bits of the IV are not used.  The 40-bit 
  262. encryption key is appended to the salt resulting in an 80-bit key.  The 
  263. PC1 engine is then cycled 10,000 times with results discarded.  Two more 
  264. cycles are made and the 16-bit result is saved in the password check 
  265. variable.  
  266.  
  267. Both the IV and the password check variable are saved in the ciphertext 
  268. file's global header.  During decryption, the IV is retrieved from the 
  269. header and the process is repeated.  If the password check matches the 
  270. stored valued then the password is assumed to be correct and the 
  271. decryption process continues.  
  272.  
  273. The global IV/salt is only used for the password check.  Each file 
  274. encrypted in the archive uses a unique IV/salt.  If the encrypted 
  275. headers option is used, the local headers are encrypted with unique 
  276. IV/salts, also.
  277.  
  278. File Compression
  279. ----------------
  280.  
  281. Puffer uses LZ77, an unpatented sliding dictionary-based algorithm for 
  282. file compression.  Puffer's implementation includes a 4096-byte sliding 
  283. window with an 18 byte look-ahead buffer.  The output format consists of 
  284. a series of 8-bit flags followed by 8 output tokens.  The flag bits are 
  285. read from right to left.  A flag bit of 1 means the next output token is 
  286. a standalone byte ready for output.  A flag bit of 0 means the next 
  287. output token is a 16-bit offset/length combination.  The first 12 bits 
  288. (0..4095) represent the offset into the sliding window and the remaining 
  289. 4 bits (0..15) represent the length (3..18) of the string to output.
  290.  
  291.