↓ Skip to main content
Security

The locks I use every day without noticing

·8 mins
Getting ready for quantum computers - This article is part of a series.
Part 0: This Article
I type gh pr list dozens of times a day. The answer comes back in under a second from a server I’ve never met, and nobody in between can read it or change it. One evening I got curious about what actually happens in that second.
Four cards. Agree a key: RSA, Diffie-Hellman, ECDH, X25519, like mixing paint in public. Sign: RSA, ECDSA, EdDSA, like a wax seal only you can make. Encrypt the data: AES, like a house key cut twice. Fingerprint: SHA-256 and HMAC, like a fingerprint of a file. The first two are public-key, the last two shared-key. Below, opening a website: agree a key, check the signature, encrypt with AES, with hashes throughout.
Three jobs, four families

Following one command onto the wire
#

First, where does gh go? Its debug switch shows every request:

GH_DEBUG=api gh api rate_limit
* Request to https://api.github.com/rate_limit
> GET /rate_limit HTTP/1.1
> Authorization: token ████████████████████
< HTTP/2.0 200 OK
* Request took 402.1103ms

So it’s an ordinary HTTPS call to api.github.com, carrying my login token (the debug output masks it). The interesting part happens before that request, when the connection is set up. OpenSSL can show that step. I ran this on Linux with OpenSSL 3.5 and trimmed the output to the lines that matter:

echo | openssl s_client -connect api.github.com:443 -servername api.github.com
Certificate chain
 0 s:CN=*.github.com
   i:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication CA DV E36
   a:PKEY: EC, (prime256v1); sigalg: ecdsa-with-SHA256
 1 s:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication CA DV E36
   i:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication Root E46
No client certificate CA names sent
Peer signature type: ecdsa_secp256r1_sha256
Peer Temp Key: X25519, 253 bits
Verification: OK
New, TLSv1.3, Cipher is TLS_AES_128_GCM_SHA256

Ten lines, and nearly every one names a different piece of cryptography. The rest of this post decodes them.

Three jobs
#

Strip away the names and the connection is doing three jobs:

  1. Keep a secret. Only GitHub and I can read what’s sent.
  2. Prove who’s talking. It really is GitHub, not someone pretending.
  3. Prove nothing changed. Nobody altered the data on the way.

The TLS 1.3 standard says the same in one line: it is “designed to prevent eavesdropping, tampering, and message forgery”. The current text is RFC 9846 (July 2026), “a minor update to TLS 1.3” that replaced the original RFC 8446 and kept the version number.

Cipher is TLS_AES_128_GCM_SHA256: the shared key
#

The simplest lock is a house key cut twice: you keep one copy, I keep the other, and either of us can lock or unlock the box. This is symmetric or shared-key encryption, and its workhorse is AES. It’s fast, so it carries the actual data. The name on that line says AES, with a 128-bit key, in GCM mode, which also checks that nothing was altered, plus SHA-256, a hash we’ll meet below.

It has one big problem. How did GitHub and my laptop get the same key, when they’ve never met and every packet between them crosses networks I don’t control?

Peer Temp Key: X25519: agreeing a key in public
#

The classic picture uses paint. We both start with the same tin of yellow, in public. I secretly add my own colour and send you the mix; you add yours and send me your mix. Each of us then adds our own secret colour to the mix we received, and we end up with the same final colour. Anyone watching saw only the two mixes, which are very hard to “unmix”.

Whitfield Diffie and Martin Hellman published that idea in 1976 (“New Directions in Cryptography”). Modern versions use elliptic curves and are called ECDH. X25519 is the one on my screen: its standard says it works on “32-byte strings” and “is used when implementing Diffie-Hellman” (RFC 7748). “Temp” means a fresh key pair for this connection only. The colour we agree on becomes the AES key.

RSA, from 1977, offers another way: hand out open padlocks. Anyone can snap one shut on a box, but only you hold the key that opens it. The RSA paper promised that “couriers or other secure means are not needed to transmit keys”. TLS 1.3 uses the Diffie-Hellman style, but RSA is still everywhere in certificates and older systems.

These are public-key methods: each side has a public key it can hand to anyone, and a private key it never shares.

ecdsa-with-SHA256: proving who’s talking
#

Agreeing a key with a stranger is no use if the stranger is an impostor. That’s what the certificate lines are for.

A wax seal is something only its owner can make, but anyone who knows the seal can check it. A digital signature works the same way: signed with a private key, checked with the public key. My screen shows two kinds:

  • The certificate chain. GitHub’s certificate for *.github.com is signed by Sectigo, whose certificate is signed by Sectigo’s root, which my computer already trusts. Each sigalg: ecdsa-with-SHA256 is a seal on the link below.
  • Peer signature type: ecdsa_secp256r1_sha256. During the handshake GitHub’s server signs the conversation so far with its own private key. RFC 9846 calls this “a signature over the entire handshake”. It proves the server holds the key in the certificate, right now.

The names you’ll meet are ECDSA (signatures on elliptic curves, as here), RSA (which signs as well), and EdDSA, usually Ed25519, which offers “high performance” with “small public keys (32 or 57 bytes) and signatures (64 or 114 bytes)” (RFC 8032).

Verification: OK means my side checked every seal in the chain and they all held.

Hashes: proving nothing changed
#

