{"id":705,"date":"2008-11-20T14:36:25","date_gmt":"2008-11-20T14:36:25","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2008\/11\/20\/asymmetric-cryptography-the-basic-idea-of-public-key-cryptosystems\/"},"modified":"2015-02-23T11:47:48","modified_gmt":"2015-02-23T16:47:48","slug":"asymmetric-cryptography-the-basic-idea-of-public-key-cryptosystems","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2008\/11\/20\/asymmetric-cryptography-the-basic-idea-of-public-key-cryptosystems\/","title":{"rendered":"Asymmetric Cryptography: the Basic Idea of Public Key Cryptosystems"},"content":{"rendered":"<p> I&#8217;ve been trying for a couple of weeks to put together a couple of interesting posts on the cryptographic modes of operation for confidentiality and integrity, and I just can&#8217;t do it. I&#8217;m finding it boring to write about, and if it bores me to write it, I know there&#8217;s no way that it&#8217;s going to be engaging to readers!<\/p>\n<p> So, I&#8217;m going to move on. I&#8217;ve explained the basic idea of the message authentication code as an integrity check, and I&#8217;ve described one simple way of integrating it into a common mode of operation. If you&#8217;re really interested in learning more, I recommend Bruce Schnier&#8217;s book on cryptography, which has ton of material on modes of operation and protocols, how they work, and how they can fail.<\/p>\n<p> Meanwhile, I&#8217;m going to move on to something that doesn&#8217;t bore me to write about, and therefore hopefully won&#8217;t bore <em>you<\/em> to read about: asymmetric cryptography, also commonly referred to (although not entirely accurately) as public key cryptography.<\/p>\n<p><!--more--><br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"symmetric-cipher.png\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_339.png?resize=349%2C243\" width=\"349\" height=\"243\" class=\"inset right\" \/><\/p>\n<p> What we&#8217;ve looked at so far is symmetric cryptography. The basic idea of it is illustrated to the right. In a symmetric cryptosystem, you&#8217;ve got two parties who want to communicate, and they&#8217;ve got a <em>shared secret<\/em>. That shared secret is the key to the cryptosystem. Put in pseudo-mathematical syntax, the symmetric cryptosystem is a pair of functions, En and De, such that given a secret key S:<\/p>\n<ul>\n<li> Ciphertext = En(S, Plaintext)<\/li>\n<li> Plaintext = De(S, Ciphertext)<\/li>\n<\/ul>\n<p> We call it symmetric because both the sender and the receiver need the <em>same<\/em> information. Both of them can encrypt messages using the key; both can decrypt. There&#8217;s no way to distinguish between the two on the basis of what information they have, or how they encrypt their messages.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"public-key.png\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_340.png?resize=453%2C542\" width=\"453\" height=\"542\" \/><\/p>\n<p> In an asymmetric system (as illustrated above) that&#8217;s no longer true. Asymmetric systems use two keys, S<sub>1<\/sub> and S<sub>2<\/sub> (also called the private key and the public key) such that:<\/p>\n<ul>\n<li> Ciphertext<sub>S<sub>1<\/sub><\/sub> = En(S<sub>1<\/sub>, Plaintext)<\/li>\n<li> Plaintext = De(S<sub>2<\/sub>, Ciphertext<sub>S<sub>1<\/sub><\/sub>)<\/li>\n<li> Ciphertext<sub>S<sub>2<\/sub><\/sub> = En(S<sub>2<\/sub>, Plaintext)<\/li>\n<li> Plaintext = De(S<sub>1<\/sub>, Ciphertext<sub>S<sub>2<\/sub><\/sub>)<\/li>\n<\/ul>\n<p> In english, suppose you&#8217;ve got two people, Ann and Bob who want to communicate. They each have <em>their own<\/em> key. To send a message to Bob, Ann encrypts the message with <em>her<\/em> key. When Bob receives the message, he decrypts it <em>not<\/em> with the same key that Ann used to encrypt it, but with <em>his own<\/em> key. When he wants to send a message back to Ann, he takes the same key that he used to <em>decrypt<\/em> the message from Ann, and uses it to <em>encrypt<\/em> a message <em>to<\/em> Ann.<\/p>\n<p> This leads to one of the basic terminological confusions. Reading that description: Bob&#8217;s key decrypts messages <em>from<\/em> Ann, and encrypts messages <em>to<\/em> Ann has an element of symmetry to it. There is a very elegant symmetry to asymmetric encryption! But the terms asymmetric and symmetric in cryptography refer to the information that each of the parties uses in a cryptosystem. In a symmetric system, both parties have <em>exactly the same information<\/em>. In an asymmetric system, they&#8217;ve got <em>different<\/em> information.<\/p>\n<p> For the most part, the basic requirements of an asymmetric cryptosystem are very similar to the requirements of a symmetric one &#8211; you want to be able to compute the ciphertext easily given the encryption key and the plaintext; you want to be able to compute the  plaintext easily given the ciphertext and the decryption key; you don&#8217;t want to be able to compute the key given the ciphertext and the plaintext, and so on. But there&#8217;s one <em>major<\/em> complication in asymmetric cryptosystems that creates an additional requirement: given the encryption key, it must be computationally infeasible to generate the decryption key.<\/p>\n<p> That last requirement kills the overwhelming majority of potential and proposed asymmetric systems. Having one of the keys in a pair means that you&#8217;ve effectively got access to an unlimited chosen plaintext attack: you&#8217;ve got the ability to generate the ciphertext of any plaintext, as many times as you want, and to use that to try to find the value of the key that will decrypt that text.<\/p>\n<p> The most common use of asymmetric cryptography is public key cryptography. One of the really fascinating things about it is that instead of trying to keep the keys private, you deliberate make one of the two keys widely available &#8211; you give it to <em>everyone<\/em>.<\/p>\n<p> The idea is that you take one key, which we call your private key, and you lock that away. No one but you should <em>ever<\/em> have access to your private key. The second key, called your public key, you give to everyone. You post it on public websites, you register it with key libraries, you send it to all of your friends, etc.  Anyone who wants to be able to read encrypted messages from you needs to be able to get your public key.<\/p>\n<p> Now, when you want to send someone a message and prove it&#8217;s from you, you encrypt it with your private key. Anyone can decrypt it &#8211; but <em>only you<\/em> could have encrypted it in a way that allows your public key to decrypt it.<\/p>\n<p> Similarly, when someone wants to send you an encrypted message, they encrypt it with your public key. Then <em>only you<\/em> can decrypt it.<\/p>\n<p> To set up a secure cryptographic channel with someone, you need to have <em>their<\/em> public key. So, suppose that we have Amy and Bill, who want to send secure messages to each other. What are the goals of the cryptosystem here? When Amy wants to send a message to Bill, she wants to make sure that <em>only Bill<\/em> can read it. When Bill gets a message from Amy, he wants to make sure that <em>only Amy<\/em> could have sent it.<\/p>\n<p> The way we can provide both of those is by having Amy take her message, and <em>first<\/em> encrypt it with <em>her<\/em> private key. Then she encrypts it with <em>Bill&#8217;s<\/em> public key. The message has been encrypted twice: the first encryption pass guarantees that the message is from her (because no one else could have encrypted a message with her private key); the second encryption pass guarantees that no one but Bill can read it (because no one but Bill can decrypt a message with his private key).<\/p>\n<p> Bill does exactly the same thing when he wants to send a message to Amy. First he encrypts it with his private key, to show that it&#8217;s really him who sent the message. And then he encrypts it with <em>Amy&#8217;s<\/em> public key, which ensures that only Amy can read it.<\/p>\n<p> Towards the beginning of this message, I said that asymmetric cryptography is sometimes <em>incorrectly<\/em> called public key cryptography. The reason that I said that is because public key cryptography is really the combination of an asymmetric cryptosystem <em>together with<\/em> the infrastructure that allows the kind of scenario I described above, for Amy and Bill, to work. For it to work, Amy and Bill need to have a way of getting each other&#8217;s public keys &#8211; and <em>being sure<\/em> that they are really getting the correct, valid public keys for each other. There&#8217;s a very elegant cryptographic attack called a <em>man in the middle<\/em> attack, which relies on weaknesses in the public key infrastructure, not in the actual asymmetric cryptographic system used by the public key system, which I&#8217;ll describe in a future post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been trying for a couple of weeks to put together a couple of interesting posts on the cryptographic modes of operation for confidentiality and integrity, and I just can&#8217;t do it. I&#8217;m finding it boring to write about, and if it bores me to write it, I know there&#8217;s no way that it&#8217;s going [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[84],"tags":[],"class_list":["post-705","post","type-post","status-publish","format-standard","hentry","category-encryption"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-bn","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=705"}],"version-history":[{"count":3,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/705\/revisions"}],"predecessor-version":[{"id":3131,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/705\/revisions\/3131"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=705"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}