{"id":1468,"date":"2010-12-15T16:47:16","date_gmt":"2010-12-15T20:47:16","guid":{"rendered":"http:\/\/www.acarlstein.com\/?p=1468"},"modified":"2010-12-15T19:53:36","modified_gmt":"2010-12-15T23:53:36","slug":"introduction-to-network-security-part-11","status":"publish","type":"post","link":"http:\/\/blog.acarlstein.com\/?p=1468","title":{"rendered":"Introduction to Network Security &#8211; Part 11"},"content":{"rendered":"<p><strong>NOTIFICATION:<\/strong><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. You are welcome to point out any mistakes in my posting and\/or leave a comment.<\/p>\n<p><strong>Key Distribution Using Public-Key Cryptography<\/strong><\/p>\n<p>In the previous post, introduction to network security &#8211; part 10, we saw three main methods of public-key:<\/p>\n<ol>\n<li>Public announcement,<\/li>\n<li>Public-key authority, and<\/li>\n<li>Public-key certificates<\/li>\n<\/ol>\n<p>These methods can be used for encryption and decryption of messages (secrecy) and\/or authentication.<\/p>\n<p>These methods the disadvantage of being slow; therefore, its common to use symmetric-key encryption for secrecy and distribute using public-key encryption session keys. In this way we use the advantage of the speed of symmetric-key encryption and the security of public-key encryption.<\/p>\n<p><strong>Simple Key Distribution<\/strong><\/p>\n<p>In 1979,\u00a0 Ralph C. Merkle created his thesis entitled &#8220;Secrecy, authentication and public key systems&#8221; which let him receive his Ph. D. in Electrical Engineering at Stanford University &lt;<a href=\"http:\/\/en.wikipedia.org\/wiki\/Ralph_Merkle\" target=\"_blank\">http:\/\/en.wikipedia.org\/wiki\/Ralph_Merkle<\/a>&gt;.<\/p>\n<p>For a key distribution, Merkle proposed:<\/p>\n<ol>\n<li>User A will generate a new temporaty public key pair, <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span><\/li>\n<li>User A send the public key, <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span>, to user B together with its identity, <span style=\"color: #ff0000;\"><em>IDa<br \/>\nPUa, IDa<br \/>\n<\/em><\/span><\/li>\n<li>User B generate the session key <span style=\"color: #ff0000;\"><em>K<\/em><\/span>.<\/li>\n<li>User B uses the public key, <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span>, supplied by user A to encrypt the session key <span style=\"color: #ff0000;\"><em>K<\/em><\/span>. Then user B send the encrypted session to user A<\/li>\n<li>User A decrypt the message to obtain the session key <span style=\"color: #ff0000;\"><em>K<\/em><\/span>.<\/li>\n<li>User A discards the public key <em><span style=\"color: #ff0000;\">PUa<\/span><\/em><\/li>\n<li>User B discards user A&#8217;s public key, <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span>.<\/li>\n<li>After the exchange of information is complete, user A and B discard the session key <span style=\"color: #ff0000;\"><em>K<\/em><\/span>.<\/li>\n<\/ol>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-132.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1482\" title=\"Screenshot-13\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-132.png\" alt=\"\" width=\"615\" height=\"216\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-132.png 615w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-132-300x105.png 300w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><\/a><\/p>\n<p><span style=\"text-decoration: underline;\">The Man-In-The-Middle Attack<\/span><\/p>\n<p>This type of key distribution have a disadvantage.\u00a0 Lets assume that we have an attacker that gets in the middle of the communication in a way that this attacker can intercept the messages and then replay this message, modify this message, or send another different message.<\/p>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-141.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1484\" title=\"Screenshot-14\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-141.png\" alt=\"\" width=\"715\" height=\"216\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-141.png 715w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-141-300x90.png 300w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/a><\/p>\n<p>Lets analyse this problem:<\/p>\n<ol>\n<li>User A send a message to user B which holds the public key <span style=\"color: #ff0000;\">PUa<\/span>, and user A&#8217;s identifier <span style=\"color: #ff0000;\">IDa<\/span><\/li>\n<li><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">The attacker <span style=\"color: #000000;\">T<\/span> intercept this message and create its own pair keys, public key <em><span style=\"color: #ff0000;\">PUt<\/span><\/em> and private key <em><span style=\"color: #ff0000;\">PRt<\/span><\/em>:<br \/>\n<em><span style=\"color: #ff0000;\">{PUt, PRt}<\/span><\/em> <\/span><br \/>\n<\/span><\/li>\n<li>The attacker T send to user B, its own public key <span style=\"color: #ff0000;\"><em>PUt<\/em><\/span> together with the user A&#8217;s identification <span style=\"color: #ff0000;\"><em>IDa<\/em><\/span> :<br \/>\n<span style=\"color: #ff0000;\"><em>PUt||IDa<\/em><\/span><\/li>\n<li>User B generate a session key <span style=\"color: #ff0000;\"><em>Ks<\/em><\/span>. Then user B send this session key <span style=\"color: #ff0000;\">Ks<\/span> encrypted using the public-key <span style=\"color: #ff0000;\"><em>PUt<\/em><\/span> that he received thinking that it came from user A.<br \/>\n<span style=\"color: #ff0000;\"><em>Ciphertext = E(PUt, Ks)<\/em><\/span><\/li>\n<li>The attacker T intercept the message obtaining the session key <em><span style=\"color: #ff0000;\">Ks<\/span><\/em> by decrypting the message with his private key <span style=\"color: #ff0000;\"><em>PRt<\/em><\/span>.<br \/>\n<span style=\"color: #ff0000;\"><em>Ks = D(PRt, Ciphertext) = D(PRt, E(PUt, Ks))<\/em><\/span><\/li>\n<li>Then attacker T send the key session <span style=\"color: #ff0000;\"><em>Ks<\/em><\/span> to the user A using user A&#8217;s public key <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span><\/li>\n<li>Without user A and B knowing, the attacket T obtained the session <span style=\"color: #ff0000;\"><em>Ks<\/em><\/span> successfully.<\/li>\n<\/ol>\n<p><em><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-151.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1477\" title=\"Screenshot-15\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-151.png\" alt=\"\" width=\"715\" height=\"216\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-151.png 715w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-151-300x90.png 300w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/a><\/em><\/p>\n<p><span style=\"text-decoration: underline;\">Solution to The Man-In-The-Middle Attack<\/span><\/p>\n<ol>\n<li>The process begins with user A. User A encrypt the message containing the user A identification <span style=\"color: #ff0000;\"><em>IDa<\/em><\/span> plus a nonce <span style=\"color: #ff0000;\">N1<\/span> using the user B&#8217;s public key <span style=\"color: #ff0000;\">PUb<\/span><\/li>\n<li><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">User B generate a new nonce <em><span style=\"color: #ff0000;\">N2<\/span><\/em> and encrypts the message containing user A&#8217;s nonce <em><span style=\"color: #ff0000;\">N1<\/span><\/em> plus a new nonce <em><span style=\"color: #ff0000;\">N2<\/span><\/em> using the user A&#8217;s public key.<span style=\"color: #000000;\"><br \/>\n<\/span><\/span><\/span><\/li>\n<li><span style=\"color: #ff0000;\"><span style=\"color: #000000;\"><span style=\"color: #000000;\">Since user B is the only one that could decrypted the first message coming from user A plus the new message send from user B to user A will contain the nonce <span style=\"color: #ff0000;\"><em>N1<\/em><\/span> (given by\u00a0 user A in the first message<\/span><\/span><span style=\"color: #000000;\">), user A will know the new message is coming from user B and not an attacker.<\/span><\/span><\/li>\n<li><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">User A will encrypt nonce <span style=\"color: #ff0000;\"><em>N2<\/em><\/span> using the public key <span style=\"color: #ff0000;\"><em>PUb<\/em><\/span> of user B. Then user A will send then encrypted nonce <span style=\"color: #ff0000;\"><em>N2<\/em><\/span> to user B. In this way, since nonce <em><span style=\"color: #ff0000;\">N2<\/span><\/em> was generated by user B, when user B find nonce <em><span style=\"color: #ff0000;\">N2<\/span><\/em>, user B will known the message came from user A.<\/span><\/span><\/li>\n<li><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">User A generate a secret key <span style=\"color: #ff0000;\"><em>Ks<\/em><\/span>. User A will encrypt first the secret key <span style=\"color: #ff0000;\"><em>Ks<\/em><\/span> using the private key <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span> of user A which would provide authentication, and then it will encrypt the output of the encryption with the public key <em><span style=\"color: #ff0000;\">PUb<\/span><\/em> of user B to produce a new ciphertext <span style=\"color: #ff0000;\"><em>M<\/em><\/span> which provide confidentiality.<\/span><\/span><\/li>\n<li><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">User B decrypt the ciphertext <em><span style=\"color: #ff0000;\">M<\/span><\/em> by decrypting the ciphertext <em><span style=\"color: #ff0000;\">M<\/span><\/em> using the private key <span style=\"color: #ff0000;\"><em>PUb<\/em><\/span> of userB, and the result will be decrypted again using the public key <span style=\"color: #ff0000;\"><em>PUa<\/em><\/span> of user A. In this way the secret key <em><span style=\"color: #ff0000;\">Ks<\/span><\/em> is obtained.<\/span><\/span><\/li>\n<\/ol>\n<p><a href=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1486\" title=\"Screenshot-16\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2010\/12\/Screenshot-16.png\" alt=\"\" width=\"817\" height=\"334\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-16.png 817w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2010\/12\/Screenshot-16-300x122.png 300w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/a><\/p>\n<p><span style=\"color: #333333;\"><strong>Hybrid Key Distribution<\/strong><\/span><\/p>\n<p><span style=\"color: #333333;\">Public key encryption is an algorithm that require a lot of processing. In a system that require to distribute session keys thought many users and require a frequently change of session keys, the public key encryption can slow the performance of the system as the load on the system keep increasing. One solution to this problem is to use an hybrid of different key distribution.<\/span><\/p>\n<p><span style=\"color: #333333;\">In an hybrid key distribution, the key distribution center (KDC) will be in charge of distributing a master key <span style=\"color: #ff0000;\"><em>MK<\/em><\/span> to each user of the system plus perform the distribution of session keys. Before these session keys are distributed, they will be encrypted by using the master key <em><span style=\"color: #ff0000;\">MK<\/span><\/em>. Also, the master key is encrypted using a public key encryption. Since the master key only update in few occasions then the load of the system is reduced.<\/span><\/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. You are welcome to point out any mistakes in my posting and\/or leave a comment. [&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":[333,462,469,318,461,468,470,338,467,471,466,265,416,465,335,266,464,378,463],"class_list":["post-1468","post","type-post","status-publish","format-standard","hentry","category-programming","category-network-security","tag-attack","tag-authentication","tag-center","tag-cryptography","tag-distribution","tag-hybrid","tag-kdc","tag-key","tag-man-in-the-middle","tag-master","tag-merkle","tag-network","tag-public-key","tag-ralph","tag-secret","tag-security","tag-session","tag-simple","tag-symmetric-key"],"_links":{"self":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/1468","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=1468"}],"version-history":[{"count":13,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/1468\/revisions"}],"predecessor-version":[{"id":1479,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/1468\/revisions\/1479"}],"wp:attachment":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1468"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}