home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / UTILITIE / TANGLE30.ZIP / TANGLE.DOC < prev    next >
Text File  |  1990-05-08  |  10KB  |  144 lines

  1.                          User manual for Tangle 3.0
  2.                          --------------------------
  3.  
  4. This program supercedes Crypt 2.0, a name change has  been  adopted  to  avoid
  5. confusion with the Unix password encryption function (one way trapdoor).  This
  6. program does not support the encryption algorithm of  Crypt  2.0  however  the
  7. name  change should make it somewhat easier to introduce version 3 without too
  8. much confusion and gradually convert the encrypted files.
  9.  
  10. The source code "tangle.c" can be  used  to  produce  two   executable   files
  11. which  are   assumed   to  be  called  "tangle"  and "untangle" by the program
  12. itself.  The source is in Turbo C (Trademark) and can be  compiled  with   the
  13. tiny   memory model.   Since  use  is  made  of system dependent functions for
  14. obtaining the input file size for tangle, the program is not portable as is.
  15.  
  16. To use tangle and untangle simply type the command name followed by the source
  17. and  destination  file  names.  You will be prompted for a password and status
  18. information is produced.  The password is  echoed  since  for  the  length  of
  19. password  intended it would be too easy to mess it up.  The password should be
  20. a long sequence of characters such as a sentence with some  strange  words  or
  21. characters  in  it.  The maximum length is the same as the maximum block array
  22. width (100 as supplied).  The password is scrolled off the  screen  after  the
  23. line  is  terminated  and  an  error  checking  code  is displayed.  The error
  24. checking code number reveals some  information  about  the  password  but  not
  25. enough to worry about.  The purpose of the error checking code is to alert the
  26. user to an incorrectly typed password, since it is a function of the  password
  27. it should always be the same when the same password is used.
  28.  
  29. The algorithm used was inspired by the Rubik's cube.  The core algorithm works
  30. as follows:
  31.  
  32.    First a fixed block size is determined which is the product of two numbers
  33.    "wide" and "high".  The data is processed in a two dimensional array with
  34.    these dimensions one block at a time.  If the last block cannot be entirely
  35.    filled it is padded with junk characters.  The password is used to
  36.    determine a key on a column per character basis.  The key value for each
  37.    column (modulo the height) is the amount this column is shifted down.  The
  38.    part which emerges from the bottom is inserted into the top (i.e. a cyclic
  39.    shift).  The rows are similarly shifted but using the values 1,2,3,...,etc.
  40.    This two stage process which is called a shuffle is repeated a fixed number
  41.    of times.  The result is a permutation of the array determined by the
  42.    password alone.
  43.  
  44. This algorithm produces a pure permutation of the data which has the advantage
  45. of  not  changing  the character set but weaknesses that cannot be ignored for
  46. any serious use.  A number of modifications to the algorithm produce one which
  47. in  the  author's opinion is secure against a chosen plaintext attack and if a
  48. large enough good password is used then immune to brute force attack  for  the
  49. conceivable future.
  50.  
  51. The first modification is to change the nature of the algorithm so that it  is
  52. no  longer  a pure permutation.  The strategy adopted is to include a phase in
  53. each shuffle which replaces each second line by the  bitwise  exclusive-or  of
  54. itself  and  the  line  before.  This means that the history of the encryption
  55. process, which characters happen to  be  located  above  each  other  in  each
  56. shuffle, affects the final outcome.  An analogy is that of shuffling a pack of
  57. cards on which the ink is still wet as compared to  a  normal  shuffle.   With
  58. this  modification  the  algorithm  is  strong against known plaintext attack.
  59. Secure that is provided the known text is not a simple pattern (e.g. all space
  60. characters).   To secure against simple patterned source a simple substitution
  61. of the block is performed after the first  shuffle.   This  eliminates  simple
  62. patterns  and  also  prevents  a  simple  chosen plaintext attack strategy the
  63. author discovered which applies to Crypt 2.0 (Tangle's predecessor).
  64.  
  65. If the input file is smaller than 450 bytes it is padded to  this  size.   The
  66. block  size  is  determined  according  to  the size of the input file and the
  67. minimum size.  For files smaller than 10 Kbyte there will be only  one  block.
  68. Each  block  has two dimensions - wide and high.  The last block usually needs
  69. some padding which is chosen from whatever happens to be in the array already.
  70. The  junk  is  selected  randomly  though the random number generator has only
  71. about 30,000 possible seeds. The password or key is a string supplied  by  the
  72. user,  this  is extended to the maximum length (100) by repetition however the
  73. repeated strings are modified  by  exclusive-or  '152'  to  help  extract  the
  74. maximum  information  from the supplied string (since later only the remainder
  75. mod high will be utilised).
  76.  
  77. The security of the system is highly dependent on the choice of  password  and
  78. particularly  its  length.   Passwords  which  are  too  short  are  rejected.
  79. Naturally  the  password  is  not   recorded  permanently   anywhere   by  the
  80. encryption  program  and  version  3.0  erases the password from memory before
  81. exit.  The easiest way to choose a good password is to use  a  whole  sentence
  82. (spaces and punctuation are  allowed) with  some  strange  characters  in  it.
  83. It is relatively easy for a cryptanalyst to try out all short  sentences  with
  84. words  from  a  standard  dictionary.  Brute  force  cracking of an  encrypted
  85. file with  n blocks of block size b, a password of p units chosen from  a  set
  86. of  q  values  and  with  s  shuffles  per  block  requires  O(s  * b * (q^p))
  87. operations.  Obviously increasing q and/or p pays great dividends.  For a pure
  88. permutation  it  would be possible to try all b!  rearrangements of  a  block.
  89. This  is ruled out by the minimum block size being 450.  To check all possible
  90. keys  with  the  minimum block dimensions of 32*15 (width*height) and with the
  91. minimum password length of 10 characters we need to  consider  15^10  possible
  92. keys.   15^10  possibilities would take a week to check at the rate of one per
  93. microsecond.  Actually the number of keys is greater than this (note  how  the
  94. password  is extended above) so it would take longer.  Using a password length
  95. of 15 characters the time would be  increased  to  over  ten  thousand  years.
  96. Longer  passwords are supported by the program since these calculations assume
  97. an unpredictable password is used.  Even if the  password  is  chosen  from  a
  98. dictionary of 1000 four letter words the program would allow 6 such words with
  99. the minimum block size corresponding to 1000^6  keys  which  is  approximately
  100. 15^15.   It  is  clear that increasing s is not an effective way of  improving
  101. security against brute force attack.  The time taken by the algorithm is O(s *
  102. b  *  n).   Since  (b*n)  cannot  be changed s should be chosen as small as is
  103. considered safe.  Note that s is  a  compile  time  constant  for  the  Tangle
  104. program and may be changed (it is called SECURE).
  105.  
  106. There is another security issue to consider.  Even when a cyphertext cannot be
  107. deciphered  it  may  reveal  information  about  a  sequence  of  cyphertexts.
  108. Consider the encryption of two files differing by  only  one  character.   The
  109. difference  in  the  input files causes a cascade of differences in the output
  110. files due to the exclusive-or in  the  shuffle  operation.   This  cascade  is
  111. approximately  2  to  the power of the number of shuffles when the differences
  112. are sparse hence ideally the value chosen for SECURE should be  at  least  the
  113. logarithm  base 2 of the block size.  The block size varies from 450 to 10000.
  114. Hence a conservative choice for SECURE would  be  LOG2(100)*2=13.   Using  the
  115. minimum  block  size of 450, SECURE=9 would be sufficient.  This should not be
  116. taken too seriously however since if the files require  more  than  one  block
  117. then  the identical input blocks (except most likely the last block due to the
  118. padding) will be encrypted identically.  The value chosen for SECURE in Tangle
  119. is  10  which  is  a  compromise.   Where  the  user  is  not  concerned if an
  120. eavesdropper can determine that two  encrypted  files  correspond  to  sources
  121. which  are  nearly identical then smaller values of SECURE can be used safely,
  122. providing the benefit of a proportional speedup in the algorithm.
  123.  
  124. The security of the above algorithm to detection of similar  sources  is  also
  125. compromised  by  the  fact  that  so far the algorithm encrypts each bit plane
  126. (corresponding to the 8 bits in a byte) independently.  This is a weakness  of
  127. version  2  which  has  been  corrected  in  version  3.0.   A  one  character
  128. difference will be a one bit difference in some planes but not very likely for
  129. all  planes.  To fix this the exclusive-or phase of the shuffle is modified in
  130. version 3 to add 1 mod 256 to the byte.  This means  the  bit  planes  are  no
  131. longer independent each entire block is completely mixed up.
  132.  
  133. Version 3 also incorporates a change recommended by Russel Herman that using a
  134. floating  point  library  for  a  single  use  of the square root function was
  135. unwarranted.  Version 3 uses a simple linear search  square  root  calculation
  136. and this cuts the size of the executable code by about 50% - thanks Herman!
  137.  
  138. Some final operational advice.  Confidential documents should be created using
  139. a  ram  disk or a floppy which will be destroyed.  Note that deleting and even
  140. overwriting magnetic media does not prevent the data's  recovery.   Watch  out
  141. for  editors  which keep temporary copies of files which they are working upon
  142. in places of their own choice.  A  deleted  temporary  file  is  often  easily
  143. recovered and you may not even be aware of its existence.
  144.