home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / pc / crypto / encrypt.use < prev    next >
Encoding:
Text File  |  2003-06-11  |  46.9 KB  |  842 lines

  1.                 An Introduction to the Use of Encryption
  2.  
  3.                             by Peter Meyer
  4.  
  5.                            Dolphin Software
  6.                         48 Shattuck Square #147
  7.                           Berkeley, CA 94704
  8.  
  9.                         Written January 1994
  10.                       Last revision 1994-04-29
  11.  
  12. The purpose of this article is to provide information in the area of
  13. practical cryptography of interest to anyone wishing to use cryptographic
  14. software.  I have mostly avoided discussion of technical matters in favor
  15. of a more general explanation of what I regard as the main things to be
  16. understood by someone beginning to use encryption.  Those wishing to get
  17. more deeply into the theoretical aspects should consult Bruce Schneier's
  18. book (see bibliography at end).
  19.  
  20. Dolphin Software publishes several commercial cryptographic software
  21. products for the PC, including Dolphin Encrypt and Dolphin Encrypt Advanced
  22. Version (file and disk encryption software) and EZ-Crypt (an on-the-fly
  23. encryption TSR).  (Product information available upon request). Occasionally
  24. in this article I include some remarks specifically concerning these or
  25. other products.
  26.  
  27. Cryptography is the art or science of secret writing, or more exactly, of
  28. storing information (for a shorter or longer period of time) in a form
  29. which allows it to be revealed to those you wish to see it yet hides it
  30. from all others.  A cryptosystem is a method to accomplish this.
  31. Cryptanalysis is the practice of defeating such attempts to hide
  32. information.  Cryptology includes both cryptography and cryptanalysis.
  33.  
  34. The original information to be hidden is called plaintext.  The hidden
  35. information is called ciphertext.  Encryption is any procedure to convert
  36. plaintext into ciphertext.  Decryption is any procedure to convert
  37. ciphertext into plaintext.
  38.  
  39. A cryptosystem is designed it so that decryption can be accomplished only
  40. under certain conditions, which generally means only by persons in
  41. possession of both a decryption engine (these days, generally a computer
  42. program) and a particular piece of information, called the decryption key,
  43. which is supplied to the decryption engine in the process of decryption.
  44.  
  45. Plaintext is converted into ciphertext by means of an encryption engine
  46. (again, generally a computer program) whose operation is fixed and
  47. determinate (the encryption method) but which functions in practice in a
  48. way dependent on a piece of information (the encryption key) which has a
  49. major effect on the output of the encryption process.
  50.  
  51. The result of using the decryption method and the decryption key to decrypt
  52. ciphertext produced by using the encryption method and the encryption key
  53. should always be the same as the original plaintext (except perhaps for
  54. some insignificant differences).
  55.  
  56. In this process the encryption key and the decryption key may or may not be
  57. the same.  When they are the cryptosystem is called a "symmetric key"
  58. system; when they are not it is called an "asymmetric key" system.  The
  59. most widely-known instance of a symmetric cryptosystem is DES (the
  60. so-called Data Encryption Standard).  The most widely-known instance of an
  61. asymmetric key cryptosystem is PGP.  Dolphin Encrypt and EZ-Crypt are
  62. symmetric key cryptosystems.
  63.  
  64. There are many reasons for using encryption (examples are given below), and
  65. the cryptosystem that one should use is the one best suited for one's
  66. particular purpose and which satisfies the requirements of security,
  67. reliability and ease-of-use.  Ease-of-use is easy to understand.
  68. Reliability means that the cryptosystem, when used as its designer intended
  69. it to be used, will always reveal exactly the information hidden when it is
  70. needed (in other words, that the ciphertext will always be recoverable and
  71. the recovered data will be the same as to the original plaintext).
  72. Security means that the cryptosystem will in fact keep the information
  73. hidden from all but those persons intended to see it despite the attempts
  74. of others to crack the system.
  75.  
  76. Ease-of-use is the quality easiest to ascertain.  If the encryption key is
  77. a sequence of 64 hexadecimal digits (a 256-bit key), such as:
  78.  
  79.   B923A24C98D98F83E24234CF8492C384E9AD19A128B3910F3904C324E920DA31
  80.  
  81. then you may have a problem not only in remembering it but also in using it
  82. (try typing the sequence above a few times).  With such a key it is
  83. necessary to write it down or store it in a disk file, in which case there
  84. is the danger that it may be discovered by someone else. Thus such a key is
  85. not only inconvenient to use but also is a security risk.
  86.  
  87. The key used in Dolphin Encrypt is any typeable string of from 10 to 60
  88. characters and thus may be a phrase which is easy to remember, e.g. "Lay on
  89. MacDuff!"  Spaces are not significant, and upper and lower case are
  90. equivalent, so you don't have to remember whether the key is "Lay on
  91. MacDuff!" or "Lay on Macduff!"
  92.  
  93. Reliability is the quality next easiest to test for.  If it is not possible
  94. to provide a formal proof that the decryption of the encryption of the
  95. plaintext is always identical to the plaintext it is at least possible to
  96. write software to perform multiple encryptions and decryptions with many
  97. different keys to test for reliability (though this testing cannot be
  98. exhaustive).  Such software is provided with Dolphin Encrypt.
  99.  
  100. Finally there is the question of security.  The security of a cryptosystem
  101. is always relative to the task it is intended to accomplish and the
  102. conditions under which it will be used.  A theoretically secure system
  103. becomes insecure if used by people who write their encryption keys on
  104. pieces of paper which they stick to their computer terminals.
  105.  
  106. In general a cryptosystem can never be shown to be completely secure in
  107. practice, in the sense that without knowledge of the decryption key it is
  108. impossible to recover the plaintext with real-world computing power in less
  109. than, say, a thousand years.  There is one cryptosystem known as the
  110. one-time pad, which is absolutely secure, but in practice it is cumbersome
  111. and the key can be used only once without compromising the security of the
  112. system.
  113.  
  114. In some cases it is possible to show that cracking a cryptosystem is
  115. equivalent to solving some particular mathematical problem, e.g. the
  116. problem of factoring large numbers ("large" here means numbers with several
  117. hundred decimal digits).  If many mathematicians working for many years
  118. have been unable to solve a problem then this is a reason to regard a
  119. cryptosystem based on it as secure.  However, there is no guarantee that a
  120. solution to the mathematical problem may not be found tomorrow, in which
  121. case the security of the cryptosystem would disappear overnight (or at
  122. least, as soon as word got around).
  123.  
  124. In the case of PGP and other encryption software such as RIPEM which rely
  125. on an asymmetric encryption algorithm known as the RSA Algorithm, it is
  126. widely believed that these are secure if and only if the problem of
  127. factoring large numbers is insoluble (that is, computationally infeasible
  128. in real time).  Yet recently a claim has been made, but has not been
  129. confirmed, that a method of cryptanalysis of the RSA Algorithm has been
  130. found which does not depend on a general solution to the problem of factor
  131. ing large numbers.  A poster to the Usenet newsgroup sci.crypt (Francis
  132. Barrett) has remarked:
  133.  
  134.     Although factoring is believed to be hard, and factoring breaks
  135.     RSA, breaking RSA does not simplify factoring.  Trivial
  136.     non-factoring methods of breaking RSA could therefore exist.
  137.     Whether this paper [by William H. Payne] is legitimate remains to
  138.     be seen, but it is certainly not beyond the realm of possiblity.
  139.  
  140. Some have claimed that PGP is the most secure encryption program available
  141. for PCs, a claim that does not withstand critical examination.  Given two
  142. encryption programs, each of which generates random-looking ciphertext, how
  143. does one decide that one of them is "more secure" than the other - even if
  144. full details of the encryption algorithms are known?  Short of breaking one
  145. of the systems there is no clear answer.  If one cannot provide criteria
  146. for determining when one program is more secure than another then it does
  147. not make sense to ask which is the most secure.
  148.  
  149. Brute force attacks upon a cryptosystem (a brute force attack involves
  150. trying every possible key to decrypt some ciphertext until finding one that
  151. works) can be compared since the average time required by a brute force
  152. attack is half the number of possible keys multiplied by the time required
  153. to test each key (by using it to decrypt the ciphertext and seeing whether
  154. anything intelligible results).  It is true that if the size of the key
  155. space associated with a cryptosystem is small (e.g. 2^16 = 65,536) then the
  156. cryptosystem is vulnerable to a brute force attack.  But if a cryptosystem
  157. has a large key space (e.g. the key space associated with Dolphin Encrypt,
  158. whose size is about 10^109) then a brute force attack is not feasible and
  159. so any weakness in the system, if it exists, must be sought elsewhere.
  160.  
  161. Some may wonder: When trying to decrypt an encoded message by brute force,
  162. how does a computer know when it has succeeded?  The answer is that in a
  163. brute force attack one tries one key after another, and if a key is
  164. incorrect the "decryption" will normally be garbage, i.e. will look like
  165. random bytes.  There are statistical tests for randomness that can easily
  166. distinguish random bytes from natural language, so if the output does not
  167. appear like garbage then it is probably the plaintext, or at least is
  168. flagged for closer inspection.  Randomness tests will distinguish between
  169. garbage and natural language text regardless of what the natural language
  170. is.  More sensitive tests may actually be able to detect which natural
  171. language, since natural language texts in different languages have
  172. different statistical qualities.
  173.  
  174. In general, the security of a cryptosystem can only be measured by its
  175. resistance to actual attempts to break it in practice.  Those that have
  176. been broken are obviously insecure.  (There are several commercially
  177. available PC encryption packages that have been broken; see for example the
  178. articles by Kochanski in the bibliography at the end of this article.)
  179. Those that have resisted the attentions of many cryptanalysts for many
  180. years may be deemed secure, at least until better methods of cryptanalysis
  181. are invented.
  182.  
  183. In the case of DES there has long been widespread suspicion that the
  184. National Security Agency influenced its designers at IBM so that it was
  185. strong enough to withstand most attacks but not strong enough to withstand
  186. the NSA computers.
  187.  
  188.     The original design submitted by IBM permitted all 16 x 48 = 768
  189.     bits of key used in the 16 rounds to be selected independently.
  190.     A U.S. Senate Select Committee ascertained in 1977 that the U.S.
  191.     National Security Agency (NSA) was instrumental in reducing the
  192.     DES secret key to 56 bits that are each used many times, although
  193.     this had previously been denied by IBM ... (Massey, p.541.)
  194.  
  195. But the best attempts by cryptanalysts over the years have produced only
  196. meager results (in particular, the demonstration of Adi Shamir that
  197. cryptanalysis of DES ciphertext, in the simplest DES mode (electronic code
  198. book), can be done with somewhat less effort than that required for a brute
  199. force attack).  But recently a new method of DES cryptanalysis has been
  200. proposed which involves the use of parallel processing (using many
  201. computers simultaneously), and it now seems clear that for a few million
  202. dollars a computer can be built which can crack DES ciphertext in a few
  203. hours.  Since NSA has practically unlimited funding and has the largest
  204. concentration of computing power and mathematical talent in the world, it
  205. is likely that NSA possesses the ability to decrypt DES ciphertext fairly
  206. easily.
  207.  
  208. NSA has, of course, never affirmed or denied their ability to crack DES.
  209. (NSA also means Never Say Anything.)  However, the absence of publication
  210. of a demonstration that a particular cryptosystem has been cracked is no
  211. proof that it hasn't.  Anyone who discovered a way to crack DES, RSA, etc.,
  212. could make a lot more money by quietly providing a decryption service than
  213. by telling the world about his discovery. In fact if he did announce it
  214. people would quickly stop using that cryptosystem and he would have few
  215. clients.
  216.  
  217. When selecting a cryptosystem, or cryptographic software, you should first
  218. consider what you want it to accomplish.  There are numerous (legitimate)
  219. reasons why you might wish to conceal information, for example:
  220.  
  221. (i)  Companies often possess data files on employees which are confidential,
  222. such as medical records, salary records, etc.  Employees will feel safer
  223. knowing that these files are encrypted and are not accessible to casual
  224. inspection by data entry clerks (who may be bribed to obtain information on
  225. someone).
  226.  
  227. (ii)  Individuals may share working space with others, of whose honor they
  228. are not entirely sure, and may wish to make certain that in their absence
  229. no-one will find anything by snooping about in their hard disk.
  230.  
  231. (iii)  A company may wish to transfer sensitive business information
  232. between sites such as branch offices.  Or it may wish to send confidential
  233. information (for example, a negotiating position, operating procedures or
  234. proprietary data) to an agent in the field (perhaps abroad).  If the
  235. information is encrypted before transmission then one does not have to
  236. worry about it being intercepted since if this happens the encrypted data
  237. is incomprehensible (without the encryption key).
  238.  
  239. (iv)  A company may have information that a competitor would like to see,
  240. such as information concerning legal or financial problems, results of
  241. research, who the customers are and what they are buying, information
  242. revealing violations of government regulations, secret formulas or details
  243. of manufacturing processes, plans for future expansion or for the
  244. development of new products.
  245.  
  246. (v)  A person or company may wish to transport to a distant location a
  247. computer which contains sensitive information without being concerned that
  248. if the computer is examined en route (e.g. by foreign customs agents) then
  249. the information will be revealed.
  250.  
  251. (vi)  Two individuals may wish to correspond by email on matters that they
  252. wish to keep private and be sure that no-one else is reading their mail.
  253.  
  254. >From the above examples it can be seen that there are two general cases
  255. when encryption is needed:
  256.  
  257. (a)  When information, once encrypted, is simply to be stored on-site (and
  258. invulnerable to unauthorized access) until there is a need to access that
  259. information.
  260.  
  261. (b)  When information is to be transmitted somewhere and it is encrypted so
  262. that if it is intercepted before reaching its intended destination the
  263. interceptor will not find anything they can make sense of.
  264.  
  265. In case (b) there arises the problem of secure key exchange.  This problem
  266. exists because the person who will decrypt the information is usually not
  267. the same as the person who encrypted the information. Assuming that the
  268. decryptor is in posssession of the decryption engine (normally a software
  269. program) how does the decryptor know which decryption key to use?  This
  270. information must be communicated to the decryptor in some way.  If, during
  271. the course of this communication, the key is intercepted by a third party
  272. then that third party can intercept and decrypt the ciphertext subsequently
  273. sent by the encryptor to the decryptor.
  274.  
  275. This is a problem which all users of symmetric key systems (e.g. DES and
  276. Dolphin Encrypt) must face when transmitting encrypted data, because in
  277. such systems the decryption key is the same as the encryption key.  The
  278. encryptor can choose any encryption key they wish, but how are they to
  279. communicate that key to the decryptor in a secure way?  Governments
  280. typically solve this problem by putting the key in a locked briefcase,
  281. handcuffing it to the wrist of a trusted minion, and despatching him with
  282. several armed guards to deliver the briefcase in person (typically at an
  283. embassy in a foreign country). This solution is generally too expensive for
  284. ordinary citizens.
  285.  
  286. If you know that your mail is not being opened then you can send the key
  287. that way, but who can be sure of this?  Even registered mail may be opened.
  288. The best way to pass the key to whoever you will be sending encrypted
  289. material to is by personal contact someplace where there is no chance of
  290. being observed.  If this is not possible then various less secure means are
  291. available.  For example, if you used to live in the same city as the person
  292. for some years then you might call them and say, "Remember that restaurant
  293. in San Diego where we used to have breakfast?  Remember the name of that
  294. cute waitress?  Let's use her name as the key."  Then you have a key that
  295. only you two know, unless someone has extensive information on your
  296. breakfast habits in San Diego several years ago and the names of the
  297. waitresses you might have come in contact with.
  298.  
  299. There is a class of cryptosystems knowns as "public key" systems which were
  300. first developed in the 1970s to solve this problem of secure key exchange.
  301. These are the systems referred to above as "asymmetric key" systems, in
  302. which the decryption key is not the same as the encryption key.  Such
  303. public key systems can, if used properly, go a long way toward solving the
  304. problem of secure key exchange because the encryption key can be given out
  305. to the world without compromising the security of communication, provided
  306. that the decryption key is kept secret.
  307.  
  308. Let's say you wish to receive encrypted email from your girlfriend Alice.
  309. You call her and give her your public key - the one used to perform
  310. encryption.  Alice writes a passionate love letter, encrypts it with your
  311. public key and sends it to you.  You decrypt it with your private key.  If
  312. your other girlfriend Cheryl intercepts this then there is no way she can
  313. decrypt it because the public key (assumed to be known to everyone and thus
  314. to her) is no good for decryption. Decryption can only be performed with
  315. the private key, which only you know (unless Cheryl finds it written on a
  316. piece of paper in the top drawer of the dresser under your socks).
  317.  
  318. A public key cryptosystem relies on some mathematical procedure to generate
  319. the public and private keys.  The mathematical nature of these systems
  320. usually allows the security of the system to be measured by the difficulty
  321. of solving some mathematical problem.  There are numerous public key
  322. cryptosystems, the most well known being the one based on the RSA Algorithm
  323. (which is patented by its inventors, Rivest, Shamir and Adelman), which, as
  324. noted above, relies for its security on the difficulty of factoring large
  325. numbers.  There are other public key systems available for licensing for
  326. commercial use, such as the LUC public key system (from LUC Encryption
  327. Technology, Sierra Madre, CA), and one developed by the computer
  328. manufacturer Next, Inc.
  329.  
  330. Public key cryptography has applications beyond the classical one of hiding
  331. information.  As a consequence of the encryption key and the decryption key
  332. being different, public key cryptography makes possible digital signatures
  333. (for authentification of documents) and digital forms of such activities as
  334. simultaneous contract signing.  Digital cash is also an idea which builds
  335. on the use of an asymmetric cryptosystem.
  336.  
  337. Although public key cryptography in theory solves the problem of secure key
  338. exchange, it does in general have a couple of disadvantages compared to
  339. asymmetric (or secret) key systems.  The first is speed.  Generally public
  340. key systems, such as PGP, are much slower than secret key systems, and so
  341. may be suitable for encrypting small amounts of data, such as messages sent
  342. by email, but are not suitable for bulk encryption, where it may be
  343. required to encrypt megabytes of data.  Secret key systems can be very fast
  344. (especially if implemented by instructions hard-coded into chips rather
  345. than running in a computer's memory).  The more complex such a system is
  346. the slower it tends to be, but even complex systems are generally of
  347. acceptable speed.  For example, Dolphin Encrypt will encrypt and decrypt at
  348. about 30 Kb/sec on a 80486 PC running at 50 Mhz (equivalent to 1 megabyte
  349. in 35 seconds), which is fast enough for most people.
  350.  
  351. The second disadvantage of public key systems is that there is a problem of
  352. key validation.  If you wish to send encrypted data to a person, Fred, say,
  353. and you have obtained what is claimed to be Fred's public key, how do you
  354. know it really is Fred's public key?  What if a third party, Jack, were to
  355. publish a public key in Fred's name?  If Jack works for a U.S. intelligence
  356. or law enforcement agency and can monitor communications channels used by
  357. Fred then he can intercept encrypted data sent to Fred, including any
  358. message you send to him, and can then decrypt it (since he has the
  359. corresponding private key). If Jack were really sneaky, and knew Fred's
  360. real public key, he could re-encrypt your message to Fred using the real
  361. public key (perhaps after altering your message in ways you might not
  362. approve of) and deliver it to Fred as if it had come directly from you.
  363. Fred would then decrypt it with his private key and read a message which he
  364. assumes is from you, but which may in fact be quite different from what you
  365. sent. In theory Jack could sit in the middle of an assumed two-way email
  366. correspondence between you and Fred, read everything each of you send to
  367. the other, and pass to each of you faked messages saying anything he wanted
  368. you to believe was from the other.
  369.  
  370. A recent contributor to sci.crypt (Terry Ritter, 11/29/93) wrote:
  371.  
  372.     When we have a secret-key cipher, we have the serious problem of
  373.     transporting a key in absolute secrecy.  However, after we do
  374.     this, we can depend on the cipher providing its level of technical
  375.     secrecy as long as the key is not exposed.
  376.  
  377.     When we have a public-key cipher, we apparently have solved the
  378.     problem of transporting a key.  In fact, however, we have only
  379.     done so if we ignore the security requirement to validate that
  380.     key.  Now, clearly, validation must be easier than secure
  381.     transport, so it can be a big advantage.  But validation is not
  382.     trivial, and many people do not understand that it is necessary.
  383.  
  384.     When we have a public-key cipher and use an unvalidated key, our
  385.     messages could be exposed to a spoofer who has not had to "break"
  386.     the cipher.  The spoofer has not had to break RSA.  The spoofer
  387.     has not had to break IDEA.  Thus, discussion of the technical
  388.     strength of RSA and IDEA are insufficient to characterize the
  389.     overall strength of such a cipher.  In contrast, discussion of the
  390.     technical strength of a secret-key cipher *IS* sufficient to
  391.     characterize the strength of that cipher.
  392.  
  393.     Discussion of the strength of public-key cipher mechanisms is
  394.     irrelevant without a discussion of the strength of the public-key
  395.     validation protocol.  Private-key ciphers need no such protocol,
  396.     nor any such discussion.  And a public-key cipher which includes
  397.     the required key-validation protocol can be almost as much
  398.     trouble as a secret-key cipher which needs none.
  399.  
  400. When encryption is used in case (a), to be stored on-site (and invulnerable
  401. to unauthorized access) until there is a need to access that information, a
  402. secret key cryptosystem is clearly preferable, since such a system has the
  403. virtue of speed, and there is no problem of key validation and no problem
  404. of key exchange (since there is no need to transmit the encryption key to
  405. anyone other than by face-to-face communication).
  406.  
  407. However, many people are still using secret key cryptosystems that are
  408. relatively easy to break since those people don't know any better. For
  409. example, the WordPerfect word processing program allows you to lock the
  410. information in a file by means of a password.  In a bad marriage one spouse
  411. might think that by locking their WordPerfect files they can write what
  412. they like and not worry that the other spouse might later use this against
  413. them.  What the first spouse doesn't know is that there are programs around
  414. that can automatically (and in a few seconds) find the password used to
  415. lock a WordPerfect file.
  416.  
  417. In fact the WordPerfect encryption method (at least for Versions 5.1 and
  418. earlier) has been shown to be very easy to break.  Full descriptions are
  419. given in the articles by Bennett, for Version 4.2, and by Bergen and
  420. Caelli, for Version 5.0 (see the bibliography below).
  421.  
  422. Another case is the encryption scheme used by Microsoft's word processing
  423. program Word.  A method to crack encrypted Word files was published on
  424. Usenet late in 1993, so this method of protecting information is now
  425. obsolete.  There is even a company, Access Data Recovery (in Orem, Utah)
  426. that sells software that automatically recovers the passwords used to
  427. encrypt data in a number of commercial software applications, including
  428. Lotus 123.
  429.  
  430. For a cryptosystem to be considered strong it should possess the following
  431. properties (I shall illustrate these by reference to the Dolphin Encrypt
  432. file encryption software):
  433.  
  434. (i)  The security of a strong system resides with the secrecy of the key
  435. rather than with the supposed secrecy of the algorithm.  In other words,
  436. even if an attacker knows the full details of the method used to encrypt
  437. and to decrypt, this should not allow him to decrypt the ciphertext if he
  438. does not know the key which was used to encrypt it (although obviously his
  439. task is even more difficult if he does not know the method).  The
  440. encryption algorithm used in Dolphin Encrypt is defined by the C source
  441. code for the encryption and decryption functions, and this source code is
  442. part of a publicly available C function library (the Dolphin Encryption
  443. Library).  The method is not secret and its full details are available for
  444. examination to anyone who purchases the library.
  445.  
  446. (ii)  A strong cryptosystem has a large keyspace, that is, there are very
  447. many possible encryption keys.  DES is considered by many to be flawed in
  448. this respect, because there are only 2^56 (about 10^17) possible keys.  The
  449. size of the keyspace associated with Dolphin Encrypt is about 10^109, due
  450. to the fact that keys can be up to 60 characters in length.
  451.  
  452. (iii)  A strong cryptosystem will produce ciphertext which appears random
  453. to all standard statistical tests.  A full discussion of these tests is
  454. beyond the scope of an introductory article such as this on the use of
  455. encryption software, but we may consider one interesting test, the
  456. so-called kappa test, otherwise known as the index of coincidence.
  457.  
  458. The idea behind this is as follows:  Suppose that the elements of the
  459. cipher text are any of the 256 possible bytes (0 through FF). Consider the
  460. ciphertext to be a sequence of bytes (laid out in a row). Now duplicate
  461. this sequence and place it beneath the first (with the first byte of the
  462. second sequence below the first byte of the first sequence).  We then have
  463. a sequence of pairs of identical bytes.  Slide the lower sequence to the
  464. right a certain distance, say, 8 places. Then count how many pairs there
  465. are in which the bytes are identical. If the sequence of bytes were truly
  466. random then we would expect about 1/256 of the pairs to consist of
  467. identical bytes, i.e. about 0.39% of them.  It is not difficult to write a
  468. program which analyzes a file of data, calculating the indices of
  469. coincidence (also known as the kappa value) for multiple displacement
  470. values.
  471.  
  472. When we run such a program on ordinary English text we obtain values such
  473. as the following ("IC" means "index of coincidence"):
  474.  
  475.                  Offset       IC       coincidences
  476.                       1      5.85%     2397 in 40968
  477.                       2      6.23%     2551 in 40967
  478.                       3      9.23%     3780 in 40966
  479.                       4      8.31%     3406 in 40965
  480.                       5      7.91%     3240 in 40964
  481.                       6      7.88%     3227 in 40963
  482.                       7      7.78%     3187 in 40962
  483.                       8      7.92%     3244 in 40961
  484.                       9      8.24%     3377 in 40960
  485.                      10      7.98%     3268 in 40959
  486.                      11      8.16%     3341 in 40958
  487.                      12      8.09%     3315 in 40957
  488.                      13      8.15%     3337 in 40956
  489.                      14      7.97%     3264 in 40955
  490.                      15      7.97%     3265 in 40954
  491.                      16      8.07%     3306 in 40953
  492.                      17      8.04%     3293 in 40952
  493.                      18      7.85%     3214 in 40951
  494.  
  495. Typically only 80 or so different byte values occur in a file of English
  496. text.  If these byte values occurred randomly then we would expect an index
  497. of coincidence for each displacement of about 1/80, i.e. about 1.25%.
  498. However, the distribution of characters in English text is not random ("e",
  499. "t" and the space character occur most frequently), which is why we obtain
  500. the larger IC values shown above.
  501.  
  502. The kappa test can be used to break a weak cryptosystem, or at least, to
  503. provide a clue toward breaking it.  The index of coincidence for the
  504. displacement equal to the length of the encryption key will often be
  505. significantly higher than the other indices, in which case one can infer
  506. the length of the key.
  507.  
  508. For example, here are the indices of coincidence for a file of ciphertext
  509. (2048 bytes in size) produced by encrypting a text file using a weak
  510. cryptosystem (one which was discussed on sci.crypt in December 1993):
  511.  
  512.                  Offset       IC       coincidences
  513.                       1      0.15%     3 in 2047
  514.                       2      0.34%     7 in 2046
  515.                       3      0.34%     7 in 2045
  516.                       4      0.54%     11 in 2044
  517.                       5      0.44%     9 in 2043
  518.                       6      0.39%     8 in 2042
  519.                       7      0.24%     5 in 2041
  520.                       8      0.49%     10 in 2040
  521.                       9      0.49%     10 in 2039
  522.                      10      0.29%     6 in 2038
  523.                      11      0.15%     3 in 2037
  524.                      12      0.10%     2 in 2036
  525.                      13      0.64%     13 in 2035
  526.                      14      0.74%     15 in 2034
  527.                      15      0.39%     8 in 2033
  528.                      16      0.20%     4 in 2032
  529.                      17      0.30%     6 in 2031
  530.                      18      0.34%     7 in 2030
  531.  
  532. 256 different byte values occur in the ciphertext, so if it were to appear
  533. as random then the kappa value should be about 0.39% for each displacement.
  534. But the kappa values for displacements 13 and 14 are significantly higher
  535. than the others, suggesting that the length of the key used in the
  536. encryption was either 13 or 14.  This clue led to the decryption of the
  537. ciphertext and it turned out that the key length was in fact 13.
  538.  
  539. As an example of how non-random some ciphertext produced by commercial
  540. cryptosystems may be it is instructive to consider the proprietary
  541. encryption algorithm used by the Norton Diskreet program.  The file named
  542. NORTON.INI, which comes with the Diskreet program, contains 530 bytes and
  543. 41 different byte values, including 403 instances of the byte value 0.  The
  544. non-zero byte values are dispersed among the zero values.  If we encrypt
  545. this file using Diskreet's proprietary encryption method and the key
  546. "ABCDEFGHIJ" we obtain a file, NORTON.SEC, which contains 2048 bytes,
  547. including 1015 0-bytes.  When we examine this file with a hex editor we
  548. find that it consists of the letters "PNCICRYPT", seven 0-bytes or 1-bytes,
  549. 1024 bytes of apparent gibberish (the ciphertext) and finally 1008 0-bytes.
  550. Suppose we extract the 1024 bytes of ciphertext.  There are 229 different
  551. byte values in this ciphertext, so if it really appeared random we would
  552. expect the kappa values to be about 1/229, i.e. about 0.44%.  What we find
  553. is the following:
  554.  
  555.                 Offset       IC       coincidences
  556.                      1      0.29%     3 in 1023
  557.                      2     21.72%     222 in 1022
  558.                      3      0.69%     7 in 1021
  559.                      4      1.08%     11 in 1020
  560.                      5      0.49%     5 in 1019
  561.                      6      0.20%     2 in 1018
  562.                      7      0.39%     4 in 1017
  563.                      8      0.00%     0 in 1016
  564.                      9      0.79%     8 in 1015
  565.                     10      0.39%     4 in 1014
  566.                     11      0.69%     7 in 1013
  567.                     12      0.69%     7 in 1012
  568.                     13      0.30%     3 in 1011
  569.                     14      0.99%     10 in 1010
  570.                     15      0.20%     2 in 1009
  571.                     16      0.30%     3 in 1008
  572.                     17      0.40%     4 in 1007
  573.                     18      0.20%     2 in 1006
  574.  
  575. The figure of 21.72% for offset 2 is quite astounding.  When we look at the
  576. ciphertext with a hex editor we see that there are many lines which have a
  577. byte pattern:
  578.  
  579.     xx yy aa bb aa bb cc dd cc dd ee ff ee ff gg hh
  580.     gg hh ...
  581.  
  582. that is, in which pairs of bytes tend to be repeated, for example:
  583.  
  584.           4B 25 4B 25 8D 28 8D 28 2D F8 2D F8 21 AC
  585.     21 AC E8 9E E8 9E F2 FC F2 FC C6 C5 C6 C5 7E 4F
  586.     7E 4F B2 8B B2 8B 32 EE 32 EE 25 2C 25 2C A5 32
  587.     A5 32 8D 61 8D 61 E5 C1 E5 C1 D4 F7 D4 F7
  588.  
  589. This explains why sliding the ciphertext against itself two places to the
  590. right produces such a large number of coincidences.
  591.  
  592. Clearly this ciphertext shows obvious regularities, and appears to be very
  593. far from random.  Such regularities are what a cryptanalyst looks for, as a
  594. clue to the encryption method and to the key, and which a good cryptosystem
  595. denies him.
  596.  
  597. In contrast to Diskreet, Dolphin Encrypt encrypts the same file,
  598. NORTON.INI, using the same key, to a file of 450 bytes (in which there are
  599. 207 different byte values, implying that the kappa values should be about
  600. 0.48% if the ciphertext is to appear random) with kappa values as follows:
  601.  
  602.                 Offset       IC       coincidences
  603.                       1      0.45%     2 in 449
  604.                       2      0.45%     2 in 448
  605.                       3      0.00%     0 in 447
  606.                       4      0.45%     2 in 446
  607.                       5      0.00%     0 in 445
  608.                       6      0.23%     1 in 444
  609.                       7      0.45%     2 in 443
  610.                       8      0.23%     1 in 442
  611.                       9      0.23%     1 in 441
  612.                      10      0.23%     1 in 440
  613.                      11      0.46%     2 in 439
  614.                      12      0.23%     1 in 438
  615.                      13      0.23%     1 in 437
  616.                      14      0.46%     2 in 436
  617.                      15      0.23%     1 in 435
  618.                      16      0.69%     3 in 434
  619.                      17      0.00%     0 in 433
  620.                      18      0.46%     2 in 432
  621.  
  622. The essentially discrete distribution of these indices of coincidence
  623. (0.00, 0.23, 0.46, 0.69) are due to the small size of the ciphertext (450
  624. bytes).  When we do the same test for a file of Dolphin ciphertext of size
  625. 60201 bytes (in which there are 256 different byte values, implying a
  626. desired kappa value of 0.39%) we find:
  627.  
  628.                 Offset       IC       coincidences
  629.                       1      0.41%     248 in 60200
  630.                       2      0.43%     258 in 60199
  631.                       3      0.44%     263 in 60198
  632.                       4      0.43%     258 in 60197
  633.                       5      0.43%     257 in 60196
  634.                       6      0.34%     205 in 60195
  635.                       7      0.40%     239 in 60194
  636.                       8      0.42%     252 in 60193
  637.                       9      0.40%     241 in 60192
  638.                      10      0.40%     242 in 60191
  639.                      11      0.41%     247 in 60190
  640.                      12      0.36%     216 in 60189
  641.                      13      0.41%     245 in 60188
  642.                      14      0.37%     223 in 60187
  643.                      15      0.36%     219 in 60186
  644.                      16      0.41%     247 in 60185
  645.                      17      0.40%     238 in 60184
  646.                      18      0.37%     222 in 60183
  647.  
  648. The kappa test, and other statistical tests, reveal no regularities in
  649. the ciphertext produced by Dolpin Encrypt (or by EZ-Crypt).
  650.  
  651. When evaluating an encryption program it is reasonable to ask whether the
  652. cipher used is something as weak as a repeated exclusive-or cipher, in
  653. which the bytes of the key are repeatedly exclusive-or'd against those of
  654. the plaintext - the sort of "crypto system designed by a 16-year-old on a
  655. long weekend" that some like to accuse very new system of being.  In a such
  656. a crypto system each byte of the ciphertext is affected only by the
  657. corresponding byte in the key and not by every byte (or every bit) in the
  658. key.  In this case the system is generally easy to crack (by determining
  659. the length of the key, say n, and then considering the n sets of bytes
  660. affected by each byte in the ciphertext).  Some simple tests of the
  661. encryption program may be performed to answer this question of the extent
  662. of the dependence of each byte of the ciphertext on all of, or only on some
  663. of, the bytes of the key.  To illustrate in the case of Dolphin Encrypt:
  664.  
  665. A file, NULLFILE, of 50,000 zero-bytes (good for testing ciphers because
  666. the plaintext consists entirely of a single byte value) was encrypted using
  667. Dolphin Encrypt and two similar keys, "abcdefghij" and "abcdefghik".  These
  668. keys differ only in their final bit ('k' instead of 'j').  The ciphertext
  669. files produced were, respectively, NULLFILE.E1 (length 1800 bytes) and
  670. NULLFILE.E2 (length 1830) bytes (Dolphin Encrypt performs compression
  671. before encryption).  A byte-by-byte file comparison utility was run on the
  672. two output files, with the following result:
  673.  
  674.                     File 1:   NULLFILE.E1
  675.                     Filesize: 1800
  676.                     File 2:   NULLFILE.E2
  677.                     Filesize: 1830
  678.  
  679.                     152 bytes are different.
  680.                     One byte is identical.
  681.                     38 bytes are different.
  682.                     One byte is identical.
  683.                     31 bytes are different.
  684.                     One byte is identical.
  685.                     174 bytes are different.
  686.                     One byte is identical.
  687.                     107 bytes are different.
  688.                     One byte is identical.
  689.                     318 bytes are different.
  690.                     One byte is identical.
  691.                     155 bytes are different.
  692.                     One byte is identical.
  693.                     175 bytes are different.
  694.                     One byte is identical.
  695.                     8 bytes are different.
  696.                     One byte is identical.
  697.                     125 bytes are different.
  698.                     One byte is identical.
  699.                     42 bytes are different.
  700.                     One byte is identical.
  701.                     464 bytes are different.
  702.  
  703. Thus exactly 11 bytes, at apparently random locations, in the first 1800
  704. bytes of the first file were the same as the bytes in the corresponding
  705. positions in the second file.  This is more-or-less what we would expect
  706. when comparing files which consist of what appear to be random bytes and
  707. which are independent of each other (since 1800/256 = 7.03).
  708.  
  709. A similar test is to take a string of characters such as "aabbccddee" and
  710. encrypt it using two keys which differ by one bit.  When this string is
  711. encrypted using Dolphin Encrypt and the keys "abcdefghij" and "abcdefghik"
  712. (as before) the resulting ciphertext is as follows (these are hexdumps of
  713. the two ciphertext files):
  714.  
  715.   85 E0 08 22 F6 54 27 DE - 6A 1F A0 2C 8F C1 C7 D3  ...".T'.j..,....
  716.   87 54 DF 59 CF 2F 75 64 - 82 D3 95 23 2A 70 3D EA  .T.Y./ud...#*p=.
  717.   D6 AB 12 1C 6D 9E 52 4E - 41 20 0A A9 E7 47 89 90  ....m.RNA ...G..
  718.   47 2C 14 83 EF EE DB 44 - AD FA 2C 38 5C 89 E7 0F  G,.....D..,8\...
  719.   FE 6A EC 16 7C 55 33 EC - 51 2E 52 5C 30 9F 0B 00  .j..|U3.Q.R\0..
  720.   7C 11 91 7B 25 B6 66 10 - 24 B4 29 E1 14 88 12 00  |..{%.f.$.)....
  721.   49 03 E5 6A 10 99 37 24 - 98 B9 28                 I..j..7$..(
  722.  
  723.   A2 59 8D 70 B3 B0 44 D1 - C9 F9 54 EE CA 2E 4D 7C  .Y.p..D...T...M|
  724.   FE 39 72 7B F3 C3 D6 87 - 64 EC 2A 5E AD ED D3 9D  .9r{....d.*^....
  725.   81 FC 40 CA DF 71 7A 97 - 42 26 FC 65 19 23 C6 08  ..@..qz.B&.e.#..
  726.   76 7B AD CA 0A 71 F5 B2 - 51 DF 21 06 0A D9 0A 0E  v{...q..Q.!.....
  727.   EA 8D EA 14 88 C8 22 69 - B1 38 66 D1 89 DE 00 56  ......"i.8f... V
  728.   0A F7 F6 C4 E9 57 B7 92 - BF E5 1C 58 8B 14 2F B7  .....W.....X../.
  729.   01 2F 00 CF 5E 06 69 4D - AD 43 F9 DC 94           ./ .^.iM.C...
  730.  
  731. The ciphertext produced is quite different even though the keys are almost
  732. the same.  In fact, each byte in the first ciphertext block is different
  733. from its corresponding byte in the second ciphertext block.
  734.  
  735. When attempting to break a cipher this test is often one of the first to be
  736. applied, namely, take some known plaintext and encrypt it with slightly
  737. different keys and compare the resulting ciphertext to see whether a
  738. particular change in the key produces a particular change in the ciphertext.
  739. With a strong cipher a change of a single bit in the key will have a
  740. cascading effect, producing large changes in the resulting ciphertext,
  741. as we see above.
  742.  
  743. As to the increase in size of the ciphertext in this case:  Dolphin Encrypt
  744. adds random bytes (a.k.a. garbage) to the ciphertext (this makes crypt-
  745. analysis of the cipher more difficult), so very small files are increased.
  746. Larger ciphertext blocks (a few Kb or more) are usually considerably
  747. smaller than the plaintext blocks because the decrease in size resulting
  748. from compression is usually much more than the increase resulting from
  749. interpolation of random bytes.
  750.  
  751.  
  752.                         Selected Bibliography
  753.  
  754. Cryptology is an academic discipline which has implications for the
  755. security of life and property, and thus there is a vast literature on the
  756. subject, often highly technical in nature.  Much of the research is secret
  757. and unpublished.  The following are just a few of the many books and
  758. journal articles available. The history of codes and code-breaking is
  759. especially interesting.  The best book on this subject is David Kahn's The
  760. Codebreakers (the bound edition is recommended).  Among the following works
  761. those marked with an asterisk are more historical than technical and tend
  762. to be somewhat easier reading. Those marked "#" contain commentary on some
  763. contemporary political aspects of the civilian use of cryptography.
  764.  
  765. Andreassen, K.:  Computer Cryptology, Prentice-Hall.
  766. Angluin, D. and Lichtenstein, D.:  Provable Security in Cryptosystems,
  767.     Yale University, 1983.
  768. #Bamford, J.:  The Puzzle Palace, Penguin Books.
  769. #Barlow, J. P.:  "Decrypting the Puzzle Palace", Communications  of the ACM,
  770.     July 1992, pp. 25-31.
  771. *Barker, W. G.:  History of Codes and Ciphers in the U.S., several volumes, 
  772.     Aegean Park Press, P. O. Box 2837, Laguna Hills, CA 92654.
  773. Beker, H. and Piper, F.:  Cipher Systems, Wiley, 1982.
  774. Bennett, J.:  "Analysis of the Encryption Algorithm Used in the WordPerfect 
  775.     Word Processing Program", Cryptologia 11(4), pp. 206-210, 1987.
  776. Bergen, H. A. and Caelli, W. J.:  "File Security in WordPerfect 5.0",
  777.     Cryptologia 15(1), pp. 57-66, January 1991.
  778. Biham, E. and Shamir, A.:  "Differential cryptanalysis of DES-like 
  779.     cryptosystems", Journal of Cryptology, vol. 4, #1, pp. 3-72, 1991.
  780. *Boyd, C.:  "Anguish under Siege: High-Grade Japanese Signal Intelligence 
  781.     and the Fall of Berlin", Cryptologia 8(3), July 1989, pp. 193-209.
  782. Brassard, G.:  Modern Cryptology, Springer-Verlag, 1988.
  783. Deavours, C. A. and Kruh, L.:  Machine Cryptography and Modern Crypt-
  784.     analysis, Artech House, 610 Washington St., Dedham, MA 02026, 1985.
  785. DeLaurentis, J. M.:  "A Further Weakness in the Common Modulus Protocol 
  786.     in the RSA Cryptoalgorithm", Cryptologia, 8(3), July 1984, pp. 253-259.
  787. Denning, D.:  Cryptography and Data Security, Addison-Wesley, 1982.
  788. *Diffie, W.: "The first ten years of public key cryptography",
  789.     IEEE proceedings, 76(5), 560--577, 1988.
  790. ---- and Hellman, M.: "Privacy and authentication:  an introduction to 
  791.     cryptography", IEEE proceedings, 67(3), 397-427, 1979.
  792. Feistel, H.:  "Cryptography and Computer Privacy", Scientific American, 
  793.     228(5), pp. 15-23, 1973.
  794. *Flicke, W. F.:  War Secrets in the Ether, Volumes 1 & 2, Aegean Park Press. 
  795. *Friedman, W. F.: Solving German Codes in World War I, Aegean Park Press.
  796. *---- and Mendelsohn, C. J.:  The Zimmermann Telegram of 1917 and its 
  797.     Cryptographic Backround, Aegean Park Press.
  798. Gaines, H. F.: Cryptanalysis, Dover, 1956.
  799. Garon, G. and Outerbridge, R.:  "DES watch: an examination of the sufficiency 
  800.     of the Data Encryption Standard for financial institutions in the 1990's",
  801.     Cryptologia 15(3), 1991, pp. 177-193.
  802. *Hinsley, F. H. et al.: British Intelligence in the Second World War, 
  803.     Cambridge U. P., volumes 1 - 4.
  804. *---- and Stripp, A. (eds.):  Codebreakers: The Inside Story of Bletchley
  805.     Park, Oxford U.P., 1993.
  806. Held, G.:  Top Secret Data Encryption Techniques, Sams Publishing, 1993.
  807. Hellman, M.:  "The mathematics of public key cryptography", Scientific 
  808.     American, pp. 130-139, 1979.
  809. *Kahn, D.:  The Codebreakers, Macmillan, 1967.
  810. *----:  Seizing the Enigma, Houghton Mifflin, 1991.
  811. Kochanski, M.: "A Survey of Data Insecurity Packages", Cryptologia 11(1),
  812.     pp. 1-15, 1987.
  813. ----: "Another Data Insecurity Package", Cryptologia 12(3), pp.165-177,
  814.     July 1988.
  815. Konheim, A. G.:  Cryptography: A Primer, John Wiley, 1981.
  816. #Kruh, L.:  "The Control of Public Cryptography and Freedom of Speech
  817.     - A Review", Cryptologia 10(1), January 1986, pp. 2-9.
  818. Lysing, H.:  Secret Writing, Dover, 1974.
  819. Marotta, M.:  The Code Book, Loompanics, 1987.
  820. Massey, J.:  "An Introduction to Contemporary Cryptology", IEEE Proceedings, 
  821.     76(5), pp. 533-549, May 1988.
  822. Meyer, C. H., and Matyas, S. M.:  Cryptography, John Wiley, 1982.
  823. #Pierce, K. J.:  "Public Cryptography, Arms Export Controls, and the First
  824.     Amendment: A Need for Legislation", Cornell International Law
  825.     Journal, Vol. 17, No. 3 (Winter 1984), pp. 197-236.
  826. Rivest, R. L., Shamir, A. and Adelman, L.:  "A Method for Obtaining Digital 
  827.     Signatures and Public-key Cryptosystems," Communications of the 
  828.     ACM, February 1979.
  829. Salomaa, A.:  Public Key Cryptography, Springer-Verlag, 1990. 
  830. Schneier, B.:  "Untangling Public Key Cryptography", Dr Dobb's Journal,
  831.     May 1992, pp. 16-28.
  832. ----:  "The IDEA Encryption Algorithm", Dr Dobb's Journal, December 1993,
  833.     pp. 50-56.
  834. ----:  Applied Cryptography, John Wiley & Sons, 1994.
  835. Simmons, G. (ed.):  Contemporary Cryptology: the Science of Information 
  836.     Integrity, IEEE Press, 1991.
  837. Smith, L. D.:  Cryptography, Dover, 1955.
  838. *Weber, R. E.:  United States Diplomatic Codes and Ciphers 1775-1938, 
  839.     Precedent, 1979.
  840. Welsh, D.:  Codes and Cryptography, Claredon Press, 1988.
  841. *Yardley, H. O.:  The American Black Chamber, Ballantine 1981.
  842.