← All 179 books wireguard, one handshake per page
One handshake per page

wireguard, one handshake per page

Twenty-eight lessons on what WireGuard is: a free and open-source protocol implementing encrypted VPNs over UDP, lighter than IPsec, better performing than OpenVPN; the law of one handshake per page; the overlay across a public net; long-term Curve25519 keys, ephemeral values, RFC 1918 addresses; the Noise IK pattern, the two-message ladder, the optional pre-shared key against quantum, the ChaCha20 session key with Poly1305; AEAD, the nonce, the byte toll, the MTU ladder of 1280, 1420 and 1440; UDP only and the TCP meltdown, port 51820, v4-in-v6, the roaming phone; the machine-checked proof, the IPsec and OpenVPN neighbors, the fixed menu; Donenfeld 2015, Linux 5.6 2020, one honest hour.


Steve Hodgkiss 7 lessons

One handshake, one page, one honest run. That is the shape of this book.

wireguard, one handshake per page

Twenty-eight lessons on what WireGuard is: a free and open-source protocol implementing encrypted VPNs over UDP, lighter than IPsec, better performing than OpenVPN; the law of one handshake per page; the overlay across a public net; long-term Curve25519 keys, ephemeral values, RFC 1918 addresses; the Noise IK pattern, the two-message ladder, the optional pre-shared key against quantum, the ChaCha20 session key with Poly1305; AEAD, the nonce, the byte toll, the MTU ladder of 1280, 1420 and 1440; UDP only and the TCP meltdown, port 51820, v4-in-v6, the roaming phone; the machine-checked proof, the IPsec and OpenVPN neighbors, the fixed menu; Donenfeld 2015, Linux 5.6 2020, one honest hour.


Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).

An honest book about its demos: wg (wireguard-tools v1.0.20210914) ran on the machine that built this book for key generation ONLY, under umask 077: one wg genkey piped straight into wg pubkey (the private key went to the pipe and was never printed) and one wg genpsk; no interface was ever brought up by this machine and no networking was touched. Every quoted output line in these pages (the version banner and both key strings) was captured from those real runs, quoted verbatim from the captured run log. No wg output was invented. Every other fact is as the primary source states it, read during this build: the Wikipedia articles WireGuard, Virtual private network, Curve25519, ChaCha20-Poly1305, IPsec and OpenVPN, cached verbatim beside this book. No facts come from Reddit, Stack Overflow, vendor blogs or commercial sites. Every lesson that describes a practice exercise carries the label 'this book's plan', never posing as a captured fact. Independent, not affiliated with Jason A. Donenfeld, the WireGuard project or the Wikimedia Foundation.

Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.

© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.

Edition 1.0 · stevehodgkiss.net

Contents

Contents


Part 1 · The tunnel itself
The first keys4
Part 2 · The cryptokey roster
The curve's math5
Part 3 · The handshake itself
The session key6
Part 4 · The sealed data
The MTU ladder7
Part 5 · The carrier
Roaming8
Part 6 · The wider field
The OpenVPN neighbor9
Part 7 · The long view
One honest hour10

Per a real local run captured at dispatch, wg --version printed wireguard-tools v1.0.20210914, and under umask 077 a wg genkey piped straight into wg pubkey printed the public key IecgtV/eRXjsn321JYto/QYafqlwsPw0fZvrzeNWOzY=; the private key went to the pipe and was never printed. Scope: key material generation only; no interface was created, no networking touched.

WireGuard companion · No. 01
the proof

The first keys

a real local run, quoted honestly

the proof: real keys, generated here, quoted verbatimumask 077 ; wg genkey | wg pubkeyIecgtV/eRXjsn321JYto/QYafqlwsPw0fZvrzeNWOzY=wireguard-tools v1.0.20210914no invented outputtraced verbatimthe private key went to the pipe, never printedscope: key generation only,no interface was ever brought uptwo commands, one secret kept, one public given

Before anything else, the law: wireguard-tools v1.0.20210914 ran on this machine for key generation only, and no wg output was invented.

