home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / HPACK78S.ZIP / docs / hpackext.doc < prev    next >
Text File  |  1992-11-23  |  21KB  |  415 lines

  1.  
  2.                          -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  3.   Ver:0.78a0             HPACK - Extended Documentation            1 Sept 1992
  4.                          -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  5.  
  6.    The following represents the extended documentation for the HPACK archiver.
  7.  It  contains  information not generally needed in the day-to-day use of HPACK
  8.  and is intended mainly for the more experienced user,  covering  among  other
  9.  things  HPACK  return  codes,  more  details on the encryption system used in
  10.  HPACK, and details on the availability of HPACK for other systems.
  11.  
  12.  
  13. More on Archive Comments:
  14. -------------------------
  15.  
  16.    To make plain text archive  comments  portable  across  multiple  operating
  17.  systems  it  is  recommended that they not be hardcoded for some fixed screen
  18.  size (such as 80 x 24) but instead use HPACK's built-in  formatting  commands
  19.  as  part  of  the  text.   HPACK  will  then  format  the text of the comment
  20.  according to these commands when  displaying  it.   The  formatting  commands
  21.  available are:
  22.  
  23.  Text type control:
  24.  
  25.  .no = normal text                      .iv = inverse text
  26.  .ul = underline text                   .fl = flashing text
  27.  .bo = boldface text                    .it = italics
  28.  
  29.  Text display control:
  30.  
  31.  .ce = center following text            .fi = justify following text
  32.  .nf = stop justifying text
  33.  
  34.  Miscellaneous control options:
  35.  
  36.  .bp = page break (new page)            .br = line break
  37.  .in xx = left margin at xx             .rm xx = right margin at ( max - xx )
  38.  .ti = temporary indent                 .ew = end woof
  39.  
  40.  Note  that  some  of the text types may not be available on some systems.  By
  41.  default HPACK will wrap words at the end of the screen.  Justification of the
  42.  output text (the right margins of the text being made even) can be turned  on
  43.  with  the  .fi  command  and off with the .nf command.  When a .nf command is
  44.  encountered, the current text is printed before the .nf command takes effect.
  45.  This is known as a break, and can be explicitly forced using the .br command.
  46.  Page breaks can be forced with the .bp command.  The left and  right  margins
  47.  are controlled by the .in and .rm commands respectively.  The .ti command can
  48.  be  used to produce a temporary indent which sets the indent position for one
  49.  line only.  This can be used to produce hanging indents:
  50.  
  51.  .in 5
  52.  .ti -5
  53.  
  54.  will produce output of the form:
  55.  
  56.  The  .in,  .rm,  and  .ti  commands  can also take relative values instead of
  57.       absolute ones; thus they can be used to specify a change in the  current
  58.       value.   This is illustrated in the above example, where the left margin
  59.       is set to 5, and a temporary indent of 5  places  to  the  left  of  the
  60.       margin is set for the next line.  If the value is given merely as is, it
  61.       is  treated  as an absolute value; if it is given as +value or -value it
  62.       is treated as a change in the existing  value  instead  of  an  absolute
  63.       setting.
  64.  
  65.  An example of text with format control codes is:
  66.  
  67.  .ce
  68.  This is a sample of formatted text
  69.  .br
  70.  .in 5
  71.  .rm 5
  72.  .fi
  73.  .ti 2
  74.    This sample of text shows how to use HPACK's build-in formatting
  75.  commands.  Since the text is not preformatted but is reformatted by HPACK
  76.  according to the width of the screen the text is being displayed
  77.  on, there are no problems with lines going off the screen, text only
  78.  covering half the screen, or the system being unable to display
  79.  half the character set in use.
  80.  .br
  81.  .br
  82.  .ce
  83.  --------
  84.  
  85.  After formatting for an 80-column screen this comes out as:
  86.  
  87.                       This is a sample of formatted text
  88.  
  89.       This  sample  of  text  shows  how to use HPACK's build-in formatting
  90.     commands.  Since the text is not preformatted  but  is  reformatted  by
  91.     HPACK  according to the width of the screen the text is being displayed
  92.     on,  there  are  no problems with lines going off the screen, text only
  93.     covering half the screen, or the system being unable  to  display  half
  94.     the character set in use.
  95.  
  96.                                    --------
  97.  
  98.  After formatting for a 40-column screen this comes out as:
  99.  
  100.      This is a sample of formatted
  101.                  text
  102.  
  103.       This  sample  of  text  shows
  104.     how  to  use  HPACK's  build-in
  105.     formatting commands.  Since the
  106.     text is  not  preformatted  but
  107.     is    reformatted    by   HPACK
  108.     according to the width  of  the
  109.     screen   the   text   is  being
  110.     displayed  on,  there  are   no
  111.     problems  with  lines going off
  112.     the screen, text only  covering
  113.     half  the screen, or the system
  114.     being unable  to  display  half
  115.     the character set in use.
  116.  
  117.                --------
  118.  
  119.  
  120. HPACK Return Codes:
  121. -------------------
  122.  
  123.    If an error occurs during archive processing, HPACK will return one of four
  124.  sets of return values.  These are:
  125.  
  126.    0         No error
  127.    001-099   Severe error
  128.    100-199   Error
  129.    201-255   Warning
  130.  
  131.  The error types can thus be quickly grouped into one  of  three  classes  and
  132.  handled appropriately.  The actual values of these error return values are:
  133.  
  134.      Type:             Value:      Description:
  135.      -----             ------      ------------
  136.  
  137.    EXIT_OK               0         No error
  138.  
  139.    EXIT_INT_ERR          1         Internal error
  140.    EXIT_NO_MEM           2         Out of memory
  141.    EXIT_NO_DISK          3         Out of disk space
  142.    EXIT_NO_ARCH          4         Can't open archive file
  143.    EXIT_NO_SCRIPT        5         Can't open script file
  144.    EXIT_NO_PATH          6         Can't find path
  145.    EXIT_NO_BASE          7         Can't access base directory
  146.    EXIT_NO_MKDIR         8         Can't create directory
  147.    EXIT_BREAK            9         User interrupt
  148.    EXIT_FILE_ERR        10         Unknown file error
  149.    EXIT_DIR_CORRUPT     11         Archive directory corrupted
  150.  
  151.    EXIT_LONG_PATH      100         Path too long
  152.    EXIT_NO_OVERRIDE    101         Can't override base path
  153.    EXIT_NEST           102         Directories nested too deeply
  154.    EXIT_SCRIPT_ERR     103         Error(s) in script file
  155.    EXIT_NOT_ARCH       104         Not an HPACK archive
  156.    EXIT_BAD_KEYFILE    105         Bad keyfile
  157.    EXIT_NOTHING        106         Nothing to do
  158.    EXIT_COMMAND        107         Unknown command
  159.    EXIT_OPTION         108         Unknown option
  160.  
  161.    EXIT_PASS           200         Differing or incorrect password(s)
  162.    EXIT_CHANGE         201         Bad attempt to change archive (eg attempt
  163.                                     to change a block-encrypted archive)
  164.    EXIT_NOLONG         202         Long arg.format not supported
  165.    EXIT_BADWILD        203         Bad wildcard format or inappropriate use of
  166.                                     wildcards
  167.    EXIT_SECURITY       204         General security/encryption error
  168.    EXIT_NOCRYPT        205         Cannot process encrypted archive
  169.  
  170.  Under  VMS  return  values are handled in a somewhat different manner.  HPACK
  171.  will return the error code as above in the facility number field, as well  as
  172.  a  status  of  success,  warning, error, or severe error corresponding to the
  173.  above categories of error.
  174.  
  175.  For  more  details on the error types, see the section "HPACK Error Messages"
  176.  in the main HPACK documentation HPACK.DOC.
  177.  
  178.  
  179. General Archive Information:
  180. ----------------------------
  181.  
  182.    HPACK uses a central directory  structure  contained  at  the  end  of  the
  183.  archive, with the option of including directory information headers with each
  184.  archived file for improved error recovery.  All data stored in HPACK archives
  185.  is  left  unchanged  -  there  is  no  need  for any truncation of filenames,
  186.  translation of file attributes, or omission of OS-dependant information  from
  187.  a  file  in  order  to  archive  it.   All  information about a file (such as
  188.  attributes, file datestamps, attached comments, icons, graphics  information,
  189.  security  information,  user-defined  file  attributes, and so on), is stored
  190.  with the file and is translated on extraction if necessary.  HPACK includes a
  191.  fairly complete set of internal filesystem management routines  which  handle
  192.  operations  such  as  creating directories, adding and deleting files to/from
  193.  directories, and so on.  Filenames and directory  names  of  any  length  and
  194.  containing   any   characters   are   supported,  as  are  special  operating
  195.  system-dependant files such as links, volume labels/ID's,  and  so  on.   All
  196.  versions of HPACK will handle all the extra information which can be added to
  197.  a  file, but due to differences between various operating systems some of the
  198.  information may not be used on some systems (for example  MSDOS,  a  somewhat
  199.  complex  bootstrap loader used on many 80x86 systems, will ignore most of the
  200.  extra information it finds in an archive).
  201.  
  202.  
  203. HPACK Data Authentication/Encryption:
  204. -------------------------------------
  205.  
  206.    HPACK  allows  files  to  be  encrypted using a variety of either public or
  207.  conventional-key cryptosystems.   At  the  moment  only  the  RSA  public-key
  208.  cryptosystem  is  used  for data authentication, and the MDC conventional-key
  209.  and RSA public-key cryptosystems are used for file or archive encryption. The
  210.  RSA key format used in HPACK is compatible with  version  2.0  or  higher  of
  211.  Philip Zimmermann's excellent PGP encryption package.
  212.  
  213.    In public-key encryption, each user choses a pair of  keys,  a  public  key
  214.  (which  as  the  name suggests is made available publicly), and a private key
  215.  which only the user knows.  This allows a complete stranger to use the public
  216.  key  to encrypt a message to the user which only the user can decrypt, unlike
  217.  conventional-key encryption which requires that the encryption key  be  first
  218.  somehow communicated to the user.
  219.  
  220.    HPACK  uses  the  RSA  Data  Security Inc.  MD5 message digest algorithm to
  221.  generate a unique 'fingerprint'  of  the  data  to  be  authenticated.   This
  222.  fingerprint consists of a cryptographically strong 128-bit one-way hash value
  223.  which  it is computationally infeasible to invert.  This is a bit like a CRC,
  224.  but unlike a CRC it is *very* difficult for an attacker to bypass:  Not  only
  225.  is  the  MD5  function  specifically designed for this purpose (which the CRC
  226.  function is not), but it is also generally agreed that a  message  digest  of
  227.  this sort should be a minimum of 128 bits long: A 32-bit CRC will take around
  228.  65,000  attempts  to  defeat  using  a so-called 'birthday attack', a 128-bit
  229.  message digest will take in the order of 20,000,000,000,000,000,000  attempts
  230.  to  break  (in  fact CRC's are even easier to defeat than that - it is a very
  231.  simple matter to generate a message with an arbitrary CRC value, making CRC's
  232.  worthless for detecting deliberate manipulation of data).   MD5  has  so  far
  233.  resisted  attack, although a much-reduced form of MD5 was broken at Eurocrypt
  234.  '92 in 2^13 attempts  with  a  chosen  plaintext  attack  using  differential
  235.  cryptanalysis.
  236.  
  237.    This message digest is then signed  using  the  RSA  public-key  encryption
  238.  algorithm,  with  the  option  of  using  a commercial-grade (512 bits or 155
  239.  digits) or military-grade (1024 bits or 310 digits) key (HPACK will  in  fact
  240.  use  keys  of  any length up to 1200 bits or 360 digits, the two values given
  241.  above are simply the default key lengths used by PGP 2.0).  The exact size of
  242.  the key to use depends on how long the secret must be kept  secure,  and  how
  243.  large  an amount of resources your opponent is prepared to commit to breaking
  244.  (factoring) the key.  In "Public-Key  Cryptography,  State  of  the  Art  and
  245.  Future  Directions",  a  report from a workshop involving the world's leading
  246.  experts in the field, the authors state:
  247.  
  248.  "For most applications a modulus size of 1024 bits for RSA should  achieve  a
  249.   sufficient  level of security for 'tactical' secrets for the next ten years.
  250.   This is for long term secrecy purposes, for short term authenticity purposes
  251.   512 bits might suffice in this century".
  252.  
  253.  RSA Data Security's frequently-asked-question list contains the statement:
  254.  
  255.  "Rivest  estimates  that a 512-bit modulus, currently the most common modulus
  256.   length,  can  be  factored  with  an  $8.2 million effort today, less in the
  257.   future.   Those with extremely valuable data (or large potential damage from
  258.   digital forgery) should use a modulus of, say 700 or 800 bits in length.   A
  259.   certifying authority should use a modulus of 1000 bits or more, because  the
  260.   validity  of  many  other  key  pairs depends on the security of one central
  261.   key."
  262.  
  263.  The $8.2 million figure is actually somewhat optimistic, in reality it should
  264.  be somewhat more difficult than that.  For an example from real life, in 1977
  265.  RSA Data Security published a  129-digit  (or  430-bit)  number  which  is  a
  266.  product of two primes, and offered a $100 prize to the first person to factor
  267.  it.  In spite of fifteen years of work on it, noone has done so (at least not
  268.  publicly).
  269.  
  270.  Finally, the US government allows export of RSA encryption code provided  the
  271.  key  size  is  limited  to less than 512 bits.  You are left to draw your own
  272.  conclusions from this fact.
  273.  
  274.    The encryption routine used by HPACK  employs  the  MDC  algorithm  run  in
  275.  cipher  feedback  mode,  a  128-bit block cipher derived from the MD5 message
  276.  digest algorithm with a key size of up to 2048 bits (though HPACK limits this
  277.  to 80 ASCII characters or around 560 bits of effective key information). This
  278.  algorithm  has  been  designed  to  make  encryption  relatively   fast   and
  279.  brute-force  attacks  slow and painful.  Once the initial password management
  280.  is done, en/decryption proceeds at  a  fairly  rapid  pace,  however  if  the
  281.  password  is  changed  constantly (as it would be for a brute-force attack) a
  282.  lot of time is spent in password management after each change.   MDC  has  so
  283.  far  not been seriouly attacked, and it is not known whether generalizing the
  284.  MD5 attack to MDC is possible.
  285.  
  286.    Due to the layout of an HPACK archive all encrypted data blocks begin  with
  287.  raw  compressed  data,  greatly  reducing  the  chances  of a so-called known
  288.  plaintext attack (in which the attacker knows, or  can  guess,  some  of  the
  289.  unencrypted  data).   HPACK  overwrites any sensitive data in memory once the
  290.  encryption/decryption/authentication  process  has  completed,  and  contains
  291.  extensive  error trapping and handling to ensure that even if a serious error
  292.  were to occur, the program stack and data areas would be wiped on exit.
  293.  
  294.    The  code  for  the encryption and authentication routines used in HPACK is
  295.  freely available in source form  (see  the  next  section,  "Verification  of
  296.  HPACK's  Encryption/Authentication").   In this way it is possible to compile
  297.  the code and independantly verify that HPACK  is  indeed  using  the  correct
  298.  algorithms  and  encryption/authentication techniques, and thus eliminate any
  299.  fears of trapdoors hidden in the code/encrypted data.
  300.  
  301.  
  302. Verification of HPACK's Encryption/Authentication:
  303. --------------------------------------------------
  304.  
  305.    The encryption and authentication code used by HPACK can be freely examined
  306.  by anyone wishing to reassure themselves of its security.   The  MD5  message
  307.  digest algorithm is described in the following source:
  308.  
  309.    Internet  RFC 1321, "The MD5 Message-Digest Algorithm", Internet Activities
  310.      Board, 1992.  Obtainable from ftp.nisc.sri.com in the rfc directory.
  311.  
  312.  The mode of operation of the MDC cipher is described in the following federal
  313.  and international standards:
  314.  
  315.    National Bureau of Standards FIPS publication 81: "DES Modes of Operation",
  316.      December 1980.
  317.  
  318.    ISO/IEC 10116:1991 "Information technology - Modes  of  operations  for  an
  319.      n-bit block cipher algorithm", 1991.
  320.  
  321.    ISO 10126-2:1991 "Banking - Procedures for message encipherment (wholesale)
  322.      - Part 2", 1991
  323.  
  324.  The RSA algorithm is described in many texts, among them:
  325.  
  326.    Brassard,  G.  "Modern  Cryptology",  Lecture  Notes  in  Computer  Science
  327.      vol.325, 1988.
  328.  
  329.    Rivest,  R.,  Shamir,  A.,  and Adleman, L. "A method for obtaining digital
  330.      signatures and public-key cryptosystems", CACM vol.21, no.2, Feb.1978
  331.  
  332.    RSA Data Security Inc. "PKCS  #1:  RSA  Encryption  Standard",  June  1991,
  333.      Version 1.4.
  334.  
  335.  It is also a part of the following standards:
  336.  
  337.    AS 2805.6.5.3 "Electronic Funds Transfer - Key Management", 1990.
  338.  
  339.    ISO  9796:1988  "Information  technology,  security  techniques  -  Digital
  340.      signature scheme giving message recovery", 1988
  341.  
  342.    RSA Data Security Inc. "PKCS  #1:  RSA  Encryption  Standard",  June  1991,
  343.      Version 1.4.
  344.  
  345.  In all cases the above algorithms can be derived from the relevant standards,
  346.  and all code used in  HPACK  checked  against  official  implementations  for
  347.  accuracy.
  348.  
  349.  
  350. An Analysis of HPACK Encryption Security:
  351. -----------------------------------------
  352.  
  353.    Much has been made recently of the dangerously insecure encryption  methods
  354.  used by some archivers.  HPACK goes to great lengths to try and make breaking
  355.  of  its  encryption system as difficult as possible.  An analysis of possible
  356.  weak points in the encryption is given below:
  357.  
  358.  Encryption of individual files:
  359.    Slow  and  reasonably safe.  Since a different 64-bit initialization vector
  360.    is used to rekey the MDC algorithm for each file, performing a  brute-force
  361.    attack  on  a  collection of files would involve rekeying the algorithm for
  362.    each file being attacked.  Very difficult to attack unless the plaintext is
  363.    known.
  364.  
  365.  Encryption of the entire archive:
  366.    Faster  than  encrypting  individual  files,  and  more secure for the data
  367.    portion of the archive since only the start of the first file is  available
  368.    to  be  attacked.   However  the  encryption  of  the directory information
  369.    provides partially-known plaintext in the form of  the  directory  headers.
  370.    The  information content is probably enough to allow at least a preliminary
  371.    form of automatic checking.
  372.  
  373.  Encryption of the entire archive with a secondary password:
  374.    About the same speed as encrypting the entire archive, and the most  secure
  375.    of  the  encryption  schemes.   Even if the encryption for the directory is
  376.    broken, the main data is still protected by a second  password,  and  again
  377.    only the start of the first file is available to be attacked.
  378.  
  379.  There  are two possible methods of attack, either a known-plaintext attack on
  380.  the archive data, or a partially-known-plaintext attack on the directory data.
  381.  If  the  uncompressed,  unencrypted  contents of the archive are known, HPACK
  382.  can be used to compress them without encryption and provide  plaintext  which
  383.  can  be  used  in  a  brute-force  or dictionary-based attack.  Similary, the
  384.  archive directory contains a relatively fixed format which can be  parsed  as
  385.  part of a brute-force attack to narrow down the search range considerably.
  386.  
  387.  Using  public-key  encryption  offers  more security against dictionary-based
  388.  cracking programs since the hybrid method employed by HPACK  uses  a  128-bit
  389.  binary  MDC key encrypted with an RSA public key.  Breaking this system would
  390.  entail a brute-force search on the entire 128-bit key space, a total of 1.7 x
  391.  10^38 keys assuming a match is found after half the keys have been scanned.
  392.  
  393.  
  394. Availability of HPACK for Other Systems:
  395. ----------------------------------------
  396.  
  397.    HPACK  is  currently  available in Amiga, Archimedes, Atari ST, MSDOS, OS/2
  398.  (16 and 32 bit), Unix,  and  Windows  versions,  with  other  ports  becoming
  399.  available as access to the relevant hardware and software permits.  If anyone
  400.  wants  a version for their particular system, they are welcome to try to port
  401.  it across.  The code consists of around 500K of mostly ANSI C code with  some
  402.  low-level  system  I/O  thrown in, and a knowledge of assembly language being
  403.  useful  on  low-end  systems  to  speed  up a few of the core compression and
  404.  encryption  routines.   Anyone  interested  in porting HPACK to any system is
  405.  urged to contact the author...
  406.  
  407.  All  code  contained  in  HPACK,  with  the  exception of the RSA encryption/
  408.  decryption routines and the MD5 message  digest  routines,  is  entirely  the
  409.  result  of original research and is not patented, nor do I have any intention
  410.  of ever patenting it.  The only code in HPACK which falls under any  sort  of
  411.  restrictions  is  the  RSA code.  MD5 has been placed in the public domain by
  412.  its  authors.   Since  HPACK originates from outside the US and since I don't
  413.  believe in crippleware, there is no "restricted" or "crippled" version - full
  414.  encryption and authentication capabilities are available to everyone.
  415.