{"id":33,"date":"2018-07-21T09:08:18","date_gmt":"2018-07-21T09:08:18","guid":{"rendered":"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=33"},"modified":"2018-12-27T09:48:40","modified_gmt":"2018-12-27T09:48:40","slug":"substitution-cipherand-cryptanalysis","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/chapter\/substitution-cipherand-cryptanalysis\/","title":{"rendered":"Substitution Cipherand Cryptanalysis"},"content":{"raw":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/hx3mUX-lRls\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>Learning Objectives<\/strong>\r\n\r\n\u00d8\u00a0 To know the substitution cipher in classical cryptography\r\n\r\n\u00d8\u00a0\u00a0 To learn about the mono alphabetic substitution cipher\r\n\r\n\u00d8\u00a0\u00a0 To learn about the poly alphabetic substitution cipher\r\n\r\n\u00d8\u00a0\u00a0 Cryptanalysis of substitution cipher\r\n\r\n&nbsp;\r\n\r\n<strong>3.1 Introduction<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Humans could encode their own documents, but computers do it faster and more efficiently. To do this, the computer at each end uses a document called an \"SSL Certificate\" containing character strings that are the keys to their secret \"codes.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cryptography\">cryptography, <\/a>a transposition cipher is a method of encryption by which the positions held by units of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Plaintext\">plaintext <\/a>are shifted according to a regular system, so that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ciphertext\">ciphertext <\/a>constitutes a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Permutation\">permutation <\/a>of the plaintext. That is, the order of the units is changed. Mathematically a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bijective\">bijective <\/a>function is used on the characters' positions to encrypt and an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Inverse_function\">inverse function <\/a>to decrypt. So let\u2019s know about the terminologies and concepts behind the cryptography which acts as a base behind our day today online transactions.<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>3.2 Substitution Cipher<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Substitution cipher is a method of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Encoding\">encoding <\/a>in which units of plaintext are replaced with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ciphertext\">ciphertext, <\/a>according to a fixed system. The \"units\" may be single letters (the most common), pairs of letters, triplets of letters, and mixtures of the above. The receiver deciphers the text by performing the inverse substitution.In substitution ciphers, we replace the plaintext letters with other letters<\/p>\r\n&nbsp;\r\n\r\n\u2013\u00a0 The resulting text is the ciphertext\r\n\r\n\u2013\u00a0 The substitution rule is the key\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">It Corresponds to Shannon\u2019s principle of confusion. The letters of plaintext are replaced by other letters or by numbers or symbols. Plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with ciphertext bit patterns.The simple substitution cipher is a cipher that has been in use for many hundreds of years. It basically consists of substituting every plaintext character for a different ciphertext character. It differs from the <a href=\"http:\/\/practicalcryptography.com\/ciphers\/caesar-cipher\/\">Caesar cipher <\/a>in that the cipher alphabet is not simply the alphabet shifted, it is completely jumbled.The simple substitution cipher offers very little communication security, and it will be shown that it can be easily broken even by hand, especially as the messages become longer (more than several hundred ciphertext characters).<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\nExample\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Here is a quick example of the encryption and decryption steps involved with the simple substitution cipher. The text we will encrypt is 'defend the east wall of the castle'.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Keys for the simple substitution cipher usually consist of 26 letters (compared to the caeser cipher's single number). An example key is:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"background-color: #ffcc99\">plain alphabet : abcdefghijklmnopqrstuvwxyz<\/span><\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<span style=\"background-color: #ffcc99\">\u00a0 \u00a0 cipher alphabet: phqgiumeaylnofdxjkrcvstzwb<\/span>\r\n\r\n&nbsp;\r\n\r\nAn example encryption using the above key:\r\n\r\n&nbsp;\r\n\r\n<span style=\"background-color: #ffcc99\">plaintext : defend the east wall of the castle<\/span>\r\n\r\n&nbsp;\r\n\r\n<span style=\"background-color: #ffcc99\">ciphertext: giuifg cei iprc tpnn du cei qprcni<\/span>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">It is easy to see how each character in the plaintext is replaced with the corresponding letter in the cipher alphabet. Decryption is just as easy, by going from the cipher alphabet back to the plain alphabet. When generating keys it is popular to use a key word, e.g. 'zebra' to generate it, since it is much easier to remember a key word compared to a random jumble of 26 characters. Using the keyword 'zebra', the key would become:<\/p>\r\n&nbsp;\r\n\r\n<span style=\"background-color: #ffcc99\">cipher alphabet: zebracdfghijklmnopqstuvwxy<\/span>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">This key is then used identically to the example above. If your key word has repeated characters e.g. 'mammoth', be careful not to include the repeated characters in the cipher alphabet<\/p>\r\n&nbsp;\r\n\r\n<strong>3.3 Caesar Cipher<\/strong>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The Caesar cipher is one of the earliest known and simplest ciphers. It is a type of substitution cipher in which each letter in the plaintext is 'shifted' a certain number of places down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is named after Julius Caesar, who apparently used it to communicate with his generals. It is used until 16th century and it replaces each letter by 3rd letter.<\/p>\r\n&nbsp;\r\n\r\nexample:\r\n\r\n&nbsp;\r\n\r\nmeet me after the toga party\r\n\r\nPHHW PH DIWHU WKH WRJD SDUWB\r\n\r\ncan define transformation as:\r\n\r\n<\/div>\r\n<div>\r\n\r\n\u00a0 \u00a0 a b c d e f g h i j k l m n o p q r s t u v w x y z\r\n\r\nD E F G H I J K L M N O P Q R S T U V W X Y Z A B C\r\n\r\n&nbsp;\r\n\r\nmathematically give each letter a number\r\n\r\n&nbsp;\r\n\r\na b c d e f g h i j k l m n o p q r s t u\u00a0 v w x y z\r\n\r\n0\u00a0\u00a0\u00a0 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\r\n\r\n&nbsp;\r\n\r\nIt can be easily depicted using the following\u00a0\u00a0 Caesar cipher :\r\n\r\n&nbsp;\r\n\r\nc = E(p) = (p + k) mod (26)\r\n\r\np = D(c) = (c \u2013 k) mod (26)\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.3.1 Cryptanalysis Of Caesar Cipher<\/strong>\r\n\r\n\u00d8\u00a0 only have 26 possible ciphers\r\n\r\n&nbsp;\r\n<p style=\"padding-left: 60px\">\u00a7\u00a0\u00a0\u00a0 A maps to A,B,..Z<\/p>\r\n&nbsp;\r\n\r\n\u00d8\u00a0\u00a0 could simply try each in turn a brute force search\r\n\r\n\u00d8\u00a0\u00a0 given ciphertext, just try all shifts of letters\r\n\r\n\u00d8\u00a0\u00a0 do need to recognize when have plaintext\r\n\r\n\u00d8\u00a0\u00a0 eg. break ciphertext \"GCUA VQ DTGCM\"\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The Caesar cipher is probably the easiest of all ciphers to break. Since the shift has to be a number between 1 and 25, (0 or 26 would result in an unchanged plaintext) we can simply try each possibility and see which one results in a piece of readable text. If you happen to know what a piece of the ciphertext is, or you can guess a piece, then this will allow you to immediately find the key.<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.4 Simple Substitution Cipher<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 rather than just shifting the alphabet\r\n\r\n\u00d8\u00a0\u00a0 could shuffle (jumble) the letters arbitrarily\r\n\r\n\u00d8\u00a0\u00a0 each plaintext letter maps to a different random ciphertext letter\r\n\r\n\u00d8\u00a0\u00a0 hence key is 26 letters long\r\n\r\n<\/div>\r\n<div>\r\n<p style=\"text-align: justify\">A monoalphabetic substitution cipher, also known as a simple substitution cipher, relies on a fixed replacement structure. That is, the substitution is fixed for each letter of the alphabet. Thus, if \"a\" is encrypted to \"R\", then every time we see the letter \"a\" in the plaintext, we replace it with the letter \"R\" in the ciphertext.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">A simple example is where each letter is encrypted as the next letter in the alphabet: \"a simple message\" becomes \"B TJNQMF NFTTBHF\". In general, when performing a simple substitution manually, it is easiest to generate the ciphertext alphabet first, and encrypt by comparing this to the plaintext alphabet. The table below shows how one might choose to, and we will, lay them out for this example.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-36 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6.png\" alt=\"\" width=\"643\" height=\"58\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The ciphertext alphabet for the cipher where you replace each letter by the next letter in the alphabet. There are many different monoalphabetic substitution ciphers, in fact infinitely many, as each letter can be encrypted to any symbol, not just another letter.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The history of simple substitution ciphers can be traced back to the very earliest civilisations, and for a long time they were more than adequate for the purposes for which they were needed. By today's standards they are very weak, and incredibly easy to break, but they were a very important step in developing.<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.4.1 Simple Substitution Cipher Security<\/strong>\r\n\r\n&nbsp;\r\n\r\nMonoalphabetic ciphers are not very secure and can be easily broken by statistical means\r\n\r\n\u00d8 now have a total of 26! = 4 x 1026 keys\u00a0\u00a0 HY6JIN9YI66inj\r\n\r\n\u00d8\u00a0\u00a0 with so many keys, might think is secure\r\n\r\n\u00d8\u00a0\u00a0 but would be !!!WRONG!!!\r\n\r\n\u00d8\u00a0\u00a0 problem is language characteristics\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>3.5 Cryptanalysis<\/strong>\r\n\r\n\u00d8\u00a0 Statistical analysis\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Statistics might reveal info about key<\/p>\r\n\u00d8\u00a0 Ciphertext should appear random\r\n\r\n\u00d8\u00a0\u00a0 But randomness is not easy\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Difficult to define random (entropy)<\/p>\r\n\u00d8\u00a0 Human languages are redundant\r\n\r\n\u00d8\u00a0 A strong familiarity with a language includes a grasp of the language's redundancy.\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Redundancy means that every language contains more characters or words than are actually needed to convey information. The rules of the English language create redundancy. For example, no English word will begin with the letters \"ng.\" English also relies heavily on a small number of words. Words like \"the,\" \"of,\" \"and,\" \"to,\" \"a,\" \"in,\" \"that,\" \"it,\" \"is,\" and \"I\" account for more than one quarter of the text of an average message written in English.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Knowing the redundant qualities of a language makes a cryptanalyst's task much easier. No matter how convoluted the cipher is, it follows some language's rules in order for the recipient to understand the message. Cryptanalysts look for patterns within ciphers to find common words and letter pairings.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">One basic technique in cryptanalysis is frequency analysis. Every language uses certain letters more often than others. In English, the letter \"e\" is the most common letterin English E is by far the most common letter<\/p>\r\n\r\n<ul>\r\n \t<li>followed by T,R,N,I,O,A,S<\/li>\r\n<\/ul>\r\n&nbsp;\r\n<p style=\"text-align: justify\">. By counting up the characters in a text, a cryptanalyst can see very quickly what sort of cipher he has. If the distribution of cipher frequency is similar to the distribution of the frequency of a normal alphabet, the cryptanalyst may conclude that he's dealing with a monoalphabetic cipher.<\/p>\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n<ul>\r\n \t<li>other letters like Z,J,K,Q,X are fairly rare<\/li>\r\n \t<li>have tables of single, double &amp; triple letter frequencies for various languages<\/li>\r\n<\/ul>\r\n<img class=\"size-full wp-image-37 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7.png\" alt=\"\" width=\"656\" height=\"403\" \/>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n<ul>\r\n \t<li>English Letter Frequencies<\/li>\r\n<\/ul>\r\n&nbsp;\r\n\r\n<strong>3.5.1 Use In Cryptanalysis<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 key concept - monoalphabetic substitution ciphers do not change relative letter frequencies\r\n\r\n\u00d8\u00a0 discovered by Arabian scientists in 9th century\r\n\r\n\u00d8\u00a0\u00a0 calculate letter frequencies for ciphertext\r\n\r\n\u00d8\u00a0\u00a0 compare counts\/plots against known values\r\n\r\n\u00d8\u00a0 If caesar cipher look for common peaks\/troughs\r\n<ul>\r\n \t<li>peaks at: A-E-I triple, NO pair, RST triple<\/li>\r\n \t<li>troughs at: JK, X-Z<\/li>\r\n<\/ul>\r\n\u00d8\u00a0 for monoalphabetic must identify each letter\r\n\r\n<\/div>\r\n<div>\r\n<ul>\r\n \t<li>tables of common double\/triple letters help<\/li>\r\n<\/ul>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.5.2 Example Cryptanalysis<\/strong>\r\n\r\n\u00d8\u00a0 given ciphertext:\r\n\r\n&nbsp;\r\n<p style=\"padding-left: 60px\">UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ<\/p>\r\n&nbsp;\r\n\r\n\u00d8\u00a0 count relative letter frequencies (see text)\r\n\r\n\u00d8\u00a0\u00a0 guess P &amp; Z are e and t\r\n\r\n\u00d8\u00a0\u00a0 guess ZW is th and hence ZWP is the\r\n\r\n\u00d8\u00a0\u00a0 proceeding with trial and error finally get:\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 it was disclosed yesterday that several informal but direct contacts have been made,<\/p>\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 representatives of the viet cong in Moscow<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.6 Poly-Alphabetic Substitution<\/strong>\r\n\r\n&nbsp;\r\n\r\nA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 polyalphabetic cipher is based on <a href=\"https:\/\/en.wikipedia.org\/wiki\/Substitution_cipher\">substitution, <\/a>using multiple substitution alphabets.\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0\u00a0 Like a simple substitution, but permutation (\u201calphabet\u201d) changes\r\n<p style=\"padding-left: 120px\">\u2013\u00a0 Often, a new alphabet for each letter<\/p>\r\n\u00d8\u00a0 Very common in classic ciphers\r\n\r\n&nbsp;\r\n<p style=\"padding-left: 120px\">\u2013\u00a0 Vigenere cipher is an example<\/p>\r\n<p style=\"padding-left: 120px\">\u2013\u00a0 Discuss Vigenere later in this section<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u00d8\u00a0\u00a0\u00a0\u00a0\u00a0 The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Enigma_machine\">Enigma machine <\/a>is more complex but still fundamentally a polyalphabetic substitution cipher.<\/p>\r\n\u00d8\u00a0 Used in WWII-era cipher machines.\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>3.7 Playfair Cipher<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The Playfair cipher was the first practical digraph substitution cipher. The scheme was invented in 1854 by Charles Wheatstone, but was named after Lord Playfair who promoted the use of the cipher. The technique encrypts pairs of letters (digraphs), instead of single letters as in the simple substitution cipher. The Playfair is significantly harder to break since the frequency analysis used for simple substitution ciphers does not work with it. Frequency analysis can still be undertaken, but on the 25*25=625 possible digraphs rather than the 25 possible monographs. Frequency analysis thus requires much more ciphertext in order to work. Playfair is reasonably fast to use and requires no special equipment. A typical scenario for Playfair use would be to protect important but non-critical secrets during actual combat.<\/p>\r\n&nbsp;\r\n\r\n<strong>3.7.1 Playfair Key Matrix<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 a 5X5 matrix of letters based on a keyword\r\n\r\n\u00d8\u00a0\u00a0 fill in letters of keyword (sans duplicates)\r\n\r\n\u00d8\u00a0\u00a0 fill rest of matrix with other letters\r\n\r\n\u00d8\u00a0\u00a0 eg. using the keyword MONARCHY\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-38 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8.png\" alt=\"\" width=\"378\" height=\"243\" \/>\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>3.7.2 Encrypting And Decrypting<\/strong>\r\n\r\n&nbsp;\r\n\r\nplaintext is encrypted two letters at a time\r\n\r\n\u00d8\u00a0 if a pair is a repeated letter, insert filler like 'X\u2019\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 if both letters fall in the same row, replace each with letter to right(wrapping back to start from end)\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u00d8\u00a0 if both letters fall in the same column, replace each with the letter below it (again wrapping to top from bottom)<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u00d8\u00a0 otherwise each letter is replaced by the letter in the same row and in the column of the other letter of the pair<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In order to encrypt using the Playfair Cipher, we must first draw up a <a href=\"http:\/\/crypto.interactive-maths.com\/polybius-square.html\">Polybius<\/a> <a href=\"http:\/\/crypto.interactive-maths.com\/polybius-square.html\">Square <\/a>(but without the need for the number headings). This is usually done using a keyword, and either combining \"i\" and \"j\" or omitting \"q\" from the square.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">We must now split the plaintext up into digraphs (that is pairs of letters). On each digraph we perform the following encryption steps.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">If the digraph consists of the same letter twice (or there is only one letter left by itself at the end of the plaintext) then insert the letter \"X\" between the same letters (or at the end), and then continue with the rest of the steps.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">If the two letters appear on the same row in the square, then replace each letter by the letter immediately to the right of it in the square (cycling round to the left hand side if necessary).<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">If the two letters appear in the same column in the square, then replace each letter by the letter immediately below it in the square (cycling round to the top of the square if necessary).<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Otherwise, form the rectangle for which the two plaintext letters are two opposite corners. Then replace each plaintext letter with the letter that forms the other corner of\u00a0<span style=\"font-size: 1em;text-align: initial\">the rectangle that lies on the same row as that plaintext letter (being careful to maintain the order).<\/span><\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>3.7.3 Security Of Playfair Cipher<\/strong>\r\n\r\n\u00d8\u00a0 security much improved over monoalphabetic\r\n\r\n\u00d8\u00a0\u00a0 since have 26 x 26 = 676 digrams\r\n\r\n\u00d8\u00a0\u00a0 would need a 676 entry frequency table to analyse (verses 26 for a monoalphabetic)\r\n\r\n\u00d8\u00a0\u00a0 and correspondingly more ciphertext\r\n\r\n\u00d8\u00a0\u00a0 was widely used for many years\r\n\r\n\u00d8\u00a0\u00a0 eg. by US &amp; British military in WW1\r\n\r\n\u00d8\u00a0\u00a0 it can be broken, given a few hundred letters\r\n\r\n\u00d8\u00a0\u00a0 still has much of plaintext structure\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.8 Affine Cipher<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The affine cipher encrypts by multiplying the plaintext by one part of the key followed by addition of another part of the key followed by addition of another part of the key.<\/p>\r\n<img class=\"alignnone size-full wp-image-39\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-9.png\" alt=\"\" width=\"340\" height=\"202\" \/>\u00d8\u00a0 Require that gcd(a, 26) = 1 (why?)\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The restriction gcd(a,26)=1 arises from the fact that the key parameter a needs to be inverted for decryption. An element a and the modulus must be relatively prime for the inverse of a to exist. Thus, a must be in the set:<\/p>\r\n\r\n<\/div>\r\n<div>\r\n<p style=\"text-align: center\">A \u20ac{1,3,5,7,9,11,15,17,19,21,23,25}<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">But how do we find inverse of a? We can simply compute it by trial and error. For a given a we simply try all possible values of a-1until we obtain<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-40\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-10.png\" alt=\"\" width=\"274\" height=\"79\" \/>\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 Keyspace size?\r\n\r\n&nbsp;\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Keyspace size is 26\u00b7\u00a0 (26) = 312\r\n<p style=\"text-align: justify\">\u2022\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Too small to be practical. A key space with 312 elements can, still be searched exhaustively that is brute-force attacked, in a fraction of a second with current desktop PCs. Here the mapping between the plaintext letters and ciphertext letters is fixed. Hence, it can easily be broken with letter frequency analysis.<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.9 Vigenere Cipher<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">A vigenere cipher is a special case of polyalphabetic system in which number of different substitution alphabets are used rather than just one. The number of substitution alphabets used may be anything from 2 to many thousands.<\/p>\r\n&nbsp;\r\n\r\n\u00d8\u00a0 Key is of the form K = (k0,k1,\u2026,kn-1) Where each ki\u00a0\u00a0 {0,1,2,\u2026,25}\r\n\r\n\u00d8\u00a0\u00a0 Encryption\r\n<p style=\"padding-left: 60px\">ci = pi + ki (mod n) (mod 26)<\/p>\r\n&nbsp;\r\n\r\n\u00d8\u00a0 Decryption\r\n<p style=\"padding-left: 60px\">pi = ci \u2013 ki (mod n) (mod 26)<\/p>\r\n&nbsp;\r\n\r\nJust a repeating sequence of (shift by n) simple substitutions.\r\n\r\n&nbsp;\r\n\r\n<strong>3.9.1 Example<\/strong>\r\n\r\n&nbsp;\r\n\r\nFor example, suppose key is MATH\r\n\r\nThat is, K = (12,0,19,7), since M is letter 12, and so on\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n<p style=\"padding-left: 90px\">\u00a0 \u00a0 Plaintext:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SECRETMESSAGE<\/p>\r\n<p style=\"padding-left: 90px\">Ciphertext:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 EEVYQTFLESTNQ<\/p>\r\n&nbsp;\r\n\r\nEncrypt:\r\n\r\n&nbsp;\r\n<p style=\"padding-left: 90px\">S E C R E T M E S S A G E<\/p>\r\n<p style=\"padding-left: 90px\">18 4 2 17 4 19 12 4 18 18 0 6 4<\/p>\r\n<p style=\"padding-left: 90px\">+12 0 19 7 12 0 19 7 12 0 19 7 12<\/p>\r\n<p style=\"padding-left: 90px\">4\u00a0\u00a0\u00a0\u00a0 4 21 24 16 19 5 11 4 18 19 13 16 (mod 26)<\/p>\r\n<p style=\"padding-left: 90px\">E E V Y Q T F L E S T N Q<\/p>\r\n&nbsp;\r\n\r\nBut how to determine k (key length)?\r\n\r\nThere are two methods for that. They are,\r\n\r\n&nbsp;\r\n\r\n\u2013\u00a0 Kasiski Method\r\n\r\n\u2013\u00a0 Index of coincidence\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.9.2 Kasiski Method<\/strong>\r\n\r\n\u00d8\u00a0 method developed by Babbage \/ Kasiski\r\n\r\n\u00d8\u00a0\u00a0 repetitions in ciphertext give clues to period\r\n\r\n\u00d8\u00a0\u00a0 so find same plaintext an exact period apart\r\n\r\n\u00d8\u00a0\u00a0 which results in the same ciphertext\r\n\r\n\u00d8\u00a0\u00a0 of course, could also be random fluke\r\n\r\n\u00d8\u00a0 then attack each monoalphabetic cipher individually using same techniques as before\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.9.3 Index Of Coincidence<\/strong>\r\n\r\n\u00d8\u00a0 Assume ciphertext is English letters\r\n\r\n\u00d8\u00a0 Let n0 be number of As, n1 number of Bs, \u2026, n25 number of Zs in ciphertext\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">\u00d8\u00a0 Let n = n0 + n1 + \u2026 + n25<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\u00d8\u00a0 Gives the probability that 2 randomly selected letters are the same<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\u00d8\u00a0\u00a0 For plain English, prob. 2 letter are same:<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img class=\"alignnone size-full wp-image-41\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11.png\" alt=\"\" width=\"503\" height=\"51\" \/>\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 Then for simple substitution, I \u2248 0.065\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 For random letters, each pi = 1\/26\r\n\r\n<img class=\"alignnone size-full wp-image-42\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-12.png\" alt=\"\" width=\"299\" height=\"52\" \/>\r\n\r\n&nbsp;\r\n\r\n\u00d8 Then I \u2248 0.03846 for poly-alphabetic substitution with a very long keyword\r\n\r\n\u00d8 How to use this to estimate length of keyword in Vigenere cipher?\r\n\r\n\u00d8 Suppose keyword is length k, message is length n\r\n<p style=\"padding-left: 90px\">o Ciphertext in matrix with k columns, n\/k rows \u00d8<\/p>\r\n&nbsp;\r\n\r\n\u00d8 Select 2 letters from same columns\r\n<p style=\"padding-left: 90px\">o Like selecting from simple substitution<\/p>\r\n&nbsp;\r\n\r\n\u00d8 Select 2 letters from different columns\r\n<p style=\"padding-left: 120px\">o\u00a0 Like selecting random letters<\/p>\r\n&nbsp;\r\n\r\n<strong>3.10 Hill Cipher<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u00d8\u00a0 Invented by Lester Hill in 1929 o A pre-modern block cipher\r\n\r\n\u00d8\u00a0 Idea is to create a substitution cipher with a large \u201calphabet\u201d.\r\n\r\n\u00d8\u00a0 Plaintext, p0, p1, p2, \u2026\r\n\r\n\u00d8\u00a0 Each pi is block of n consecutive letters\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 As a column vector<\/p>\r\n\u00d8\u00a0 Let A be n x n invertible matrix, mod 26\r\n\r\n\u00d8\u00a0 Then ciphertext block ci is given by\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Encryption: ci = Api (mod 26)<\/p>\r\n<p style=\"padding-left: 60px\"><span style=\"text-align: initial;font-size: 1em\">o\u00a0 Decryption: pi = A\u00a0<\/span><sup style=\"text-align: initial\">\u20131<\/sup><span style=\"text-align: initial;font-size: 1em\"> ci (mod 26)<\/span><\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n\u00d8 The matrix A is the key\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.10.1 Hill Cipher Example<\/strong>\r\n\r\n\u00d8\u00a0 Let n = 2 and\r\n\r\n\u00d8\u00a0\u00a0 Plaintext\r\n<p style=\"padding-left: 60px\">\u00a7\u00a0\u00a0\u00a0 MEETMEHERE = (12,4,4,19,12,4,7,4,17,4)<\/p>\r\n\u00d8\u00a0\u00a0 Then Ciphertext will be\r\n<p style=\"padding-left: 60px\">\u00a7\u00a0\u00a0\u00a0 (4,22,23,9,4,22,24,19,10,25) = EWXJEWYTKZ<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>3.10.2 Hill Cipher Cryptanalysis<\/strong>\r\n\r\n\u00d8\u00a0 Trudy suspects Alice and Bob are using Hill cipher, with n x n matrix A\r\n\r\n\u00d8\u00a0\u00a0 Suppose Trudy knows n plaintext blocks\r\n\r\n&nbsp;\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Plaintext blocks p0,p1,\u2026,pn-1<\/p>\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Ciphertext blocks c0,c1,\u2026,cn-1<\/p>\r\n&nbsp;\r\n\r\n\u00d8\u00a0 Let P be matrix with columns p0,p1,\u2026,pn-1\r\n\r\n\u00d8\u00a0 Let C be matrix with columns c0,c1,\u2026,cn-1\r\n\r\n\u00d8 Then AP = C and A = CP<sup>\u20131<\/sup> if P <sup>\u20131<\/sup> exists\r\n\r\n\u00d8\u00a0 Linear ciphers are weak\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Since linear equations are easy to solve<\/p>\r\n\u00d8\u00a0 Strong cipher must have nonlinearity\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Linear components are useful<\/p>\r\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 But cipher cannot be entirely linear<\/p>\r\n\u00d8\u00a0 Cryptanalyst try to approximate nonlinear parts with linear equations\r\n\r\n<\/div>\r\n&nbsp;\r\n\r\n<strong>Summary<\/strong>\r\n<ul>\r\n \t<li>\u00d8 Discussed about the Substitution cipher cryptography<\/li>\r\n \t<li>\u00d8 Discussed about the Cryptanalysis<\/li>\r\n \t<li>\u00d8 Explored the substitution cipher- monoalphabet cipher and polyalphabet cipher<\/li>\r\n \t<li>\u00d8 Discussed about the monoalphabet cipher, polyalphabet cipher and its cryptanalysis<\/li>\r\n<\/ul>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on Substitution Cipherand Cryptanalysis<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/hx3mUX-lRls\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n<img class=\"size-full wp-image-44 alignleft\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14.png\" alt=\"\" width=\"643\" height=\"467\" \/>","rendered":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/hx3mUX-lRls\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Learning Objectives<\/strong><\/p>\n<p>\u00d8\u00a0 To know the substitution cipher in classical cryptography<\/p>\n<p>\u00d8\u00a0\u00a0 To learn about the mono alphabetic substitution cipher<\/p>\n<p>\u00d8\u00a0\u00a0 To learn about the poly alphabetic substitution cipher<\/p>\n<p>\u00d8\u00a0\u00a0 Cryptanalysis of substitution cipher<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.1 Introduction<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Humans could encode their own documents, but computers do it faster and more efficiently. To do this, the computer at each end uses a document called an &#8220;SSL Certificate&#8221; containing character strings that are the keys to their secret &#8220;codes.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cryptography\">cryptography, <\/a>a transposition cipher is a method of encryption by which the positions held by units of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Plaintext\">plaintext <\/a>are shifted according to a regular system, so that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ciphertext\">ciphertext <\/a>constitutes a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Permutation\">permutation <\/a>of the plaintext. That is, the order of the units is changed. Mathematically a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bijective\">bijective <\/a>function is used on the characters&#8217; positions to encrypt and an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Inverse_function\">inverse function <\/a>to decrypt. So let\u2019s know about the terminologies and concepts behind the cryptography which acts as a base behind our day today online transactions.<\/p>\n<\/div>\n<div>\n<p><strong>3.2 Substitution Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Substitution cipher is a method of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Encoding\">encoding <\/a>in which units of plaintext are replaced with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ciphertext\">ciphertext, <\/a>according to a fixed system. The &#8220;units&#8221; may be single letters (the most common), pairs of letters, triplets of letters, and mixtures of the above. The receiver deciphers the text by performing the inverse substitution.In substitution ciphers, we replace the plaintext letters with other letters<\/p>\n<p>&nbsp;<\/p>\n<p>\u2013\u00a0 The resulting text is the ciphertext<\/p>\n<p>\u2013\u00a0 The substitution rule is the key<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">It Corresponds to Shannon\u2019s principle of confusion. The letters of plaintext are replaced by other letters or by numbers or symbols. Plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with ciphertext bit patterns.The simple substitution cipher is a cipher that has been in use for many hundreds of years. It basically consists of substituting every plaintext character for a different ciphertext character. It differs from the <a href=\"http:\/\/practicalcryptography.com\/ciphers\/caesar-cipher\/\">Caesar cipher <\/a>in that the cipher alphabet is not simply the alphabet shifted, it is completely jumbled.The simple substitution cipher offers very little communication security, and it will be shown that it can be easily broken even by hand, especially as the messages become longer (more than several hundred ciphertext characters).<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Example<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Here is a quick example of the encryption and decryption steps involved with the simple substitution cipher. The text we will encrypt is &#8216;defend the east wall of the castle&#8217;.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Keys for the simple substitution cipher usually consist of 26 letters (compared to the caeser cipher&#8217;s single number). An example key is:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"background-color: #ffcc99\">plain alphabet : abcdefghijklmnopqrstuvwxyz<\/span><\/p>\n<\/div>\n<div>\n<p><span style=\"background-color: #ffcc99\">\u00a0 \u00a0 cipher alphabet: phqgiumeaylnofdxjkrcvstzwb<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>An example encryption using the above key:<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ffcc99\">plaintext : defend the east wall of the castle<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ffcc99\">ciphertext: giuifg cei iprc tpnn du cei qprcni<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">It is easy to see how each character in the plaintext is replaced with the corresponding letter in the cipher alphabet. Decryption is just as easy, by going from the cipher alphabet back to the plain alphabet. When generating keys it is popular to use a key word, e.g. &#8216;zebra&#8217; to generate it, since it is much easier to remember a key word compared to a random jumble of 26 characters. Using the keyword &#8216;zebra&#8217;, the key would become:<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ffcc99\">cipher alphabet: zebracdfghijklmnopqstuvwxy<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">This key is then used identically to the example above. If your key word has repeated characters e.g. &#8216;mammoth&#8217;, be careful not to include the repeated characters in the cipher alphabet<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.3 Caesar Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The Caesar cipher is one of the earliest known and simplest ciphers. It is a type of substitution cipher in which each letter in the plaintext is &#8216;shifted&#8217; a certain number of places down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is named after Julius Caesar, who apparently used it to communicate with his generals. It is used until 16th century and it replaces each letter by 3rd letter.<\/p>\n<p>&nbsp;<\/p>\n<p>example:<\/p>\n<p>&nbsp;<\/p>\n<p>meet me after the toga party<\/p>\n<p>PHHW PH DIWHU WKH WRJD SDUWB<\/p>\n<p>can define transformation as:<\/p>\n<\/div>\n<div>\n<p>\u00a0 \u00a0 a b c d e f g h i j k l m n o p q r s t u v w x y z<\/p>\n<p>D E F G H I J K L M N O P Q R S T U V W X Y Z A B C<\/p>\n<p>&nbsp;<\/p>\n<p>mathematically give each letter a number<\/p>\n<p>&nbsp;<\/p>\n<p>a b c d e f g h i j k l m n o p q r s t u\u00a0 v w x y z<\/p>\n<p>0\u00a0\u00a0\u00a0 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<\/p>\n<p>&nbsp;<\/p>\n<p>It can be easily depicted using the following\u00a0\u00a0 Caesar cipher :<\/p>\n<p>&nbsp;<\/p>\n<p>c = E(p) = (p + k) mod (26)<\/p>\n<p>p = D(c) = (c \u2013 k) mod (26)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.3.1 Cryptanalysis Of Caesar Cipher<\/strong><\/p>\n<p>\u00d8\u00a0 only have 26 possible ciphers<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 60px\">\u00a7\u00a0\u00a0\u00a0 A maps to A,B,..Z<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0\u00a0 could simply try each in turn a brute force search<\/p>\n<p>\u00d8\u00a0\u00a0 given ciphertext, just try all shifts of letters<\/p>\n<p>\u00d8\u00a0\u00a0 do need to recognize when have plaintext<\/p>\n<p>\u00d8\u00a0\u00a0 eg. break ciphertext &#8220;GCUA VQ DTGCM&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The Caesar cipher is probably the easiest of all ciphers to break. Since the shift has to be a number between 1 and 25, (0 or 26 would result in an unchanged plaintext) we can simply try each possibility and see which one results in a piece of readable text. If you happen to know what a piece of the ciphertext is, or you can guess a piece, then this will allow you to immediately find the key.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.4 Simple Substitution Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 rather than just shifting the alphabet<\/p>\n<p>\u00d8\u00a0\u00a0 could shuffle (jumble) the letters arbitrarily<\/p>\n<p>\u00d8\u00a0\u00a0 each plaintext letter maps to a different random ciphertext letter<\/p>\n<p>\u00d8\u00a0\u00a0 hence key is 26 letters long<\/p>\n<\/div>\n<div>\n<p style=\"text-align: justify\">A monoalphabetic substitution cipher, also known as a simple substitution cipher, relies on a fixed replacement structure. That is, the substitution is fixed for each letter of the alphabet. Thus, if &#8220;a&#8221; is encrypted to &#8220;R&#8221;, then every time we see the letter &#8220;a&#8221; in the plaintext, we replace it with the letter &#8220;R&#8221; in the ciphertext.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">A simple example is where each letter is encrypted as the next letter in the alphabet: &#8220;a simple message&#8221; becomes &#8220;B TJNQMF NFTTBHF&#8221;. In general, when performing a simple substitution manually, it is easiest to generate the ciphertext alphabet first, and encrypt by comparing this to the plaintext alphabet. The table below shows how one might choose to, and we will, lay them out for this example.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-36 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6.png\" alt=\"\" width=\"643\" height=\"58\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6.png 643w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6-300x27.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6-65x6.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6-225x20.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-6-350x32.png 350w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The ciphertext alphabet for the cipher where you replace each letter by the next letter in the alphabet. There are many different monoalphabetic substitution ciphers, in fact infinitely many, as each letter can be encrypted to any symbol, not just another letter.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The history of simple substitution ciphers can be traced back to the very earliest civilisations, and for a long time they were more than adequate for the purposes for which they were needed. By today&#8217;s standards they are very weak, and incredibly easy to break, but they were a very important step in developing.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.4.1 Simple Substitution Cipher Security<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Monoalphabetic ciphers are not very secure and can be easily broken by statistical means<\/p>\n<p>\u00d8 now have a total of 26! = 4 x 1026 keys\u00a0\u00a0 HY6JIN9YI66inj<\/p>\n<p>\u00d8\u00a0\u00a0 with so many keys, might think is secure<\/p>\n<p>\u00d8\u00a0\u00a0 but would be !!!WRONG!!!<\/p>\n<p>\u00d8\u00a0\u00a0 problem is language characteristics<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>3.5 Cryptanalysis<\/strong><\/p>\n<p>\u00d8\u00a0 Statistical analysis<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Statistics might reveal info about key<\/p>\n<p>\u00d8\u00a0 Ciphertext should appear random<\/p>\n<p>\u00d8\u00a0\u00a0 But randomness is not easy<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Difficult to define random (entropy)<\/p>\n<p>\u00d8\u00a0 Human languages are redundant<\/p>\n<p>\u00d8\u00a0 A strong familiarity with a language includes a grasp of the language&#8217;s redundancy.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Redundancy means that every language contains more characters or words than are actually needed to convey information. The rules of the English language create redundancy. For example, no English word will begin with the letters &#8220;ng.&#8221; English also relies heavily on a small number of words. Words like &#8220;the,&#8221; &#8220;of,&#8221; &#8220;and,&#8221; &#8220;to,&#8221; &#8220;a,&#8221; &#8220;in,&#8221; &#8220;that,&#8221; &#8220;it,&#8221; &#8220;is,&#8221; and &#8220;I&#8221; account for more than one quarter of the text of an average message written in English.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Knowing the redundant qualities of a language makes a cryptanalyst&#8217;s task much easier. No matter how convoluted the cipher is, it follows some language&#8217;s rules in order for the recipient to understand the message. Cryptanalysts look for patterns within ciphers to find common words and letter pairings.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">One basic technique in cryptanalysis is frequency analysis. Every language uses certain letters more often than others. In English, the letter &#8220;e&#8221; is the most common letterin English E is by far the most common letter<\/p>\n<ul>\n<li>followed by T,R,N,I,O,A,S<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">. By counting up the characters in a text, a cryptanalyst can see very quickly what sort of cipher he has. If the distribution of cipher frequency is similar to the distribution of the frequency of a normal alphabet, the cryptanalyst may conclude that he&#8217;s dealing with a monoalphabetic cipher.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<ul>\n<li>other letters like Z,J,K,Q,X are fairly rare<\/li>\n<li>have tables of single, double &amp; triple letter frequencies for various languages<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-37 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7.png\" alt=\"\" width=\"656\" height=\"403\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7.png 656w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7-300x184.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7-65x40.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7-225x138.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-7-350x215.png 350w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>English Letter Frequencies<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>3.5.1 Use In Cryptanalysis<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 key concept &#8211; monoalphabetic substitution ciphers do not change relative letter frequencies<\/p>\n<p>\u00d8\u00a0 discovered by Arabian scientists in 9th century<\/p>\n<p>\u00d8\u00a0\u00a0 calculate letter frequencies for ciphertext<\/p>\n<p>\u00d8\u00a0\u00a0 compare counts\/plots against known values<\/p>\n<p>\u00d8\u00a0 If caesar cipher look for common peaks\/troughs<\/p>\n<ul>\n<li>peaks at: A-E-I triple, NO pair, RST triple<\/li>\n<li>troughs at: JK, X-Z<\/li>\n<\/ul>\n<p>\u00d8\u00a0 for monoalphabetic must identify each letter<\/p>\n<\/div>\n<div>\n<ul>\n<li>tables of common double\/triple letters help<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.5.2 Example Cryptanalysis<\/strong><\/p>\n<p>\u00d8\u00a0 given ciphertext:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 60px\">UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 count relative letter frequencies (see text)<\/p>\n<p>\u00d8\u00a0\u00a0 guess P &amp; Z are e and t<\/p>\n<p>\u00d8\u00a0\u00a0 guess ZW is th and hence ZWP is the<\/p>\n<p>\u00d8\u00a0\u00a0 proceeding with trial and error finally get:<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 it was disclosed yesterday that several informal but direct contacts have been made,<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 representatives of the viet cong in Moscow<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.6 Poly-Alphabetic Substitution<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 polyalphabetic cipher is based on <a href=\"https:\/\/en.wikipedia.org\/wiki\/Substitution_cipher\">substitution, <\/a>using multiple substitution alphabets.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0\u00a0 Like a simple substitution, but permutation (\u201calphabet\u201d) changes<\/p>\n<p style=\"padding-left: 120px\">\u2013\u00a0 Often, a new alphabet for each letter<\/p>\n<p>\u00d8\u00a0 Very common in classic ciphers<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 120px\">\u2013\u00a0 Vigenere cipher is an example<\/p>\n<p style=\"padding-left: 120px\">\u2013\u00a0 Discuss Vigenere later in this section<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u00d8\u00a0\u00a0\u00a0\u00a0\u00a0 The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Enigma_machine\">Enigma machine <\/a>is more complex but still fundamentally a polyalphabetic substitution cipher.<\/p>\n<p>\u00d8\u00a0 Used in WWII-era cipher machines.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>3.7 Playfair Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The Playfair cipher was the first practical digraph substitution cipher. The scheme was invented in 1854 by Charles Wheatstone, but was named after Lord Playfair who promoted the use of the cipher. The technique encrypts pairs of letters (digraphs), instead of single letters as in the simple substitution cipher. The Playfair is significantly harder to break since the frequency analysis used for simple substitution ciphers does not work with it. Frequency analysis can still be undertaken, but on the 25*25=625 possible digraphs rather than the 25 possible monographs. Frequency analysis thus requires much more ciphertext in order to work. Playfair is reasonably fast to use and requires no special equipment. A typical scenario for Playfair use would be to protect important but non-critical secrets during actual combat.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.7.1 Playfair Key Matrix<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 a 5X5 matrix of letters based on a keyword<\/p>\n<p>\u00d8\u00a0\u00a0 fill in letters of keyword (sans duplicates)<\/p>\n<p>\u00d8\u00a0\u00a0 fill rest of matrix with other letters<\/p>\n<p>\u00d8\u00a0\u00a0 eg. using the keyword MONARCHY<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-38 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8.png\" alt=\"\" width=\"378\" height=\"243\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8.png 378w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8-300x193.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8-65x42.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8-225x145.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-8-350x225.png 350w\" sizes=\"auto, (max-width: 378px) 100vw, 378px\" \/><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>3.7.2 Encrypting And Decrypting<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>plaintext is encrypted two letters at a time<\/p>\n<p>\u00d8\u00a0 if a pair is a repeated letter, insert filler like &#8216;X\u2019<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 if both letters fall in the same row, replace each with letter to right(wrapping back to start from end)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u00d8\u00a0 if both letters fall in the same column, replace each with the letter below it (again wrapping to top from bottom)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u00d8\u00a0 otherwise each letter is replaced by the letter in the same row and in the column of the other letter of the pair<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In order to encrypt using the Playfair Cipher, we must first draw up a <a href=\"http:\/\/crypto.interactive-maths.com\/polybius-square.html\">Polybius<\/a> <a href=\"http:\/\/crypto.interactive-maths.com\/polybius-square.html\">Square <\/a>(but without the need for the number headings). This is usually done using a keyword, and either combining &#8220;i&#8221; and &#8220;j&#8221; or omitting &#8220;q&#8221; from the square.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">We must now split the plaintext up into digraphs (that is pairs of letters). On each digraph we perform the following encryption steps.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">If the digraph consists of the same letter twice (or there is only one letter left by itself at the end of the plaintext) then insert the letter &#8220;X&#8221; between the same letters (or at the end), and then continue with the rest of the steps.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">If the two letters appear on the same row in the square, then replace each letter by the letter immediately to the right of it in the square (cycling round to the left hand side if necessary).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">If the two letters appear in the same column in the square, then replace each letter by the letter immediately below it in the square (cycling round to the top of the square if necessary).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Otherwise, form the rectangle for which the two plaintext letters are two opposite corners. Then replace each plaintext letter with the letter that forms the other corner of\u00a0<span style=\"font-size: 1em;text-align: initial\">the rectangle that lies on the same row as that plaintext letter (being careful to maintain the order).<\/span><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>3.7.3 Security Of Playfair Cipher<\/strong><\/p>\n<p>\u00d8\u00a0 security much improved over monoalphabetic<\/p>\n<p>\u00d8\u00a0\u00a0 since have 26 x 26 = 676 digrams<\/p>\n<p>\u00d8\u00a0\u00a0 would need a 676 entry frequency table to analyse (verses 26 for a monoalphabetic)<\/p>\n<p>\u00d8\u00a0\u00a0 and correspondingly more ciphertext<\/p>\n<p>\u00d8\u00a0\u00a0 was widely used for many years<\/p>\n<p>\u00d8\u00a0\u00a0 eg. by US &amp; British military in WW1<\/p>\n<p>\u00d8\u00a0\u00a0 it can be broken, given a few hundred letters<\/p>\n<p>\u00d8\u00a0\u00a0 still has much of plaintext structure<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.8 Affine Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The affine cipher encrypts by multiplying the plaintext by one part of the key followed by addition of another part of the key followed by addition of another part of the key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-39\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-9.png\" alt=\"\" width=\"340\" height=\"202\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-9.png 340w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-9-300x178.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-9-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-9-225x134.png 225w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/>\u00d8\u00a0 Require that gcd(a, 26) = 1 (why?)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The restriction gcd(a,26)=1 arises from the fact that the key parameter a needs to be inverted for decryption. An element a and the modulus must be relatively prime for the inverse of a to exist. Thus, a must be in the set:<\/p>\n<\/div>\n<div>\n<p style=\"text-align: center\">A \u20ac{1,3,5,7,9,11,15,17,19,21,23,25}<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">But how do we find inverse of a? We can simply compute it by trial and error. For a given a we simply try all possible values of a-1until we obtain<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-40\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-10.png\" alt=\"\" width=\"274\" height=\"79\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-10.png 274w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-10-65x19.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-10-225x65.png 225w\" sizes=\"auto, (max-width: 274px) 100vw, 274px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 Keyspace size?<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Keyspace size is 26\u00b7\u00a0 (26) = 312<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Too small to be practical. A key space with 312 elements can, still be searched exhaustively that is brute-force attacked, in a fraction of a second with current desktop PCs. Here the mapping between the plaintext letters and ciphertext letters is fixed. Hence, it can easily be broken with letter frequency analysis.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.9 Vigenere Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">A vigenere cipher is a special case of polyalphabetic system in which number of different substitution alphabets are used rather than just one. The number of substitution alphabets used may be anything from 2 to many thousands.<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 Key is of the form K = (k0,k1,\u2026,kn-1) Where each ki\u00a0\u00a0 {0,1,2,\u2026,25}<\/p>\n<p>\u00d8\u00a0\u00a0 Encryption<\/p>\n<p style=\"padding-left: 60px\">ci = pi + ki (mod n) (mod 26)<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 Decryption<\/p>\n<p style=\"padding-left: 60px\">pi = ci \u2013 ki (mod n) (mod 26)<\/p>\n<p>&nbsp;<\/p>\n<p>Just a repeating sequence of (shift by n) simple substitutions.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.9.1 Example<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>For example, suppose key is MATH<\/p>\n<p>That is, K = (12,0,19,7), since M is letter 12, and so on<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<p style=\"padding-left: 90px\">\u00a0 \u00a0 Plaintext:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SECRETMESSAGE<\/p>\n<p style=\"padding-left: 90px\">Ciphertext:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 EEVYQTFLESTNQ<\/p>\n<p>&nbsp;<\/p>\n<p>Encrypt:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 90px\">S E C R E T M E S S A G E<\/p>\n<p style=\"padding-left: 90px\">18 4 2 17 4 19 12 4 18 18 0 6 4<\/p>\n<p style=\"padding-left: 90px\">+12 0 19 7 12 0 19 7 12 0 19 7 12<\/p>\n<p style=\"padding-left: 90px\">4\u00a0\u00a0\u00a0\u00a0 4 21 24 16 19 5 11 4 18 19 13 16 (mod 26)<\/p>\n<p style=\"padding-left: 90px\">E E V Y Q T F L E S T N Q<\/p>\n<p>&nbsp;<\/p>\n<p>But how to determine k (key length)?<\/p>\n<p>There are two methods for that. They are,<\/p>\n<p>&nbsp;<\/p>\n<p>\u2013\u00a0 Kasiski Method<\/p>\n<p>\u2013\u00a0 Index of coincidence<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.9.2 Kasiski Method<\/strong><\/p>\n<p>\u00d8\u00a0 method developed by Babbage \/ Kasiski<\/p>\n<p>\u00d8\u00a0\u00a0 repetitions in ciphertext give clues to period<\/p>\n<p>\u00d8\u00a0\u00a0 so find same plaintext an exact period apart<\/p>\n<p>\u00d8\u00a0\u00a0 which results in the same ciphertext<\/p>\n<p>\u00d8\u00a0\u00a0 of course, could also be random fluke<\/p>\n<p>\u00d8\u00a0 then attack each monoalphabetic cipher individually using same techniques as before<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.9.3 Index Of Coincidence<\/strong><\/p>\n<p>\u00d8\u00a0 Assume ciphertext is English letters<\/p>\n<p>\u00d8\u00a0 Let n0 be number of As, n1 number of Bs, \u2026, n25 number of Zs in ciphertext<\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">\u00d8\u00a0 Let n = n0 + n1 + \u2026 + n25<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00d8\u00a0 Gives the probability that 2 randomly selected letters are the same<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00d8\u00a0\u00a0 For plain English, prob. 2 letter are same:<\/span><\/p>\n<\/div>\n<div>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-41\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11.png\" alt=\"\" width=\"503\" height=\"51\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11.png 503w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11-300x30.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11-65x7.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11-225x23.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-11-350x35.png 350w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 Then for simple substitution, I \u2248 0.065<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 For random letters, each pi = 1\/26<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-42\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-12.png\" alt=\"\" width=\"299\" height=\"52\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-12.png 299w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-12-65x11.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-12-225x39.png 225w\" sizes=\"auto, (max-width: 299px) 100vw, 299px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8 Then I \u2248 0.03846 for poly-alphabetic substitution with a very long keyword<\/p>\n<p>\u00d8 How to use this to estimate length of keyword in Vigenere cipher?<\/p>\n<p>\u00d8 Suppose keyword is length k, message is length n<\/p>\n<p style=\"padding-left: 90px\">o Ciphertext in matrix with k columns, n\/k rows \u00d8<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8 Select 2 letters from same columns<\/p>\n<p style=\"padding-left: 90px\">o Like selecting from simple substitution<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8 Select 2 letters from different columns<\/p>\n<p style=\"padding-left: 120px\">o\u00a0 Like selecting random letters<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.10 Hill Cipher<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 Invented by Lester Hill in 1929 o A pre-modern block cipher<\/p>\n<p>\u00d8\u00a0 Idea is to create a substitution cipher with a large \u201calphabet\u201d.<\/p>\n<p>\u00d8\u00a0 Plaintext, p0, p1, p2, \u2026<\/p>\n<p>\u00d8\u00a0 Each pi is block of n consecutive letters<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 As a column vector<\/p>\n<p>\u00d8\u00a0 Let A be n x n invertible matrix, mod 26<\/p>\n<p>\u00d8\u00a0 Then ciphertext block ci is given by<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Encryption: ci = Api (mod 26)<\/p>\n<p style=\"padding-left: 60px\"><span style=\"text-align: initial;font-size: 1em\">o\u00a0 Decryption: pi = A\u00a0<\/span><sup style=\"text-align: initial\">\u20131<\/sup><span style=\"text-align: initial;font-size: 1em\"> ci (mod 26)<\/span><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p>\u00d8 The matrix A is the key<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.10.1 Hill Cipher Example<\/strong><\/p>\n<p>\u00d8\u00a0 Let n = 2 and<\/p>\n<p>\u00d8\u00a0\u00a0 Plaintext<\/p>\n<p style=\"padding-left: 60px\">\u00a7\u00a0\u00a0\u00a0 MEETMEHERE = (12,4,4,19,12,4,7,4,17,4)<\/p>\n<p>\u00d8\u00a0\u00a0 Then Ciphertext will be<\/p>\n<p style=\"padding-left: 60px\">\u00a7\u00a0\u00a0\u00a0 (4,22,23,9,4,22,24,19,10,25) = EWXJEWYTKZ<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.10.2 Hill Cipher Cryptanalysis<\/strong><\/p>\n<p>\u00d8\u00a0 Trudy suspects Alice and Bob are using Hill cipher, with n x n matrix A<\/p>\n<p>\u00d8\u00a0\u00a0 Suppose Trudy knows n plaintext blocks<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Plaintext blocks p0,p1,\u2026,pn-1<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Ciphertext blocks c0,c1,\u2026,cn-1<\/p>\n<p>&nbsp;<\/p>\n<p>\u00d8\u00a0 Let P be matrix with columns p0,p1,\u2026,pn-1<\/p>\n<p>\u00d8\u00a0 Let C be matrix with columns c0,c1,\u2026,cn-1<\/p>\n<p>\u00d8 Then AP = C and A = CP<sup>\u20131<\/sup> if P <sup>\u20131<\/sup> exists<\/p>\n<p>\u00d8\u00a0 Linear ciphers are weak<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Since linear equations are easy to solve<\/p>\n<p>\u00d8\u00a0 Strong cipher must have nonlinearity<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 Linear components are useful<\/p>\n<p style=\"padding-left: 60px\">o\u00a0\u00a0 But cipher cannot be entirely linear<\/p>\n<p>\u00d8\u00a0 Cryptanalyst try to approximate nonlinear parts with linear equations<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>Summary<\/strong><\/p>\n<ul>\n<li>\u00d8 Discussed about the Substitution cipher cryptography<\/li>\n<li>\u00d8 Discussed about the Cryptanalysis<\/li>\n<li>\u00d8 Explored the substitution cipher- monoalphabet cipher and polyalphabet cipher<\/li>\n<li>\u00d8 Discussed about the monoalphabet cipher, polyalphabet cipher and its cryptanalysis<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on Substitution Cipherand Cryptanalysis<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/hx3mUX-lRls\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-44 alignleft\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14.png\" alt=\"\" width=\"643\" height=\"467\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14.png 643w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14-300x218.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14-65x47.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14-225x163.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-14-350x254.png 350w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/p>\n","protected":false},"author":3,"menu_order":2,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["dr-kulothungan"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-33","chapter","type-chapter","status-publish","hentry","contributor-dr-kulothungan"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/users\/3"}],"version-history":[{"count":6,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/33\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/33\/revisions\/522"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/33\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapter-type?post=33"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/contributor?post=33"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/license?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}