Two real lines from the run: umask 077 ; wg genkey | wg pubkey, which printed the public key IecgtV/eRXjsn321JYto/QYafqlwsPw0fZvrzeNWOzY=. The private half went to the pipe and was never printed. No interface was ever brought up.

A key pair in two commands: one secret kept, one public given away.

ONE HONEST HANDSHAKE

Why does umask 077 matter on the command that births a private key?

Per the Wikipedia Curve25519 article, the curve used is y2 = x3 + 486662*x2 + x, a Montgomery curve over the prime field defined by 2^255 - 19 (hence the numeric 25519 in the name), using the base point with x = 9; Bernstein has since proposed that the name Curve25519 be used for the underlying curve, and the name X25519 for the DH function; Curve25519 is constructed such that it avoids many potential implementation pitfalls.

WireGuard companion · No. 02
the math

The curve's math

designed to resist mistakes

the math: a Montgomery curve over 2^255 - 19y2 = x3 + 486662*x2 + xover 2^255 - 19, base point x = 9a Montgomery curve,the prime names it:25519the DH function: X25519avoids pitfallsconstructed so that careful handstrip less oftenthe name is the prime; the math is the guardrail

The name is the prime: the curve is a Montgomery curve over the field defined by 2 to the power 255 minus 19, and its base point sits at x = 9. Per the article, Bernstein has since proposed the name Curve25519 be used for the underlying curve, and the name X25519 for the DH function.

The design aim: Curve25519 is constructed such that it avoids many potential implementation pitfalls.

Math chosen so ordinary implementations trip less often.

ONE HONEST HANDSHAKE

Why does a curve carry its own prime field in its name?

Per the Wikipedia WireGuard article, once the keys have been confirmed by both peers, the Noise Protocol is used to generate a shared ChaCha20 session key for symmetric encryption authenticated with Poly1305; SipHash24 is used for hashtable keys, while BLAKE2s is used as a cryptographic hash function.

WireGuard companion · No. 03
the yield

The session key

what the handshake hands over

the yield: one key both ends share, helpers around itconfirmed public keysthe Noise Protocolshared ChaCha20 session key,symmetric encryption authenticatedwith Poly1305SipHash24 for hashtable keys,BLAKE2s as the hash functionthen the talking starts

Per the article, Once the keys have been confirmed by both peers, the Noise Protocol is used to generate a shared ChaCha20 session key for symmetric encryption authenticated with Poly1305.

Around it sit the helpers: SipHash24 is used for hashtable keys, while BLAKE2s is used as a cryptographic hash function.

The handshake's whole yield: one shared key, one hash, one fast table. Then the talking starts.

ONE HONEST HANDSHAKE

Why does the tunnel re-run the handshake instead of using one key forever?

Per the Wikipedia WireGuard article, assuming the underlay maintains a 1500 byte MTU, configuring the WireGuard interface to 1420 bytes MTU for all involved peers is ideal for being transported over IPv6 + IPv4; when exclusively utilizing legacy IPv4 transport, a higher MTU of 1440 bytes for the WireGuard interface suffices; for mobile clients with varying connectivity, an MTU of 1280 can be beneficial allowing for IPv6 transport inside the tunnel as that is its minimum allowed MTU.

WireGuard companion · No. 04
the sizes

The MTU ladder

1280, 1420, 1440

the ladder of sizes: pick the honest rung1440IPv4-only transport1420ideal for IPv6 + IPv4 transport1280the roaming phone, IPv6 minimum inside1500 outside, minus the toll,sets the ceiling insidethree rungs: 1440, 1420, and the safe 1280

Per the article, configuring the WireGuard interface to 1420 bytes MTU for all involved peers is ideal for being transported over IPv6 + IPv4, while a higher MTU of 1440 bytes for the WireGuard interface suffices on IPv4 only.

For phones that wander, an MTU of 1280 can be beneficial allowing for IPv6 transport inside the tunnel as that is its minimum allowed MTU.

