<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Public-key cryptography — from the mathematics to SSH, PGP and HTTPS on Benjamin Italiaander</title><link>https://tlnd.org/math/public_key_cryptography/</link><description>Recent content in Public-key cryptography — from the mathematics to SSH, PGP and HTTPS on Benjamin Italiaander</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 29 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tlnd.org/math/public_key_cryptography/index.xml" rel="self" type="application/rss+xml"/><item><title>Clock arithmetic — exercises</title><link>https://tlnd.org/math/public_key_cryptography/01a_clock_arithmetic/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01a_clock_arithmetic/</guid><description>&lt;h1 id="-clock-arithmetic-exercises"&gt;✏️ Clock arithmetic: exercises&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#1-clock-arithmetic"&gt;1. The mathematics, section 1&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/01b_easy_forward_hard_backward/"&gt;Easy forward, hard backward →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Everything in public-key cryptography happens on a clock. If this page feels easy, the rest of the series will too. Every exercise has its answer hidden below it: work it out on paper first, then click &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-the-remainder"&gt;1. The remainder&lt;/h2&gt;
&lt;p&gt;$a \bmod n$ is the &lt;strong&gt;remainder&lt;/strong&gt; after dividing $a$ by $n$. It is always one of $0, 1, \dots, n-1$.&lt;/p&gt;</description></item><item><title>Diffie–Hellman — exercises and in depth</title><link>https://tlnd.org/math/public_key_cryptography/01e_diffie_hellman/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01e_diffie_hellman/</guid><description>&lt;h1 id="-diffiehellman-exercises-and-in-depth"&gt;✏️ Diffie–Hellman: exercises and in depth&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#4-diffiehellman-key-exchange-1976"&gt;1. The mathematics, section 4&lt;/a&gt; · Previous: &lt;a href="https://tlnd.org/math/public_key_cryptography/01d_rsa/"&gt;← RSA&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/01f_elliptic_curves/"&gt;Elliptic curves in depth →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Diffie–Hellman is the idea that both SSH and TLS rely on for every connection. The formula is one line; the subtle part is &lt;strong&gt;which numbers you may use&lt;/strong&gt;. This page lets you play the exchange, then attack it in three ways, each of which happened to real software. You need &lt;a href="https://tlnd.org/math/public_key_cryptography/01a_clock_arithmetic/"&gt;clock arithmetic&lt;/a&gt; and &lt;a href="https://tlnd.org/math/public_key_cryptography/01b_easy_forward_hard_backward/#3-generators-and-the-order-of-a-number"&gt;generators&lt;/a&gt;. Answers are hidden under &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Digital signatures — exercises and in depth</title><link>https://tlnd.org/math/public_key_cryptography/01g_signatures/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01g_signatures/</guid><description>&lt;h1 id="-digital-signatures-exercises-and-in-depth"&gt;✏️ Digital signatures: exercises and in depth&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#6-digital-signatures-on-a-curve-schnorr--eddsa"&gt;1. The mathematics, section 6&lt;/a&gt; · Previous: &lt;a href="https://tlnd.org/math/public_key_cryptography/01f_elliptic_curves/"&gt;← Elliptic curves&lt;/a&gt; · Back to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/"&gt;1. The mathematics&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Everything here uses part 1&amp;rsquo;s small curve $y^2 = x^3 + 2x + 2 \pmod{17}$ with $G = (5, 1)$ and group order $n = 19$. All &amp;ldquo;signature numbers&amp;rdquo; ($k$, $s$, $e$, $x$) count &lt;strong&gt;modulo 19&lt;/strong&gt;; point coordinates count modulo 17. The table of multiples $kG$ is in &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#53-multiplying-a-point-by-a-number"&gt;part 1&lt;/a&gt;; &lt;a href="https://tlnd.org/math/public_key_cryptography/01f_elliptic_curves/"&gt;Elliptic curves in depth&lt;/a&gt; explains it. Answers are hidden under &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Easy forward, hard backward — exercises</title><link>https://tlnd.org/math/public_key_cryptography/01b_easy_forward_hard_backward/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01b_easy_forward_hard_backward/</guid><description>&lt;h1 id="-easy-forward-hard-backward-exercises"&gt;✏️ Easy forward, hard backward: exercises&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#2-easy-forward-hard-backward"&gt;1. The mathematics, section 2&lt;/a&gt; · Previous: &lt;a href="https://tlnd.org/math/public_key_cryptography/01a_clock_arithmetic/"&gt;← Clock arithmetic&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/01c_prime_numbers/"&gt;Prime numbers →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Public-key cryptography needs a calculation that is &lt;strong&gt;fast one way and hopeless the other way&lt;/strong&gt;. This page lets you feel both directions with your own hands: first how quick the forward direction is, then how slow going back gets, and finally the clever shortcuts attackers use (and why real keys are big enough to survive them). Answers are hidden under &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Elliptic curves and ECDH — the mathematics in depth</title><link>https://tlnd.org/math/public_key_cryptography/01f_elliptic_curves/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01f_elliptic_curves/</guid><description>&lt;h1 id="-elliptic-curves-and-ecdh-the-mathematics-in-depth"&gt;🌀 Elliptic curves and ECDH: the mathematics in depth&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#5-elliptic-curves"&gt;1. The mathematics, section 5&lt;/a&gt; · Previous: &lt;a href="https://tlnd.org/math/public_key_cryptography/01e_diffie_hellman/"&gt;← Diffie–Hellman&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/01g_signatures/"&gt;Signatures in depth →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Part 1 &lt;em&gt;showed&lt;/em&gt; the addition formulas and a table of points. This page &lt;strong&gt;derives&lt;/strong&gt; them, so you see where every symbol comes from, and then follows the path all the way to X25519, the key exchange your SSH client used the last time you connected to GitHub. You need &lt;a href="https://tlnd.org/math/public_key_cryptography/01a_clock_arithmetic/"&gt;clock arithmetic&lt;/a&gt; (inverses) and the idea of &lt;a href="https://tlnd.org/math/public_key_cryptography/01e_diffie_hellman/"&gt;Diffie–Hellman&lt;/a&gt;. Exercises have their answers hidden under &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Prime numbers — the atoms of cryptography</title><link>https://tlnd.org/math/public_key_cryptography/01c_prime_numbers/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01c_prime_numbers/</guid><description>&lt;h1 id="-prime-numbers-the-atoms-of-cryptography"&gt;🔢 Prime numbers: the atoms of cryptography&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/"&gt;1. The mathematics&lt;/a&gt; · Previous: &lt;a href="https://tlnd.org/math/public_key_cryptography/01b_easy_forward_hard_backward/"&gt;← Easy forward, hard backward&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/01d_rsa/"&gt;RSA →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;RSA multiplies two primes. Diffie–Hellman calculates modulo a prime. Curve25519 is named after the prime $2^{255} - 19$. This chapter explains what makes primes so special, proves the two theorems everything rests on, and shows how your computer finds a 1536-bit prime in a fraction of a second. Exercises have their answers hidden under &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Public-key cryptography 1 — The mathematics</title><link>https://tlnd.org/math/public_key_cryptography/01_the_math/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01_the_math/</guid><description>&lt;h1 id="-1-the-mathematics-of-public-key-cryptography"&gt;🔢 1. The mathematics of public-key cryptography&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/02_ssh/"&gt;2. SSH →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Two computers that have never met, talking over a line that everybody can listen to, agree on a secret that nobody else knows. That sounds impossible, and for most of history it was. Since the 1970s it is done billions of times a day: every SSH login, every HTTPS page, every signed software update.&lt;/p&gt;
&lt;p&gt;This part explains the mathematics behind it. Every example uses &lt;strong&gt;small numbers that you can check by hand&lt;/strong&gt; (or in Python: &lt;code&gt;pow(base, exponent, modulus)&lt;/code&gt;). Real systems use the same formulas with numbers of 77 to 925 digits (&lt;a href="https://tlnd.org/math/public_key_cryptography/01h_why_so_many_digits/"&gt;why exactly those sizes?&lt;/a&gt;).&lt;/p&gt;</description></item><item><title>Public-key cryptography 2 — How an SSH connection is built</title><link>https://tlnd.org/math/public_key_cryptography/02_ssh/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/02_ssh/</guid><description>&lt;h1 id="-2-how-an-ssh-connection-is-built"&gt;🔐 2. How an SSH connection is built&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/"&gt;← 1. The mathematics&lt;/a&gt; · &lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/03_pgp/"&gt;3. OpenPGP →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/"&gt;part 1&lt;/a&gt; we saw the building blocks: Diffie–Hellman on elliptic curves, signatures, and the hybrid with ML-KEM. Here we follow one real connection, &lt;code&gt;ssh git@github.com&lt;/code&gt;, from the first byte to the moment you are logged in. Every log line on this page is real output of &lt;code&gt;ssh -vv&lt;/code&gt; (OpenSSH 10.2, November 2026), shortened.&lt;/p&gt;</description></item><item><title>Public-key cryptography 3 — How OpenPGP (GnuPG) encrypts and signs</title><link>https://tlnd.org/math/public_key_cryptography/03_pgp/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/03_pgp/</guid><description>&lt;h1 id="-3-how-openpgp-encrypts-and-signs"&gt;✉️ 3. How OpenPGP encrypts and signs&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/02_ssh/"&gt;← 2. SSH&lt;/a&gt; · &lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/04_tls_wireguard_fido2_signal/"&gt;4. TLS, WireGuard, FIDO2 and Signal →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/02_ssh/"&gt;SSH&lt;/a&gt; has a live connection: both sides are online and can do a Diffie–Hellman exchange back and forth. &lt;strong&gt;Email and files do not.&lt;/strong&gt; When you encrypt a file for Bob, Bob may be asleep, and he may read it in five years. There is no &amp;ldquo;back and forth&amp;rdquo;; you have one shot.&lt;/p&gt;</description></item><item><title>Public-key cryptography 4 — TLS, WireGuard, FIDO2 and Signal</title><link>https://tlnd.org/math/public_key_cryptography/04_tls_wireguard_fido2_signal/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/04_tls_wireguard_fido2_signal/</guid><description>&lt;h1 id="-4-tls-wireguard-fido2-and-signal"&gt;🌐 4. TLS, WireGuard, FIDO2 and Signal&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/03_pgp/"&gt;← 3. OpenPGP&lt;/a&gt; · &lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/05_smime/"&gt;5. S/MIME →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/02_ssh/"&gt;SSH&lt;/a&gt; and &lt;a href="https://tlnd.org/math/public_key_cryptography/03_pgp/"&gt;OpenPGP&lt;/a&gt; use the same building blocks from &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/"&gt;part 1&lt;/a&gt;, but combine them differently, because they solve different problems. Four more protocols you use every day make the differences even clearer. For each: what problem it solves, and which choice in the design follows from that.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-tls-13-https"&gt;1. TLS 1.3: HTTPS&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt; your browser talks to millions of servers it has never seen before. &amp;ldquo;Trust on first use&amp;rdquo; like SSH (&lt;a href="https://tlnd.org/math/public_key_cryptography/02_ssh/#-do-i-know-this-server-known_hosts"&gt;part 2, ⑤&lt;/a&gt;) does not work: you would have to check a fingerprint for every website.&lt;/p&gt;</description></item><item><title>Public-key cryptography 5 — S/MIME: email encryption with certificates</title><link>https://tlnd.org/math/public_key_cryptography/05_smime/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/05_smime/</guid><description>&lt;h1 id="-5-smime-email-encryption-with-certificates"&gt;✉️ 5. S/MIME: email encryption with certificates&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/04_tls_wireguard_fido2_signal/"&gt;← 4. TLS, WireGuard, FIDO2 and Signal&lt;/a&gt; · &lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There are two standards for signing and encrypting email: &lt;strong&gt;OpenPGP&lt;/strong&gt; (&lt;a href="https://tlnd.org/math/public_key_cryptography/03_pgp/"&gt;part 3&lt;/a&gt;) and &lt;strong&gt;S/MIME&lt;/strong&gt;. They use the same mathematics. The big difference is the answer to the question every protocol has to answer: &lt;em&gt;whose key is this?&lt;/em&gt; OpenPGP lets people vouch for each other (or you check a fingerprint yourself); S/MIME uses &lt;strong&gt;certificates from a certificate authority&lt;/strong&gt;, exactly like HTTPS (&lt;a href="https://tlnd.org/math/public_key_cryptography/04_tls_wireguard_fido2_signal/"&gt;part 4&lt;/a&gt;). That makes S/MIME the choice of companies, governments and universities: it is built into Outlook, Apple Mail, Thunderbird and most phones, and an organisation can hand out certificates centrally.&lt;/p&gt;</description></item><item><title>RSA — exercises and in depth</title><link>https://tlnd.org/math/public_key_cryptography/01d_rsa/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01d_rsa/</guid><description>&lt;h1 id="-rsa-exercises-and-in-depth"&gt;✏️ RSA: exercises and in depth&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#3-rsa-1977"&gt;1. The mathematics, section 3&lt;/a&gt; · Previous: &lt;a href="https://tlnd.org/math/public_key_cryptography/01c_prime_numbers/"&gt;← Prime numbers&lt;/a&gt; · Next: &lt;a href="https://tlnd.org/math/public_key_cryptography/01e_diffie_hellman/"&gt;Diffie–Hellman in depth →&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Part 1 made one RSA key with $p = 47$ and $q = 59$. Here you make several yourself, prove why it works, see how real software makes it four times faster, and break it in the ways real attackers have. You need &lt;a href="https://tlnd.org/math/public_key_cryptography/01a_clock_arithmetic/"&gt;clock arithmetic&lt;/a&gt; (inverses) and &lt;a href="https://tlnd.org/math/public_key_cryptography/01c_prime_numbers/"&gt;prime numbers&lt;/a&gt; (Euler&amp;rsquo;s φ). Answers are hidden under &lt;strong&gt;Answer&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Why 77 to 925 digits? — how big is big enough</title><link>https://tlnd.org/math/public_key_cryptography/01h_why_so_many_digits/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>https://tlnd.org/math/public_key_cryptography/01h_why_so_many_digits/</guid><description>&lt;h1 id="-why-77-to-925-digits-how-big-is-big-enough"&gt;📏 Why 77 to 925 digits? How big is big enough&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://tlnd.org/math/public_key_cryptography/"&gt;Overview&lt;/a&gt; · Belongs to &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/"&gt;1. The mathematics&lt;/a&gt; and its &lt;a href="https://tlnd.org/math/public_key_cryptography/01_the_math/#7-how-big-is-big-enough"&gt;section 7, key sizes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The examples in this series use numbers like 23, 2773 and a curve modulo 17, small enough to check by hand. Part 1 says that real systems use &lt;strong&gt;the same formulas with numbers of 77 to 925 digits&lt;/strong&gt;. This page explains where exactly those two numbers come from, and why they are this size: not smaller (then they could be broken) and not bigger (then everything gets slow for nothing).&lt;/p&gt;</description></item></channel></rss>