|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<title>How Does Encryption Work, in Theory? | 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>
|
|
|
<h1>tait.tech</h1>
|
|
|
|
|
|
<nav>
|
|
|
|
|
|
<a href="/" class="nav-link" >Home</a>
|
|
|
|
|
|
<a href="/blog/" class="nav-link" >Blog</a>
|
|
|
|
|
|
<a href="/ideas/" class="nav-link" >Ideas</a>
|
|
|
|
|
|
<a href="/links/" class="nav-link" >Links</a>
|
|
|
|
|
|
<a href="https://github.com/TTWNO/" class="nav-link" target="_blank" rel="noopener noreferrer" >Github</a>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
</header>
|
|
|
<main>
|
|
|
<article>
|
|
|
<header>
|
|
|
<h1 class="post-title">How Does Encryption Work, in Theory?</h1>
|
|
|
<time datetime="20-02-19" class="post-date">Wednesday, February 19 2020</time>
|
|
|
</header>
|
|
|
<hr>
|
|
|
|
|
|
<p>There are many kinds of encryption used in our everyday communication. Online and offline, over the internet and in person. In this article, I will explain the basics of how encryption should work in theory. I explain in <a href="/2020/01/26/rsa1/">this article</a> why encryption is important, and why <em>you</em> should care about it.</p>
|
|
|
|
|
|
<p>We will start by looking at in-person, offline encryption.</p>
|
|
|
|
|
|
<h2 id="cryptography-we-do-everyday">Cryptography We Do Everyday</h2>
|
|
|
<p>We encrypt things all the time without even thinking about it.
|
|
|
If you spend a significant amount of time with the same group of friends, you will tend to develop common codes that may not make sense to others outside the group.
|
|
|
For example: for years, my family called sombody falling from a sitting position “doing a Don”. There is a story of course—We knew a guy named Don who fell from his plastic beach chair in a rather hilarious way; “doing a Don” was born.</p>
|
|
|
|
|
|
<p>These types of minor dialects in speech are cryptographic in their own way. The truth is though, that we use cryptography much more than that!</p>
|
|
|
|
|
|
<blockquote>
|
|
|
<p>“Is cryptography any different than talking?
|
|
|
We say something other than what we mean, and then expect everyone is able to decipher the true meaning behind the words.
|
|
|
Only, I never do…” — Adapted from a scene in <a href="https://www.benedictcumberbatch.co.uk/wordpress/wp-content/uploads/ScreenplayTIG.pdf">The Imitation Game (p. 39-40)</a></p>
|
|
|
</blockquote>
|
|
|
|
|
|
<p>How many times have you hinted, flirted, and innuendoed to try to say “I find you very physically attractive”?
|
|
|
Have you told your friend that always stinks to wear more deodorant?
|
|
|
Have you ever had someone say the words “I’m fine” when you know <em>for certain</em> that they are indeed not okay?</p>
|
|
|
|
|
|
<table>
|
|
|
<thead>
|
|
|
<tr>
|
|
|
<th>Words Said</th>
|
|
|
<th>Meaning</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
<tr>
|
|
|
<td>What can you do?</td>
|
|
|
<td>I don’t want to talk about this anymore.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>I don’t want to overstay my welcome.</td>
|
|
|
<td>I want to go home now.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>I don’t like them and don’t know why.</td>
|
|
|
<td>They threaten my ego.</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td>Creepy</td>
|
|
|
<td>Unattractive and friendly</td>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
|
|
|
<p>All of these scenarios are perfect examples of <del>lies</del> encryption! If we have the key to these codes, we can start to understand what people really mean.
|
|
|
Hopefully I have convinced you that you use <del>deceit</del> cryptography on a regular basis in your life, so let us consider what a basic encryption method might be:</p>
|
|
|
|
|
|
<h2 id="grade-school-encryption">Grade-School Encryption</h2>
|
|
|
<p>Back when I was in middle school I used to pass notes like these:</p>
|
|
|
|
|
|
<figure>
|
|
|
<img alt="A message I would have sent in middle school. ROT5: Xfwfm hx hzy" src="/assets/img/ceasar1.jpg" />
|
|
|
<figcaption>
|
|
|
The kind of message I would have sent in middle school. A ROT5 Ceasar cipher.
|
|
|
</figcaption>
|
|
|
</figure>
|
|
|
<p>This is a message encrypted using the Caesar cipher. This encryption technique was used by Julius Caesar during the reign of the Roman Empire to “encrypt messages of military significance.”<a class="citation-link" href="https://en.wikipedia.org/wiki/Caesar_chipher/">[1]</a>
|
|
|
This is one of the oldest and simplest methods of encryption known to us today.</p>
|
|
|
|
|
|
<figure>
|
|
|
<img alt="A diagram of a Ceasar Shift algorithm. A <-> N, B <-> O, et cetera." src="/assets/img/ceasar13.png" />
|
|
|
<figcaption>
|
|
|
A diagram of a ROT13 Ceasar shift algorithm. A <-> N, B <-> O, et cetera.
|
|
|
</figcaption>
|
|
|
</figure>
|
|
|
|
|
|
<p>You can try this out yourself by moving some letters forward in the alphabet.
|
|
|
An ‘A’ turns into a ‘B’, ‘B’ into ‘C’, ‘C’ into ‘D’, et cetera.
|
|
|
In this case, “Hello!” would become “Ifmmp!”
|
|
|
That is just using a shift of one. You can use a shift of seven, for example, and then you would shift letters like so:</p>
|
|
|
|
|
|
<ul>
|
|
|
<li><code class="language-plaintext highlighter-rouge">A -> +7 -> H</code></li>
|
|
|
<li><code class="language-plaintext highlighter-rouge">Q -> +7 -> X</code></li>
|
|
|
<li><code class="language-plaintext highlighter-rouge">T -> +7 -> A</code></li>
|
|
|
</ul>
|
|
|
|
|
|
<p>When you reach the end of the alphabet, wrap around to the beginning to find the encrypted letter.</p>
|
|
|
|
|
|
<h2 id="example-of-a-caesar-cipher">Example of a Caesar Cipher</h2>
|
|
|
<p>Let’s setup a little story to illustrate the problems of encryption. We will have three characters:</p>
|
|
|
|
|
|
<ul>
|
|
|
<li>Alice, young lady with feelings for Bob</li>
|
|
|
<li>Bob, a young lad with an addiction to pancakes</li>
|
|
|
<li>Eve, a wee jealous girl scout who sits between Bob and Alice</li>
|
|
|
</ul>
|
|
|
|
|
|
<p>Alice really likes Bob and wants to tell Bob her feelings, so she writes “I love you, Bob! Please eat healthier!” on a sticky note.
|
|
|
She passes it to Eve, so Eve can pass it to Alice’s love interest.
|
|
|
However, in an unfortunate turn of events Eve reads the note herself, and decides not to give it to Bob.</p>
|
|
|
|
|
|
<p>Oh the horror! Alice is without young love! How could she remedy this so that Bob can read her message, but evil Eve can not?
|
|
|
Let’s use the Caesar cipher to fix this problem.</p>
|
|
|
|
|
|
<p>Let us assume that Alice and Bob already have a shared key, 7 for example. To encrypt this message, she should shift her letters seven letters forward in the alphabet—just like the example above.</p>
|
|
|
|
|
|
<figure>
|
|
|
<img alt="A longer Ceasar cipher encrypted message: ROT2: Wpeng Vgf ku dqqogt ogog]" src="/assets/img/ceasar2.jpg" />
|
|
|
<figcaption>
|
|
|
A longer Ceasar cipher encrypted message using ROT2.
|
|
|
</figcaption>
|
|
|
</figure>
|
|
|
|
|
|
<p>Now Alice’s message reads “P svcl fvb, Ivi! Wslhzl lha olhsaoply!”</p>
|
|
|
|
|
|
<p>Now, when Alice sends her Romeo a little note, all he has to do is decrypt the text by shifting the letters down by 7.
|
|
|
<a href="https://www.xarg.org/tools/caesar-cipher/">Here is a site</a> which can do longer pieces of text for you instead of doing it manually.</p>
|
|
|
|
|
|
<h2 id="problems">Problems</h2>
|
|
|
|
|
|
<p>Before the two love-birds start smooching on the branch of a big pine tree in the schoolyard, perhaps we should consider some problems with the Ceasar cipher.</p>
|
|
|
|
|
|
<h4 id="it-is-very-easy-to-break">It is Very Easy to Break</h4>
|
|
|
|
|
|
<p>Even Eve with her measly grade 4 math skills could easily start going through this message with pen and paper and figure out any combination in a couple hours at maximum.
|
|
|
Imagine how easy this is for a computer?
|
|
|
This could be broken in a few microseconds even on an older processor like the Intel Core 2 Duo.</p>
|
|
|
|
|
|
<h4 id="no-secure-way-of-sharing-keys">No Secure Way of Sharing Keys</h4>
|
|
|
|
|
|
<p>We assumed in our previous example that Bob and Alice already have a shared key (seven) to encrypt and decrypt all of their messages.
|
|
|
If Bob and Alice did not have a previous friendship and time to share secrets of this sort, there is no way to share their key with eachother without Eve also knowing.
|
|
|
This would defeat the entire purpose of obscuring the message in the first place.</p>
|
|
|
|
|
|
<h4 id="universal-vulnerability-of-messages">Universal Vulnerability of Messages</h4>
|
|
|
|
|
|
<p>Every message sent between the two parties uses the same code to encrypt and decrypt. If someone finds out the code once, all previous communications are comprimised.</p>
|
|
|
|
|
|
<h2 id="better-encryption-methods">Better Encryption Methods</h2>
|
|
|
|
|
|
<p>To combat the issues with easily breakable, shared-key cryptography, we can turn to the beautiful beast that is <a href="https://en.wikipedia.org/wiki/Public-key_cryptography">Asymetric Cryptography</a>.
|
|
|
I will discuss this more in another article, but for the technically inclined:</p>
|
|
|
|
|
|
<ol>
|
|
|
<li><a href="https://en.wikipedia.org/wiki/RSA_(cryptosystem)">RSA</a>/<a href="https://en.wikipedia.org/wiki/Elliptic-curve_cryptography">EC</a> provides <em>very</em> large cryptographic keys. It would be impossible for a human to encrypt or decrypt a message manually.</li>
|
|
|
<li><a href="https://www.youtube.com/watch?v=GSIDS_lvRv4">Asymetric cryptography</a> provides four keys, instead of just one; stopping evesdroppers from listening in on your secret conversations—even if you do not have the chance to exchange keys in advance.</li>
|
|
|
</ol>
|
|
|
|
|
|
|
|
|
</article>
|
|
|
|
|
|
</main>
|
|
|
<hr>
|
|
|
<footer>
|
|
|
This page is mirrored on <a href="https://beta.tait.tech/2020/02/19/rsa2/">beta.tait.tech</a>.
|
|
|
|
|
|
</footer>
|
|
|
</div>
|
|
|
</body>
|
|
|
</html>
|