1500 outside, minus the toll, sets the ceiling inside; the ladder has three honest rungs.

ONE HONEST HANDSHAKE

Why is 1280 the safe rung for a phone that changes networks all day?

Per the Wikipedia Virtual private network article, mobile virtual private networks are used in settings where an endpoint of the VPN is not fixed to a single IP address, but instead roams across various networks such as data networks from cellular carriers or between multiple Wi-Fi access points without dropping the secure VPN session; with IKE version 2 the tunnel can be seamlessly restored when the IP address of the associated host is changing, which is typical of a roaming mobile device; per the Wikipedia WireGuard article, WireGuard uses only UDP.

WireGuard companion · No. 05
the roamer

Roaming

change networks, keep the session

roaming: change the network, keep the sessionwi-fi network,the officecellular network,the streetthe phone walksthe session stays up while the address changesa UDP walk has no circuitto tear down behind itthe keys still name the peers when the address cannot

Per the article, a mobile endpoint instead roams across various networks such as data networks from cellular carriers or between multiple Wi-Fi access points without dropping the secure VPN session.

With IKEv2, the tunnel can be seamlessly restored when the IP address of the associated host is changing, which is typical of a roaming mobile device.

Per this book's plan, the lesson is the carrier: a UDP walk needs no circuit to tear down.

ONE HONEST HANDSHAKE

What does a phone switch behind the scenes while its tunnel stays up?

Per the Wikipedia OpenVPN article, OpenVPN is a virtual private network system that implements techniques to create secure point-to-point or site-to-site connections in routed or bridged configurations; it uses the OpenSSL encryption library extensively, as well as the Transport Layer Security (TLS) protocol; it runs in userspace instead of requiring IP stack operation, and also supports Perfect Forward Secrecy (PFS).

WireGuard companion · No. 06
the neighbor

The OpenVPN neighbor

TLS inside, userspace at heart

two tunnels, two wardrobesOpenVPNTLS plus the OpenSSL library,userspace, UDP or TCPWireGuardfixed crypto, in the kernel,UDP onlyboth carry a private network across a public oneone negotiates a wardrobe,the other ships one fixedthe neighbor wears TLS; the newcomer wears the menu

Per the article, OpenVPN builds secure point-to-point or site-to-site connections in routed or bridged configurations and uses the OpenSSL encryption library extensively, as well as the TLS protocol.

It runs in userspace instead of requiring IP stack (therefore kernel) operation, and OpenVPN also supports Perfect Forward Secrecy (PFS).

A TLS veteran with a big cipher drawer, living outside the kernel.

ONE HONEST HANDSHAKE

What does living in userspace cost a tunnel the kernel could carry?

Per this book's plan, one honest hour of practice is: check wg --version, generate a key pair under umask 077 with wg genkey piped into wg pubkey and print nothing you would not share, run wg genpsk once, sketch both peers' public keys and tunnel addresses, name the five parts of the construction string, and set an MTU for a phone that roams.

WireGuard companion · No. 07
the handoff

One honest hour

a practice plan, labelled as such

one honest hour: six moves, planned and labelled1check the bannerwg --version2make a key pairumask 077 first3run wg genpskone extra lock4sketch two peerskeys and addresses5read the stringfive parts named6pick the MTU1280 for a phonethis book's plan: six moves, one hour, every line traceablewrite down which key you wouldrotate first, and which MTU you pickone hour of honest runs beats a year of guessing

Per this book's plan, one honest hour: check the banner with wg --version, then umask 077 ; wg genkey | wg pubkey and keep the private half off screen.

Run wg genpsk once, sketch two peers with public keys and tunnel addresses, name the five parts of the construction string, and pick an MTU for a roaming phone.

Six moves, one hour, every line traceable to a run you watched yourself.

ONE HONEST HANDSHAKE

Book the hour this week; which of the six moves will surprise you most?

Index

Index


One honest hour10
Roaming8
The curve's math5
The first keys4
The MTU ladder7
The OpenVPN neighbor9
The session key6