The last tool is a fingerprint. A hash such as SHA-256 turns any data, of any size, into a short fixed-size fingerprint; change one letter and the fingerprint changes. Hashes sit inside almost every line above: in ecdsa-with-SHA256 the signature is made over a hash of the certificate, and the handshake is fingerprinted as it goes. Mix a hash with a shared secret and you get HMAC, “a mechanism for message authentication using cryptographic hash functions” (RFC 2104).

No client certificate CA names sent: when the server checks me too
#

That line is easy to skip. It says GitHub didn’t ask my side for a certificate. RFC 9846 puts it this way: “The server side of the channel is always authenticated; the client side is optionally authenticated.” For gh, I prove who I am later, with the token inside the encrypted connection.

Between services, the optional part is often switched on. In mutual TLS (mTLS), the client also presents a certificate and signs the handshake with its private key, so each side checks the other’s seal before a byte of data moves. It’s common between microservices and in service meshes, where there’s no human to type a password. For this series that matters for one reason: mTLS doubles the signatures, and every one of them is public-key cryptography.

A surprise: who signed GitHub’s certificate?
#

The first time I ran that openssl command, on Windows, the chain didn’t end at Sectigo. The issuer was the antivirus on my laptop. As far as I can tell, it inspects encrypted traffic by ending my connection itself, opening its own to GitHub, and handing me a certificate it signed with a root it had installed in Windows’ list of trusted roots. OpenSSL, which keeps its own list, noticed: “unable to verify the first certificate”. A small Go program, which uses the Windows list, accepted the same certificate without a word.

Nothing was broken, but it taught me two things: the seal is only as good as the list of roots you trust, and when you measure a connection, make sure you’re measuring the one you think you are. (The output above is from Linux, where the real chain shows.)

The one split that matters
#

On my screenNameJobEveryday pictureFamily
Peer Temp KeyX25519, ECDH, Diffie-Hellman, RSAAgree a keyMixing paint; open padlocksPublic-key
sigalg, Peer signature typeECDSA, EdDSA, RSAProve who’s talkingA wax sealPublic-key
Cipher is TLS_AES_...AESEncrypt the dataA house key cut twiceShared-key
..._SHA256SHA-256, HMACProve nothing changedA fingerprintShared-key side

Hold on to the last column. The public-key family works because it rests on maths puzzles that are easy to set and very hard to undo: RSA on “the difficulty of factoring” a huge number, and the curves and Diffie-Hellman on a cousin of that puzzle called the discrete logarithm. The next post is about why those puzzles have started to worry me.

Keywords
#

KeywordMeaning here
TLSThe protocol behind HTTPS; it uses everything below
Symmetric / shared-keyBoth sides hold the same key (AES)
Public-key / asymmetricEach side has a public key to share and a private key to keep
Key exchangeTwo strangers agreeing a secret over a public line (Diffie-Hellman, ECDH, X25519)
Digital signatureProof made with a private key that anyone can check with the public key (ECDSA, EdDSA, RSA)
Certificate chainSignatures linking a server’s key to a root your computer already trusts
HashA short fixed-size fingerprint of any data (SHA-256)
HMACA hash mixed with a shared secret, to prove who sent a message
mTLSMutual TLS: the client also presents a certificate and signs the handshake

Takeaways
#

  • One gh command opens a TLS connection that does three jobs: keep a secret, prove who’s talking, prove nothing changed.
  • AES carries the data; key exchange (X25519) is how two strangers get the shared AES key.
  • Signatures (ECDSA, EdDSA, RSA) prove identity, in the certificate chain and over the handshake; mTLS adds the client’s signature too.
  • Hashes (SHA-256) fingerprint everything along the way.
  • Key exchange and signatures are public-key cryptography, resting on hard maths puzzles. That’s where this series begins.

References
#

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.
Getting ready for quantum computers - This article is part of a series.
Part 0: This Article

Related

Three things osv.dev taught me

I thought of osv.dev as a big list of bugs: look up your package and version, get a yes or no. Then I downloaded its raw data and counted. The list turned out to be mostly something else, the word “fixed” turned out to depend on who you ask, and one famous bug turned out to be many records. What the raw data showed me In the Learning OSV series I learned how to read a record, run the scanner and let it fix a project. This post is different. I didn’t read one record; I looked at OSV’s data as a whole, asked the API a few pointed questions, and wrote down what surprised me. All numbers are from 4 December 2026.

Learning OSV, part 5: I scanned my own blog, and the real problem wasn't in the report

A test project is a controlled experiment; your own repository is the one that talks back. I pointed OSV-Scanner at the source of this blog expecting a dull report. The report was indeed dull. The interesting part was what it could not see. The mood of the evening. It lasted until the first command. In parts 2 and 3 I used a project built to be vulnerable. This time the target is the repository behind this site: Hugo, the Blowfish theme as a git submodule, some Python helper scripts and two GitHub Actions workflows. All runs used OSV-Scanner v2.7.0.

Learning OSV, part 4: where it fits, and my recommendation

·4 mins
Three parts of trying things. This one is the verdict: what I would actually switch on, in what order, and what I would still look elsewhere for. The loop I would run, and the verdict as a checklist. Quick recap of the proof of concept: part 1 read the database, part 2 scanned a project (5 dependencies, 68 packages, 49 vulnerabilities), and part 3 fixed it (7 of 50 safely, 50 of 50 with a major upgrade).