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

  1.  
  2. Archive-name: cryptography-faq/part04
  3.  
  4.  
  5. This is the fourth of ten parts of the sci.crypt FAQ. The parts are
  6. mostly independent, but you should read the first part before the rest.
  7. We don't have the time to send out missing parts by mail, so don't ask.
  8. Notes such as ``[KAH67]'' refer to the reference list in the last part.
  9.  
  10.  
  11.  
  12. Contents:
  13.  
  14. 4.1. In mathematical terms, what is a private-key cryptosystem?
  15. 4.2. What is an attack?
  16. 4.3. What's the advantage of formulating all this mathematically?
  17. 4.4. Why is the one-time pad secure?
  18. 4.5. What's a ciphertext-only attack?
  19. 4.6. What's a known-plaintext attack?
  20. 4.7. What's a chosen-plaintext attack?
  21. 4.8. In mathematical terms, what can you say about brute-force attacks?
  22. 4.9. What's a key-guessing attack? What's entropy?
  23.  
  24.  
  25. Reader, beware: This section is highly mathematical. Well, maybe not
  26. _highly_ mathematical, but it's got a bunch of symbols and scary-looking
  27. formulas. You have been warned.
  28.  
  29.  
  30. 4.1. In mathematical terms, what is a private-key cryptosystem?
  31.  
  32.   A private-key cryptosystem consists of an encryption system E and a
  33.   decryption system D. The encryption system E is a collection of
  34.   functions E_K, indexed by ``keys'' K, mapping some set of
  35.   ``plaintexts'' P to some set of ``ciphertexts'' C. Similarly the
  36.   decryption system D is a collection of functions D_K such that
  37.   D_K(E_K(P)) = P for every plaintext P. That is, succesful decryption
  38.   of ciphertext into plaintext is accomplished using the same key
  39.   (index) as was used for the corresponding encryption of plaintext
  40.   into ciphertext. Such systems, where the same key value is used to
  41.   encrypt and decrypt, are also known as ``symmetric'' cryptoystems.
  42.  
  43. 4.2. What is an attack?
  44.  
  45.   In intuitive terms a (passive) attack on a cryptosystem is any method
  46.   of starting with some information about plaintexts and their
  47.   corresponding ciphertexts under some (unknown) key, and figuring out
  48.   more information about the plaintexts. It's possible to state
  49.   mathematically what this means. Here we go.
  50.  
  51.   Fix functions F, G, and H of n variables. Fix an encryption system E,
  52.   and fix a distribution of plaintexts and keys.
  53.  
  54.   An attack on E using G assuming F giving H with probability p is an
  55.   algorithm A with a pair f, g of inputs and one output h, such that
  56.   there is probability p of computing h = H(P_1,...,P_n), if we have
  57.   f = F(P_1,...,P_n) and g = G(E_K(P_1),...,E_K(P_n)). Note that this
  58.   probability depends on the distribution of the vector (K,P_1,...,P_n).
  59.  
  60.   The attack is trivial (or ``pointless'') if there is probability at
  61.   least p of computing h = H(P_1,...,P_n) if f = F(P_1,...,P_n) and
  62.   g = G(C_1,...,C_n). Here C_1,...,C_n range uniformly over the possible
  63.   ciphertexts, and have no particular relation to P_1,...,P_n. In other
  64.   words, an attack is trivial if it doesn't actually use the encryptions
  65.   E_K(P_1),...,E_K(P_n).
  66.  
  67.   An attack is called ``one-ciphertext'' if n = 1, ``two-ciphertext'' if
  68.   n = 2, and so on.
  69.  
  70. 4.3. What's the advantage of formulating all this mathematically?
  71.  
  72.   In basic cryptology you can never prove that a cryptosystem is secure.
  73.   Read part 3: we keep saying ``a strong cryptosystem must have this
  74.   property, but having this property is no guarantee that a cryptosystem
  75.   is strong!''
  76.  
  77.   In contrast, the purpose of mathematical cryptology is to precisely
  78.   formulate and, if possible, prove the statement that a cryptosystem is
  79.   strong. We say, for example, that a cryptosystem is secure against
  80.   all (passive) attacks if any nontrivial attack against the system (as
  81.   defined above) is too slow to be practical. If we can prove this
  82.   statement then we have confidence that our cryptosystem will resist
  83.   any (passive) cryptanalytic technique. If we can reduce this statement
  84.   to some well-known unsolved problem then we still have confidence that
  85.   the cryptosystem isn't easy to break.
  86.  
  87.   Other parts of cryptology are also amenable to mathematical
  88.   definition. Again the point is to explicitly identify what assumptions
  89.   we're making and prove that they produce the desired results. We can
  90.   figure out what it means for a particular cryptosystem to be used
  91.   properly: it just means that the assumptions are valid.
  92.  
  93.   The same methodology is useful for cryptanalysis too. The cryptanalyst
  94.   can take advantage of incorrect assumptions. Often he can try to
  95.   construct a proof of security for a system, see where the proof fails,
  96.   and use these failures as the starting points for his analysis.
  97.   
  98. 4.4. Why is the one-time pad secure?
  99.  
  100.   By definition, the one-time pad is a cryptosystem where the
  101.   plaintexts, ciphertexts, and keys are all strings (say byte strings)
  102.   of some length m, and E_K(P) is just the sum (let's say the exclusive
  103.   or) of K and P.
  104.  
  105.   It is easy to prove mathematically that there are _no_ nontrivial
  106.   single-ciphertext attacks on the one-time pad, assuming a uniform
  107.   distribution of keys. Note that we don't have to assume a uniform
  108.   distribution of plaintexts. (Here's the proof: Let A be an attack,
  109.   i.e., an algorithm taking two inputs f, g and producing one output h,
  110.   with some probability p that h = H(P) whenever f = F(P) and
  111.   g = G(E_K(P)) (i.e., g = G(K + P)). Then, because the distribution of
  112.   K is uniform and independent of P, the distribution of K + P must also
  113.   be uniform and independent of P. But also the distribution of C is
  114.   uniform and independent of P. Hence there is probability exactly p
  115.   that h = H(P) whenever f = F(P) and g = G(C), over all P and C. Thus
  116.   a fortiori A is trivial.)
  117.  
  118.   On the other hand the one-time pad is _not_ secure if a key K is used
  119.   for more than one plaintext: i.e., there are nontrivial
  120.   multiple-ciphertext attacks. So to be properly used a key K must be
  121.   thrown away after one encryption. The key is also called a ``pad'';
  122.   this explains the name ``one-time pad.''
  123.  
  124. 4.5. What's a ciphertext-only attack?
  125.  
  126.   In the notation above, a ciphertext-only attack is one where F is
  127.   constant. Given only some information G(E_K(P_1),...,E_K(P_n)) about
  128.   n ciphertexts, the attack has to have some chance of producing some
  129.   information H(P_1,...,P_n) about the plaintexts. The attack is trivial
  130.   if it has just as good a chance of producing H(P_1,...,P_n) when given
  131.   G(C_1,...,C_n) for random C_1,...,C_n.
  132.  
  133.   For example, say G(C) = C, and say H(P) is the first bit of P. We can
  134.   easily write down an attack---the ``guessing attack,'' which simply
  135.   guesses that H(P) is 1. This attack is trivial because it doesn't use
  136.   the ciphertext: it has a fifty-fifty chance of guessing correctly no
  137.   matter what. On the other hand there is an attack on RSA which
  138.   produces one bit of information about P, with 100% success, using C.
  139.   If it is fed a random C then the success rate drops to 50%. So this is
  140.   a nontrivial attack.
  141.  
  142. 4.6. What's a known-plaintext attack?
  143.  
  144.   The classic known-plaintext attack has F(P_1,P_2) = P_1,
  145.   G(C_1,C_2) = (C_1,C_2), and H(P_1,P_2) depending only on P_2.
  146.   In other words, given two ciphertexts C_1 and C_2 and one decryption
  147.   P_1, the known-plaintext attack should produce information about the
  148.   other decryption P_2.
  149.  
  150.   Note that known-plaintext attacks are often defined in the literature
  151.   as producing information about the key, but this is pointless: the
  152.   cryptanalyst generally cares about the key only insofar as it lets him
  153.   decrypt further messages.
  154.  
  155. 4.7. What's a chosen-plaintext attack?
  156.  
  157.   A chosen-plaintext attack is the first of an increasingly impractical
  158.   series of _active_ attacks on a cryptosystem: attacks where the
  159.   cryptanalyst feeds data to the encryptor. These attacks don't fit into
  160.   our model of passive attacks explained above. Anyway, a
  161.   chosen-plaintext attack lets the cryptanalyst choose a plaintext and
  162.   look at the corresponding ciphertext, then repeat until he has figured
  163.   out how to decrypt any message. More absurd examples of this sort of
  164.   attack are the ``chosen-key attack'' and ``chosen-system attack.''
  165.  
  166.   A much more important form of active attack is a message corruption
  167.   attack, where the attacker tries to change the ciphertext in such a
  168.   way as to make a useful change in the plaintext.
  169.  
  170.   There are many easy ways to throw kinks into all of these attacks:
  171.   for instance, automatically encrypting any plaintext P as
  172.   T,E_K(h(T+R+P),R,P), where T is a time-key (sequence number) chosen anew
  173.   for each message, R is a random number, and h is a one-way hash
  174.   function. Here comma means concatenation and plus means exclusive-or.
  175.  
  176. 4.8. In mathematical terms, what can you say about brute-force attacks?
  177.  
  178.   Consider the following known-plaintext attack. We are given some
  179.   plaintexts P_1,...,P_{n-1} and ciphertexts C_1,...,C_{n-1}. We're
  180.   also given a ciphertext C_n. We run through every key K. When we find
  181.   K such that E_K(P_i) = C_i for every i < n, we print D_K(C_n).
  182.  
  183.   If n is big enough that only one key works, this attack will succeed
  184.   on valid inputs all the time, while it will produce correct results
  185.   only once in a blue moon for random inputs. Thus this is a nontrivial
  186.   attack. Its only problem is that it is very slow if there are many
  187.   possible keys.
  188.  
  189. 4.9. What's a key-guessing attack? What's entropy?
  190.  
  191.   Say somebody is using the one-time pad---but isn't choosing keys
  192.   randomly and uniformly from all m-bit messages, as he was supposed to
  193.   for our security proof. In fact say he's known to prefer keys which
  194.   are English words. Then a cryptanalyst can run through all English
  195.   words as possible keys. This attack will often succeed, and it's much
  196.   faster than a brute-force search of the entire keyspace.
  197.  
  198.   We can measure how bad a key distribution is by calculating its
  199.   entropy. This number E is the number of ``real bits of information''
  200.   of the key: a cryptanalyst will typically happen across the key within
  201.   2^E guesses. E is defined as the sum of -p_K log_2 p_K, where p_K is
  202.   the probability of key K.
  203.