{"id":1176,"date":"2010-11-02T15:34:55","date_gmt":"2010-11-02T19:34:55","guid":{"rendered":"http:\/\/www.acarlstein.com\/?p=1176"},"modified":"2010-11-04T15:01:11","modified_gmt":"2010-11-04T19:01:11","slug":"introduction-to-network-security-part-6","status":"publish","type":"post","link":"http:\/\/blog.acarlstein.com\/?p=1176","title":{"rendered":"Introduction to Network Security &#8211; Part 6"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\"><strong>NOTIFICATION:<\/strong><\/span><strong> <\/strong>These examples are provided for  educational purposes.     The use of this code and\/or information is  under your own responsibility and risk. The information and\/or code is      given \u2018as is\u2019. I do not take responsibilities of how they are used.<\/p>\n<p><strong>Poly-alphabetic Cipher<\/strong><\/p>\n<p>In the previous posting, we say that the mono-alphabetic cipher  instead of shifting the alphabet a number of  letters (Caesar cipher),  its substitute each letter arbitrarily by mapping the plaintext  letter  map to a random arranged ciphertext. The only requirement for  the  ciphertext was that the letters must not be repeated. Now we are going to see a cipher that uses a set of related mono-alphabetic rules plus a key to determine which rule will be use to perform a transformation.<\/p>\n<p><strong>Vigen\u00e8re Cipher<\/strong><\/p>\n<p><span style=\"text-decoration: underline;\">Encryption:<\/span><strong><br \/>\n<\/strong><\/p>\n<p>This cipher is similar to the Caesar cipher for the use of the 26 letters alphabet with the only different that we create a table in which:<\/p>\n<ol>\n<li> The columns represent the plain text<\/li>\n<li>The rows represent the key<\/li>\n<li>The alphabet inside the table is shifted to the right one letter one time for each letter of the alphabet key.<\/li>\n<\/ol>\n<p>To be more clear, let take a quick look of the Caesar cipher table:<br \/>\n<a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/10\/table-alphabets-234.jpg\"><\/a><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/10\/alphabet-table-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1144\" title=\"alphabet table 2\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/10\/alphabet-table-2.jpg\" alt=\"\" width=\"682\" height=\"89\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/10\/alphabet-table-2.jpg 682w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/10\/alphabet-table-2-300x39.jpg 300w\" sizes=\"auto, (max-width: 682px) 100vw, 682px\" \/><\/a>In this example, We started the alphabet on the letter &#8216;E&#8217; because the key was 5.<\/p>\n<p>Now, the Vigen\u00e8re Cipher will apply this shifting 26 times, one time per row, for each letter of the alphabet that correspond to the key as follow:<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vigerene_table.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1180\" title=\"vigerene_table\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vigerene_table.jpg\" alt=\"\" width=\"720\" height=\"820\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vigerene_table.jpg 720w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vigerene_table-263x300.jpg 263w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a>Lets say that you have the following key &#8220;THIS\u00a0 MESSAGE WAS FOR YOU&#8221;, and your key is &#8220;HELLO&#8221; then using the table:<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vigerene_table_4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1181\" title=\"vigerene_table_4\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vigerene_table_4.jpg\" alt=\"\" width=\"692\" height=\"790\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vigerene_table_4.jpg 692w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vigerene_table_4-262x300.jpg 262w\" sizes=\"auto, (max-width: 692px) 100vw, 692px\" \/><\/a>We would obtain:<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vergene_table_cipher.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1182\" title=\"vergene_table_cipher\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vergene_table_cipher.jpg\" alt=\"\" width=\"740\" height=\"128\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vergene_table_cipher.jpg 740w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vergene_table_cipher-300x51.jpg 300w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><\/a><\/p>\n<p>From a mathematical point of view we have:<\/p>\n<ol>\n<li>Lets assume that we take the letters of the alphabet from A to Z and be replace them with number starting from 0, for example: A = 0, B = 1, &#8230;, Z = 25.<\/li>\n<li>Since we have 26 letters in the alphabet, lets perform module of 26 on this equation.<\/li>\n<li>If &#8216;i&#8217; is the letter position, P indicate the plaintext, K indicate the key, and C indicate the ciphertext then:<br \/>\n<img decoding=\"async\" src=\"http:\/\/upload.wikimedia.org\/math\/c\/3\/1\/c314980a8135dce53ffcff6e8e17c18c.png\" alt=\"C_i \\equiv (P_i + K_i) \\pmod {26}\" \/><br \/>\n(For more information about the algebra involved in the Vigen\u00e8re cipher: <a title=\"wikipedia vigenere cipher\" href=\"http:\/\/en.wikipedia.org\/wiki\/Vigen%C3%A8re_cipher\" target=\"_blank\">http:\/\/en.wikipedia.org\/wiki\/Vigen%C3%A8re_cipher<\/a>)<\/li>\n<\/ol>\n<p><span style=\"text-decoration: underline;\">Decryption<\/span><\/p>\n<p>For decryption we only need to use a letter of the key to identify the row and the letter of the ciphertext in the row to identify the column, the letter designated to the column give us the plaintext letter.<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vigerene_table_4_decrypt.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1194\" title=\"vigerene_table_4_decrypt\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/vigerene_table_4_decrypt.jpg\" alt=\"\" width=\"344\" height=\"279\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vigerene_table_4_decrypt.jpg 610w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/vigerene_table_4_decrypt-300x243.jpg 300w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/a><\/p>\n<p>From a mathematical point of view we have:<\/p>\n<ol>\n<li>Lets assume that we take the letters of the alphabet from A to Z and   be replace them with number starting from 0, for example: A = 0, B =  1,  &#8230;, Z = 25.<\/li>\n<li>Since we have 26 letters in the alphabet, lets perform module of 26 on this equation.<\/li>\n<li>If &#8216;i&#8217; is the letter position, P indicate the plaintext, K indicate the key, and C indicate the ciphertext then:<br \/>\n<img decoding=\"async\" src=\"http:\/\/upload.wikimedia.org\/math\/1\/3\/0\/130b6a5636dcecdd06dce6ccd444ee29.png\" alt=\"P_i \\equiv (C_i - K_i) \\pmod {26}\" \/><br \/>\n(For more information about the algebra involved in the Vigen\u00e8re cipher: <a title=\"wikipedia vigenere cipher\" href=\"http:\/\/en.wikipedia.org\/wiki\/Vigen%C3%A8re_cipher\" target=\"_blank\">http:\/\/en.wikipedia.org\/wiki\/Vigen%C3%A8re_cipher<\/a>)<\/li>\n<\/ol>\n<p><span style=\"text-decoration: underline;\">Security<\/span><\/p>\n<p>This cipher is not secure. If two or more sequences are identical inside the plaintext, we run the risk that identical ciphertext sequence will be generated. The attacker can use these repetition in the ciphertext to make a deduction about what is the plaintext. The more plaintext is needed to encrypt, the more chances that the ciphertext can be broken or the key found.<\/p>\n<p>As an example, lets assume we have the following:<br \/>\nPlaintext:\u00a0\u00a0 WE RUN WHEN WE WERE DISCOVER BY THEM<br \/>\nKey: \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 RUNNING NO RUNNING NO RUNNING NO<\/p>\n<p>This would give us a ciphertext in which we can spot the repetitions:<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/example-vigenere.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1203\" title=\"example vigenere\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/example-vigenere.jpg\" alt=\"\" width=\"589\" height=\"83\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/example-vigenere.jpg 780w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/example-vigenere-300x42.jpg 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/a><\/p>\n<p>The only way around this problem is by using the Autokey cipher.<\/p>\n<p><strong>Autokey Cipher<\/strong><\/p>\n<p>An auto-key cipher is the concept of generating a key that does not have a repetition cycle.<\/p>\n<p>Instead of having a plaintext and a key such as this example:<br \/>\nPlaintext:\u00a0\u00a0 WE RUN WHEN WE WERE DISCOVER BY THEM<br \/>\nKey: \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 RUNNING NO RUNNING NO RUNNING NO<\/p>\n<p>We could have the following key:<br \/>\nPlaintext:\u00a0\u00a0 WE RUN WHEN WE WERE DISCOVER BY THEM<br \/>\nKey: \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 RUNNING IS NOT THE SOLUTION THIS<\/p>\n<p>This would give us a ciphertext with no repetitions:<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/example-vigenere_21.jpg\"><\/a><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/example-vigenere_22.jpg\"><\/a><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/example-vigenere_23.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1211\" title=\"example vigenere_2\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/11\/example-vigenere_23.jpg\" alt=\"\" width=\"650\" height=\"90\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/example-vigenere_23.jpg 772w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/11\/example-vigenere_23-300x41.jpg 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p><strong>One-Time Pad Cipher<br \/>\n<\/strong><\/p>\n<p>The One-Time Pad cipher use a similar concept as the Auto-Key Cipher; however, the difference is the generation of a random key which is as long as the message. Also, it is required that at the end of the transmission, the random key generated must be destroyed.<\/p>\n<p>The only problem is to find a secure way to distribute the random generated key between the principals.<\/p>\n\n<script>\nvar zbPregResult = '0';\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>NOTIFICATION: These examples are provided for educational purposes. The use of this code and\/or information is under your own responsibility and risk. The information and\/or code is given \u2018as is\u2019. I do not take responsibilities of how they are used. Poly-alphabetic Cipher In the previous posting, we say that the mono-alphabetic cipher instead of shifting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,264],"tags":[355,352,217,316,321,323,338,354,265,341,324,353,266,174,216],"class_list":["post-1176","post","type-post","status-publish","format-standard","hentry","category-programming","category-network-security","tag-autokey","tag-caesar","tag-cipher","tag-ciphertext","tag-decryption","tag-encryption","tag-key","tag-module","tag-network","tag-one-time-pad","tag-plaintext","tag-polyalphabetic","tag-security","tag-table","tag-vigenere"],"_links":{"self":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/1176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1176"}],"version-history":[{"count":24,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/1176\/revisions"}],"predecessor-version":[{"id":1185,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/1176\/revisions\/1185"}],"wp:attachment":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1176"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}