You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
9.2 KiB

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>How Asymetric Encryption Works | tait.tech</title> <link rel="stylesheet" href="/assets/css/style.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="author" content="Tait Hoyem"> <meta name="keywords" content=""> <meta name="description" content=""> </head> <body> <div id="wrapper"> <header> <nav> <input type="checkbox" id="menu"> <label for="menu">&#9776;</label> <div class="menu-content"> <a href="/" class="nav-link">Home</a> <a href="/blog/" class="nav-link">Blog</a> <a href="https://github.com/TTWNO/" class="nav-link" target="_blank" rel="noopener noreferrer">Github</a> </div> </nav> </header> <main> <article> <header> <h1 class="post-title">How Asymetric Encryption Works</h1> <time datetime="20-04-02" class="post-date">Thursday, April 02 2020</time> </header> <hr> <p>In a few previous articles I have explained <a href="/2020/01/26/rsa1.html">why encryption may be important to you</a> and <a href="/2020/02/19/rsa2.html">how the theory behind encryption works</a>. I did not yet explain the system of asymetric cryptography, however. That is what this article is for.</p> <p>Previously, we talked about how <em>symetric</em> encryption works. This is by having a shared key that both parties use to simultaniously encrypt, and decrypt the data. (See Ceasar Cipher for example).</p> <h2 id="public-key-or-asymetric-encryption">Public-key, or Asymetric Encryption</h2> <p>Asymetric encryption is based on the idea of having multiple keys instead of only one shared key. For example: instead of encrypting with one key, and decrypting with that same key (like our ROT ciphers we talked about previously), we can use one key to <em>encrypt</em> the information, and a different key to <em>decrypt</em> the information.</p> <figure> <img src="/assets/img/alice-to-bob.png" alt="Alice sending her message to Bob using Bob's public key. Bob decrypts the message with his private key."/> <figcaption> Alice sending her message to Bob using Bob's public key. Bob decrypts the message with his private key. </figcaption> </figure> <p>In the picture above, see how Alice uses Bobs public key to encrypt some data, then sends it to Bob for him to decrypt with his private key? That is the essense of public-key encryption.</p> <p>The great thing about public-key encryption is that your public key is <em>public</em>! There is no need to be afraid of sending this everywhere! You can attach it at the end of all your emails, the end of your forum posts, <a href="/public-key.asc">a link to it on your low-power webserver</a> (wink). There are even things called <a href="http://keys.gnupg.net/">keyservers</a> that will save your public key on them for retrival in case somebody wants to verify your public key.</p> <p>Anything encrypted with your public key can only be decrypted with your private key. Provided you never, <em>NEVER</em> share your private key with anyone ever, we can assume that all messages sent to you encrypted with your public key will never be read by anyone else.</p> <p>Asymetric encryption, however, often contains four keys instead of two. Why is this?</p> <h4 id="verification-of-author">Verification of Author</h4> <p>One interesting thing about keys pairs is that not only can the private key decrypt anything the public key encrypts, but the public key can decrypt anything the private key encrypts.</p> <p>Now why would one want to encrypt a message that can be decrypted by anyone?</p> <figure> <img src="/assets/img/alice-sign-to-bob.png" alt="Alice sending a message to bob which is 'signed' with her private key. This allows Bob to know only Alice could have sent it!"/> <figcaption> Alice sending a message to bob which is 'signed' with her private key. This allows Bob to know only Alice could have sent it! <br/> <br/> Note: Although the picture shows otherwise, the text is not sent in the plain. It is encrypted with Alice's private key. </figcaption> </figure> <p>This is how you can verify that the person who says they wrote the mess