Part IV Secret-key cryptosystems CHAPTER 4: Classical (secret-key) cryptosystems ■ In this chapter we deal with some of the very old or quite old classical (secret-key symmetric) cryptosystems that were primarily used in the pre-computer era. ■ These cryptosystems are too weak nowadays, too easy to break, especially with computers. ■ However, these simple cryptosystems give a good illustration of several of the important ideas of the cryptography and cryptanalysis. ■ Moreover, most of them can be very useful in combination with more modern cryptosystem - to add a new level of security. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 2/47 Cryptology, Cryptosystems - secret-key cryptography Cryptology (— cryptography + cryptanalysis) has more than two thousand years of history. Basic historical observation ■ People have always had fascination with keeping information away from others. Some people - rulers, diplomats, militaries, businessmen - have always had needs to keep some information away from others. Importance of cryptography nowadays ■ Applications: cryptography is the key tool to make modern information transmission secure, and to create secure information society. ■ Foundations: cryptography gave rise to several new key concepts of the foundation of informatics: one-way functions, computationally perfect pseudorandom generators, zero-knowledge proofs, holographic proofs, program self-testing and self-correcting, . . . prof. Jozef Gruska IV054 4. Secret-key cryptosystems 3/47 Approaches and paradoxes of cryptography Sound approaches to cryptography ■ Shannon's approach based on information theory (enemy has not enough information to break a cryptosystem). ■ Current approach based on complexity theory (enemy has not enough computation power to break a cryptosystem). ■ Very recent approach based on the laws and limitations of quantum physics (enemy would need to break laws of nature to break a cryptosystem). Paradoxes of modern cryptography ■ Positive results of modern cryptography are based on negative results of complexity theory. ■ Computers, that were designed originally for decryption, seem to be now more useful for encryption. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 4/47 Cryptosystems - ciphers The cryptography deals with problem of sending a message (plaintext, cleartext), through a insecure channel, that may be tapped by an adversary (eavesdropper, cryptanalyst), to a legal receiver. ( key source ] legal prof. Jozef Gruska IV054 4. Secret-key cryptosystems 5/47 Components of cryptosystems: Plaintext-space: P - a set of plaintexts over an alphabet ^ Cryptotext-space: C - a set of cryptotexts (ciphertexts) over alphabet A Key-space: K - a set of keys Each key k determines an encryption algorithm ek and an decryption algorithm dk such that, for any plaintext w, ek(w) is the corresponding cryptotext and w E dk(ek(w)) or w = dk{ek{w)). Note: As encryption algorithms we can use also randomized algorithms. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 6/47 100 - 42 B.C., CAESAR cryptosystem, Shift cipher CAESAR can be used to encrypt words in any alphabet. In order to encrypt words in English alphabet we use: Key-space: {0,1,..., 25} An encryption algorithm substitutes any letter by the letter occurring k positions ahead (cyclically) in the alphabet. A decryption algorithm cfc substitutes any letter by the one occurring k positions backward (cyclically) in the alphabet. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 7/47 100 - 42 B.C., CAESAR cryptosystem, Shift cipher Example ^(EXAMPLE) = GZCOSNG, ^(EXAMPLE) = HADPTOH, ei(HAL) = IBM, e3(COLD) = FROG ABCDEFGHIJKLMNOPQRSTUVWXYZ Example Find the plaintext to the following cryptotext obtained by the encryption with CAESAR with k = ?. Cryptotext: VHFUHW GH GHXA, VHFUHW GH GLHX, VHFUHW GH WURLV, VHFUHW GH WRXV. Numerical version of CAESAR is defined on the set {0,1,2,..., 25} by the encryption algorithm: ek{i) = (/ + k){mod 26) prof. Jozef Gruska IV054 4. Secret-key cryptosystems 8/47 POLYBIOUS cryptosystem for encryption of words of the English alphabet without J. Key-space: Polybious checkerboards 5x5 with 25 English letters and with rows + columns labeled by symbols. Encryption algorithm: Each symbol is substituted by the pair of symbols denoting the row and the column of the checkerboard in which the symbol is placed. Example: F G H 1 J A A B C D E B F G H 1 K C L M N 0 P D Q R S T U E V W X Y Z KONIEC -> Decryption algorithm: ??? prof. Jozef Gruska IV054 4. Secret-key cryptosystems 9/47 Kerckhoff's Principle The philosophy of modern cryptanalysis is embodied in the following principle formulated in 1883 by Jean Guillaume Hubert Victor Francois Alexandre Auguste Kerckhoffs von Nieuwenhof (1835 - 1903). The security of a cryptosystem must not depend on keeping secret the encryption algorithm. The security should depend only on keeping secret the key. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 10/47 Requirements for good cryptosystems (Sir Francis R. Bacon (1561 - 1626)) □ Given ek and a plaintext w, it should be easy to compute c = ek(w). B Given dk and a cryptotext c, it should be easy to compute w = dk(c). B A cryptotext ek(w) should not be much longer than the plaintext w. □ It should be unfeasible to determine w from ek(w) without knowing dk. 0 The so called avalanche effect should hold: A small change in the plaintext, or in the key, should lead to a big change in the cryptotext (i.e. a change of one bit of the plaintext should result in a change of all bits of the cryptotext, each with the probability close to 0.5). El The cryptosystem should not be closed under composition, i.e. not for every two keys k\, there is a key k such that ek{w) = ekl{ek2{w)). Q The set of keys should be very large. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 11/47 Crypta na lysis The aim of cryptanalysis is to get as much information about the plaintext or the key as possible. Main types of cryptoanalytics attack □ Cryptotexts-only attack. The cryptanalysts get cryptotexts ci = e^(wi),... , c„ = ek(wn) and try to infer the key k or as many of the plaintexts w\,... ,wn as possible. B Known-plaintexts attack (given are some pairs plaintext —> cryptotext) The cryptanalysts know some pairs w;, e^(w,), 1 < / < n, and try to infer k, or at least wn+i for a new cryptotext e^(w„+i). B Chosen-plaintexts attack (given are cryptotext for some chosen plaintexts) The cryptanalysts choose plaintexts wi,. .., w„ to get cryptotexts e^(wi),..., e^(w„), and try to infer k or at least wn+i for a new cryptotext c„+i = e^(w„+i). (For example, if they get temporary access to encryption machinery.) prof. Jozef Gruska IV054 4. Secret-key cryptosystems 12/47 Crypta na lysis □ Known-encryption-algorithm attack The encryption algorithm is given and the cryptanalysts try to get the decryption algorithm d^. B Chosen-cryptotext attack (given are plaintexts for some chosen cryptotexts) The cryptanalysts know some pairs (q, dk(cj)), 1 < / < n, where the cryptotexts c,- have been chosen by the cryptanalysts. The aim is to determine the key. (For example, if cryptanalysts get a temporary access to decryption machinery.) prof. Jozef Gruska IV054 4. Secret-key cryptosystems 13/47 WHAT CAN a BAD EVE DO? Let us assume that a clever Alice sends an encrypted message to Bob. What can a bad enemy, called usually Eve (eavesdropper), do? ■ Eve can read (and try to decrypt) the message. ■ Eve can try to get the key that was used and then decrypt all messages encrypted with the same key. ■ Eve can change the message sent by Alice into another message, in such a way that Bob will have the feeling, after he gets the changed message, that it was a message from Alice. ■ Eve can pretend to be Alice and communicate with Bob, in such a way that Bob thinks he is communicating with Alice. An eavesdropper can therefore be passive - Eve or active - Mallot. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 14/47 Basic goals of broadly understood cryptography Confidentiality: Eve should not be able to decrypt the message Alice sends to Bob. Data integrity: Bob wants to be sure that Alice's message has not been altered by Eve. Authentication: Bob wants to be sure that only Alice could have sent the message he has received. Non-repudiation: Alice should not be able to claim that she did not send messages that she has sent. Anonymity: Alice does not want that Bob finds who send the message prof. Jozef Gruska IV054 4. Secret-key cryptosystems 15/47 HILL cryptosystem The cryptosystem presented in this slide was probably never used. In spite of that this cryptosystem played an important role in the history of modern cryptography. We describe Hill cryptosystem for a fixed n and the English alphabet. Key-space: matrices M of degree n with elements from the set {0,1,..., 25} such that M^1mod 26 exist. Plaintext + cryptotext space: English words of length n. Encoding: For a word w let cw be the column vector of length n of the integer codes of symbols of w. (A -> 0, B -> 1, C -> 2,...) Encryption: cc = Mcw mod 26 Decryption: cw = M_1cc mod 26 prof. Jozef Gruska IV054 4. Secret-key cryptosystems 16/47 HILL cryptosystem Example A B C D E F G H I J K L M N O P Q R S T U VWX Y Z M 4 7 1 1 Plaintext: w = LONDON Cm — MClo Cnd — , MCN 17 11 9 16 i Con — , MCon Cryptotext: MZVQRB Theorem If M Proof: Exercise an ai2 321 322 , thenM i det M 322 — 312 -321 311 prof. Jozef Gruska IV054 4. Secret-key cryptosystems 17/47 Secret-key (symmetric) cryptosystems A cryptosystem is called secret-key cryptosystem if some secret piece of information - the key - has to be agreed first between any two parties that have, or want, to communicate through the cryptosystem. Example: CAESAR, HILL. Another name is symmetric cryptosystem (cryptography). Two basic types of secret-key cryptosystems ■ substitution based cryptosystems ■ transposition based cryptosystems Two basic types of substitution cryptosystems ■ monoalphabetic cryptosystems - they use a fixed substitution - CAESAR, POLYBIOUS ■ polyalphabetic cryptosystems - substitution keeps changing during the encryption A monoalphabetic cryptosystem with letter-by-letter substitution is uniquely specified by a permutation of letters. (Number of permutations (keys) is 26!) prof. Jozef Gruska IV054 4. Secret-key cryptosystems 18/47 Secret-key cryptosystems Example: AFFINE cryptosystem is given by two integers 0 < a, b< 25, gcd(a, 26) = 1. Encryption: ea^(x) = (ax + b) mod 26 Example a = 3, b = 5, e3i5(x) = (3x + 5) mod 26, 63,5(3) = 14, 63,5(15) = 24 - e3,5(D) = 0, e3,5(P) = Y ABCDEFGHIJK LMNOPQRSTUVWXYZ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Decryption: d3yb(y) = a_1(y — b) mod 26 prof. Jozef Gruska IV054 4. Secret-key cryptosystems 19/47 Cryptanalysis The basic cryptanalytic attack against monoalphabetic substitution cryptosystems begins with a frequency count: the number of each letter in the cryptotext is counted. The distributions of letters in the cryptotext is then compared with some official distribution of letters in the plaintext laguage. The letter with the highest frequency in the cryptotext is likely to be substitute for the letter with highest frequency in the plaintext language .... The likehood grows with the length of cryptotext. Frequency counts in English: 12.31 9.59 8.05 7.18 6.59 6.03 5.14 and for other languages: % Finnish % French % Itali; 18.46 11.42 8.02 7.14 7.04 5.38 5.22 5.01 12.06 10.59 9.76 8.64 8.11 7.83 5.86 5.54 5.20 15.87 9.42 8.41 7.90 7.29 7.15 6.46 6.24 5.34 11.79 11.74 11.28 9.83 6.88 6.51 6.37 5.62 13.15 12.69 9.49 7.60 6.95 6.25 6.25 5.94 5.58 The 20 most common digrams are (in decreasing order) TH, HE, IN, ER, AN, RE, ED, ON, ES, ST, EN, AT, TO, NT, HA, ND, OU, EA, NG, AS. The six most common trigrams: THE, ING, AND, HER, ERE, ENT. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 20/47 Crypta na lysis Cryptanalysis of a cryptotext encrypted using the AFINE cryptosystem with an encryption algorithm ea,b(x) = (sx + b) mod 26 = (xa + b) mod 26 where 0 < a, b < 25, gcd(a, 26) = 1. (Number of keys: 12x26 = 312.) Example: Assume that an English plaintext is divided into blocks of 5 letters and encrypted by an AFINE cryptosystem (ignoring space and interpunctions) as follows: How to find the plaintext? B H J U H N B U L S v U LRU S L Y X H 0 N U U N B W N U A x U S N L U Y J S S W X R L K G N B 0 N u U N B W S W X K X H K X D H U Z D L K x B H J U H B N U 0 N U M H U G S W H U x M B X R W X K X L U X B H J U H C X K x A X K Z S W K x X L K 0 L J K C X L C M X 0 N U U B V u L R R W H S H B H J U H N B X M B X R W X K X N 0 Z L J B X X H B N F U B H J u H L U S W X G L L K z L J P H U U L S Y X B J K x s W H S S w X K X N B H B H J U H Y X W N U G S W x G L L K prof. Jozef Gruska IV054 4. Secret-key cryptosystems 21/47 Cryptanalysis Frequency analysis of plainext and frequency table for English: X - 32 J - 11 U - 30 0 -6 H - 23 R - 6 B - 19 G - 5 L - 19 M - 4 N - 16 Y - 4 S - 15 W - 14 C - 3 T - 0 First guess: E = X, T = U Encodings: 4a + b = 23 (mod 26) xa + b = y 19a + b = 20 (mod 26) Solutions: a = 5, b = 3 —> a1 = Translation table crypto|^ CDEFGHI JKLMNOPQRSTUVWXYZ PKFAVQLGBWRMH CXSM IDYTOJ E Z U B H J U H O M U U M W X R L K H K X D H M U M H U U X B H J L K O L J R R W H S K X M O Z L U S W X B J K X S H Y X W M B W M U A G M B O M U Z D L K G S W H U U H C X K K C X L C G L L K Z SSW S W X V U L R U X U S M L U U M B W X B H J U X M B X R X A X K Z M X O M U H M B X M H B M F U L J P H U X K X M B G L L K S L Y X H U Y J S S S W X K X H B M U O W X K X L S W K X X U B V U L B X R W X B H J U H U L S Y X H B H J U provides from the above cryptotext the plaintext that starts with KGWTG CKTMO OTMIT DMZEG, what does not make sense. prof. Jozef Gruska IV054 4. Secret-key cryptosystei Crypta na lysis Second guess: E = X,A = H Equations 4a + 6 = 23 (mod 26) 6=7 (mod 26) Solutions: a = 4 or a = 17 and therefore a = 17 This gives the translation table crypto plain and the following plaintext from the above cryptotext ABCDEFGHIJKLMNOPQRSTUVWXYZ VSPMJGDAXUROL I FCZWTQNK H EBY S A U N A 1 S N 0 T K N 0 W N T 0 B E A F 1 N N 1 S H 1 N V E N T 1 0 N B U T T H E W 0 R D 1 S F 1 N N 1 s H T H E R E A R E M A N Y M 0 R E S A u N A S 1 N F 1 N L A N D T H A N E L S E W H E R E 0 N E S A U N A P E R E V E R Y T H R E E 0 R F 0 U R P E 0 P L E F 1 N N S K N 0 w w H A T A S A U N A 1 S E L S E W H E R E 1 F Y 0 U S E E A S 1 G N S A U N A 0 N T H E D 0 0 R Y 0 U C A N N 0 T B E S U R E T H A T T H E R E 1 S A S A U N A B E H 1 N D T H E D 0 0 R prof. Jozef Gruska IV054 4. Secret-key cryptosystems Example of monoalphabetic cryptosystem Symbols of the English alphabet will be replaced by squares with or without points and with or without surrounding lines using the following rule: A: B: C: J- K- L- S T u D: E: F: M- N- 0- V W X G: H: 1: P- Q- R- Y z For example the plaintext: WE TALK ABOUT FINNISH SAUNA MANY TIMES LATER results in the cryptotext: □□UJLUJUELUCr DDrjHJJLDJ^JD nummjLJumr Garbage in between method: the message (plaintext or cryptotext) is supplemented by "garbage letters" . Richelieu cryptosystem used sheets of card board with holes. prof. JozefGruska E YOU E YOU U M D E R I M MY 123456789 10 AST R S P A C IV054 4. Secret-key cryptosystt Polyalphabetic Substitution Cryptosystems Playfair cryptosystem Invented around 1854 by Ch. Wheatstone. Key - a Playfair square is defined by a word w of length at most 25. In w repeated letters are then removed, remaining letters of alphabets (except j) are then added and resulting word is divided to form an 5 x 5 array (a Playfair square). Encryption: of a pair of letters x, y Q If x and y are in the same row (column), then they are replaced by the pair of symbols to the right (bellow) them. B If x and y are in different rows and columns they are replaced by symbols in the opposite corners of rectangle created by x and y. Example: PLAYFAIR is encrypted as LCMNNFCS Playfair was used in World War I by British army. S D Z 1 U H A F N G B M V Y W R P L C X T 0 E K Q prof. Jozef Gruska IV054 4. Secret-key cryptosystems 25/47 Polyalphabetic Substitution Cryptosystems VIGENERE and AUTOCLAVE cryptosystems Several of the following polyalphabetic cryptosystems are modification of the CAESAR cryptosystem. A 26x26 table is first designed with the first row containing a permutation of all symbols of alphabet and all columns represent CAESAR shifts starting with the symbol of the first row. Secondly, for a plaintext w a key k is a word of the same length as w. Encryption: the i-th letter of the plaintext - w; is replaced by the letter in the w,-row and /(,-column of the table. VIGENERE cryptosystem: a short keyword p is chosen and k = Prefix\w\p°° VIGENERE is actually a cyclic version of the CAESAR cryptosystem. AUTOCLAVE cryptosystem: k = Prefix\w\pw prof. Jozef Gruska IV054 4. Secret-key cryptosystems 26/47 Keyword: Plaintext: Vi gen e re-key: Autoclave-key: Vigerere-cryp.: Autoclave-cryp.: Substitution Cryptosystems VIGENERE and AUTOCLAVE cryptosystems abcdefgh i jklmnopqrstuvwxyz b c d e f g h i jklmnopqrstuvwxyza c d e f g h i jklmnopqrstuvwxyzab d e f g h i jklmnopqrstuvwxyzabc e f g h i jklmnopqrstuvwxyzabcd f g h i j klmmopqrstuvwxyzabcde gh i j klmmopqrstuvwxyzabcdef h i jklmmopqrstuvwxyzabcdefg i jklmmopqrstuvwxyzabcdefgh j klmmopqrstuvwxyzabcde fgh i klmmopqrstuvwxyzabcdefgh i j lmmopqrstuvwxyzabcdefgh i j k Examole- mnopqrstuvwxyzabcdefgh i jkl " " mopqrstuvwxyzabcdefgh i jklm opqrstuvwxyzabcde fgh i j k l m m pqrstuvwxyzabcde fgh i j k l m m o qrstuvwxyzabcdefgh i j k l m m o p rstuvwxyzabcdefgh i j klmmopq stuvwxyzabcdefgh i j klmmopqr tuvwxyzabcde fgh i jklmmopqrs uvwxyzabcdefgh i j klmmopqrst vwxyzabcdefgh i j klmmopqrstu wxyzabcdefgh i j klmmopqrstuv xyzabcdefgh i jklmnopqrstuvw yzabcdefgh i jklmnopqrstuvwx zabcdefgh i jklmnopqrstuvwxy HAMBURG INJEDEMMENSCHENGE5ICHTESTEHT5EINEG HAMBURGHAMBURGHAMBURGHAMBURGHAMBUR HAMBURGINJEDEMMENSCHENGESICHTE5TEH PNVFXVSTEZTWYKUGQTCTNAEEVYYZZEUOYX PNVFXVSURWWFLQZKRKKJLGKWLMJALIAGIN prof. Jozef Gruska iv054 4. Secret-key cryptosystems 27/47 CRYPTOANALYSIS of cryptotexts produced by VIGENERE cryptosystem □ Task 1 - to find the length of the key Kasiski method (1852) - invented also by Charles Babbage (1853). Basic observation If a subword of a plaintext is repeated at a distance that is a multiple of the length of the key, then the corresponding subwords of the cryptotext are the same. Example, cryptotext: CHRGQPWOEIRULYANDOSHCHRIZKEBUSNOFKYWROPDCHRKGAXBNRHROAKERBKSCHRIWK Substring "CHR" occurs in positions 1, 21, 41, 66: expected keyword length is therefore 5. Method. Determine the greatest common divisor of the distances between identical subwords (of length 3 or more) of the cryptotext. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 28/47 CRYPTOANALYSIS of cryptotexts produced by VIGENERE cryptosystem Friedman method Let n-, be the number of occurrences of the i-th letter the cryptotext. Let I be the length of the keyword. Let n be the length of the cryptotext. Then it holds / =_°-027"_ / = V26 I rieri IL NUlUb / (n_2)/-0.038n+u.u65 ' ' Z^/=l n(n-l) Once the length of the keyword is found it is easy to determine the key using the statistical (frequency analysis) method of analyzing monoalphabetic cryptosystems. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 29/47 Derivation of the Friedman method □ Let n; be the number of occurrences of /-th alphabet symbol in a text of length n. The probability that if one selects a pair of symbols from the text, then they are the same is ' ~~ "("-1) ~~ ^'=1 (2") and it is called the index of coincidence. B Let pi be the probability that a randomly chosen symbol is the /-th symbol of the alphabet. The probability that two randomly chosen symbols are the same is E26 2 ;=i Pi For English text one has E^P,2 = 0.065 For randomly chosen text: ESiP? = E2i 5^=0.038 Approximately l 2 ' = E;=i P- prof. Jozef Gruska IV054 4. Secret-key cryptosystems 30/47 Derivation of the Friedman method Assume that a cryptotext is organized into / columns headed by the letters of the keyword letters Si Si s2 S3 s, Xl X3 x, Xl+1 Xl+2 Xl+3 X2I X2I+1 X2I+2 X2I+3 X3I First observation Each column is obtained using the CAESAR cryptosystem. Probability that two randomly chosen letters are the same in ■ the same column is 0.065. ■ different columns is 0.038. The number of pairs of letters in the same column: ^ ■ j(j — 1) = "^7^ The number of pairs of letters in different columns: '^"^ ■ ^ = " ^/~^ The expected number A of pairs of equals letters is A = ■ 0.065 + " ■ 0.038 Since / = = -t^IO.027 + /(0.038/7 - 0.065)] 2 one gets the formula for I from the previous slide. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 31/47 ONE-TIME PAD cryptosystem - Vernam's cipher plaintext w Binary case: key k > are binary words of the same length cryptotext c J Encryption: c = w © k Decryption: w = c © k Example: w = 101101011 k = 011011010 c = 110110001 What happens if the same key is used twice or 3 times for encryption? Cl = Wl © k, C2 = W2 © k, C3 = W3 © k Cl © C2 = Wl © W2 Cl © C3 = Wi © w3 C2 © C3 = M/2 © W3 prof. Jozef Gruska 32/47 Perfect secret cryptosystems By Shannon, a cryptosystem is perfect if the knowledge of the cryptotext provides no information whatsoever about its plaintext (with the exception of its length). It follows from Shannon's results that perfect secrecy is possible if the key-space is as large as the plaintext-space. In addition, a key has to be as long as plaintext and the same key should not be used twice. An example of a perfect cryptosystem ONE-TIME PAD cryptosystem (Gilbert S. Vernam (1917) - AT&T + Major Joseph Mauborgne). If used with the English alphabet, it is simply a polyalphabetic substitution cryptosystem of VIGENERE with the key being a randomly chosen English word of the same length as the plaintext. Proof of perfect secrecy: by the proper choice of the key any plaintext of the same length could provide the given cryptotext. Did we gain something? The problem of secure communication of the plaintext got transformed to the problem of secure communication of the key of the same length. Yes- □ ONE-TIME PAD cryptosystem is used in critical applications El It suggests an idea how to construct practically secure cryptosystems. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 33/47 Transposition Cryptosystems 1 N J E D E M M E N s C H E N G E S 1 C H T E S T E H T S E 1 N E G E S C H 1 C H T E T 0 J E 0 N 0 The basic idea is very simple: permutate the plaintext to get the cryptotext. Less clear it is how to specify and perform efficiently permutations. One idea: choose n, write plaintext into rows, with n symbols in each row and then read it by columns to get cryptotext. Example Cryptotexts obtained by transpositions, called anagrams, were popular among scientists of 17th century. They were used also to encrypt scientific findings. Newton wrote to Leibnitz aVc/VW/WnVqVsWV what stands for: "data aequatione quodcumque fluentes quantitates involvente, fluxiones invenire et vice versa" Exa m pi e a2 cde f3g2 i2jkm n8 o5 prs212 u3 z Solution: prof. Jozef Gruska IV054 4. Secret-key cryptosystems 34/47 KEYWORD CAESAR cryptosysteml Choose an integer 0 < k < 25 and a string, called keyword, of length at most 25 with all letters different. The keyword is then written bellow the English alphabet letters, beginning with the fc-symbol, and the remaining letters are written in the alphabetic order and cyclicly after the keyword. Example: keyword: HOW MANY ELKS, k = 8 0 8 ABCDEFGH I J K LMNOPQRSTUVWXYZ PQRTUVXZHOWMANYELKSBCD FG I J prof. Jozef Gruska IV054 4. Secret-key cryptosystems 35/47 KEYWORD CAESAR cryptosystem Exercise Decrypt the following cryptotext encrypted using the KEYWORD CAESAR and determine the keyword and k T 1 V D Z C R T 1 C F Q N 1 Q T U T F Q X A V F C Z F E Q X C P C Q U C Z W K Q F U V B C FN R R T X T C 1 U A K W T Y D T U P M C F E C X U U V u P C B V A N H C VR UP C F E Q X C U P C F U V B C X V 1 U Q TIF F U V 1 c F N F N Q A A K VI UP C U V E u v U Q G C Q F Q N 1 Q W Q U P TU T F Q A F V 1 C X C F F Q M K U P Q U U P C F u V B C T F E M V E C MAK P C Q U C Z Q 1 Z U P Q U K V N P Q B C U P C R Q X T A T u K V R U P M V D T 1 Y D Q U C M V 1 U p C F U V 1 C F prof. Jozef Gruska IV054 4. Secret-key cryptosystems 36/47 KEYWORD CAESAR cryptosystem Step 1. Make the frequency counts: Step 2. Cryptotext contains two one-letter words T and Q. They must be A and I. Since T occurs once and Q three times it is likely that T is I and Q is A. The three letter word UPC occurs 7 times and all other 3-letter words occur only once. Hence UPC is likely to be THE. Let us now decrypt the remaining letters in the high frequency group: F,V,I From the words TU, TF => F=S From UV => V=0 From VI => l = N The result after the remaining guesses ABCDEFGH IJKLMNOPQRSTUVWXYZ LVEWPSKMN?Y?RU?HEF?ITOBCGD prof. Jozef Gruska IV054 4. Secret-key cryptosystems 37/47 UNICITY DISTANCE of CRYPTOSYSTEMS Redundancy of natural languages is of the key importance for cryptanalysis. Would all letters of a 26-symbol alphabet have the same probability, a character would carry Ig 26 = 4.7 bits of Information. The estimated average amount of information carried per letter in a meaningful English text is 1.5 bits. The unicity distance of a cryptosystem is the minimum number of cryptotext (number of letters) required to a computationally unlimited adversary to recover the unique encryption key. Empirical evidence indicates that if any simple cryptosystem is applied to a meaningful English message, then about 25 cryptotext characters is enough for an experienced cryptanalyst to recover the plaintext. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 38/47 ANAGRAMS - EXAMPLES German: English: IRI BRATER, GENF FRANK PEKL, REGEN PEER ASSSTIL, MELK INGO DILMR, PEINE EMIL REST, GERA KARL SORDORT, PEINE Briefträgerl algorithms antagonist compressed coordinate creativity deductions descriptor impression introduces procedures logarithms stagnation decompress decoration reactivity discounted predictors permission reductions reproduces prof. Jozef Gruska IV054 4. Secret-key cryptosystems APPENDIX prof. Jozef Gruska 40/47 STREAM CRYPTOSYSTEMS Two basic types of cryptosystems are: ■ Block cryptosystems (Hill cryptosystem,. . .) - they are used to encrypt simultaneously blocks of plaintext. ■ Stream cryptosystems (CAESAR, ONE-TIME PAD,. . .) - they encrypt plaintext letter by letter, or block by block, using an encryption that may vary during the encryption process. Stream cryptosystems are more appropriate in some applications (telecommunication), usually are simpler to implement (also in hardware), usually are faster and usually have no error propagation (what is of importance when transmission errors are highly probable). Two basic types of stream cryptosystems: secret key cryptosystems (ONE-TIME PAD) and public-key cryptosystems (Blum-Goldwasser) prof. Jozef Gruska IV054 4. Secret-key cryptosystems 41/47 Block versus stream cryptosystems In block cryptosystems the same key is used to encrypt arbitrarily long plaintext - block by block - (after dividing each long plaintext w into a sequence of subplaintexts (blocks) W1W2W3 ). In stream cryptosystems each block is encryptyd using a different key ■ The fixed key k is used to encrypt all blocks. In such a case the resulting cryptotext has the form c = cic2c3 ... = ek(w1)ek(w2)ek(w3)... ■ A stream of keys is used to encrypt subplaintexts. The basic idea is to generate a key-stream K = k\, k2, k3,... and then to compute the cryptotext as follows c = cic2c3 ... = ekl(w1)ek2{w2)ek3(w3). prof. Jozef Gruska IV054 4. Secret-key cryptosystems 42/47 CRYPTOSYSTEMS WITH STREAMS OF KEYS Various techniques are used to compute a sequence of keys. For example, given a key k k; = fi(k, k\, k2, ■ ■ ■, k-,-1) In such a case encryption and decryption processes generate the following sequences: Encryption: To encrypt the plaintext W1W2W3 . . .the sequence ki, ci, k2, C2, kj„ C3,.. . of keys and sub-cryptotexts is computed. Decryption: To decrypt the cryptotext C1C2C3 . . .the sequence k\, wt,k2, w2, k3, w3,... of keys and subplaintexts is computed. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 43/47 EXAMPLES A keystream is called synchronous if it is independent of the plaintext. KEYWORD VIGENERE cryptosystem can be seen as an example of a synchronous keystream cryptosystem. Another type of the binary keystream cryptosystem is specified by an initial sequence of keys ki,k2,k3.. • km and a initial sequence of binary constants b\, b?, b$ ... bm-i and the remaining keys are computed using the rule kl+m = Y^j=o bjki+j mod 2 A keystream is called periodic with period p if kl+p = k; for all /. Example Let the keystream be generated by the rule kj+4 = k-, 0 kj+i If the initial sequence of keys is (1,0,0,0), then we get the following keystream: 1,0,0,0,1,0,0,1,1,0,1,0 1,1,1, . .. of period 15. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 44/47 PERFECT SECRECY - BASIC CONCEPTS Let P, K and C be sets of plaintexts, keys and cryptotexts. Let Pk(I<) be the probability that the key k is chosen from K and let a priori probability that plaintext w is chosen be pp(w). If for a key k G K, C(k) = {e^(w)|w G P}, then for the probability Pc(y) that c is the cryptotext that is transmitted it holds Pc{c) = Y.{k\cec{k)} Px{k)pp{dk{c)). For the conditional probability pc(c\w) that c is the cryptotext if w is the plaintext it holds Pc(c\w) = Y;Ww=dkic)} Px(k). Using Bayes' conditional probability formula p(y)p(x\y) = p(x)p(y\x) we get for probability pp(w\c) that w is the plaintext if c is the cryptotext the expression _ pp(w)T,{k\w=dk[c)} pkW PP ~ E{(,|c6C(K)} PK(l<)pp(dK(c))- prof. Jozef Gruska IV054 4. Secret-key cryptosystems 45/47 PERFECT SECRECY - BASIC RESULTS Definition A cryptosystem has perfect secrecy if Pp(w\c) = pp(w) for all w G P and c G C. (That is, the a posteriori probability that the plaintext is w,given that the cryptotext is c is obtained, is the same as a priori probability that the plaintext is w.) Example CAESAR cryptosystem has perfect secrecy if any of the 26 keys is used with the same probability to encode any symbol of the plaintext. Proof Exercise. An analysis of perfect secrecy: The condition pp(w\c) = pp(w) is for all w G P and c G C equivalent to the condition pc(c\w) = Pc(c). Let us now assume that Pc(c) > 0 for all c G C. Fix w G P. For each c G C we have pc(c\w) = pc(c) > 0. Hence, for each c G C there must exist at least one key k such that e^(vv) = c. Consequently, \K\ > \C\ > \P\. In a special case \K\ = \ C\ = \P\, the following nice characterization of the perfect secrecy can be obtained: Theorem A cryptosystem in which \P\ = \K\ = \ C\ provides perfect secrecy if and only if every key is used with the same probability and for every w G P and every c G C there is a unique key k such that e^(vv) = c. Proof Exercise. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 46/47 PRODUCT CRYPTOSYSTEMS A cryptosystem S = (P, K, C, e, d) with the sets of plaintexts P, keys K and cryptotexts C and encryption (decryption) algorithms e(d) is called endomorphic if P = C. If Si = (P, Ki, P, e(1), c/(1))andS2 = (P, K2, P, e(2), c/(2)) are endomorphic cryptosystems, then the product cryptosystem is Si ®S2 = (P,Ki ®K2,P,e,d), where encryption is performed by the procedure e(ki,k2)(w) = ek2(ekl(w)) and decryption by the procedure d(ki,k2){c) = dkl{dk2{c)). Example (Multiplicative cryptosystem): Encryption: ea(w) = aw mod p; decryption: d3(c) = a~1c mod 26. If M denote the multiplicative cryptosystem, then clearly CAESAR x M is actually the AFFINE cryptosystem. Exercise Show that also M ® CAESAR is actually the AFFINE cryptosystem. Two cryptosystems Si and S2 are called commutative if Si ® S2 = S2 ® Si. A cryptosystem S is called idempotent if S ® S = S. prof. Jozef Gruska IV054 4. Secret-key cryptosystems 47/47